Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion network/bridge_networkclient_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ func (client *LinuxBridgeClient) CreateBridge() error {
},
}

return netlink.AddLink(&link)
if err := netlink.AddLink(&link); err != nil {
return err
}

return epcommon.DisableRAForInterface(client.bridgeName)
}

func (client *LinuxBridgeClient) DeleteBridge() error {
Expand Down
19 changes: 19 additions & 0 deletions network/epcommon/endpoint_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const (
enableIPForwardCmd = "sysctl -w net.ipv4.ip_forward=1"
toggleIPV6Cmd = "sysctl -w net.ipv6.conf.all.disable_ipv6=%d"
enableIPV6ForwardCmd = "sysctl -w net.ipv6.conf.all.forwarding=1"
disableRACmd = "sysctl -w net.ipv6.conf.%s.accept_ra=0"
)

func getPrivateIPSpace() []string {
Expand Down Expand Up @@ -71,6 +72,10 @@ func CreateEndpoint(hostVethName string, containerVethName string) error {
return err
}

if err := DisableRAForInterface(hostVethName); err != nil {
return err
}

return nil
}

Expand All @@ -87,6 +92,10 @@ func SetupContainerInterface(containerVethName string, targetIfName string) erro
return err
}

if err := DisableRAForInterface(targetIfName); err != nil {
return err
}

// Bring the interface back up.
log.Printf("[net] Setting link %v state up.", targetIfName)
return netlink.SetLinkState(targetIfName, true)
Expand Down Expand Up @@ -228,3 +237,13 @@ func AddSnatRule(match string, ip net.IP) error {
target := fmt.Sprintf("SNAT --to %s", ip.String())
return iptables.InsertIptableRule(version, iptables.Nat, iptables.Postrouting, match, target)
}

func DisableRAForInterface(ifName string) error {
cmd := fmt.Sprintf(disableRACmd, ifName)
out, err := platform.ExecuteCommand(cmd)
if err != nil {
log.Errorf("[net] Diabling ra failed with err: %v out: %v", err, out)
}

return err
}
5 changes: 5 additions & 0 deletions network/ovs_networkclient_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"

"github.com/Azure/azure-container-networking/log"
"github.com/Azure/azure-container-networking/network/epcommon"
"github.com/Azure/azure-container-networking/ovsctl"
)

Expand Down Expand Up @@ -72,6 +73,10 @@ func (client *OVSNetworkClient) CreateBridge() error {
}
}()

if err := epcommon.DisableRAForInterface(client.bridgeName); err != nil {
return err
}

return updateOVSConfig(ovsOpt)
}

Expand Down
12 changes: 12 additions & 0 deletions network/ovssnat/ovssnat.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ func CreateSnatBridge(snatBridgeIP string, mainInterface string) error {
return nil
}

if err := epcommon.DisableRAForInterface(SnatBridgeName); err != nil {
return err
}

vethLink := netlink.VEthLink{
LinkInfo: netlink.LinkInfo{
Type: netlink.LINK_TYPE_VETH,
Expand All @@ -356,6 +360,14 @@ func CreateSnatBridge(snatBridgeIP string, mainInterface string) error {
return err
}

if err := epcommon.DisableRAForInterface(azureSnatVeth0); err != nil {
return err
}

if err := epcommon.DisableRAForInterface(azureSnatVeth1); err != nil {
return err
}

log.Printf("Assigning %v on snat bridge", snatBridgeIP)

ip, addr, _ := net.ParseCIDR(snatBridgeIP)
Expand Down