Skip to content

Commit

Permalink
Merge pull request kubevirt#6537 from kubevirt-bot/cherry-pick-6465-t…
Browse files Browse the repository at this point in the history
…o-release-0.45

[release-0.45] Properly process Gateway DHCP Option as IPv4 in DHCP Server
  • Loading branch information
kubevirt-bot authored Oct 13, 2021
2 parents 9869d33 + 4eb40bf commit aac4623
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/network/dhcp/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func prepareDHCPOptions(
dhcpOptions[dhcp.OptionSubnetMask] = clientMask
}
if len(routerIP) != 0 {
dhcpOptions[dhcp.OptionRouter] = routerIP
dhcpOptions[dhcp.OptionRouter] = routerIP.To4()
}

netRoutes := formClasslessRoutes(routes)
Expand Down
7 changes: 7 additions & 0 deletions pkg/network/dhcp/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,13 @@ var _ = Describe("DHCP Server", func() {
Expect(options[240]).To(Equal([]byte("private.options.kubevirt.io")))
})

It("expects the gateway as an IPv4 addresses", func() {
gw := net.ParseIP("192.168.2.1")
options, err := prepareDHCPOptions(gw.DefaultMask(), gw, nil, nil, nil, 1500, "myhost", nil)
Expect(err).NotTo(HaveOccurred())
Expect(options[dhcp4.OptionRouter]).To(Equal([]byte{192, 168, 2, 1}))
})

Context("Options set to invalid value", func() {
var (
err error
Expand Down

0 comments on commit aac4623

Please sign in to comment.