@@ -18,7 +18,6 @@ import (
18
18
"encoding/json"
19
19
"errors"
20
20
"fmt"
21
- "io/ioutil"
22
21
"net"
23
22
"os"
24
23
"runtime"
@@ -57,6 +56,7 @@ type NetConf struct {
57
56
PromiscMode bool `json:"promiscMode"`
58
57
Vlan int `json:"vlan"`
59
58
MacSpoofChk bool `json:"macspoofchk,omitempty"`
59
+ EnableDad bool `json:"enabledad,omitempty"`
60
60
61
61
Args struct {
62
62
Cni BridgeArgs `json:"cni,omitempty"`
@@ -402,20 +402,6 @@ func setupBridge(n *NetConf) (*netlink.Bridge, *current.Interface, error) {
402
402
}, nil
403
403
}
404
404
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
-
419
405
func enableIPForward (family int ) error {
420
406
if family == netlink .FAMILY_V4 {
421
407
return ip .EnableIP4Forward ()
@@ -516,18 +502,12 @@ func cmdAdd(args *skel.CmdArgs) error {
516
502
517
503
// Configure the container hardware address and IP address(es)
518
504
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
- }
505
+ if n .EnableDad {
506
+ _ , _ = sysctl .Sysctl (fmt .Sprintf ("/net/ipv6/conf/%s/enhanced_dad" , args .IfName ), "1" )
507
+ _ , _ = sysctl .Sysctl (fmt .Sprintf ("net/ipv6/conf/%s/accept_dad" , args .IfName ), "1" )
508
+ } else {
509
+ _ , _ = sysctl .Sysctl (fmt .Sprintf ("net/ipv6/conf/%s/accept_dad" , args .IfName ), "0" )
529
510
}
530
-
531
511
_ , _ = sysctl .Sysctl (fmt .Sprintf ("net/ipv4/conf/%s/arp_notify" , args .IfName ), "1" )
532
512
533
513
// Add the IP to the interface
0 commit comments