Browse code

Vendor libnetwork @ 36d3bed0e9

Signed-off-by: John Howard <jhoward@microsoft.com>

John Howard authored on 2018/09/12 06:43:09
Showing 16 changed files
... ...
@@ -3,7 +3,7 @@
3 3
 # LIBNETWORK_COMMIT is used to build the docker-userland-proxy binary. When
4 4
 # updating the binary version, consider updating github.com/docker/libnetwork
5 5
 # in vendor.conf accordingly
6
-LIBNETWORK_COMMIT=f30a35b091cc2a431ef9856c75c343f75bb5f2e2
6
+LIBNETWORK_COMMIT=36d3bed0e9f4b3c8c66df9bd45278bb90b33e911
7 7
 
8 8
 install_proxy() {
9 9
 	case "$1" in
... ...
@@ -37,7 +37,7 @@ github.com/mitchellh/hashstructure 2bca23e0e452137f789efbc8610126fd8b94f73b
37 37
 #get libnetwork packages
38 38
 
39 39
 # When updating, also update LIBNETWORK_COMMIT in hack/dockerfile/install/proxy accordingly
40
-github.com/docker/libnetwork a79d3687931697244b8e03485bf7b2042f8ec6b6
40
+github.com/docker/libnetwork 36d3bed0e9f4b3c8c66df9bd45278bb90b33e911
41 41
 github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9
42 42
 github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80
43 43
 github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec
... ...
@@ -32,7 +32,7 @@ var (
32 32
 	ErrBitAllocated = errors.New("requested bit is already allocated")
33 33
 )
34 34
 
35
-// Handle contains the sequece representing the bitmask and its identifier
35
+// Handle contains the sequence representing the bitmask and its identifier
36 36
 type Handle struct {
37 37
 	bits       uint64
38 38
 	unselected uint64
... ...
@@ -95,7 +95,7 @@ func (s *Server) EnableDiagnostic(ip string, port int) {
95 95
 	s.srv = srv
96 96
 	s.enable = 1
97 97
 	go func(n *Server) {
98
-		// Ingore ErrServerClosed that is returned on the Shutdown call
98
+		// Ignore ErrServerClosed that is returned on the Shutdown call
99 99
 		if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
100 100
 			logrus.Errorf("ListenAndServe error: %s", err)
101 101
 			atomic.SwapInt32(&n.enable, 0)
... ...
@@ -598,7 +598,7 @@ func (d *driver) checkConflict(config *networkConfiguration) error {
598 598
 		nwConfig := nw.config
599 599
 		nw.Unlock()
600 600
 		if err := nwConfig.Conflicts(config); err != nil {
601
-			if config.DefaultBridge {
601
+			if nwConfig.DefaultBridge {
602 602
 				// We encountered and identified a stale default network
603 603
 				// We must delete it as libnetwork is the source of truth
604 604
 				// The default network being created must be the only one
... ...
@@ -24,7 +24,7 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo,
24 24
 		return fmt.Errorf("network id %q not found", nid)
25 25
 	}
26 26
 	if ifInfo.MacAddress() != nil {
27
-		return fmt.Errorf("%s interfaces do not support custom mac address assigment", ipvlanType)
27
+		return fmt.Errorf("%s interfaces do not support custom mac address assignment", ipvlanType)
28 28
 	}
29 29
 	ep := &endpoint{
30 30
 		id:     eid,
... ...
@@ -53,13 +53,15 @@ type SvcStats struct {
53 53
 // Destination defines an IPVS destination (real server) in its
54 54
 // entirety.
55 55
 type Destination struct {
56
-	Address         net.IP
57
-	Port            uint16
58
-	Weight          int
59
-	ConnectionFlags uint32
60
-	AddressFamily   uint16
61
-	UpperThreshold  uint32
62
-	LowerThreshold  uint32
56
+	Address             net.IP
57
+	Port                uint16
58
+	Weight              int
59
+	ConnectionFlags     uint32
60
+	AddressFamily       uint16
61
+	UpperThreshold      uint32
62
+	LowerThreshold      uint32
63
+	ActiveConnections   int
64
+	InactiveConnections int
63 65
 }
64 66
 
65 67
 // Handle provides a namespace specific ipvs handle to program ipvs
... ...
@@ -439,6 +439,10 @@ func assembleDestination(attrs []syscall.NetlinkRouteAttr) (*Destination, error)
439 439
 			d.LowerThreshold = native.Uint32(attr.Value)
440 440
 		case ipvsDestAttrAddressFamily:
441 441
 			d.AddressFamily = native.Uint16(attr.Value)
442
+		case ipvsDestAttrActiveConnections:
443
+			d.ActiveConnections = int(native.Uint16(attr.Value))
444
+		case ipvsDestAttrInactiveConnections:
445
+			d.InactiveConnections = int(native.Uint16(attr.Value))
442 446
 		}
443 447
 	}
444 448
 	return &d, nil
445 449
new file mode 100644
... ...
@@ -0,0 +1,3 @@
0
+package ns
1
+
2
+// File is present so that go build ./... is closer to working on Windows from repo root.
... ...
@@ -297,7 +297,7 @@ func (n *networkNamespace) AddInterface(srcName, dstPrefix string, options ...If
297 297
 			logrus.Errorf("renaming interface (%s->%s) failed, %v after config error %v", i.DstName(), i.SrcName(), nerr, err)
298 298
 		}
299 299
 		if nerr := nlh.LinkSetNsFd(iface, ns.ParseHandlerInt()); nerr != nil {
300
-			logrus.Errorf("moving inteface %s to host ns failed, %v, after config error %v", i.SrcName(), nerr, err)
300
+			logrus.Errorf("moving interface %s to host ns failed, %v, after config error %v", i.SrcName(), nerr, err)
301 301
 		}
302 302
 		return err
303 303
 	}
... ...
@@ -227,7 +227,7 @@ func NewSandbox(key string, osCreate, isRestore bool) (Sandbox, error) {
227 227
 		logrus.Warnf("Failed to set the timeout on the sandbox netlink handle sockets: %v", err)
228 228
 	}
229 229
 	// In live-restore mode, IPV6 entries are getting cleaned up due to below code
230
-	// We should retain IPV6 configrations in live-restore mode when Docker Daemon
230
+	// We should retain IPV6 configurations in live-restore mode when Docker Daemon
231 231
 	// comes back. It should work as it is on other cases
232 232
 	// As starting point, disable IPv6 on all interfaces
233 233
 	if !isRestore && !n.isDefault {
... ...
@@ -1,3 +1,5 @@
1
+// +build !windows
2
+
1 3
 package portallocator
2 4
 
3 5
 import (
4 6
new file mode 100644
... ...
@@ -0,0 +1 @@
0
+package portallocator
... ...
@@ -76,7 +76,7 @@ func reexecSetupResolver() {
76 76
 
77 77
 	for _, rule := range rules {
78 78
 		if iptables.RawCombinedOutputNative(rule...) != nil {
79
-			logrus.Errorf("setting up rule failed, %v", rule)
79
+			logrus.Errorf("set up rule failed, %v", rule)
80 80
 		}
81 81
 	}
82 82
 }
... ...
@@ -135,8 +135,7 @@ func (n *network) addLBBackend(ip net.IP, lb *loadBalancer) {
135 135
 			if ep := sb.getGatewayEndpoint(); ep != nil {
136 136
 				gwIP = ep.Iface().Address().IP
137 137
 			}
138
-			filteredPorts := filterPortConfigs(lb.service.ingressPorts, false)
139
-			if err := programIngress(gwIP, filteredPorts, false); err != nil {
138
+			if err := programIngress(gwIP, lb.service.ingressPorts, false); err != nil {
140 139
 				logrus.Errorf("Failed to add ingress: %v", err)
141 140
 				return
142 141
 			}
... ...
@@ -227,8 +226,7 @@ func (n *network) rmLBBackend(ip net.IP, lb *loadBalancer, rmService bool, fullR
227 227
 			if ep := sb.getGatewayEndpoint(); ep != nil {
228 228
 				gwIP = ep.Iface().Address().IP
229 229
 			}
230
-			filteredPorts := filterPortConfigs(lb.service.ingressPorts, true)
231
-			if err := programIngress(gwIP, filteredPorts, true); err != nil {
230
+			if err := programIngress(gwIP, lb.service.ingressPorts, true); err != nil {
232 231
 				logrus.Errorf("Failed to delete ingress: %v", err)
233 232
 			}
234 233
 		}
... ...
@@ -299,8 +297,10 @@ func filterPortConfigs(ingressPorts []*PortConfig, isDelete bool) []*PortConfig
299 299
 
300 300
 func programIngress(gwIP net.IP, ingressPorts []*PortConfig, isDelete bool) error {
301 301
 	addDelOpt := "-I"
302
+	rollbackAddDelOpt := "-D"
302 303
 	if isDelete {
303 304
 		addDelOpt = "-D"
305
+		rollbackAddDelOpt = "-I"
304 306
 	}
305 307
 
306 308
 	ingressMu.Lock()
... ...
@@ -381,18 +381,35 @@ func programIngress(gwIP net.IP, ingressPorts []*PortConfig, isDelete bool) erro
381 381
 		}
382 382
 	}
383 383
 
384
-	for _, iPort := range ingressPorts {
384
+	//Filter the ingress ports until port rules start to be added/deleted
385
+	filteredPorts := filterPortConfigs(ingressPorts, isDelete)
386
+	rollbackRules := make([][]string, 0, len(filteredPorts)*3)
387
+	var portErr error
388
+	defer func() {
389
+		if portErr != nil && !isDelete {
390
+			filterPortConfigs(filteredPorts, !isDelete)
391
+			for _, rule := range rollbackRules {
392
+				if err := iptables.RawCombinedOutput(rule...); err != nil {
393
+					logrus.Warnf("roll back rule failed, %v: %v", rule, err)
394
+				}
395
+			}
396
+		}
397
+	}()
398
+
399
+	for _, iPort := range filteredPorts {
385 400
 		if iptables.ExistChain(ingressChain, iptables.Nat) {
386 401
 			rule := strings.Fields(fmt.Sprintf("-t nat %s %s -p %s --dport %d -j DNAT --to-destination %s:%d",
387 402
 				addDelOpt, ingressChain, strings.ToLower(PortConfig_Protocol_name[int32(iPort.Protocol)]), iPort.PublishedPort, gwIP, iPort.PublishedPort))
388
-			if err := iptables.RawCombinedOutput(rule...); err != nil {
389
-				errStr := fmt.Sprintf("setting up rule failed, %v: %v", rule, err)
403
+			if portErr = iptables.RawCombinedOutput(rule...); portErr != nil {
404
+				errStr := fmt.Sprintf("set up rule failed, %v: %v", rule, portErr)
390 405
 				if !isDelete {
391 406
 					return fmt.Errorf("%s", errStr)
392 407
 				}
393
-
394 408
 				logrus.Infof("%s", errStr)
395 409
 			}
410
+			rollbackRule := strings.Fields(fmt.Sprintf("-t nat %s %s -p %s --dport %d -j DNAT --to-destination %s:%d", rollbackAddDelOpt,
411
+				ingressChain, strings.ToLower(PortConfig_Protocol_name[int32(iPort.Protocol)]), iPort.PublishedPort, gwIP, iPort.PublishedPort))
412
+			rollbackRules = append(rollbackRules, rollbackRule)
396 413
 		}
397 414
 
398 415
 		// Filter table rules to allow a published service to be accessible in the local node from..
... ...
@@ -400,24 +417,29 @@ func programIngress(gwIP net.IP, ingressPorts []*PortConfig, isDelete bool) erro
400 400
 		// 2) unmanaged containers on bridge networks
401 401
 		rule := strings.Fields(fmt.Sprintf("%s %s -m state -p %s --sport %d --state ESTABLISHED,RELATED -j ACCEPT",
402 402
 			addDelOpt, ingressChain, strings.ToLower(PortConfig_Protocol_name[int32(iPort.Protocol)]), iPort.PublishedPort))
403
-		if err := iptables.RawCombinedOutput(rule...); err != nil {
404
-			errStr := fmt.Sprintf("setting up rule failed, %v: %v", rule, err)
403
+		if portErr = iptables.RawCombinedOutput(rule...); portErr != nil {
404
+			errStr := fmt.Sprintf("set up rule failed, %v: %v", rule, portErr)
405 405
 			if !isDelete {
406 406
 				return fmt.Errorf("%s", errStr)
407 407
 			}
408 408
 			logrus.Warnf("%s", errStr)
409 409
 		}
410
+		rollbackRule := strings.Fields(fmt.Sprintf("%s %s -m state -p %s --sport %d --state ESTABLISHED,RELATED -j ACCEPT", rollbackAddDelOpt,
411
+			ingressChain, strings.ToLower(PortConfig_Protocol_name[int32(iPort.Protocol)]), iPort.PublishedPort))
412
+		rollbackRules = append(rollbackRules, rollbackRule)
410 413
 
411 414
 		rule = strings.Fields(fmt.Sprintf("%s %s -p %s --dport %d -j ACCEPT",
412 415
 			addDelOpt, ingressChain, strings.ToLower(PortConfig_Protocol_name[int32(iPort.Protocol)]), iPort.PublishedPort))
413
-		if err := iptables.RawCombinedOutput(rule...); err != nil {
414
-			errStr := fmt.Sprintf("setting up rule failed, %v: %v", rule, err)
416
+		if portErr = iptables.RawCombinedOutput(rule...); portErr != nil {
417
+			errStr := fmt.Sprintf("set up rule failed, %v: %v", rule, portErr)
415 418
 			if !isDelete {
416 419
 				return fmt.Errorf("%s", errStr)
417 420
 			}
418
-
419 421
 			logrus.Warnf("%s", errStr)
420 422
 		}
423
+		rollbackRule = strings.Fields(fmt.Sprintf("%s %s -p %s --dport %d -j ACCEPT", rollbackAddDelOpt,
424
+			ingressChain, strings.ToLower(PortConfig_Protocol_name[int32(iPort.Protocol)]), iPort.PublishedPort))
425
+		rollbackRules = append(rollbackRules, rollbackRule)
421 426
 
422 427
 		if err := plumbProxy(iPort, isDelete); err != nil {
423 428
 			logrus.Warnf("failed to create proxy for port %d: %v", iPort.PublishedPort, err)
... ...
@@ -648,7 +670,7 @@ func fwMarker() {
648 648
 
649 649
 	for _, rule := range rules {
650 650
 		if err := iptables.RawCombinedOutputNative(rule...); err != nil {
651
-			logrus.Errorf("setting up rule failed, %v: %v", rule, err)
651
+			logrus.Errorf("set up rule failed, %v: %v", rule, err)
652 652
 			os.Exit(8)
653 653
 		}
654 654
 	}
... ...
@@ -735,7 +757,7 @@ func redirector() {
735 735
 
736 736
 	for _, rule := range rules {
737 737
 		if err := iptables.RawCombinedOutputNative(rule...); err != nil {
738
-			logrus.Errorf("setting up rule failed, %v: %v", rule, err)
738
+			logrus.Errorf("set up rule failed, %v: %v", rule, err)
739 739
 			os.Exit(6)
740 740
 		}
741 741
 	}
... ...
@@ -752,14 +774,14 @@ func redirector() {
752 752
 	} {
753 753
 		if !iptables.ExistsNative(iptables.Filter, "INPUT", rule...) {
754 754
 			if err := iptables.RawCombinedOutputNative(append([]string{"-A", "INPUT"}, rule...)...); err != nil {
755
-				logrus.Errorf("setting up rule failed, %v: %v", rule, err)
755
+				logrus.Errorf("set up rule failed, %v: %v", rule, err)
756 756
 				os.Exit(7)
757 757
 			}
758 758
 		}
759 759
 		rule[0] = "-s"
760 760
 		if !iptables.ExistsNative(iptables.Filter, "OUTPUT", rule...) {
761 761
 			if err := iptables.RawCombinedOutputNative(append([]string{"-A", "OUTPUT"}, rule...)...); err != nil {
762
-				logrus.Errorf("setting up rule failed, %v: %v", rule, err)
762
+				logrus.Errorf("set up rule failed, %v: %v", rule, err)
763 763
 				os.Exit(8)
764 764
 			}
765 765
 		}
... ...
@@ -1,21 +1,21 @@
1 1
 github.com/Azure/go-ansiterm d6e3b3328b783f23731bc4d058875b0371ff8109
2 2
 github.com/BurntSushi/toml a368813c5e648fee92e5f6c30e3944ff9d5e8895
3
-github.com/Microsoft/go-winio v0.4.7
4
-github.com/Microsoft/hcsshim v0.6.11
3
+github.com/Microsoft/go-winio v0.4.11
4
+github.com/Microsoft/hcsshim v0.7.3
5 5
 github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec
6 6
 github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80
7
-github.com/boltdb/bolt fff57c100f4dea1905678da7e90d92429dff2904
8 7
 github.com/codegangsta/cli a65b733b303f0055f8d324d805f393cd3e7a7904
9 8
 github.com/containerd/continuity d3c23511c1bf5851696cba83143d9cbcd666869b
10 9
 github.com/coreos/etcd v3.2.1
11 10
 github.com/coreos/go-semver v0.2.0
12 11
 github.com/deckarep/golang-set ef32fa3046d9f249d399f98ebaf9be944430fd1d
12
+go.etcd.io/bbolt v1.3.1-etcd.8
13 13
 
14 14
 github.com/docker/docker 162ba6016def672690ee4a1f3978368853a1e149
15 15
 github.com/docker/go-connections 7beb39f0b969b075d1325fecb092faf27fd357b6
16 16
 github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9
17 17
 github.com/docker/go-units 9e638d38cf6977a37a8ea0078f3ee75a7cdb2dd1
18
-github.com/docker/libkv 1d8431073ae03cdaedb198a89722f3aab6d418ef
18
+github.com/docker/libkv 458977154600b9f23984d9f4b82e79570b5ae12b
19 19
 
20 20
 github.com/godbus/dbus v4.0.0
21 21
 github.com/gogo/protobuf v1.0.0
... ...
@@ -36,7 +36,6 @@ github.com/opencontainers/runc 69663f0bd4b60df09991c08812a60108003fa340
36 36
 github.com/opencontainers/runtime-spec v1.0.1
37 37
 github.com/samuel/go-zookeeper d0e0d8e11f318e000a8cc434616d69e329edc374
38 38
 github.com/sirupsen/logrus v1.0.3
39
-github.com/syndtr/gocapability 33e07d32887e1e06b7c025f27ce52f62c7990bc0
40 39
 github.com/ugorji/go f1f1a805ed361a0e078bb537e4ea78cd37dcf065
41 40
 github.com/vishvananda/netlink b2de5d10e38ecce8607e6b438b6d174f389a004e
42 41
 github.com/vishvananda/netns 604eaf189ee867d8c147fafc28def2394e878d25