mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
bridge: disable IPv6 router advertisements
Signed-off-by: Samuel Karp <skarp@amazon.com> (cherry picked from commit 9489546c44d94d37337191c263879a7ac075a331) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
fd1765ca9b
commit
e65003a722
2 changed files with 25 additions and 0 deletions
|
@ -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.
|
||||
|
|
|
@ -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"
|
||||
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue