diff --git a/pkg/daemon/config.go b/pkg/daemon/config.go index 823c93f35b9..10083eb3332 100644 --- a/pkg/daemon/config.go +++ b/pkg/daemon/config.go @@ -26,6 +26,8 @@ import ( // Configuration is the daemon conf type Configuration struct { + // interface being used for tunnel + tunnelIface string Iface string MTU int MSS int @@ -178,6 +180,9 @@ func (config *Configuration) initNicConfig(nicBridgeMappings map[string]string) return fmt.Errorf("iface %s has no ip address", tunnelNic) } encapIP = strings.Split(addrs[0].String(), "/")[0] + + klog.Infof("use %s as tunnel interface", iface.Name) + config.tunnelIface = iface.Name } if config.MTU == 0 { @@ -211,7 +216,6 @@ func findInterface(ifaceStr string) (*net.Interface, error) { } for _, iface := range ifaces { if ifaceRegex.MatchString(iface.Name) { - klog.Infof("use %s as tunnel interface", iface.Name) return &iface, nil } } diff --git a/pkg/daemon/controller.go b/pkg/daemon/controller.go index 8a36fb452b1..0c1305751ce 100644 --- a/pkg/daemon/controller.go +++ b/pkg/daemon/controller.go @@ -1016,6 +1016,10 @@ func (c *Controller) loopEncapIpCheck() { klog.Errorf("iface %s has no ip address", nodeTunnelName) return } + if iface.Name != c.config.tunnelIface { + klog.Infof("use %s as tunnel interface", iface.Name) + c.config.tunnelIface = iface.Name + } // if assigned iface in node annotation is down or with no ip, the error msg should be printed periodically if c.config.Iface == nodeTunnelName {