Skip to content

Commit

Permalink
Vendoring libnetwork v0.7.0-dev.8
Browse files Browse the repository at this point in the history
Signed-off-by: Alessandro Boch <[email protected]>
  • Loading branch information
aboch committed Mar 16, 2016
1 parent f817548 commit 6223291
Show file tree
Hide file tree
Showing 19 changed files with 248 additions and 58 deletions.
2 changes: 1 addition & 1 deletion hack/vendor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,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 v0.7.0-dev.7
clone git github.com/docker/libnetwork v0.7.0-dev.8
clone git github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec
clone git github.com/hashicorp/go-msgpack 71c2886f5a673a35f909803f38ece5810165097b
clone git github.com/hashicorp/memberlist 9a1e242e454d2443df330bdd51a436d5a9058fc4
Expand Down
10 changes: 10 additions & 0 deletions vendor/src/github.com/docker/libnetwork/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 0.7.0-dev.8 (2016-03-16)
- Windows driver to respect user set MAC address.
- Fix possible nil pointer reference in ServeDNS() with concurrent go routines.
- Fix netns path setting from hook (for containerd integration)
- Clear cached udp connections on resolver Stop()
- Avoid network/endpoint count inconsistences and remove stale networks after ungraceful shutdown
- Fix possible endpoint count inconsistency after ungraceful shutdown
- Reject a null v4 IPAM slice in exp vlan drivers
- Removed experimental drivers modprobe check

## 0.7.0-dev.7 (2016-03-11)
- Bumped up the minimum kernel version for ipvlan to 4.2
- Removed modprobe from macvlan/ipvlan drivers to resolve docker IT failures
Expand Down
58 changes: 58 additions & 0 deletions vendor/src/github.com/docker/libnetwork/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

$consul=<<SCRIPT
apt-get update
apt-get -y install wget
wget -qO- https://experimental.docker.com/ | sh
gpasswd -a vagrant docker
service docker restart
docker run -d -p 8500:8500 -p 8300-8302:8300-8302/tcp -p 8300-8302:8300-8302/udp -h consul progrium/consul -server -bootstrap
SCRIPT

$bootstrap=<<SCRIPT
apt-get update
apt-get -y install wget curl
apt-get -y install bridge-utils
wget -qO- https://experimental.docker.com/ | sh
gpasswd -a vagrant docker
echo DOCKER_OPTS=\\"--cluster-store=consul://192.168.33.10:8500 --cluster-advertise=${1}:0\\" >> /etc/default/docker
cp /vagrant/docs/vagrant-systemd/docker.service /etc/systemd/system/
systemctl daemon-reload
systemctl restart docker.service
SCRIPT

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
num_nodes = 2
base_ip = "192.168.33."
net_ips = num_nodes.times.collect { |n| base_ip + "#{n+11}" }

config.vm.define "consul-server" do |consul|
consul.vm.box = "ubuntu/trusty64"
consul.vm.hostname = "consul-server"
consul.vm.network :private_network, ip: "192.168.33.10"
consul.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "512"]
end
consul.vm.provision :shell, inline: $consul
end

num_nodes.times do |n|
config.vm.define "net-#{n+1}" do |net|
net.vm.box = "ubuntu/vivid64"
net_ip = net_ips[n]
net_index = n+1
net.vm.hostname = "net-#{net_index}"
net.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "1024"]
end
net.vm.network :private_network, ip: "#{net_ip}"
net.vm.provision :shell, inline: $bootstrap, :args => "#{net_ip}"
end
end

