Explorar o código

Vendoring libnetwork v0.7.0-dev.8

Signed-off-by: Alessandro Boch <aboch@docker.com>
Alessandro Boch %!s(int64=9) %!d(string=hai) anos
pai
achega
6223291965

+ 1 - 1
hack/vendor.sh

@@ -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

+ 10 - 0
vendor/src/github.com/docker/libnetwork/CHANGELOG.md

@@ -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

+ 58 - 0
vendor/src/github.com/docker/libnetwork/Vagrantfile

@@ -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

+ 13 - 5
vendor/src/github.com/docker/libnetwork/controller.go

@@ -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
@@ -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
 	}
 
@@ -521,6 +526,9 @@ func (c *controller) Networks() []Network {
 	}
 
 	for _, n := range networks {
+		if n.inDelete {
+			continue
+		}
 		list = append(list, n)
 	}
 

+ 4 - 8
vendor/src/github.com/docker/libnetwork/drivers/bridge/setup_ip_tables.go

@@ -6,7 +6,6 @@ import (
 
 	"github.com/Sirupsen/logrus"
 	"github.com/docker/libnetwork/iptables"
-	"github.com/docker/libnetwork/netutils"
 )
 
 // DockerChain: DOCKER iptable chain name
@@ -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
@@ -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 {

+ 4 - 0
vendor/src/github.com/docker/libnetwork/drivers/ipvlan/ipvlan_network.go

@@ -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 {

+ 4 - 0
vendor/src/github.com/docker/libnetwork/drivers/macvlan/macvlan_network.go

@@ -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 {

+ 3 - 0
vendor/src/github.com/docker/libnetwork/drivers/windows/labels.go

@@ -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"
 )

+ 16 - 10
vendor/src/github.com/docker/libnetwork/drivers/windows/windows.go

@@ -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
@@ -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
 		}
 	}
 
@@ -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 == "" {
@@ -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)

+ 13 - 0
vendor/src/github.com/docker/libnetwork/endpoint.go

@@ -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 - 0
vendor/src/github.com/docker/libnetwork/endpoint_cnt.go

@@ -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()

+ 4 - 3
vendor/src/github.com/docker/libnetwork/ipams/windowsipam/windowsipam.go

@@ -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

+ 39 - 21
vendor/src/github.com/docker/libnetwork/network.go

@@ -167,6 +167,7 @@ type network struct {
 	stopWatchCh  chan struct{}
 	drvOnce      *sync.Once
 	internal     bool
+	inDelete     bool
 	sync.Mutex
 }
 
