Skip to content

Commit

Permalink
Vendoring libnetwork 905d374
Browse files Browse the repository at this point in the history
Signed-off-by: Alessandro Boch <[email protected]>
(cherry picked from commit cabc5b2)
Signed-off-by: Tibor Vass <[email protected]>
  • Loading branch information
aboch authored and Tibor Vass committed Jul 26, 2016
1 parent ca9805f commit 8d7223d
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 8 deletions.
2 changes: 1 addition & 1 deletion hack/vendor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ clone git github.com/RackSec/srslog 259aed10dfa74ea2961eddd1d9847619f6e98837
clone git github.com/imdario/mergo 0.2.1

#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/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80
clone git github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec
Expand Down
2 changes: 2 additions & 0 deletions vendor/src/github.com/docker/libnetwork/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ func (c *controller) agentInit(bindAddrOrInterface string) error {
return false
})

c.WalkNetworks(joinCluster)

return nil
}

Expand Down
19 changes: 12 additions & 7 deletions vendor/src/github.com/docker/libnetwork/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -639,15 +639,20 @@ func (c *controller) NewNetwork(networkType, name string, id string, options ...
return nil, err
}

if err = network.joinCluster(); err != nil {
log.Errorf("Failed to join network %s into agent cluster: %v", name, err)
}

network.addDriverWatches()
joinCluster(network)

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() {
networks, err := c.getNetworksForScope(datastore.LocalScope)
if err != nil {
Expand Down Expand Up @@ -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 !s.isStub {
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
Expand Down Expand Up @@ -836,7 +841,7 @@ func (c *controller) NewSandbox(containerID string, options ...SandboxOption) (s
c.Lock()
if sb.ingress && c.ingressSandbox != nil {
c.Unlock()
return nil, fmt.Errorf("ingress sandbox already present")
return nil, types.ForbiddenErrorf("ingress sandbox already present")
}

if sb.ingress {
Expand Down
19 changes: 19 additions & 0 deletions vendor/src/github.com/docker/libnetwork/osl/interface_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type nwIface struct {
mac net.HardwareAddr
address *net.IPNet
addressIPv6 *net.IPNet
ipAliases []*net.IPNet
llAddrs []*net.IPNet
routes []*net.IPNet
bridge bool
Expand Down Expand Up @@ -96,6 +97,13 @@ func (i *nwIface) LinkLocalAddresses() []*net.IPNet {
return i.llAddrs
}

func (i *nwIface) IPAliases() []*net.IPNet {
i.Lock()
defer i.Unlock()

return i.ipAliases
}

func (i *nwIface) Routes() []*net.IPNet {
i.Lock()
defer i.Unlock()
Expand Down Expand Up @@ -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())},
{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())},
{setInterfaceIPAliases, fmt.Sprintf("error setting interface %q IP Aliases to %v", ifaceName, i.IPAliases())},
}

for _, config := range ifaceConfigurators {
Expand Down Expand Up @@ -377,6 +386,16 @@ func setInterfaceLinkLocalIPs(nlh *netlink.Handle, iface netlink.Link, i *nwIfac
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 {
return nlh.LinkSetName(iface, i.DstName())
}
Expand Down
6 changes: 6 additions & 0 deletions vendor/src/github.com/docker/libnetwork/osl/options_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
return func(i *nwIface) {
i.routes = routes
Expand Down
6 changes: 6 additions & 0 deletions vendor/src/github.com/docker/libnetwork/osl/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ type IfaceOptionSetter interface {
// LinkLocalAddresses returns an option setter to set the link-local IP addresses.
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
// interface. The master interface name should refer to the srcname of a
// previously added interface of type bridge.
Expand Down Expand Up @@ -147,6 +150,9 @@ type Interface interface {
// LinkLocalAddresses returns the link-local IP addresses assigned to the interface.
LinkLocalAddresses() []*net.IPNet

// IPAliases returns the IP address aliases assigned to the interface.
IPAliases() []*net.IPNet

// IP routes for the interface.
Routes() []*net.IPNet

Expand Down
8 changes: 8 additions & 0 deletions vendor/src/github.com/docker/libnetwork/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,10 @@ func (sb *sandbox) restoreOslSandbox() error {
if len(i.llAddrs) != 0 {
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
if joinInfo != nil {
for _, r := range joinInfo.StaticRoutes {
Expand Down Expand Up @@ -775,6 +779,10 @@ func (sb *sandbox) populateNetworkResources(ep *endpoint) error {
if len(i.llAddrs) != 0 {
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 {
ifaceOptions = append(ifaceOptions, sb.osSbox.InterfaceOptions().MacAddress(i.mac))
}
Expand Down

0 comments on commit 8d7223d

Please sign in to comment.