Skip to content

Commit

Permalink
EIP e2e: fix IPv6 e2e VRF test
Browse files Browse the repository at this point in the history
IPv6 link addresses behave differently than IPv4
addresses when a link is enslaved to a VRF device.
For IPv4, addresses assigned to the link are preserved
but for IPv6, non link local addresses are removed.
Therefore when a link is enslaved, this commit manually
readds the global IPv6 address.

Signed-off-by: Martin Kennelly <mkennell@redhat.com>
  • Loading branch information
martinkennelly committed Aug 9, 2024
1 parent 9905751 commit 024430b
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion test/e2e/egressip.go
Original file line number Diff line number Diff line change
Expand Up @@ -2535,7 +2535,8 @@ spec:
// 5. Check connectivity from a pod to an external "node" hosted on a secondary host network and verify the expected IP
ginkgo.It("[secondary-host-eip] uses VRF routing table if EIP assigned interface is VRF slave", func() {
var egressIP1 string
if utilnet.IsIPv6(net.ParseIP(egress1Node.nodeIP)) {
isV6Node := utilnet.IsIPv6(net.ParseIP(egress1Node.nodeIP))
if isV6Node {
egressIP1 = "2001:db8:abcd:1234:c001::"
} else {
egressIP1 = "10.10.10.100"
Expand All @@ -2559,6 +2560,35 @@ spec:
if egressInterface == "" {
framework.Failf("failed to find egress interface name")
}
// Enslaving a link to a VRF device may cause the removal of the non link local IPv6 address from the interface
// Look up the IP address, add it after enslaving the link and post test.
restoreLinkIPv6AddrFn := func() error { return nil }
if isV6Node {
ginkgo.By("attempting to find IPv6 global address for secondary network")
address, err := runCommand(containerRuntime, "inspect", "-f",
fmt.Sprintf("'{{ (index .NetworkSettings.Networks \"%s\").GlobalIPv6Address }}'", secondaryNetworkName), egress1Node.name)
if err != nil {
framework.Failf("failed to get node %s IP address for network %s: %v", egress1Node.name, secondaryNetworkName, err)
}
address = strings.TrimSuffix(address, "\n")
address = strings.Trim(address, "'")
ginkgo.By(fmt.Sprintf("found addr %q", address))
gomega.Expect(net.ParseIP(address)).ShouldNot(gomega.BeNil(), "IPv6 address for secondary network must be present")
prefix, err := runCommand(containerRuntime, "inspect", "-f",
fmt.Sprintf("'{{ (index .NetworkSettings.Networks \"%s\").GlobalIPv6PrefixLen }}'", secondaryNetworkName), egress1Node.name)
if err != nil {
framework.Failf("failed to get node %s IP prefix length for network %s: %v", egress1Node.name, secondaryNetworkName, err)
}
prefix = strings.TrimSuffix(prefix, "\n")
prefix = strings.Trim(prefix, "'")
_, err = strconv.Atoi(prefix)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred(), "requires valid IPv6 address prefix")
restoreLinkIPv6AddrFn = func() error {
_, err := runCommand(containerRuntime, "exec", egress1Node.name, "ip", "-6", "address", "add",
fmt.Sprintf("%s/%s", address, prefix), "dev", egressInterface, "nodad", "scope", "global")
return err
}
}
_, err = runCommand(containerRuntime, "exec", egress1Node.name, "ip", "link", "add", vrfName, "type", "vrf", "table", vrfRoutingTable)
if err != nil {
framework.Failf("failed to add VRF to node %s: %v", egress1Node.name, err)
Expand All @@ -2568,6 +2598,9 @@ spec:
if err != nil {
framework.Failf("failed to enslave interface %s to VRF %s node %s: %v", egressInterface, vrfName, egress1Node.name, err)
}
if isV6Node {
gomega.Expect(restoreLinkIPv6AddrFn()).Should(gomega.Succeed(), "restoring IPv6 address should succeed")
}
egressNodeAvailabilityHandler := egressNodeAvailabilityHandlerViaLabel{f}
ginkgo.By("1. Set one node as available for egress")
egressNodeAvailabilityHandler.Enable(egress1Node.name)
Expand Down

0 comments on commit 024430b

Please sign in to comment.