mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 19:23:40 +00:00
Abandon setting hairpin mode if finding the peer interface fails
Instead of setting it on every bridge-connected interface which may have unwanted effects on unrelated things installed on the machine.
This commit is contained in:
parent
c3a2cc5370
commit
0cfd09e161
@ -58,8 +58,7 @@ func setUpContainerInternal(containerInterfaceName, containerDesc string, nsente
|
|||||||
e := exec.New()
|
e := exec.New()
|
||||||
hostIfName, err := findPairInterfaceOfContainerInterface(e, containerInterfaceName, containerDesc, nsenterArgs)
|
hostIfName, err := findPairInterfaceOfContainerInterface(e, containerInterfaceName, containerDesc, nsenterArgs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Infof("Unable to find pair interface, setting up all interfaces: %v", err)
|
return err
|
||||||
return setUpAllInterfaces()
|
|
||||||
}
|
}
|
||||||
return setUpInterface(hostIfName)
|
return setUpInterface(hostIfName)
|
||||||
}
|
}
|
||||||
@ -95,17 +94,6 @@ func findPairInterfaceOfContainerInterface(e exec.Interface, containerInterfaceN
|
|||||||
return iface.Name, nil
|
return iface.Name, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func setUpAllInterfaces() error {
|
|
||||||
interfaces, err := net.Interfaces()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
for _, netIf := range interfaces {
|
|
||||||
setUpInterface(netIf.Name) // ignore errors
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func setUpInterface(ifName string) error {
|
func setUpInterface(ifName string) error {
|
||||||
glog.V(3).Infof("Enabling hairpin on interface %s", ifName)
|
glog.V(3).Infof("Enabling hairpin on interface %s", ifName)
|
||||||
ifPath := path.Join(sysfsNetPath, ifName)
|
ifPath := path.Join(sysfsNetPath, ifName)
|
||||||
|
Loading…
Reference in New Issue
Block a user