Browse code

Merge pull request #35976 from thaJeztah/bump-libnetwork2

Bump libnetwork to a1dfea384b39779552a3b4837ea9303194950976

Yong Tang authored on 2018/01/11 15:56:00
Showing 5 changed files
... ...
@@ -30,7 +30,7 @@ github.com/moby/buildkit aaff9d591ef128560018433fe61beb802e149de8
30 30
 github.com/tonistiigi/fsutil dea3a0da73aee887fc02142d995be764106ac5e2
31 31
 
32 32
 #get libnetwork packages
33
-github.com/docker/libnetwork 26531e56a76d7334e594098d7cfab88285d9065c
33
+github.com/docker/libnetwork a1dfea384b39779552a3b4837ea9303194950976
34 34
 github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9
35 35
 github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80
36 36
 github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec
... ...
@@ -13,7 +13,6 @@ import (
13 13
 	"strings"
14 14
 	"sync"
15 15
 	"syscall"
16
-	"time"
17 16
 
18 17
 	"github.com/docker/docker/pkg/reexec"
19 18
 	"github.com/docker/libnetwork/datastore"
... ...
@@ -693,6 +692,12 @@ func (n *network) initSandbox(restore bool) error {
693 693
 		n.driver.initSandboxPeerDB(n.id)
694 694
 	}
695 695
 
696
+	// If we are in swarm mode, we don't need anymore the watchMiss routine.
697
+	// This will save 1 thread and 1 netlink socket per network
698
+	if !n.driver.isSerfAlive() {
699
+		return nil
700
+	}
701
+
696 702
 	var nlSock *nl.NetlinkSocket
697 703
 	sbox.InvokeFunc(func() {
698 704
 		nlSock, err = nl.Subscribe(syscall.NETLINK_ROUTE, syscall.RTNLGRP_NEIGH)
... ...
@@ -716,7 +721,6 @@ func (n *network) initSandbox(restore bool) error {
716 716
 }
717 717
 
718 718
 func (n *network) watchMiss(nlSock *nl.NetlinkSocket) {
719
-	t := time.Now()
720 719
 	for {
721 720
 		msgs, err := nlSock.Receive()
722 721
 		if err != nil {
... ...
@@ -772,30 +776,13 @@ func (n *network) watchMiss(nlSock *nl.NetlinkSocket) {
772 772
 				continue
773 773
 			}
774 774
 
775
-			if n.driver.isSerfAlive() {
776
-				logrus.Debugf("miss notification: dest IP %v, dest MAC %v", ip, mac)
777
-				mac, IPmask, vtep, err := n.driver.resolvePeer(n.id, ip)
778
-				if err != nil {
779
-					logrus.Errorf("could not resolve peer %q: %v", ip, err)
780
-					continue
781
-				}
782
-				n.driver.peerAdd(n.id, "dummy", ip, IPmask, mac, vtep, l2Miss, l3Miss, false)
783
-			} else if l3Miss && time.Since(t) > time.Second {
784
-				// All the local peers will trigger a miss notification but this one is expected and the local container will reply
785
-				// autonomously to the ARP request
786
-				// In case the gc_thresh3 values is low kernel might reject new entries during peerAdd. This will trigger the following
787
-				// extra logs that will inform of the possible issue.
788
-				// Entries created would not be deleted see documentation http://man7.org/linux/man-pages/man7/arp.7.html:
789
-				// Entries which are marked as permanent are never deleted by the garbage-collector.
790
-				// The time limit here is to guarantee that the dbSearch is not
791
-				// done too frequently causing a stall of the peerDB operations.
792
-				pKey, pEntry, err := n.driver.peerDbSearch(n.id, ip)
793
-				if err == nil && !pEntry.isLocal {
794
-					t = time.Now()
795
-					logrus.Warnf("miss notification for peer:%+v l3Miss:%t l2Miss:%t, if the problem persist check the gc_thresh on the host pKey:%+v pEntry:%+v err:%v",
796
-						neigh, l3Miss, l2Miss, *pKey, *pEntry, err)
797
-				}
775
+			logrus.Debugf("miss notification: dest IP %v, dest MAC %v", ip, mac)
776
+			mac, IPmask, vtep, err := n.driver.resolvePeer(n.id, ip)
777
+			if err != nil {
778
+				logrus.Errorf("could not resolve peer %q: %v", ip, err)
779
+				continue
798 780
 			}
781
+			n.driver.peerAdd(n.id, "dummy", ip, IPmask, mac, vtep, l2Miss, l3Miss, false)
799 782
 		}
800 783
 	}
801 784
 }
... ...
@@ -220,9 +220,11 @@ func NewSandbox(key string, osCreate, isRestore bool) (Sandbox, error) {
220 220
 	if err != nil {
221 221
 		logrus.Warnf("Failed to set the timeout on the sandbox netlink handle sockets: %v", err)
222 222
 	}
223
-
223
+	// In live-restore mode, IPV6 entries are getting cleaned up due to below code
224
+	// We should retain IPV6 configrations in live-restore mode when Docker Daemon
225
+	// comes back. It should work as it is on other cases
224 226
 	// As starting point, disable IPv6 on all interfaces
225
-	if !n.isDefault {
227
+	if !isRestore && !n.isDefault {
226 228
 		err = setIPv6(n.path, "all", false)
227 229
 		if err != nil {
228 230
 			logrus.Warnf("Failed to disable IPv6 on all interfaces on network namespace %q: %v", n.path, err)
... ...
@@ -224,6 +224,22 @@ func createRespMsg(query *dns.Msg) *dns.Msg {
224 224
 	return resp
225 225
 }
226 226
 
227
+func (r *resolver) handleMXQuery(name string, query *dns.Msg) (*dns.Msg, error) {
228
+	addrv4, _ := r.backend.ResolveName(name, types.IPv4)
229
+	addrv6, _ := r.backend.ResolveName(name, types.IPv6)
230
+
231
+	if addrv4 == nil && addrv6 == nil {
232
+		return nil, nil
233
+	}
234
+
235
+	// We were able to resolve the name. Respond with an empty list with
236
+	// RcodeSuccess/NOERROR so that email clients can treat it as "implicit MX"
237
+	// [RFC 5321 Section-5.1] and issue a Type A/AAAA query for the name.
238
+
239
+	resp := createRespMsg(query)
240
+	return resp, nil
241
+}
242
+
227 243
 func (r *resolver) handleIPQuery(name string, query *dns.Msg, ipType int) (*dns.Msg, error) {
228 244
 	var addr []net.IP
229 245
 	var ipv6Miss bool
... ...
@@ -357,6 +373,8 @@ func (r *resolver) ServeDNS(w dns.ResponseWriter, query *dns.Msg) {
357 357
 		resp, err = r.handleIPQuery(name, query, types.IPv4)
358 358
 	case dns.TypeAAAA:
359 359
 		resp, err = r.handleIPQuery(name, query, types.IPv6)
360
+	case dns.TypeMX:
361
+		resp, err = r.handleMXQuery(name, query)
360 362
 	case dns.TypePTR:
361 363
 		resp, err = r.handlePTRQuery(name, query)
362 364
 	case dns.TypeSRV:
... ...
@@ -362,7 +362,7 @@ func (sb *sandbox) rebuildDNS() error {
362 362
 dnsOpt:
363 363
 	for _, resOpt := range resOptions {
364 364
 		if strings.Contains(resOpt, "ndots") {
365
-			for _, option := range dnsOptionsList {
365
+			for i, option := range dnsOptionsList {
366 366
 				if strings.Contains(option, "ndots") {
367 367
 					parts := strings.Split(option, ":")
368 368
 					if len(parts) != 2 {
... ...
@@ -371,7 +371,10 @@ dnsOpt:
371 371
 					if num, err := strconv.Atoi(parts[1]); err != nil {
372 372
 						return fmt.Errorf("invalid number for ndots option %v", option)
373 373
 					} else if num > 0 {
374
+						// if the user sets ndots, we mark it as set but we remove the option to guarantee
375
+						// that into the container land only ndots:0
374 376
 						sb.ndotsSet = true
377
+						dnsOptionsList = append(dnsOptionsList[:i], dnsOptionsList[i+1:]...)
375 378
 						break dnsOpt
376 379
 					}
377 380
 				}