From c9933e94947c1f92642084613ed1b4a02c84e175 Mon Sep 17 00:00:00 2001 From: Wu zhengdong Date: Tue, 22 Feb 2022 10:46:50 +0800 Subject: [PATCH] Don't delete the routes which are added for the peer IPv6 gateways "on-link" is not identified in IPv6 route entries, the peer IPv6 gateways need to add into IPv6 routes lonely. So don't delete the routes which are added for the peer IPv6 gateways. Signed-off-by: Wu zhengdong --- pkg/agent/route/route_linux.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pkg/agent/route/route_linux.go b/pkg/agent/route/route_linux.go index 67de65a8099..ea21ef1cdc0 100644 --- a/pkg/agent/route/route_linux.go +++ b/pkg/agent/route/route_linux.go @@ -683,6 +683,8 @@ func (c *Client) initServiceIPRoutes() error { // based on the desired podCIDRs. svcIPs are used for Windows only. func (c *Client) Reconcile(podCIDRs []string, svcIPs map[string]bool) error { desiredPodCIDRs := sets.NewString(podCIDRs...) + // Get the peer IPv6 gateways from pod CIDRs + desiredIPv6GWs := getIPv6Gateways(podCIDRs) // Remove orphaned podCIDRs from ipset. for _, ipsetName := range []string{antreaPodIPSet, antreaPodIP6Set} { @@ -722,6 +724,12 @@ func (c *Client) Reconcile(podCIDRs []string, svcIPs map[string]bool) error { if desiredPodCIDRs.Has(route.Dst.String()) { continue } + // "on-link" is not identified in IPv6 route entries, the peer IPv6 gateways need to + // add into IPv6 routes lonely. So don't delete the routes which are added for the peer + // IPv6 gateways. + if desiredIPv6GWs.Has(route.Dst.IP.String()) { + continue + } // Don't delete the routes which are added by AntreaProxy. if c.isServiceRoute(&route) { continue @@ -733,10 +741,8 @@ func (c *Client) Reconcile(podCIDRs []string, svcIPs map[string]bool) error { } } - // Remove any unknown IPv6 neighbors on Antrea gateway. - desiredGWs := getIPv6Gateways(podCIDRs) // Return immediately if there is no IPv6 gateway address configured on the Nodes. - if desiredGWs.Len() == 0 { + if desiredIPv6GWs.Len() == 0 { return nil } // Remove orphaned IPv6 Neighbors from host network. @@ -744,8 +750,9 @@ func (c *Client) Reconcile(podCIDRs []string, svcIPs map[string]bool) error { if err != nil { return err } + // Remove any unknown IPv6 neighbors on Antrea gateway. for neighIP, actualNeigh := range actualNeighbors { - if desiredGWs.Has(neighIP) { + if desiredIPv6GWs.Has(neighIP) { continue } // Don't delete the virtual Service IP neighbor which is added by AntreaProxy.