Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[master] bridge: disable IPv6 router advertisements #2558

Merged
merged 1 commit into from
Jun 2, 2020
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: 6 additions & 0 deletions drivers/bridge/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,12 @@ func (d *driver) createNetwork(config *networkConfiguration) (err error) {
bridgeAlreadyExists := bridgeIface.exists()
if !bridgeAlreadyExists {
bridgeSetup.queueStep(setupDevice)
bridgeSetup.queueStep(setupDefaultSysctl)
}

// For the default bridge, set expected sysctls
if config.DefaultBridge {
bridgeSetup.queueStep(setupDefaultSysctl)
}

// Even if a bridge exists try to setup IPv4.
Expand Down
19 changes: 19 additions & 0 deletions drivers/bridge/setup_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package bridge

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"

"github.com/docker/docker/pkg/parsers/kernel"
"github.com/docker/libnetwork/netutils"
Expand Down Expand Up @@ -49,6 +52,22 @@ func setupDevice(config *networkConfiguration, i *bridgeInterface) error {
return err
}

func setupDefaultSysctl(config *networkConfiguration, i *bridgeInterface) error {
// Disable IPv6 router advertisements originating on the bridge
sysPath := filepath.Join("/proc/sys/net/ipv6/conf/", config.BridgeName, "accept_ra")
if _, err := os.Stat(sysPath); err != nil {
logrus.
WithField("bridge", config.BridgeName).
WithField("syspath", sysPath).
Info("failed to read ipv6 net.ipv6.conf.<bridge>.accept_ra")
return nil
}
if err := ioutil.WriteFile(sysPath, []byte{'0', '\n'}, 0644); err != nil {
return fmt.Errorf("libnetwork: Unable to disable IPv6 router advertisement: %v", err)
}
return nil
}

// SetupDeviceUp ups the given bridge interface.
func setupDeviceUp(config *networkConfiguration, i *bridgeInterface) error {
err := i.nlh.LinkSetUp(i.Link)
Expand Down