mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
WIP - Remove commented code
Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
This commit is contained in:
parent
46864de1d7
commit
4a8b8498a7
1 changed files with 0 additions and 134 deletions
|
@ -25,27 +25,6 @@ func init() {
|
||||||
libnetwork.RegisterNetworkType(NetworkType, Create, &Configuration{})
|
libnetwork.RegisterNetworkType(NetworkType, Create, &Configuration{})
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
func Create()
|
|
||||||
|
|
||||||
- NewBridgeInterface(*Configuration) (*BridgeInterface, error)
|
|
||||||
. Issues LinkByName on config.BridgeName
|
|
||||||
- Create BridgeSetup instance with sequence of steps
|
|
||||||
- if !bridgeInterface.Exists()
|
|
||||||
. Add DeviceCreation (error if non-default name)
|
|
||||||
. Add AddressIPv4: set IPv4 (with automatic election if necessary)
|
|
||||||
- General case
|
|
||||||
. Add option EnableIPv6 if no IPv6 on bridge (disable_ipv6=0 + set IPv6)
|
|
||||||
. Verify configured addresses (with v4 and v6 updated in config)
|
|
||||||
. Add FixedCIDR v4: register subnet on IP Allocator
|
|
||||||
. Add FixedCIDR v6: register subnet on IP Allocator, route
|
|
||||||
- Add IPTables setup
|
|
||||||
- Add IPForward setup (depends on FixedCIDRv6)
|
|
||||||
- err := bridgeSetup.Apply()
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
func Create(config *Configuration) (libnetwork.Network, error) {
|
func Create(config *Configuration) (libnetwork.Network, error) {
|
||||||
bridgeIntfc := NewInterface(config)
|
bridgeIntfc := NewInterface(config)
|
||||||
bridgeSetup := NewBridgeSetup(bridgeIntfc)
|
bridgeSetup := NewBridgeSetup(bridgeIntfc)
|
||||||
|
@ -101,119 +80,6 @@ func Create(config *Configuration) (libnetwork.Network, error) {
|
||||||
return &bridgeNetwork{*config}, nil
|
return &bridgeNetwork{*config}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
func Create(config *Configuration) (libnetwork.Network, error) {
|
|
||||||
var (
|
|
||||||
addrv4 netlink.Addr
|
|
||||||
addrsv6 []netlink.Addr
|
|
||||||
)
|
|
||||||
|
|
||||||
b := &bridgeNetwork{Config: *config}
|
|
||||||
if b.Config.BridgeName == "" {
|
|
||||||
b.Config.BridgeName = DefaultBridge
|
|
||||||
}
|
|
||||||
|
|
||||||
link, err := netlink.LinkByName(b.Config.BridgeName)
|
|
||||||
if err != nil {
|
|
||||||
// The bridge interface doesn't exist, but we only attempt to create it
|
|
||||||
// if using the default name.
|
|
||||||
if b.Config.BridgeName != DefaultBridge {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the bridge interface.
|
|
||||||
if addrv4, addrsv6, err = createBridge(&b.Config); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// The bridge interface exists: start by getting its configured
|
|
||||||
// addresses and verify if it matches the requested configuration.
|
|
||||||
addrv4, addrsv6, err = getInterfaceAddr(link)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if b.Config.AddressIPv4 != "" {
|
|
||||||
bridgeIP, _, err := net.ParseCIDR(b.Config.AddressIPv4)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if !addrv4.IP.Equal(bridgeIP) {
|
|
||||||
return nil, fmt.Errorf("Bridge IP %s does not match requested configuration %s", addrv4.IP, bridgeIP)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// A bridge might exist but not have any IPv6 addr associated with it
|
|
||||||
// yet (for example, an existing Docker installation that has only been
|
|
||||||
// used with IPv4 and docker0 already is set up). In that case, we can
|
|
||||||
// perform the bridge init for IPv6 here, else we will error out below
|
|
||||||
// if --ipv6=true.
|
|
||||||
if len(addrsv6) == 0 && config.EnableIPv6 {
|
|
||||||
if err := setupIPv6Bridge(iface, config); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return b, nil
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
func createBridge(config *Configuration) (netlink.Addr, []netlink.Addr, error) {
|
|
||||||
// Formats an error return with default values.
|
|
||||||
fmtError := func(format string, params ...interface{}) (netlink.Addr, []netlink.Addr, error) {
|
|
||||||
return netlink.Addr{}, nil, fmt.Errorf(format, params...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Elect a subnet for the bridge interface.
|
|
||||||
bridgeIPNet, err := electBridgeNetwork(config)
|
|
||||||
if err != nil {
|
|
||||||
return fmtError("Failed to elect bridge network: %v", err)
|
|
||||||
}
|
|
||||||
log.Debugf("Creating bridge interface %q with network %s", config.BridgeName, bridgeIPNet)
|
|
||||||
|
|
||||||
// We attempt to create the bridge, and ignore the returned error if it is
|
|
||||||
// already existing.
|
|
||||||
iface, err := createBridgeInterface(config.BridgeName)
|
|
||||||
if err != nil && !os.IsExist(err) {
|
|
||||||
return netlink.Addr{}, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configure bridge IPv4.
|
|
||||||
if err := netlink.AddrAdd(iface, &netlink.Addr{bridgeIPNet, ""}); err != nil {
|
|
||||||
return fmtError("Failed to add address %s to bridge: %v", bridgeIPNet, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configure bridge IPv6.
|
|
||||||
if config.EnableIPv6 {
|
|
||||||
if err := setupIPv6Bridge(iface, config); err != nil {
|
|
||||||
return fmtError("Failed to setup bridge IPv6: %v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Up the bridge interface.
|
|
||||||
if err := netlink.LinkSetUp(iface); err != nil {
|
|
||||||
return fmtError("Failed to up network bridge: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.FixedCIDRv6 != "" {
|
|
||||||
dest, network, err := net.ParseCIDR(config.FixedCIDRv6)
|
|
||||||
if err != nil {
|
|
||||||
return fmtError("Invalid bridge fixed CIDR IPv6 %q: %v", config.FixedCIDRv6, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set route to global IPv6 subnet
|
|
||||||
log.Infof("Adding route to IPv6 network %q via device %q", dest, iface)
|
|
||||||
if err := netlink.RouteAdd(&netlink.Route{Dst: network, LinkIndex: iface.Attrs().Index}); err != nil {
|
|
||||||
return fmtError("Could not add route to IPv6 network %q via device %q", config.FixedCIDRv6, iface)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return getInterfaceAddrByName(config.BridgeName)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
type bridgeNetwork struct {
|
type bridgeNetwork struct {
|
||||||
Config Configuration
|
Config Configuration
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue