mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Vendoring libnetwork 905d374
Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
parent
489adc96b8
commit
cabc5b27c0
7 changed files with 54 additions and 8 deletions
|
@ -65,7 +65,7 @@ clone git github.com/RackSec/srslog 259aed10dfa74ea2961eddd1d9847619f6e98837
|
||||||
clone git github.com/imdario/mergo 0.2.1
|
clone git github.com/imdario/mergo 0.2.1
|
||||||
|
|
||||||
#get libnetwork packages
|
#get libnetwork packages
|
||||||
clone git github.com/docker/libnetwork 9b821dc123ca07e2c4d7244943f4e3e9632904fb
|
clone git github.com/docker/libnetwork 905d374c096ca1f3a9b75529e52518b7540179f3
|
||||||
clone git github.com/docker/go-events 39718a26497694185f8fb58a7d6f31947f3dc42d
|
clone git github.com/docker/go-events 39718a26497694185f8fb58a7d6f31947f3dc42d
|
||||||
clone git github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80
|
clone git github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80
|
||||||
clone git github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec
|
clone git github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec
|
||||||
|
|
|
@ -358,6 +358,8 @@ func (c *controller) agentInit(bindAddrOrInterface string) error {
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
c.WalkNetworks(joinCluster)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -639,15 +639,20 @@ func (c *controller) NewNetwork(networkType, name string, id string, options ...
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = network.joinCluster(); err != nil {
|
joinCluster(network)
|
||||||
log.Errorf("Failed to join network %s into agent cluster: %v", name, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
network.addDriverWatches()
|
|
||||||
|
|
||||||
return network, nil
|
return network, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var joinCluster NetworkWalker = func(nw Network) bool {
|
||||||
|
n := nw.(*network)
|
||||||
|
if err := n.joinCluster(); err != nil {
|
||||||
|
log.Errorf("Failed to join network %s (%s) into agent cluster: %v", n.Name(), n.ID(), err)
|
||||||
|
}
|
||||||
|
n.addDriverWatches()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (c *controller) reservePools() {
|
func (c *controller) reservePools() {
|
||||||
networks, err := c.getNetworksForScope(datastore.LocalScope)
|
networks, err := c.getNetworksForScope(datastore.LocalScope)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -801,7 +806,7 @@ func (c *controller) NewSandbox(containerID string, options ...SandboxOption) (s
|
||||||
// If not a stub, then we already have a complete sandbox.
|
// If not a stub, then we already have a complete sandbox.
|
||||||
if !s.isStub {
|
if !s.isStub {
|
||||||
c.Unlock()
|
c.Unlock()
|
||||||
return nil, types.BadRequestErrorf("container %s is already present: %v", containerID, s)
|
return nil, types.ForbiddenErrorf("container %s is already present: %v", containerID, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We already have a stub sandbox from the
|
// We already have a stub sandbox from the
|
||||||
|
@ -836,7 +841,7 @@ func (c *controller) NewSandbox(containerID string, options ...SandboxOption) (s
|
||||||
c.Lock()
|
c.Lock()
|
||||||
if sb.ingress && c.ingressSandbox != nil {
|
if sb.ingress && c.ingressSandbox != nil {
|
||||||
c.Unlock()
|
c.Unlock()
|
||||||
return nil, fmt.Errorf("ingress sandbox already present")
|
return nil, types.ForbiddenErrorf("ingress sandbox already present")
|
||||||
}
|
}
|
||||||
|
|
||||||
if sb.ingress {
|
if sb.ingress {
|
||||||
|
|
|
@ -26,6 +26,7 @@ type nwIface struct {
|
||||||
mac net.HardwareAddr
|
mac net.HardwareAddr
|
||||||
address *net.IPNet
|
address *net.IPNet
|
||||||
addressIPv6 *net.IPNet
|
addressIPv6 *net.IPNet
|
||||||
|
ipAliases []*net.IPNet
|
||||||
llAddrs []*net.IPNet
|
llAddrs []*net.IPNet
|
||||||
routes []*net.IPNet
|
routes []*net.IPNet
|
||||||
bridge bool
|
bridge bool
|
||||||
|
@ -96,6 +97,13 @@ func (i *nwIface) LinkLocalAddresses() []*net.IPNet {
|
||||||
return i.llAddrs
|
return i.llAddrs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (i *nwIface) IPAliases() []*net.IPNet {
|
||||||
|
i.Lock()
|
||||||
|
defer i.Unlock()
|
||||||
|
|
||||||
|
return i.ipAliases
|
||||||
|
}
|
||||||
|
|
||||||
func (i *nwIface) Routes() []*net.IPNet {
|
func (i *nwIface) Routes() []*net.IPNet {
|
||||||
i.Lock()
|
i.Lock()
|
||||||
defer i.Unlock()
|
defer i.Unlock()
|
||||||
|
@ -324,6 +332,7 @@ func configureInterface(nlh *netlink.Handle, iface netlink.Link, i *nwIface) err
|
||||||
{setInterfaceIPv6, fmt.Sprintf("error setting interface %q IPv6 to %v", ifaceName, i.AddressIPv6())},
|
{setInterfaceIPv6, fmt.Sprintf("error setting interface %q IPv6 to %v", ifaceName, i.AddressIPv6())},
|
||||||
{setInterfaceMaster, fmt.Sprintf("error setting interface %q master to %q", ifaceName, i.DstMaster())},
|
{setInterfaceMaster, fmt.Sprintf("error setting interface %q master to %q", ifaceName, i.DstMaster())},
|
||||||
{setInterfaceLinkLocalIPs, fmt.Sprintf("error setting interface %q link local IPs to %v", ifaceName, i.LinkLocalAddresses())},
|
{setInterfaceLinkLocalIPs, fmt.Sprintf("error setting interface %q link local IPs to %v", ifaceName, i.LinkLocalAddresses())},
|
||||||
|
{setInterfaceIPAliases, fmt.Sprintf("error setting interface %q IP Aliases to %v", ifaceName, i.IPAliases())},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, config := range ifaceConfigurators {
|
for _, config := range ifaceConfigurators {
|
||||||
|
@ -377,6 +386,16 @@ func setInterfaceLinkLocalIPs(nlh *netlink.Handle, iface netlink.Link, i *nwIfac
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setInterfaceIPAliases(nlh *netlink.Handle, iface netlink.Link, i *nwIface) error {
|
||||||
|
for _, si := range i.IPAliases() {
|
||||||
|
ipAddr := &netlink.Addr{IPNet: si}
|
||||||
|
if err := nlh.AddrAdd(iface, ipAddr); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func setInterfaceName(nlh *netlink.Handle, iface netlink.Link, i *nwIface) error {
|
func setInterfaceName(nlh *netlink.Handle, iface netlink.Link, i *nwIface) error {
|
||||||
return nlh.LinkSetName(iface, i.DstName())
|
return nlh.LinkSetName(iface, i.DstName())
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,12 @@ func (n *networkNamespace) LinkLocalAddresses(list []*net.IPNet) IfaceOption {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n *networkNamespace) IPAliases(list []*net.IPNet) IfaceOption {
|
||||||
|
return func(i *nwIface) {
|
||||||
|
i.ipAliases = list
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (n *networkNamespace) Routes(routes []*net.IPNet) IfaceOption {
|
func (n *networkNamespace) Routes(routes []*net.IPNet) IfaceOption {
|
||||||
return func(i *nwIface) {
|
return func(i *nwIface) {
|
||||||
i.routes = routes
|
i.routes = routes
|
||||||
|
|
|
@ -91,6 +91,9 @@ type IfaceOptionSetter interface {
|
||||||
// LinkLocalAddresses returns an option setter to set the link-local IP addresses.
|
// LinkLocalAddresses returns an option setter to set the link-local IP addresses.
|
||||||
LinkLocalAddresses([]*net.IPNet) IfaceOption
|
LinkLocalAddresses([]*net.IPNet) IfaceOption
|
||||||
|
|
||||||
|
// IPAliases returns an option setter to set IP address Aliases
|
||||||
|
IPAliases([]*net.IPNet) IfaceOption
|
||||||
|
|
||||||
// Master returns an option setter to set the master interface if any for this
|
// Master returns an option setter to set the master interface if any for this
|
||||||
// interface. The master interface name should refer to the srcname of a
|
// interface. The master interface name should refer to the srcname of a
|
||||||
// previously added interface of type bridge.
|
// previously added interface of type bridge.
|
||||||
|
@ -147,6 +150,9 @@ type Interface interface {
|
||||||
// LinkLocalAddresses returns the link-local IP addresses assigned to the interface.
|
// LinkLocalAddresses returns the link-local IP addresses assigned to the interface.
|
||||||
LinkLocalAddresses() []*net.IPNet
|
LinkLocalAddresses() []*net.IPNet
|
||||||
|
|
||||||
|
// IPAliases returns the IP address aliases assigned to the interface.
|
||||||
|
IPAliases() []*net.IPNet
|
||||||
|
|
||||||
// IP routes for the interface.
|
// IP routes for the interface.
|
||||||
Routes() []*net.IPNet
|
Routes() []*net.IPNet
|
||||||
|
|
||||||
|
|
|
@ -722,6 +722,10 @@ func (sb *sandbox) restoreOslSandbox() error {
|
||||||
if len(i.llAddrs) != 0 {
|
if len(i.llAddrs) != 0 {
|
||||||
ifaceOptions = append(ifaceOptions, sb.osSbox.InterfaceOptions().LinkLocalAddresses(i.llAddrs))
|
ifaceOptions = append(ifaceOptions, sb.osSbox.InterfaceOptions().LinkLocalAddresses(i.llAddrs))
|
||||||
}
|
}
|
||||||
|
if len(ep.virtualIP) != 0 {
|
||||||
|
vipAlias := &net.IPNet{IP: ep.virtualIP, Mask: net.CIDRMask(32, 32)}
|
||||||
|
ifaceOptions = append(ifaceOptions, sb.osSbox.InterfaceOptions().IPAliases([]*net.IPNet{vipAlias}))
|
||||||
|
}
|
||||||
Ifaces[fmt.Sprintf("%s+%s", i.srcName, i.dstPrefix)] = ifaceOptions
|
Ifaces[fmt.Sprintf("%s+%s", i.srcName, i.dstPrefix)] = ifaceOptions
|
||||||
if joinInfo != nil {
|
if joinInfo != nil {
|
||||||
for _, r := range joinInfo.StaticRoutes {
|
for _, r := range joinInfo.StaticRoutes {
|
||||||
|
@ -775,6 +779,10 @@ func (sb *sandbox) populateNetworkResources(ep *endpoint) error {
|
||||||
if len(i.llAddrs) != 0 {
|
if len(i.llAddrs) != 0 {
|
||||||
ifaceOptions = append(ifaceOptions, sb.osSbox.InterfaceOptions().LinkLocalAddresses(i.llAddrs))
|
ifaceOptions = append(ifaceOptions, sb.osSbox.InterfaceOptions().LinkLocalAddresses(i.llAddrs))
|
||||||
}
|
}
|
||||||
|
if len(ep.virtualIP) != 0 {
|
||||||
|
vipAlias := &net.IPNet{IP: ep.virtualIP, Mask: net.CIDRMask(32, 32)}
|
||||||
|
ifaceOptions = append(ifaceOptions, sb.osSbox.InterfaceOptions().IPAliases([]*net.IPNet{vipAlias}))
|
||||||
|
}
|
||||||
if i.mac != nil {
|
if i.mac != nil {
|
||||||
ifaceOptions = append(ifaceOptions, sb.osSbox.InterfaceOptions().MacAddress(i.mac))
|
ifaceOptions = append(ifaceOptions, sb.osSbox.InterfaceOptions().MacAddress(i.mac))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue