mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Vendoring libnetwork
Pull in version e5fea92a6c8a5968bdb8005bf959c6e23113b689 Fixes libnetwork regressions that stopped drivers that set routes from working. Pulls in libnetwork PRs #546 #543 Signed-off-by: Tom Denham <tom@tomdee.co.uk>
This commit is contained in:
parent
f018c0430b
commit
499ade0116
9 changed files with 52 additions and 26 deletions
|
@ -20,7 +20,7 @@ clone git github.com/tchap/go-patricia v2.1.0
|
|||
clone git golang.org/x/net 3cffabab72adf04f8e3b01c5baf775361837b5fe https://github.com/golang/net.git
|
||||
|
||||
#get libnetwork packages
|
||||
clone git github.com/docker/libnetwork 00a92f066e628e4c6d50979c070df377575aad18
|
||||
clone git github.com/docker/libnetwork e5fea92a6c8a5968bdb8005bf959c6e23113b689
|
||||
clone git github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec
|
||||
clone git github.com/hashicorp/go-msgpack 71c2886f5a673a35f909803f38ece5810165097b
|
||||
clone git github.com/hashicorp/memberlist 9a1e242e454d2443df330bdd51a436d5a9058fc4
|
||||
|
|
|
@ -23,6 +23,7 @@ _testmain.go
|
|||
*.exe
|
||||
*.test
|
||||
*.prof
|
||||
cmd/dnet/dnet
|
||||
|
||||
# Coverage
|
||||
*.tmp
|
||||
|
|
22
vendor/src/github.com/docker/libnetwork/Makefile
vendored
22
vendor/src/github.com/docker/libnetwork/Makefile
vendored
|
@ -1,4 +1,4 @@
|
|||
.PHONY: all all-local build build-local check check-code check-format run-tests check-local integration-tests install-deps coveralls circle-ci
|
||||
.PHONY: all all-local build build-local check check-code check-format run-tests check-local integration-tests install-deps coveralls circle-ci start-services clean
|
||||
SHELL=/bin/bash
|
||||
build_image=libnetwork-build
|
||||
dockerargs = --privileged -v $(shell pwd):/go/src/github.com/docker/libnetwork -w /go/src/github.com/docker/libnetwork
|
||||
|
@ -7,9 +7,9 @@ docker = docker run --rm -it ${dockerargs} ${container_env} ${build_image}
|
|||
ciargs = -e "COVERALLS_TOKEN=$$COVERALLS_TOKEN" -e "INSIDECONTAINER=-incontainer=true"
|
||||
cidocker = docker run ${ciargs} ${dockerargs} golang:1.4
|
||||
|
||||
all: ${build_image}.created build check integration-tests
|
||||
all: ${build_image}.created build check integration-tests clean
|
||||
|
||||
integration-tests:
|
||||
integration-tests: ./cmd/dnet/dnet
|
||||
@if [ ! -d ./integration-tmp ]; then \
|
||||
mkdir -p ./integration-tmp; \
|
||||
git clone https://github.com/sstephenson/bats.git ./integration-tmp/bats; \
|
||||
|
@ -17,6 +17,15 @@ integration-tests:
|
|||
fi
|
||||
@./integration-tmp/bin/bats ./test/integration/dnet
|
||||
|
||||
./cmd/dnet/dnet:
|
||||
make build-local
|
||||
|
||||
clean:
|
||||
@if [ -e ./cmd/dnet/dnet ]; then \
|
||||
echo "Removing dnet binary"; \
|
||||
rm -rf ./cmd/dnet/dnet; \
|
||||
fi
|
||||
|
||||
all-local: check-local build-local
|
||||
|
||||
${build_image}.created:
|
||||
|
@ -67,10 +76,10 @@ run-tests:
|
|||
done
|
||||
@echo "Done running tests"
|
||||
|
||||
check-local: check-format check-code run-tests
|
||||
check-local: check-format check-code start-services run-tests
|
||||
|
||||
install-deps:
|
||||
apt-get update && apt-get -y install iptables
|
||||
apt-get update && apt-get -y install iptables zookeeperd
|
||||
git clone https://github.com/golang/tools /go/src/golang.org/x/tools
|
||||
go install golang.org/x/tools/cmd/vet
|
||||
go install golang.org/x/tools/cmd/goimports
|
||||
|
@ -88,3 +97,6 @@ coveralls:
|
|||
circle-ci:
|
||||
@${cidocker} make install-deps build-local check-local coveralls
|
||||
make integration-tests
|
||||
|
||||
start-services:
|
||||
service zookeeper start
|
||||
|
|
|
@ -192,8 +192,8 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo,
|
|||
}
|
||||
|
||||
ifaceName := res.InterfaceName
|
||||
if ifaceName == nil {
|
||||
return fmt.Errorf("no interface name information received")
|
||||
if jinfo.InterfaceName() != nil && ifaceName == nil {
|
||||
return fmt.Errorf("no interface name information received while one is expected")
|
||||
}
|
||||
|
||||
if iface := jinfo.InterfaceName(); iface != nil {
|
||||
|
|
|
@ -203,22 +203,11 @@ func (ep *endpoint) AddStaticRoute(destination *net.IPNet, routeType int, nextHo
|
|||
ep.joinInfo.StaticRoutes = append(ep.joinInfo.StaticRoutes, &r)
|
||||
} else {
|
||||
// If the route doesn't specify a next-hop, it must be a connected route, bound to an interface.
|
||||
if err := ep.addInterfaceRoute(&r); err != nil {
|
||||
return err
|
||||
}
|
||||
ep.iface.routes = append(ep.iface.routes, r.Destination)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ep *endpoint) addInterfaceRoute(route *types.StaticRoute) error {
|
||||
ep.Lock()
|
||||
defer ep.Unlock()
|
||||
|
||||
iface := ep.iface
|
||||
iface.routes = append(iface.routes, route.Destination)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ep *endpoint) Sandbox() Sandbox {
|
||||
cnt, ok := ep.getSandbox()
|
||||
if !ok {
|
||||
|
|
|
@ -271,6 +271,11 @@ func (n *networkNamespace) AddInterface(srcName, dstPrefix string, options ...If
|
|||
return fmt.Errorf("failed to set link up: %v", err)
|
||||
}
|
||||
|
||||
// Set the routes on the interface. This can only be done when the interface is up.
|
||||
if err := setInterfaceRoutes(iface, i); err != nil {
|
||||
return fmt.Errorf("error setting interface %q routes to %q: %v", iface.Attrs().Name, i.Routes(), err)
|
||||
}
|
||||
|
||||
n.Lock()
|
||||
n.iFaces = append(n.iFaces, i)
|
||||
n.Unlock()
|
||||
|
@ -288,7 +293,6 @@ func configureInterface(iface netlink.Link, i *nwIface) error {
|
|||
{setInterfaceName, fmt.Sprintf("error renaming interface %q to %q", ifaceName, i.DstName())},
|
||||
{setInterfaceIP, fmt.Sprintf("error setting interface %q IP to %q", ifaceName, i.Address())},
|
||||
{setInterfaceIPv6, fmt.Sprintf("error setting interface %q IPv6 to %q", ifaceName, i.AddressIPv6())},
|
||||
{setInterfaceRoutes, fmt.Sprintf("error setting interface %q routes to %q", ifaceName, i.Routes())},
|
||||
{setInterfaceMaster, fmt.Sprintf("error setting interface %q master to %q", ifaceName, i.DstMaster())},
|
||||
}
|
||||
|
||||
|
@ -346,7 +350,7 @@ func setInterfaceRoutes(iface netlink.Link, i *nwIface) error {
|
|||
|
||||
// In older kernels (like the one in Centos 6.6 distro) sysctl does not have netns support. Therefore
|
||||
// we cannot gather the statistics from /sys/class/net/<dev>/statistics/<counter> files. Per-netns stats
|
||||
// are naturally found in /proc/net/dev in kernels which support netns (ifconfig relyes on that).
|
||||
// are naturally found in /proc/net/dev in kernels which support netns (ifconfig relies on that).
|
||||
const (
|
||||
netStatsFile = "/proc/net/dev"
|
||||
base = "[ ]*%s:([ ]+[0-9]+){16}"
|
||||
|
|
|
@ -49,7 +49,7 @@ func init() {
|
|||
}
|
||||
|
||||
func createBasePath() {
|
||||
err := os.MkdirAll(prefix, 0644)
|
||||
err := os.MkdirAll(prefix, 0755)
|
||||
if err != nil {
|
||||
panic("Could not create net namespace path directory")
|
||||
}
|
||||
|
|
|
@ -416,6 +416,7 @@ func (sb *sandbox) clearNetworkResources(ep *endpoint) error {
|
|||
|
||||
const (
|
||||
defaultPrefix = "/var/lib/docker/network/files"
|
||||
dirPerm = 0755
|
||||
filePerm = 0644
|
||||
)
|
||||
|
||||
|
@ -777,7 +778,7 @@ func (eh *epHeap) Pop() interface{} {
|
|||
}
|
||||
|
||||
func createBasePath(dir string) error {
|
||||
return os.MkdirAll(dir, filePerm)
|
||||
return os.MkdirAll(dir, dirPerm)
|
||||
}
|
||||
|
||||
func createFile(path string) error {
|
||||
|
|
23
vendor/src/github.com/docker/libnetwork/store.go
vendored
23
vendor/src/github.com/docker/libnetwork/store.go
vendored
|
@ -174,7 +174,11 @@ func (c *controller) watchNetworks() error {
|
|||
cs := c.store
|
||||
c.Unlock()
|
||||
|
||||
nwPairs, err := cs.KVStore().WatchTree(datastore.Key(datastore.NetworkKeyPrefix), nil)
|
||||
networkKey := datastore.Key(datastore.NetworkKeyPrefix)
|
||||
if err := ensureKeys(networkKey, cs); err != nil {
|
||||
return fmt.Errorf("failed to ensure if the network keys are valid and present in store: %v", err)
|
||||
}
|
||||
nwPairs, err := cs.KVStore().WatchTree(networkKey, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -228,7 +232,11 @@ func (n *network) watchEndpoints() error {
|
|||
stopCh := n.stopWatchCh
|
||||
n.Unlock()
|
||||
|
||||
epPairs, err := cs.KVStore().WatchTree(datastore.Key(tmp.KeyPrefix()...), stopCh)
|
||||
endpointKey := datastore.Key(tmp.KeyPrefix()...)
|
||||
if err := ensureKeys(endpointKey, cs); err != nil {
|
||||
return fmt.Errorf("failed to ensure if the endpoint keys are valid and present in store: %v", err)
|
||||
}
|
||||
epPairs, err := cs.KVStore().WatchTree(endpointKey, stopCh)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -362,3 +370,14 @@ func (c *controller) processEndpointUpdate(ep *endpoint) bool {
|
|||
|
||||
return false
|
||||
}
|
||||
|
||||
func ensureKeys(key string, cs datastore.DataStore) error {
|
||||
exists, err := cs.KVStore().Exists(key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if exists {
|
||||
return nil
|
||||
}
|
||||
return cs.KVStore().Put(key, []byte{}, nil)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue