From 54c95e484d6852748b014d0f158135f4a2bc5ffa Mon Sep 17 00:00:00 2001 From: changluyi <47097611+changluyi@users.noreply.github.com> Date: Fri, 22 Mar 2024 15:44:06 +0800 Subject: [PATCH] exclude vip as encap ip (#3859) Signed-off-by: Changlu Yi --- pkg/daemon/config.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/daemon/config.go b/pkg/daemon/config.go index 2861d8dea22..9de9e97d92e 100644 --- a/pkg/daemon/config.go +++ b/pkg/daemon/config.go @@ -237,6 +237,17 @@ func (config *Configuration) initNicConfig(nicBridgeMappings map[string]string) return fmt.Errorf("failed to get iface addr. %v", err) } for _, addr := range addrs { + _, ipCidr, err := net.ParseCIDR(addr.String()) + if err != nil { + klog.Errorf("Failed to parse CIDR address %s: %v", addr.String(), err) + continue + } + // exclude the vip as encap ip + if ones, bits := ipCidr.Mask.Size(); ones == bits { + klog.Infof("Skip address %s", ipCidr.String()) + continue + } + ipStr := strings.Split(addr.String(), "/")[0] if ip := net.ParseIP(ipStr); ip == nil || ip.IsLinkLocalUnicast() { continue