Skip to content

Commit b2f348e

Browse files
Michael ZappaMichael Zappa
authored andcommitted
Disable DAD for container side veth
Signed-off-by: Michael Zappa <[email protected]>
1 parent f531419 commit b2f348e

File tree

1 file changed

+1
-27
lines changed

1 file changed

+1
-27
lines changed

plugins/main/bridge/bridge.go

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"encoding/json"
1919
"errors"
2020
"fmt"
21-
"io/ioutil"
2221
"net"
2322
"os"
2423
"runtime"
@@ -402,20 +401,6 @@ func setupBridge(n *NetConf) (*netlink.Bridge, *current.Interface, error) {
402401
}, nil
403402
}
404403

405-
// disableIPV6DAD disables IPv6 Duplicate Address Detection (DAD)
406-
// for an interface, if the interface does not support enhanced_dad.
407-
// We do this because interfaces with hairpin mode will see their own DAD packets
408-
func disableIPV6DAD(ifName string) error {
409-
// ehanced_dad sends a nonce with the DAD packets, so that we can safely
410-
// ignore ourselves
411-
enh, err := ioutil.ReadFile(fmt.Sprintf("/proc/sys/net/ipv6/conf/%s/enhanced_dad", ifName))
412-
if err == nil && string(enh) == "1\n" {
413-
return nil
414-
}
415-
f := fmt.Sprintf("/proc/sys/net/ipv6/conf/%s/accept_dad", ifName)
416-
return ioutil.WriteFile(f, []byte("0"), 0644)
417-
}
418-
419404
func enableIPForward(family int) error {
420405
if family == netlink.FAMILY_V4 {
421406
return ip.EnableIP4Forward()
@@ -516,18 +501,7 @@ func cmdAdd(args *skel.CmdArgs) error {
516501

517502
// Configure the container hardware address and IP address(es)
518503
if err := netns.Do(func(_ ns.NetNS) error {
519-
// Disable IPv6 DAD just in case hairpin mode is enabled on the
520-
// bridge. Hairpin mode causes echos of neighbor solicitation
521-
// packets, which causes DAD failures.
522-
for _, ipc := range result.IPs {
523-
if ipc.Address.IP.To4() == nil && (n.HairpinMode || n.PromiscMode) {
524-
if err := disableIPV6DAD(args.IfName); err != nil {
525-
return err
526-
}
527-
break
528-
}
529-
}
530-
504+
_, _ = sysctl.Sysctl(fmt.Sprintf("net/ipv6/conf/%s/accept_dad", args.IfName), "0")
531505
_, _ = sysctl.Sysctl(fmt.Sprintf("net/ipv4/conf/%s/arp_notify", args.IfName), "1")
532506

533507
// Add the IP to the interface

0 commit comments

Comments
 (0)