mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Bridge driver to honor IPv6 network gateway
- Currently bridge driver discards the user specified network gateway for IPv6 Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
parent
3881fa3063
commit
30ec1b5081
2 changed files with 30 additions and 6 deletions
|
@ -62,6 +62,13 @@ func setupBridgeIPv6(config *networkConfiguration, i *bridgeInterface) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Store and program user specified bridge network and network gateway
|
||||||
|
i.bridgeIPv6 = config.AddressIPv6
|
||||||
|
i.gatewayIPv6 = config.AddressIPv6.IP
|
||||||
|
if err := netlink.AddrAdd(i.Link, &netlink.Addr{IPNet: i.bridgeIPv6}); err != nil {
|
||||||
|
return &IPv6AddrAddError{IP: i.bridgeIPv6, Err: err}
|
||||||
|
}
|
||||||
|
|
||||||
// Setting route to global IPv6 subnet
|
// Setting route to global IPv6 subnet
|
||||||
logrus.Debugf("Adding route to IPv6 network %s via device %s", config.AddressIPv6.String(), config.BridgeName)
|
logrus.Debugf("Adding route to IPv6 network %s via device %s", config.AddressIPv6.String(), config.BridgeName)
|
||||||
err = netlink.RouteAdd(&netlink.Route{
|
err = netlink.RouteAdd(&netlink.Route{
|
||||||
|
|
|
@ -1005,11 +1005,19 @@ func TestEndpointJoin(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create network 1 and add 2 endpoint: ep11, ep12
|
// Create network 1 and add 2 endpoint: ep11, ep12
|
||||||
n1, err := createTestNetwork(bridgeNetType, "testnetwork1", options.Generic{
|
netOption := options.Generic{
|
||||||
netlabel.GenericData: options.Generic{
|
netlabel.GenericData: options.Generic{
|
||||||
"BridgeName": "testnetwork1",
|
"BridgeName": "testnetwork1",
|
||||||
|
"EnableIPv6": true,
|
||||||
|
"EnableICC": true,
|
||||||
|
"EnableIPMasquerade": true,
|
||||||
},
|
},
|
||||||
}, nil, nil)
|
}
|
||||||
|
ipamV6ConfList := []*libnetwork.IpamConf{&libnetwork.IpamConf{PreferredPool: "fe90::/64", Gateway: "fe90::22"}}
|
||||||
|
n1, err := controller.NewNetwork(bridgeNetType, "testnetwork1",
|
||||||
|
libnetwork.NetworkOptionGeneric(netOption),
|
||||||
|
libnetwork.NetworkOptionIpam(ipamapi.DefaultIPAM, "", nil, ipamV6ConfList),
|
||||||
|
libnetwork.NetworkOptionDeferIPv6Alloc(true))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -1035,10 +1043,16 @@ func TestEndpointJoin(t *testing.T) {
|
||||||
if iface.Address() != nil && iface.Address().IP.To4() == nil {
|
if iface.Address() != nil && iface.Address().IP.To4() == nil {
|
||||||
t.Fatalf("Invalid IP address returned: %v", iface.Address())
|
t.Fatalf("Invalid IP address returned: %v", iface.Address())
|
||||||
}
|
}
|
||||||
|
if iface.AddressIPv6() != nil && iface.AddressIPv6().IP == nil {
|
||||||
|
t.Fatalf("Invalid IPv6 address returned: %v", iface.Address())
|
||||||
|
}
|
||||||
|
|
||||||
if info.Gateway().To4() != nil {
|
if len(info.Gateway()) != 0 {
|
||||||
t.Fatalf("Expected empty gateway for an empty endpoint. Instead found a gateway: %v", info.Gateway())
|
t.Fatalf("Expected empty gateway for an empty endpoint. Instead found a gateway: %v", info.Gateway())
|
||||||
}
|
}
|
||||||
|
if len(info.GatewayIPv6()) != 0 {
|
||||||
|
t.Fatalf("Expected empty gateway for an empty ipv6 endpoint. Instead found a gateway: %v", info.GatewayIPv6())
|
||||||
|
}
|
||||||
|
|
||||||
if info.Sandbox() != nil {
|
if info.Sandbox() != nil {
|
||||||
t.Fatalf("Expected an empty sandbox key for an empty endpoint. Instead found a non-empty sandbox key: %s", info.Sandbox().Key())
|
t.Fatalf("Expected an empty sandbox key for an empty endpoint. Instead found a non-empty sandbox key: %s", info.Sandbox().Key())
|
||||||
|
@ -1090,9 +1104,12 @@ func TestEndpointJoin(t *testing.T) {
|
||||||
|
|
||||||
// Validate if ep.Info() only gives valid gateway and sandbox key after has container has joined.
|
// Validate if ep.Info() only gives valid gateway and sandbox key after has container has joined.
|
||||||
info = ep1.Info()
|
info = ep1.Info()
|
||||||
if info.Gateway().To4() == nil {
|
if len(info.Gateway()) == 0 {
|
||||||
t.Fatalf("Expected a valid gateway for a joined endpoint. Instead found an invalid gateway: %v", info.Gateway())
|
t.Fatalf("Expected a valid gateway for a joined endpoint. Instead found an invalid gateway: %v", info.Gateway())
|
||||||
}
|
}
|
||||||
|
if len(info.GatewayIPv6()) == 0 {
|
||||||
|
t.Fatalf("Expected a valid ipv6 gateway for a joined endpoint. Instead found an invalid gateway: %v", info.GatewayIPv6())
|
||||||
|
}
|
||||||
|
|
||||||
if info.Sandbox() == nil {
|
if info.Sandbox() == nil {
|
||||||
t.Fatalf("Expected an non-empty sandbox key for a joined endpoint. Instead found a empty sandbox key")
|
t.Fatalf("Expected an non-empty sandbox key for a joined endpoint. Instead found a empty sandbox key")
|
||||||
|
@ -1699,7 +1716,7 @@ func TestEnableIPv6(t *testing.T) {
|
||||||
"BridgeName": "testnetwork",
|
"BridgeName": "testnetwork",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ipamV6ConfList := []*libnetwork.IpamConf{&libnetwork.IpamConf{PreferredPool: "fe80::/64"}}
|
ipamV6ConfList := []*libnetwork.IpamConf{&libnetwork.IpamConf{PreferredPool: "fe99::/64", Gateway: "fe99::9"}}
|
||||||
|
|
||||||
n, err := createTestNetwork("bridge", "testnetwork", netOption, nil, ipamV6ConfList)
|
n, err := createTestNetwork("bridge", "testnetwork", netOption, nil, ipamV6ConfList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue