Skip to content

Commit

Permalink
dhcp: Stop adding default gateway to gateway-less routes
Browse files Browse the repository at this point in the history
Signed-off-by: Vladik Romanovsky <[email protected]>
  • Loading branch information
vladikr committed Mar 29, 2018
1 parent aed5d0d commit 39cafbc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/virt-launcher/virtwrap/network/dhcp/dhcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ func FormClasslessRoutes(routes *[]netlink.Route, routerIP net.IP) (formattedRou
width, _ := route.Dst.Mask.Size()
octets := (width-1)/8 + 1
newRoute := append([]byte{byte(width)}, ip[0:octets]...)
gateway := route.Gw
gateway := route.Gw.To4()
if gateway == nil {
gateway = routerIP
gateway = []byte{0, 0, 0, 0}
}
newRoute = append(newRoute, gateway.To4()...)
newRoute = append(newRoute, gateway...)
formattedRoutes = append(formattedRoutes, newRoute...)
}
return
Expand Down
2 changes: 1 addition & 1 deletion pkg/virt-launcher/virtwrap/network/dhcp/dhcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var _ = Describe("DHCP", func() {

Context("check routes", func() {
It("verify should form correctly", func() {
expected := []byte{4, 224, 192, 168, 1, 1, 24, 192, 168, 1, 192, 168, 2, 1}
expected := []byte{4, 224, 0, 0, 0, 0, 24, 192, 168, 1, 192, 168, 2, 1}
gateway := net.IPv4(192, 168, 1, 1)
routes := []netlink.Route{
netlink.Route{
Expand Down

0 comments on commit 39cafbc

Please sign in to comment.