Enable KeepAddrOnDown for ipv6 addresses

This enables the keep_addr_on_down sysctl parameter for
IPV6 addresses configured via the ConfigureIface function.

This prevents IPAM confiuration to be lost when users need
to refresh the link state of an interface that has IPV6 addresses.

Signed-off-by: Marcelo Guerrero <marguerr@redhat.com>
This commit is contained in:
Marcelo Guerrero
2025-03-28 16:44:23 +01:00
committed by Casey Callendrello
parent b088cc3162
commit 062b3fceb4
2 changed files with 56 additions and 3 deletions

View File

@@ -201,6 +201,49 @@ var _ = Describe("ConfigureIface", func() {
Expect(err).NotTo(HaveOccurred())
})
It("keeps IPV6 addresses after the interface is brought down", func() {
err := originalNS.Do(func(ns.NetNS) error {
defer GinkgoRecover()
By("Configuring the interface")
err := ConfigureIface(LINK_NAME, result)
Expect(err).NotTo(HaveOccurred())
By("Verifying the IPV6 address is present")
link, err := netlinksafe.LinkByName(LINK_NAME)
Expect(err).NotTo(HaveOccurred())
Expect(link.Attrs().Name).To(Equal(LINK_NAME))
v6addrs, err := netlinksafe.AddrList(link, syscall.AF_INET6)
Expect(err).NotTo(HaveOccurred())
Expect(v6addrs).To(HaveLen(2))
var found bool
for _, a := range v6addrs {
if ipNetEqual(a.IPNet, ipv6) {
found = true
break
}
}
Expect(found).To(BeTrue())
By("Bringing the interface down")
err = netlink.LinkSetDown(link)
Expect(err).NotTo(HaveOccurred())
By("Verifying the IPV6 address is still present")
v6addrs, err = netlinksafe.AddrList(link, syscall.AF_INET6)
Expect(err).NotTo(HaveOccurred())
Expect(v6addrs).To(HaveLen(1))
Expect(ipNetEqual(v6addrs[0].IPNet, ipv6)).To(BeTrue())
return nil
})
Expect(err).NotTo(HaveOccurred())
})
It("configures a link with routes using address gateways", func() {
result.Routes[0].GW = nil
result.Routes[1].GW = nil