mirror of https://github.com/docker/docs.git
Update libnetwork to 4ded6fe3641b71863cc5985652930ce40efc3af4
Signed-off-by: David Calavera <david.calavera@gmail.com>
This commit is contained in:
parent
ad41efd9a2
commit
ad244668c3
|
@ -3,9 +3,11 @@ package bridge
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"net"
|
"net"
|
||||||
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/docker/libnetwork/driverapi"
|
"github.com/docker/libnetwork/driverapi"
|
||||||
"github.com/docker/libnetwork/ipallocator"
|
"github.com/docker/libnetwork/ipallocator"
|
||||||
"github.com/docker/libnetwork/netlabel"
|
"github.com/docker/libnetwork/netlabel"
|
||||||
|
@ -102,6 +104,12 @@ func newDriver() driverapi.Driver {
|
||||||
|
|
||||||
// Init registers a new instance of bridge driver
|
// Init registers a new instance of bridge driver
|
||||||
func Init(dc driverapi.DriverCallback) error {
|
func Init(dc driverapi.DriverCallback) error {
|
||||||
|
// try to modprobe bridge first
|
||||||
|
// see gh#12177
|
||||||
|
if out, err := exec.Command("modprobe", "-va", "bridge", "nf_nat", "br_netfilter").Output(); err != nil {
|
||||||
|
logrus.Warnf("Running modprobe bridge nf_nat failed with message: %s, error: %v", out, err)
|
||||||
|
}
|
||||||
|
|
||||||
return dc.RegisterDriver(networkType, newDriver())
|
return dc.RegisterDriver(networkType, newDriver())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,6 +295,11 @@ func (d *driver) CreateNetwork(id types.UUID, option map[string]interface{}) err
|
||||||
// Even if a bridge exists try to setup IPv4.
|
// Even if a bridge exists try to setup IPv4.
|
||||||
bridgeSetup.queueStep(setupBridgeIPv4)
|
bridgeSetup.queueStep(setupBridgeIPv4)
|
||||||
|
|
||||||
|
enableIPv6Forwarding := false
|
||||||
|
if d.config != nil && d.config.EnableIPForwarding && config.FixedCIDRv6 != nil {
|
||||||
|
enableIPv6Forwarding = true
|
||||||
|
}
|
||||||
|
|
||||||
// Conditionally queue setup steps depending on configuration values.
|
// Conditionally queue setup steps depending on configuration values.
|
||||||
for _, step := range []struct {
|
for _, step := range []struct {
|
||||||
Condition bool
|
Condition bool
|
||||||
|
@ -310,6 +323,9 @@ func (d *driver) CreateNetwork(id types.UUID, option map[string]interface{}) err
|
||||||
// specified subnet.
|
// specified subnet.
|
||||||
{config.FixedCIDRv6 != nil, setupFixedCIDRv6},
|
{config.FixedCIDRv6 != nil, setupFixedCIDRv6},
|
||||||
|
|
||||||
|
// Enable IPv6 Forwarding
|
||||||
|
{enableIPv6Forwarding, setupIPv6Forwarding},
|
||||||
|
|
||||||
// Setup Loopback Adresses Routing
|
// Setup Loopback Adresses Routing
|
||||||
{!config.EnableUserlandProxy, setupLoopbackAdressesRouting},
|
{!config.EnableUserlandProxy, setupLoopbackAdressesRouting},
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package bridge
|
package bridge
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
|
"github.com/vishvananda/netlink"
|
||||||
)
|
)
|
||||||
|
|
||||||
func setupFixedCIDRv6(config *NetworkConfiguration, i *bridgeInterface) error {
|
func setupFixedCIDRv6(config *NetworkConfiguration, i *bridgeInterface) error {
|
||||||
|
@ -10,5 +13,15 @@ func setupFixedCIDRv6(config *NetworkConfiguration, i *bridgeInterface) error {
|
||||||
return &FixedCIDRv6Error{Net: config.FixedCIDRv6, Err: err}
|
return &FixedCIDRv6Error{Net: config.FixedCIDRv6, Err: err}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Setting route to global IPv6 subnet
|
||||||
|
log.Debugf("Adding route to IPv6 network %s via device %s", config.FixedCIDRv6.String(), config.BridgeName)
|
||||||
|
err := netlink.RouteAdd(&netlink.Route{
|
||||||
|
Scope: netlink.SCOPE_UNIVERSE,
|
||||||
|
LinkIndex: i.Link.Attrs().Index,
|
||||||
|
Dst: config.FixedCIDRv6,
|
||||||
|
})
|
||||||
|
if err != nil && !os.IsExist(err) {
|
||||||
|
log.Errorf("Could not add route to IPv6 network %s via device %s", config.FixedCIDRv6.String(), config.BridgeName)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,16 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/vishvananda/netlink"
|
"github.com/vishvananda/netlink"
|
||||||
)
|
)
|
||||||
|
|
||||||
var bridgeIPv6 *net.IPNet
|
var bridgeIPv6 *net.IPNet
|
||||||
|
|
||||||
const bridgeIPv6Str = "fe80::1/64"
|
const (
|
||||||
|
bridgeIPv6Str = "fe80::1/64"
|
||||||
|
ipv6ForwardConfPerm = 0644
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// We allow ourselves to panic in this special case because we indicate a
|
// We allow ourselves to panic in this special case because we indicate a
|
||||||
|
@ -25,7 +29,7 @@ func init() {
|
||||||
func setupBridgeIPv6(config *NetworkConfiguration, i *bridgeInterface) error {
|
func setupBridgeIPv6(config *NetworkConfiguration, i *bridgeInterface) error {
|
||||||
// Enable IPv6 on the bridge
|
// Enable IPv6 on the bridge
|
||||||
procFile := "/proc/sys/net/ipv6/conf/" + config.BridgeName + "/disable_ipv6"
|
procFile := "/proc/sys/net/ipv6/conf/" + config.BridgeName + "/disable_ipv6"
|
||||||
if err := ioutil.WriteFile(procFile, []byte{'0', '\n'}, 0644); err != nil {
|
if err := ioutil.WriteFile(procFile, []byte{'0', '\n'}, ipv6ForwardConfPerm); err != nil {
|
||||||
return fmt.Errorf("Unable to enable IPv6 addresses on bridge: %v", err)
|
return fmt.Errorf("Unable to enable IPv6 addresses on bridge: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,3 +68,14 @@ func setupGatewayIPv6(config *NetworkConfiguration, i *bridgeInterface) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setupIPv6Forwarding(config *NetworkConfiguration, i *bridgeInterface) error {
|
||||||
|
// Enable IPv6 forwarding
|
||||||
|
if err := ioutil.WriteFile("/proc/sys/net/ipv6/conf/default/forwarding", []byte{'1', '\n'}, ipv6ForwardConfPerm); err != nil {
|
||||||
|
logrus.Warnf("Unable to enable IPv6 default forwarding: %v", err)
|
||||||
|
}
|
||||||
|
if err := ioutil.WriteFile("/proc/sys/net/ipv6/conf/all/forwarding", []byte{'1', '\n'}, ipv6ForwardConfPerm); err != nil {
|
||||||
|
logrus.Warnf("Unable to enable IPv6 all forwarding: %v", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
@ -60,14 +60,23 @@ type network struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *network) Name() string {
|
func (n *network) Name() string {
|
||||||
|
n.Lock()
|
||||||
|
defer n.Unlock()
|
||||||
|
|
||||||
return n.name
|
return n.name
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *network) ID() string {
|
func (n *network) ID() string {
|
||||||
|
n.Lock()
|
||||||
|
defer n.Unlock()
|
||||||
|
|
||||||
return string(n.id)
|
return string(n.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *network) Type() string {
|
func (n *network) Type() string {
|
||||||
|
n.Lock()
|
||||||
|
defer n.Unlock()
|
||||||
|
|
||||||
if n.driver == nil {
|
if n.driver == nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,11 @@ func createBasePath() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeUnusedPaths() {
|
func removeUnusedPaths() {
|
||||||
for range time.Tick(gpmCleanupPeriod) {
|
gpmLock.Lock()
|
||||||
|
period := gpmCleanupPeriod
|
||||||
|
gpmLock.Unlock()
|
||||||
|
|
||||||
|
for range time.Tick(period) {
|
||||||
gpmLock.Lock()
|
gpmLock.Lock()
|
||||||
pathList := make([]string, 0, len(garbagePathMap))
|
pathList := make([]string, 0, len(garbagePathMap))
|
||||||
for path := range garbagePathMap {
|
for path := range garbagePathMap {
|
||||||
|
|
|
@ -33,7 +33,9 @@ func newKey(t *testing.T) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the rpmCleanupPeriod to be low to make the test run quicker
|
// Set the rpmCleanupPeriod to be low to make the test run quicker
|
||||||
|
gpmLock.Lock()
|
||||||
gpmCleanupPeriod = 2 * time.Second
|
gpmCleanupPeriod = 2 * time.Second
|
||||||
|
gpmLock.Unlock()
|
||||||
|
|
||||||
return name, nil
|
return name, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue