Browse Source

Changed ipMask to string

Avoid error logs in case of local peer case, there is no need for deleteNeighbor
Avoid the network leave to readvertise already deleted entries to upper layer

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
Flavio Crisciani 7 years ago
parent
commit
ad577a25fe

+ 3 - 3
libnetwork/drivers/overlay/ov_network.go

@@ -769,7 +769,7 @@ func (n *network) watchMiss(nlSock *nl.NetlinkSocket) {
 					continue
 				}
 				n.driver.peerAdd(n.id, "dummy", ip, IPmask, mac, vtep, l2Miss, l3Miss, false)
-			} else if l3Miss && time.Since(t) > 500*time.Millisecond {
+			} else if l3Miss && time.Since(t) > time.Second {
 				// All the local peers will trigger a miss notification but this one is expected and the local container will reply
 				// autonomously to the ARP request
 				// In case the gc_thresh3 values is low kernel might reject new entries during peerAdd. This will trigger the following
@@ -778,9 +778,9 @@ func (n *network) watchMiss(nlSock *nl.NetlinkSocket) {
 				// Entries which are marked as permanent are never deleted by the garbage-collector.
 				// The time limit here is to guarantee that the dbSearch is not
 				// done too frequently causing a stall of the peerDB operations.
-				t = time.Now()
 				pKey, pEntry, err := n.driver.peerDbSearch(n.id, ip)
-				if !pEntry.isLocal {
+				if err == nil && !pEntry.isLocal {
+					t = time.Now()
 					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",
 						neigh, l3Miss, l2Miss, *pKey, *pEntry, err)
 				}

+ 23 - 23
libnetwork/drivers/overlay/peerdb.go

@@ -27,13 +27,11 @@ type peerEntry struct {
 }
 
 func (p *peerEntry) MarshalDB() peerEntryDB {
-	ones, bits := p.peerIPMask.Size()
 	return peerEntryDB{
-		eid:            p.eid,
-		vtep:           p.vtep.String(),
-		isLocal:        p.isLocal,
-		peerIPMaskOnes: ones,
-		peerIPMaskBits: bits,
+		eid:        p.eid,
+		vtep:       p.vtep.String(),
+		peerIPMask: p.peerIPMask.String(),
+		isLocal:    p.isLocal,
 	}
 }
 
@@ -41,18 +39,17 @@ func (p *peerEntry) MarshalDB() peerEntryDB {
 // the value inserted in the set has to be Hashable so the []byte had to be converted into
 // strings
 type peerEntryDB struct {
-	eid            string
-	vtep           string
-	peerIPMaskOnes int
-	peerIPMaskBits int
-	isLocal        bool
+	eid        string
+	vtep       string
+	peerIPMask string
+	isLocal    bool
 }
 
 func (p *peerEntryDB) UnMarshalDB() peerEntry {
 	return peerEntry{
 		eid:        p.eid,
 		vtep:       net.ParseIP(p.vtep),
-		peerIPMask: net.CIDRMask(p.peerIPMaskOnes, p.peerIPMaskBits),
+		peerIPMask: net.IPMask(net.ParseIP(p.peerIPMask)),
 		isLocal:    p.isLocal,
 	}
 }
@@ -454,19 +451,22 @@ func (d *driver) peerDeleteOp(nid, eid string, peerIP net.IP, peerIPMask net.IPM
 		logrus.Warn(err)
 	}
 
-	// Remove fdb entry to the bridge for the peer mac
-	if err := sbox.DeleteNeighbor(vtep, peerMac, true); err != nil {
-		if _, ok := err.(osl.NeighborSearchError); ok && dbEntries > 0 {
-			// We fall in here if there is a transient state and if the neighbor that is being deleted
-			// was never been configured into the kernel (we allow only 1 configuration at the time per <ip,mac> mapping)
-			return nil
+	// Local peers do not have any local configuration to delete
+	if !localPeer {
+		// Remove fdb entry to the bridge for the peer mac
+		if err := sbox.DeleteNeighbor(vtep, peerMac, true); err != nil {
+			if _, ok := err.(osl.NeighborSearchError); ok && dbEntries > 0 {
+				// We fall in here if there is a transient state and if the neighbor that is being deleted
+				// was never been configured into the kernel (we allow only 1 configuration at the time per <ip,mac> mapping)
+				return nil
+			}
+			return fmt.Errorf("could not delete fdb entry for nid:%s eid:%s into the sandbox:%v", nid, eid, err)
 		}
-		return fmt.Errorf("could not delete fdb entry for nid:%s eid:%s into the sandbox:%v", nid, eid, err)
-	}
 
-	// Delete neighbor entry for the peer IP
-	if err := sbox.DeleteNeighbor(peerIP, peerMac, true); err != nil {
-		return fmt.Errorf("could not delete neighbor entry for nid:%s eid:%s into the sandbox:%v", nid, eid, err)
+		// Delete neighbor entry for the peer IP
+		if err := sbox.DeleteNeighbor(peerIP, peerMac, true); err != nil {
+			return fmt.Errorf("could not delete neighbor entry for nid:%s eid:%s into the sandbox:%v", nid, eid, err)
+		}
 	}
 
 	if dbEntries == 0 {

+ 4 - 1
libnetwork/networkdb/networkdb.go

@@ -505,7 +505,10 @@ func (nDB *NetworkDB) deleteNodeNetworkEntries(nid, node string) {
 				nDB.deleteEntry(nid, tname, key)
 			}
 
-			nDB.broadcaster.Write(makeEvent(opDelete, tname, nid, key, entry.value))
+			// Notify to the upper layer only entries not already marked for deletion
+			if !oldEntry.deleting {
+				nDB.broadcaster.Write(makeEvent(opDelete, tname, nid, key, entry.value))
+			}
 			return false
 		})
 }