mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
drivers/bridge: dont use types.ParseCIDR() for fixed value
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
31d3468146
commit
da0a006b14
2 changed files with 4 additions and 14 deletions
|
@ -8,29 +8,19 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/docker/docker/libnetwork/types"
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/vishvananda/netlink"
|
"github.com/vishvananda/netlink"
|
||||||
)
|
)
|
||||||
|
|
||||||
var bridgeIPv6 *net.IPNet
|
// bridgeIPv6 is the default, link-local IPv6 address for the bridge (fe80::1/64)
|
||||||
|
var bridgeIPv6 = &net.IPNet{IP: net.ParseIP("fe80::1"), Mask: net.CIDRMask(64, 128)}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
bridgeIPv6Str = "fe80::1/64"
|
|
||||||
ipv6ForwardConfPerm = 0644
|
ipv6ForwardConfPerm = 0644
|
||||||
ipv6ForwardConfDefault = "/proc/sys/net/ipv6/conf/default/forwarding"
|
ipv6ForwardConfDefault = "/proc/sys/net/ipv6/conf/default/forwarding"
|
||||||
ipv6ForwardConfAll = "/proc/sys/net/ipv6/conf/all/forwarding"
|
ipv6ForwardConfAll = "/proc/sys/net/ipv6/conf/all/forwarding"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
|
||||||
// We allow ourselves to panic in this special case because we indicate a
|
|
||||||
// failure to parse a compile-time define constant.
|
|
||||||
var err error
|
|
||||||
if bridgeIPv6, err = types.ParseCIDR(bridgeIPv6Str); err != nil {
|
|
||||||
panic(fmt.Sprintf("Cannot parse default bridge IPv6 address %q: %v", bridgeIPv6Str, err))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func setupBridgeIPv6(config *networkConfiguration, i *bridgeInterface) error {
|
func setupBridgeIPv6(config *networkConfiguration, i *bridgeInterface) error {
|
||||||
procFile := "/proc/sys/net/ipv6/conf/" + config.BridgeName + "/disable_ipv6"
|
procFile := "/proc/sys/net/ipv6/conf/" + config.BridgeName + "/disable_ipv6"
|
||||||
ipv6BridgeData, err := ioutil.ReadFile(procFile)
|
ipv6BridgeData, err := ioutil.ReadFile(procFile)
|
||||||
|
|
|
@ -43,14 +43,14 @@ func TestSetupIPv6(t *testing.T) {
|
||||||
|
|
||||||
var found bool
|
var found bool
|
||||||
for _, addr := range addrsv6 {
|
for _, addr := range addrsv6 {
|
||||||
if bridgeIPv6Str == addr.IPNet.String() {
|
if bridgeIPv6.String() == addr.IPNet.String() {
|
||||||
found = true
|
found = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !found {
|
if !found {
|
||||||
t.Fatalf("Bridge device does not have requested IPv6 address %v", bridgeIPv6Str)
|
t.Fatalf("Bridge device does not have requested IPv6 address %v", bridgeIPv6)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue