Skip to content

Commit 8ccf5cf

Browse files
author
Santhosh Manohar
committed
Vendoring libnetwork and its dependencies..
- replace /etc/hosts based name resolution with embedded DNS for user defined networks - overlay veth cleanup: moby#18814 - check before programming ipv6 in bridge: moby#19139 - diable DAD: moby#18871 Signed-off-by: Santhosh Manohar <santhosh@docker.com>
1 parent 807d575 commit 8ccf5cf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+15590
-215
lines changed

hack/vendor.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ clone git github.com/docker/go-connections v0.1.2
2525
clone git github.com/docker/engine-api v0.1.3
2626

2727
#get libnetwork packages
28-
clone git github.com/docker/libnetwork 49c24217054e269aad3dbfd81ee32780b104dd84
28+
clone git github.com/docker/libnetwork c8ec4bd24e1e76feb4f79e3924c68cd2ce89938a
2929
clone git github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec
3030
clone git github.com/hashicorp/go-msgpack 71c2886f5a673a35f909803f38ece5810165097b
3131
clone git github.com/hashicorp/memberlist 9a1e242e454d2443df330bdd51a436d5a9058fc4
3232
clone git github.com/hashicorp/serf 7151adcef72687bf95f451a2e0ba15cb19412bf2
3333
clone git github.com/docker/libkv c2aac5dbbaa5c872211edea7c0f32b3bd67e7410
3434
clone git github.com/vishvananda/netns 604eaf189ee867d8c147fafc28def2394e878d25
35-
clone git github.com/vishvananda/netlink 8e810149a2e531fed9b837c0c7d8a8922d2bedf7
35+
clone git github.com/vishvananda/netlink bfd70f556483c008636b920dda142fdaa0d59ef9
3636
clone git github.com/BurntSushi/toml f706d00e3de6abe700c994cdd545a1a4915af060
3737
clone git github.com/samuel/go-zookeeper d0e0d8e11f318e000a8cc434616d69e329edc374
3838
clone git github.com/deckarep/golang-set ef32fa3046d9f249d399f98ebaf9be944430fd1d
@@ -41,6 +41,7 @@ fix_rewritten_imports github.com/coreos/etcd
4141
clone git github.com/ugorji/go 5abd4e96a45c386928ed2ca2a7ef63e2533e18ec
4242
clone git github.com/hashicorp/consul v0.5.2
4343
clone git github.com/boltdb/bolt v1.1.0
44+
clone git github.com/miekg/dns d27455715200c7d3e321a1e5cadb27c9ee0b0f02
4445

4546
# get graph and distribution packages
4647
clone git github.com/docker/distribution 568bf038af6d65b376165d02886b1c7fcaef1f61

vendor/src/github.com/docker/libnetwork/Dockerfile.build

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
FROM golang:1.4-cross
22
RUN apt-get update && apt-get -y install iptables
3+
4+
RUN cd /go/src && mkdir -p golang.org/x && \
5+
cd golang.org/x && git clone https://github.com/golang/tools && \
6+
cd tools && git checkout release-branch.go1.5
7+
38
RUN go get github.com/tools/godep \
49
github.com/golang/lint/golint \
510
golang.org/x/tools/cmd/vet \

vendor/src/github.com/docker/libnetwork/Makefile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ build_image=libnetworkbuild
44
dockerargs = --privileged -v $(shell pwd):/go/src/github.com/docker/libnetwork -w /go/src/github.com/docker/libnetwork
55
container_env = -e "INSIDECONTAINER=-incontainer=true"
66
docker = docker run --rm -it ${dockerargs} $$EXTRA_ARGS ${container_env} ${build_image}
7-
ciargs = -e "COVERALLS_TOKEN=$$COVERALLS_TOKEN" -e "INSIDECONTAINER=-incontainer=true"
7+
ciargs = -e CIRCLECI -e "COVERALLS_TOKEN=$$COVERALLS_TOKEN" -e "INSIDECONTAINER=-incontainer=true"
88
cidocker = docker run ${dockerargs} ${ciargs} ${container_env} ${build_image}
99
CROSS_PLATFORMS = linux/amd64 linux/386 linux/arm windows/amd64 windows/386
1010

11-
${build_image}.created:
12-
docker build -f Dockerfile.build -t ${build_image} .
13-
touch ${build_image}.created
14-
1511
all: ${build_image}.created build check integration-tests clean
1612

1713
all-local: build-local check-local integration-tests-local clean
1814

15+
${build_image}.created:
16+
docker build -f Dockerfile.build -t ${build_image} .
17+
touch ${build_image}.created
18+
1919
build: ${build_image}.created
2020
@echo "Building code... "
2121
@${docker} ./wrapmake.sh build-local
@@ -34,9 +34,9 @@ clean:
3434
cross: ${build_image}.created
3535
@mkdir -p "bin"
3636
@for platform in ${CROSS_PLATFORMS}; do \
37-
EXTRA_ARGS="-e GOOS=$${platform%/*} -e GOARCH=$${platform##*/}" ; \
37+
EXTRA_ARGS="-e GOOS=$${platform%/*} -e GOARCH=$${platform##*/}" ; \
3838
echo "$${platform}..." ; \
39-
${docker} make cross-local ; \
39+
${docker} make cross-local ; \
4040
done
4141

4242
cross-local:
@@ -91,9 +91,9 @@ coveralls:
9191
circle-ci-cross: ${build_image}.created
9292
@mkdir -p "bin"
9393
@for platform in ${CROSS_PLATFORMS}; do \
94-
EXTRA_ARGS="-e GOOS=$${platform%/*} -e GOARCH=$${platform##*/}" ; \
94+
EXTRA_ARGS="-e GOOS=$${platform%/*} -e GOARCH=$${platform##*/}" ; \
9595
echo "$${platform}..." ; \
96-
${cidocker} make cross-local ; \
96+
${cidocker} make cross-local ; \
9797
done
9898

9999
circle-ci-check: ${build_image}.created

vendor/src/github.com/docker/libnetwork/controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ type controller struct {
143143
extKeyListener net.Listener
144144
watchCh chan *endpoint
145145
unWatchCh chan *endpoint
146-
svcDb map[string]svcMap
146+
svcDb map[string]svcInfo
147147
nmap map[string]*netWatch
148148
defOsSbox osl.Sandbox
149149
sboxOnce sync.Once
@@ -171,7 +171,7 @@ func New(cfgOptions ...config.Option) (NetworkController, error) {
171171
sandboxes: sandboxTable{},
172172
drivers: driverTable{},
173173
ipamDrivers: ipamTable{},
174-
svcDb: make(map[string]svcMap),
174+
svcDb: make(map[string]svcInfo),
175175
}
176176

177177
if err := c.initStores(); err != nil {

vendor/src/github.com/docker/libnetwork/drivers/bridge/bridge.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,7 @@ func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
134134
if err := iptables.FirewalldInit(); err != nil {
135135
logrus.Debugf("Fail to initialize firewalld: %v, using raw iptables instead", err)
136136
}
137-
if err := iptables.RemoveExistingChain(DockerChain, iptables.Nat); err != nil {
138-
logrus.Warnf("Failed to remove existing iptables entries in %s : %v", DockerChain, err)
139-
}
140-
137+
removeIPChains()
141138
d := newDriver()
142139
if err := d.configure(config); err != nil {
143140
return err

vendor/src/github.com/docker/libnetwork/drivers/bridge/interface.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package bridge
22

33
import (
4+
"fmt"
45
"net"
56

67
"github.com/vishvananda/netlink"
@@ -61,3 +62,18 @@ func (i *bridgeInterface) addresses() (netlink.Addr, []netlink.Addr, error) {
6162
}
6263
return v4addr[0], v6addr, nil
6364
}
65+
66+
func (i *bridgeInterface) programIPv6Address() error {
67+
_, nlAddressList, err := i.addresses()
68+
if err != nil {
69+
return &IPv6AddrAddError{IP: i.bridgeIPv6, Err: fmt.Errorf("failed to retrieve address list: %v", err)}
70+
}
71+
nlAddr := netlink.Addr{IPNet: i.bridgeIPv6}
72+
if findIPv6Address(nlAddr, nlAddressList) {
73+
return nil
74+
}
75+
if err := netlink.AddrAdd(i.Link, &nlAddr); err != nil {
76+
return &IPv6AddrAddError{IP: i.bridgeIPv6, Err: err}
77+
}
78+
return nil
79+
}

vendor/src/github.com/docker/libnetwork/drivers/bridge/setup_ip_tables.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,3 +309,15 @@ func ensureJumpRule(fromChain, toChain string) error {
309309

310310
return nil
311311
}
312+
313+
func removeIPChains() {
314+
for _, chainInfo := range []iptables.ChainInfo{
315+
iptables.ChainInfo{Name: DockerChain, Table: iptables.Nat},
316+
iptables.ChainInfo{Name: DockerChain, Table: iptables.Filter},
317+
iptables.ChainInfo{Name: IsolationChain, Table: iptables.Filter},
318+
} {
319+
if err := chainInfo.Remove(); err != nil {
320+
logrus.Warnf("Failed to remove existing iptables entries in table %s chain %s : %v", chainInfo.Table, chainInfo.Name, err)
321+
}
322+
}
323+
}

vendor/src/github.com/docker/libnetwork/drivers/bridge/setup_ipv6.go

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"os"
88

99
"github.com/Sirupsen/logrus"
10+
"github.com/docker/libnetwork/types"
1011
"github.com/vishvananda/netlink"
1112
)
1213

@@ -22,9 +23,8 @@ const (
2223
func init() {
2324
// We allow ourselves to panic in this special case because we indicate a
2425
// failure to parse a compile-time define constant.
25-
if ip, netw, err := net.ParseCIDR(bridgeIPv6Str); err == nil {
26-
bridgeIPv6 = &net.IPNet{IP: ip, Mask: netw.Mask}
27-
} else {
26+
var err error
27+
if bridgeIPv6, err = types.ParseCIDR(bridgeIPv6Str); err != nil {
2828
panic(fmt.Sprintf("Cannot parse default bridge IPv6 address %q: %v", bridgeIPv6Str, err))
2929
}
3030
}
@@ -42,31 +42,24 @@ func setupBridgeIPv6(config *networkConfiguration, i *bridgeInterface) error {
4242
}
4343
}
4444

45-
_, addrsv6, err := i.addresses()
46-
if err != nil {
47-
return err
48-
}
49-
50-
// Add the default link local ipv6 address if it doesn't exist
51-
if !findIPv6Address(netlink.Addr{IPNet: bridgeIPv6}, addrsv6) {
52-
if err := netlink.AddrAdd(i.Link, &netlink.Addr{IPNet: bridgeIPv6}); err != nil {
53-
return &IPv6AddrAddError{IP: bridgeIPv6, Err: err}
54-
}
55-
}
56-
5745
// Store bridge network and default gateway
5846
i.bridgeIPv6 = bridgeIPv6
5947
i.gatewayIPv6 = i.bridgeIPv6.IP
6048

49+
if err := i.programIPv6Address(); err != nil {
50+
return err
51+
}
52+
6153
if config.AddressIPv6 == nil {
6254
return nil
6355
}
6456

65-
// Store and program user specified bridge network and network gateway
57+
// Store the user specified bridge network and network gateway and program it
6658
i.bridgeIPv6 = config.AddressIPv6
6759
i.gatewayIPv6 = config.AddressIPv6.IP
68-
if err := netlink.AddrAdd(i.Link, &netlink.Addr{IPNet: i.bridgeIPv6}); err != nil {
69-
return &IPv6AddrAddError{IP: i.bridgeIPv6, Err: err}
60+
61+
if err := i.programIPv6Address(); err != nil {
62+
return err
7063
}
7164

7265
// Setting route to global IPv6 subnet

vendor/src/github.com/docker/libnetwork/drivers/bridge/setup_verify.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package bridge
22

33
import (
4+
log "github.com/Sirupsen/logrus"
5+
"github.com/docker/libnetwork/types"
46
"github.com/vishvananda/netlink"
57
)
68

@@ -27,11 +29,14 @@ func setupVerifyAndReconcile(config *networkConfiguration, i *bridgeInterface) e
2729
return (*IPv6AddrNoMatchError)(bridgeIPv6)
2830
}
2931

30-
// By this time we have either configured a new bridge with an IP address
31-
// or made sure an existing bridge's IP matches the configuration
32-
// Now is the time to cache these states in the bridgeInterface.
33-
i.bridgeIPv4 = addrv4.IPNet
34-
i.bridgeIPv6 = bridgeIPv6
32+
// Release any residual IPv6 address that might be there because of older daemon instances
33+
for _, addrv6 := range addrsv6 {
34+
if addrv6.IP.IsGlobalUnicast() && !types.CompareIPNet(addrv6.IPNet, i.bridgeIPv6) {
35+
if err := netlink.AddrDel(i.Link, &addrv6); err != nil {
36+
log.Warnf("Failed to remove residual IPv6 address %s from bridge: %v", addrv6.IPNet, err)
37+
}
38+
}
39+
}
3540

3641
return nil
3742
}

vendor/src/github.com/docker/libnetwork/drivers/overlay/joinleave.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo,
5454
return err
5555
}
5656

57+
ep.ifName = name2
58+
5759
// Set the container interface and its peer MTU to 1450 to allow
5860
// for 50 bytes vxlan encap (inner eth header(14) + outer IP(20) +
5961
// outer UDP(8) + vxlan header(8))
@@ -134,5 +136,14 @@ func (d *driver) Leave(nid, eid string) error {
134136

135137
n.leaveSandbox()
136138

139+
link, err := netlink.LinkByName(ep.ifName)
140+
if err != nil {
141+
log.Warnf("Failed to retrieve interface link for interface removal on endpoint leave: %v", err)
142+
return nil
143+
}
144+
if err := netlink.LinkDel(link); err != nil {
145+
log.Warnf("Failed to delete interface link on endpoint leave: %v", err)
146+
}
147+
137148
return nil
138149
}

0 commit comments

Comments
 (0)