end
18 changes: 13 additions & 5 deletions vendor/src/github.com/docker/libnetwork/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ func New(cfgOptions ...config.Option) (NetworkController, error) {

c.sandboxCleanup()
c.cleanupLocalEndpoints()
c.networkCleanup()

if err := c.startExternalKeyListener(); err != nil {
return nil, err
Expand Down Expand Up @@ -479,19 +480,23 @@ func (c *controller) NewNetwork(networkType, name string, options ...NetworkOpti
}
}()

if err = c.updateToStore(network); err != nil {
// First store the endpoint count, then the network. To avoid to
// end up with a datastore containing a network and not an epCnt,
// in case of an ungraceful shutdown during this function call.
epCnt := &endpointCnt{n: network}
if err = c.updateToStore(epCnt); err != nil {
return nil, err
}
defer func() {
if err != nil {
if e := c.deleteFromStore(network); e != nil {
log.Warnf("couldnt rollback from store, network %s on failure (%v): %v", network.name, err, e)
if e := c.deleteFromStore(epCnt); e != nil {
log.Warnf("couldnt rollback from store, epCnt %v on failure (%v): %v", epCnt, err, e)
}
}
}()

network.epCnt = &endpointCnt{n: network}
if err = c.updateToStore(network.epCnt); err != nil {
network.epCnt = epCnt
if err = c.updateToStore(network); err != nil {
return nil, err
}

Expand Down Expand Up @@ -521,6 +526,9 @@ func (c *controller) Networks() []Network {
}

for _, n := range networks {
if n.inDelete {
continue
}
list = append(list, n)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"github.com/Sirupsen/logrus"
"github.com/docker/libnetwork/iptables"
"github.com/docker/libnetwork/netutils"
)

// DockerChain: DOCKER iptable chain name
Expand Down Expand Up @@ -60,6 +59,8 @@ func setupIPChains(config *configuration) (*iptables.ChainInfo, *iptables.ChainI
}

func (n *bridgeNetwork) setupIPTables(config *networkConfiguration, i *bridgeInterface) error {
var err error

d := n.driver
d.Lock()
driverConfig := d.config
Expand All @@ -73,14 +74,9 @@ func (n *bridgeNetwork) setupIPTables(config *networkConfiguration, i *bridgeInt
// Pickup this configuraton option from driver
hairpinMode := !driverConfig.EnableUserlandProxy

addrv4, _, err := netutils.GetIfaceAddr(config.BridgeName)
if err != nil {
return fmt.Errorf("Failed to setup IP tables, cannot acquire Interface address: %s", err.Error())
}
ipnet := addrv4.(*net.IPNet)
maskedAddrv4 := &net.IPNet{
IP: ipnet.IP.Mask(ipnet.Mask),
Mask: ipnet.Mask,
IP: i.bridgeIPv4.IP.Mask(i.bridgeIPv4.Mask),
Mask: i.bridgeIPv4.Mask,
}
if config.Internal {
if err = setupInternalNetworkRules(config.BridgeName, maskedAddrv4, true); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ func (d *driver) CreateNetwork(nid string, option map[string]interface{}, ipV4Da
return fmt.Errorf("kernel version failed to meet the minimum ipvlan kernel requirement of %d.%d, found %d.%d.%d",
ipvlanKernelVer, ipvlanMajorVer, kv.Kernel, kv.Major, kv.Minor)
}
// reject a null v4 network
if len(ipV4Data) == 0 || ipV4Data[0].Pool.String() == "0.0.0.0/0" {
return fmt.Errorf("ipv4 pool is empty")
}
// parse and validate the config and bind to networkConfiguration
config, err := parseNetworkOptions(nid, option)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ func (d *driver) CreateNetwork(nid string, option map[string]interface{}, ipV4Da
return fmt.Errorf("kernel version failed to meet the minimum macvlan kernel requirement of %d.%d, found %d.%d.%d",
macvlanKernelVer, macvlanMajorVer, kv.Kernel, kv.Major, kv.Minor)
}
// reject a null v4 network
if len(ipV4Data) == 0 || ipV4Data[0].Pool.String() == "0.0.0.0/0" {
return fmt.Errorf("ipv4 pool is empty")
}
// parse and validate the config and bind to networkConfiguration
config, err := parseNetworkOptions(nid, option)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ const (

// RoutingDomain of the network
RoutingDomain = "com.docker.network.windowsshim.routingdomain"

// Interface of the network
Interface = "com.docker.network.windowsshim.interface"
)
26 changes: 16 additions & 10 deletions vendor/src/github.com/docker/libnetwork/drivers/windows/windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ import (

// networkConfiguration for network specific configuration
type networkConfiguration struct {
ID string
Type string
Name string
HnsID string
RDID string
ID string
Type string
Name string
HnsID string
RDID string
NetworkAdapterName string
}

// endpointConfiguration represents the user specified configuration for the sandbox endpoint
Expand Down Expand Up @@ -125,6 +126,8 @@ func (d *driver) parseNetworkOptions(id string, genericOptions map[string]string
config.HnsID = value
case RoutingDomain:
config.RDID = value
case Interface:
config.NetworkAdapterName = value
}
}

Expand Down Expand Up @@ -197,9 +200,10 @@ func (d *driver) CreateNetwork(id string, option map[string]interface{}, ipV4Dat
}

network := &hcsshim.HNSNetwork{
Name: config.Name,
Type: d.name,
Subnets: subnets,
Name: config.Name,
Type: d.name,
Subnets: subnets,
NetworkAdapterName: config.NetworkAdapterName,
}

if network.Name == "" {
Expand Down Expand Up @@ -364,8 +368,10 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo,

ec, err := parseEndpointOptions(epOptions)

if err != nil {
return err
macAddress := ifInfo.MacAddress()
// Use the macaddress if it was provided
if macAddress != nil {
endpointStruct.MacAddress = strings.Replace(macAddress.String(), ":", "-", -1)
}

endpointStruct.Policies, err = convertPortBindings(ec.PortBindings)
Expand Down
13 changes: 13 additions & 0 deletions vendor/src/github.com/docker/libnetwork/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -996,9 +996,22 @@ func (c *controller) cleanupLocalEndpoints() {
}

for _, ep := range epl {
log.Infof("Removing stale endpoint %s (%s)", ep.name, ep.id)
if err := ep.Delete(true); err != nil {
log.Warnf("Could not delete local endpoint %s during endpoint cleanup: %v", ep.name, err)
}
}

epl, err = n.getEndpointsFromStore()
if err != nil {
log.Warnf("Could not get list of endpoints in network %s for count update: %v", n.name, err)
continue
}

epCnt := n.getEpCnt().EndpointCnt()
if epCnt != uint64(len(epl)) {
log.Infof("Fixing inconsistent endpoint_cnt for network %s. Expected=%d, Actual=%d", n.name, len(epl), epCnt)
n.getEpCnt().setCnt(uint64(len(epl)))
}
}
}
7 changes: 7 additions & 0 deletions vendor/src/github.com/docker/libnetwork/endpoint_cnt.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ func (ec *endpointCnt) updateStore() error {
}
}

func (ec *endpointCnt) setCnt(cnt uint64) error {
ec.Lock()
ec.Count = cnt
ec.Unlock()
return ec.updateStore()
}

func (ec *endpointCnt) atomicIncDecEpCnt(inc bool) error {
retry:
ec.Lock()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,13 @@ func (a *allocator) RequestAddress(poolID string, prefAddress net.IP, opts map[s

// TODO Windows: Remove this once the bug in docker daemon is fixed
// that causes it to throw an exception on nil gateway
if opts[ipamapi.RequestAddressType] == netlabel.Gateway {
if prefAddress != nil {
return &net.IPNet{IP: prefAddress, Mask: ipNet.Mask}, nil, nil
} else if opts[ipamapi.RequestAddressType] == netlabel.Gateway {
return ipNet, nil, nil
} else if prefAddress == nil {
} else {
return nil, nil, nil
}
return &net.IPNet{IP: prefAddress, Mask: ipNet.Mask}, nil, nil
}

// ReleaseAddress releases the address - always succeeds
Expand Down
Loading

0 comments on commit 6223291

Please sign in to comment.