@@ -306,6 +307,7 @@ func (n *network) CopyTo(o datastore.KVObject) error {
 	dstN.dbExists = n.dbExists
 	dstN.drvOnce = n.drvOnce
 	dstN.internal = n.internal
+	dstN.inDelete = n.inDelete
 
 	for _, v4conf := range n.ipamV4Config {
 		dstV4Conf := &IpamConf{}
@@ -394,6 +396,7 @@ func (n *network) MarshalJSON() ([]byte, error) {
 		netMap["ipamV6Info"] = string(iis)
 	}
 	netMap["internal"] = n.internal
+	netMap["inDelete"] = n.inDelete
 	return json.Marshal(netMap)
 }
 
@@ -463,6 +466,9 @@ func (n *network) UnmarshalJSON(b []byte) (err error) {
 	if s, ok := netMap["scope"]; ok {
 		n.scope = s.(string)
 	}
+	if v, ok := netMap["inDelete"]; ok {
+		n.inDelete = v.(bool)
+	}
 	return nil
 }
 
@@ -611,6 +617,10 @@ func (n *network) driver(load bool) (driverapi.Driver, error) {
 }
 
 func (n *network) Delete() error {
+	return n.delete(false)
+}
+
+func (n *network) delete(force bool) error {
 	n.Lock()
 	c := n.ctrlr
 	name := n.name
@@ -622,33 +632,39 @@ func (n *network) Delete() error {
 		return &UnknownNetworkError{name: name, id: id}
 	}
 
-	numEps := n.getEpCnt().EndpointCnt()
-	if numEps != 0 {
+	if !force && n.getEpCnt().EndpointCnt() != 0 {
 		return &ActiveEndpointsError{name: n.name, id: n.id}
 	}
 
-	if err = n.deleteNetwork(); err != nil {
-		return err
+	// Mark the network for deletion
+	n.inDelete = true
+	if err = c.updateToStore(n); err != nil {
+		return fmt.Errorf("error marking network %s (%s) for deletion: %v", n.Name(), n.ID(), err)
 	}
-	defer func() {
-		if err != nil {
-			if e := c.addNetwork(n); e != nil {
-				log.Warnf("failed to rollback deleteNetwork for network %s: %v",
-					n.Name(), err)
-			}
+
+	if err = n.deleteNetwork(); err != nil {
+		if !force {
+			return err
 		}
-	}()
+		log.Debugf("driver failed to delete stale network %s (%s): %v", n.Name(), n.ID(), err)
+	}
+
+	n.ipamRelease()
+	if err = c.updateToStore(n); err != nil {
+		log.Warnf("Failed to update store after ipam release for network %s (%s): %v", n.Name(), n.ID(), err)
+	}
 
 	// deleteFromStore performs an atomic delete operation and the
 	// network.epCnt will help prevent any possible
 	// race between endpoint join and network delete
-	if err = n.getController().deleteFromStore(n.getEpCnt()); err != nil {
-		return fmt.Errorf("error deleting network endpoint count from store: %v", err)
+	if err = c.deleteFromStore(n.getEpCnt()); err != nil {
+		if !force {
+			return fmt.Errorf("error deleting network endpoint count from store: %v", err)
+		}
+		log.Debugf("Error deleting endpoint count from store for stale network %s (%s) for deletion: %v", n.Name(), n.ID(), err)
 	}
 
-	n.ipamRelease()
-
-	if err = n.getController().deleteFromStore(n); err != nil {
+	if err = c.deleteFromStore(n); err != nil {
 		return fmt.Errorf("error deleting network from store: %v", err)
 	}
 
@@ -1098,25 +1114,25 @@ func (n *network) ipamRelease() {
 }
 
 func (n *network) ipamReleaseVersion(ipVer int, ipam ipamapi.Ipam) {
-	var infoList []*IpamInfo
+	var infoList *[]*IpamInfo
 
 	switch ipVer {
 	case 4:
-		infoList = n.ipamV4Info
+		infoList = &n.ipamV4Info
 	case 6:
-		infoList = n.ipamV6Info
+		infoList = &n.ipamV6Info
 	default:
 		log.Warnf("incorrect ip version passed to ipam release: %d", ipVer)
 		return
 	}
 
-	if infoList == nil {
+	if *infoList == nil {
 		return
 	}
 
 	log.Debugf("releasing IPv%d pools from network %s (%s)", ipVer, n.Name(), n.ID())
 
-	for _, d := range infoList {
+	for _, d := range *infoList {
 		if d.Gateway != nil {
 			if err := ipam.ReleaseAddress(d.PoolID, d.Gateway.IP); err != nil {
 				log.Warnf("Failed to release gateway ip address %s on delete of network %s (%s): %v", d.Gateway.IP, n.Name(), n.ID(), err)
@@ -1135,6 +1151,8 @@ func (n *network) ipamReleaseVersion(ipVer int, ipam ipamapi.Ipam) {
 			log.Warnf("Failed to release address pool %s on delete of network %s (%s): %v", d.PoolID, n.Name(), n.ID(), err)
 		}
 	}
+
+	*infoList = nil
 }
 
 func (n *network) getIPInfo(ipVer int) []*IpamInfo {

+ 12 - 0
vendor/src/github.com/docker/libnetwork/resolver.go

@@ -139,6 +139,11 @@ func (r *resolver) Start() error {
 }
 
 func (r *resolver) Stop() {
+	for i := 0; i < maxExtDNS; i++ {
+		r.extDNSList[i].extConn = nil
+		r.extDNSList[i].extOnce = sync.Once{}
+	}
+
 	if r.server != nil {
 		r.server.Shutdown()
 	}
@@ -319,6 +324,13 @@ func (r *resolver) ServeDNS(w dns.ResponseWriter, query *dns.Msg) {
 					continue
 				}
 			}
+			// If two go routines are executing in parralel one will
+			// block on the Once.Do and in case of error connecting
+			// to the external server it will end up with a nil err
+			// but extConn also being nil.
+			if extConn == nil {
+				continue
+			}
 
 			// Timeout has to be set for every IO operation.
 			extConn.SetDeadline(time.Now().Add(extIOTimeout))

+ 4 - 6
vendor/src/github.com/docker/libnetwork/sandbox_externalkey_unix.go

@@ -12,7 +12,6 @@ import (
 
 	"github.com/Sirupsen/logrus"
 	"github.com/docker/libnetwork/types"
-	"github.com/opencontainers/runc/libcontainer"
 	"github.com/opencontainers/runc/libcontainer/configs"
 )
 
@@ -21,7 +20,7 @@ const success = "success"
 
 // processSetKeyReexec is a private function that must be called only on an reexec path
 // It expects 3 args { [0] = "libnetwork-setkey", [1] = <container-id>, [2] = <controller-id> }
-// It also expects libcontainer.State as a json string in <stdin>
+// It also expects configs.HookState as a json string in <stdin>
 // Refer to https://github.com/opencontainers/runc/pull/160/ for more information
 func processSetKeyReexec() {
 	var err error
@@ -40,20 +39,19 @@ func processSetKeyReexec() {
 	}
 	containerID := os.Args[1]
 
-	// We expect libcontainer.State as a json string in <stdin>
+	// We expect configs.HookState as a json string in <stdin>
 	stateBuf, err := ioutil.ReadAll(os.Stdin)
 	if err != nil {
 		return
 	}
-	var state libcontainer.State
+	var state configs.HookState
 	if err = json.Unmarshal(stateBuf, &state); err != nil {
 		return
 	}
 
 	controllerID := os.Args[2]
-	key := state.NamespacePaths[configs.NamespaceType("NEWNET")]
 
-	err = SetExternalKey(controllerID, containerID, key)
+	err = SetExternalKey(controllerID, containerID, fmt.Sprintf("/proc/%d/ns/net", state.Pid))
 	return
 }
 

+ 1 - 1
vendor/src/github.com/docker/libnetwork/sandbox_externalkey_windows.go

@@ -11,7 +11,7 @@ import (
 
 // processSetKeyReexec is a private function that must be called only on an reexec path
 // It expects 3 args { [0] = "libnetwork-setkey", [1] = <container-id>, [2] = <controller-id> }
-// It also expects libcontainer.State as a json string in <stdin>
+// It also expects configs.HookState as a json string in <stdin>
 // Refer to https://github.com/opencontainers/runc/pull/160/ for more information
 func processSetKeyReexec() {
 }

+ 1 - 0
vendor/src/github.com/docker/libnetwork/sandbox_store.go

@@ -226,6 +226,7 @@ func (c *controller) sandboxCleanup() {
 			heap.Push(&sb.endpoints, ep)
 		}
 
+		logrus.Infof("Removing stale sandbox %s (%s)", sb.id, sb.containerID)
 		if err := sb.delete(true); err != nil {
 			logrus.Errorf("failed to delete sandbox %s while trying to cleanup: %v", sb.id, err)
 		}

+ 20 - 3
vendor/src/github.com/docker/libnetwork/store.go

@@ -71,7 +71,7 @@ func (c *controller) getNetworkFromStore(nid string) (*network, error) {
 
 		ec := &endpointCnt{n: n}
 		err = store.GetObject(datastore.Key(ec.Key()...), ec)
-		if err != nil {
+		if err != nil && !n.inDelete {
 			return nil, fmt.Errorf("could not find endpoint count for network %s: %v", n.Name(), err)
 		}
 
@@ -104,7 +104,7 @@ func (c *controller) getNetworksForScope(scope string) ([]*network, error) {
 
 		ec := &endpointCnt{n: n}
 		err = store.GetObject(datastore.Key(ec.Key()...), ec)
-		if err != nil {
+		if err != nil && !n.inDelete {
 			log.Warnf("Could not find endpoint count key %s for network %s while listing: %v", datastore.Key(ec.Key()...), n.Name(), err)
 			continue
 		}
@@ -139,7 +139,7 @@ func (c *controller) getNetworksFromStore() ([]*network, error) {
 
 			ec := &endpointCnt{n: n}
 			err = store.GetObject(datastore.Key(ec.Key()...), ec)
-			if err != nil {
+			if err != nil && !n.inDelete {
 				log.Warnf("could not find endpoint count key %s for network %s while listing: %v", datastore.Key(ec.Key()...), n.Name(), err)
 				continue
 			}
@@ -428,3 +428,20 @@ func (c *controller) startWatch() {
 
 	go c.watchLoop()
 }
+
+func (c *controller) networkCleanup() {
+	networks, err := c.getNetworksFromStore()
+	if err != nil {
+		log.Warnf("Could not retrieve networks from store(s) during network cleanup: %v", err)
+		return
+	}
+
+	for _, n := range networks {
+		if n.inDelete {
+			log.Infof("Removing stale network %s (%s)", n.Name(), n.ID())
+			if err := n.delete(true); err != nil {
+				log.Debugf("Error while removing stale network: %v", err)
+			}
+		}
+	}
+}

+ 34 - 0
vendor/src/github.com/mistifyio/go-zfs/Vagrantfile

@@ -0,0 +1,34 @@
+
+VAGRANTFILE_API_VERSION = "2"
+
+Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
+    config.vm.box = "ubuntu/trusty64"
+	config.ssh.forward_agent = true
+
+	config.vm.synced_folder ".", "/home/vagrant/go/src/github.com/mistifyio/go-zfs", create: true
+
+    config.vm.provision "shell", inline: <<EOF
+cat << END > /etc/profile.d/go.sh
+export GOPATH=\\$HOME/go
+export PATH=\\$GOPATH/bin:/usr/local/go/bin:\\$PATH
+END
+
+chown -R vagrant /home/vagrant/go
+
+apt-get update
+apt-get install -y software-properties-common curl
+apt-add-repository --yes ppa:zfs-native/stable
+apt-get update
+apt-get install -y ubuntu-zfs
+
+cd /home/vagrant
+curl -z go1.3.3.linux-amd64.tar.gz -L -O https://storage.googleapis.com/golang/go1.3.3.linux-amd64.tar.gz
+tar -C /usr/local -zxf /home/vagrant/go1.3.3.linux-amd64.tar.gz
+
+cat << END > /etc/sudoers.d/go
+Defaults env_keep += "GOPATH"
+END
+
+EOF
+
+end