|
|
|
@ -91,8 +91,8 @@ func flannel(ctx context.Context, flannelIface *net.Interface, flannelConf, kube
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func LookupExtInterface(iface *net.Interface, netMode int) (*backend.ExternalInterface, error) {
|
|
|
|
|
var ifaceAddr net.IP
|
|
|
|
|
var ifacev6Addr net.IP
|
|
|
|
|
var ifaceAddr []net.IP
|
|
|
|
|
var ifacev6Addr []net.IP
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
|
|
if iface == nil {
|
|
|
|
@ -103,30 +103,47 @@ func LookupExtInterface(iface *net.Interface, netMode int) (*backend.ExternalInt
|
|
|
|
|
}
|
|
|
|
|
logrus.Debugf("The interface %s will be used by flannel", iface.Name)
|
|
|
|
|
|
|
|
|
|
ifaceAddr, err = ip.GetInterfaceIP4Addr(iface)
|
|
|
|
|
switch netMode {
|
|
|
|
|
case ipv4:
|
|
|
|
|
ifaceAddr, err = ip.GetInterfaceIP4Addrs(iface)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, fmt.Errorf("failed to find IPv4 address for interface %s", iface.Name)
|
|
|
|
|
}
|
|
|
|
|
logrus.Infof("The interface %s with ipv4 address %s will be used by flannel", iface.Name, ifaceAddr)
|
|
|
|
|
|
|
|
|
|
if netMode == (ipv4 + ipv6) {
|
|
|
|
|
ifacev6Addr, err = ip.GetInterfaceIP6Addr(iface)
|
|
|
|
|
logrus.Infof("The interface %s with ipv4 address %s will be used by flannel", iface.Name, ifaceAddr[0])
|
|
|
|
|
ifacev6Addr = append(ifacev6Addr, nil)
|
|
|
|
|
case ipv6:
|
|
|
|
|
ifacev6Addr, err = ip.GetInterfaceIP6Addrs(iface)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, fmt.Errorf("failed to find IPv6 address for interface %s", iface.Name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
logrus.Infof("Using dual-stack mode. The ipv6 address %s will be used by flannel", ifacev6Addr)
|
|
|
|
|
logrus.Infof("The interface %s with ipv6 address %s will be used by flannel", iface.Name, ifacev6Addr[0])
|
|
|
|
|
ifaceAddr = append(ifaceAddr, nil)
|
|
|
|
|
case (ipv4 + ipv6):
|
|
|
|
|
ifaceAddr, err = ip.GetInterfaceIP4Addrs(iface)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, fmt.Errorf("failed to find IPv4 address for interface %s", iface.Name)
|
|
|
|
|
}
|
|
|
|
|
logrus.Infof("The interface %s with ipv4 address %s will be used by flannel", iface.Name, ifaceAddr[0])
|
|
|
|
|
ifacev6Addr, err = ip.GetInterfaceIP6Addrs(iface)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, fmt.Errorf("failed to find IPv6 address for interface %s", iface.Name)
|
|
|
|
|
}
|
|
|
|
|
logrus.Infof("Using dual-stack mode. The ipv6 address %s will be used by flannel", ifacev6Addr[0])
|
|
|
|
|
default:
|
|
|
|
|
ifaceAddr = append(ifaceAddr, nil)
|
|
|
|
|
ifacev6Addr = append(ifacev6Addr, nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if iface.MTU == 0 {
|
|
|
|
|
return nil, fmt.Errorf("failed to determine MTU for %s interface", ifaceAddr)
|
|
|
|
|
return nil, fmt.Errorf("failed to determine MTU for %s interface", iface.Name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return &backend.ExternalInterface{
|
|
|
|
|
Iface: iface,
|
|
|
|
|
IfaceAddr: ifaceAddr,
|
|
|
|
|
IfaceV6Addr: ifacev6Addr,
|
|
|
|
|
ExtAddr: ifaceAddr,
|
|
|
|
|
ExtV6Addr: ifacev6Addr,
|
|
|
|
|
IfaceAddr: ifaceAddr[0],
|
|
|
|
|
IfaceV6Addr: ifacev6Addr[0],
|
|
|
|
|
ExtAddr: ifaceAddr[0],
|
|
|
|
|
ExtV6Addr: ifacev6Addr[0],
|
|
|
|
|
}, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|