Przeglądaj źródła

libnetwork/osl: Namespace.DeleteNeighbor: remove osDelete argument

This argument was originally added in libnetwork:
https://github.com/moby/libnetwork/commit/03f440667f79f33ef3cb1faeb13c0bca1a0f8737

At the time, this argument was conditional, but currently it's always set
to "true", so let's remove it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 1 rok temu
rodzic
commit
4215a1542b

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

@@ -377,7 +377,7 @@ func (d *driver) peerDeleteOp(nid, eid string, peerIP net.IP, peerIPMask net.IPM
 	// Local peers do not have any local configuration to delete
 	// Local peers do not have any local configuration to delete
 	if !localPeer {
 	if !localPeer {
 		// Remove fdb entry to the bridge for the peer mac
 		// Remove fdb entry to the bridge for the peer mac
-		if err := sbox.DeleteNeighbor(vtep, peerMac, true); err != nil {
+		if err := sbox.DeleteNeighbor(vtep, peerMac); err != nil {
 			if _, ok := err.(osl.NeighborSearchError); ok && dbEntries > 0 {
 			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
 				// 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)
 				// was never been configured into the kernel (we allow only 1 configuration at the time per <ip,mac> mapping)
@@ -387,7 +387,7 @@ func (d *driver) peerDeleteOp(nid, eid string, peerIP net.IP, peerIPMask net.IPM
 		}
 		}
 
 
 		// Delete neighbor entry for the peer IP
 		// Delete neighbor entry for the peer IP
-		if err := sbox.DeleteNeighbor(peerIP, peerMac, true); err != nil {
+		if err := sbox.DeleteNeighbor(peerIP, peerMac); err != nil {
 			return fmt.Errorf("could not delete neighbor entry for nid:%s eid:%s into the sandbox:%v", nid, eid, err)
 			return fmt.Errorf("could not delete neighbor entry for nid:%s eid:%s into the sandbox:%v", nid, eid, err)
 		}
 		}
 	}
 	}

+ 37 - 40
libnetwork/osl/neigh_linux.go

@@ -45,7 +45,7 @@ func (n *Namespace) findNeighbor(dstIP net.IP, dstMac net.HardwareAddr) *neigh {
 }
 }
 
 
 // DeleteNeighbor deletes neighbor entry from the sandbox.
 // DeleteNeighbor deletes neighbor entry from the sandbox.
-func (n *Namespace) DeleteNeighbor(dstIP net.IP, dstMac net.HardwareAddr, osDelete bool) error {
+func (n *Namespace) DeleteNeighbor(dstIP net.IP, dstMac net.HardwareAddr) error {
 	var (
 	var (
 		iface netlink.Link
 		iface netlink.Link
 		err   error
 		err   error
@@ -56,56 +56,53 @@ func (n *Namespace) DeleteNeighbor(dstIP net.IP, dstMac net.HardwareAddr, osDele
 		return NeighborSearchError{dstIP, dstMac, false}
 		return NeighborSearchError{dstIP, dstMac, false}
 	}
 	}
 
 
-	if osDelete {
-		n.Lock()
-		nlh := n.nlHandle
-		n.Unlock()
+	n.Lock()
+	nlh := n.nlHandle
+	n.Unlock()
 
 
-		if nh.linkDst != "" {
-			iface, err = nlh.LinkByName(nh.linkDst)
-			if err != nil {
-				return fmt.Errorf("could not find interface with destination name %s: %v",
-					nh.linkDst, err)
-			}
+	if nh.linkDst != "" {
+		iface, err = nlh.LinkByName(nh.linkDst)
+		if err != nil {
+			return fmt.Errorf("could not find interface with destination name %s: %v", nh.linkDst, err)
 		}
 		}
+	}
+
+	nlnh := &netlink.Neigh{
+		IP:     dstIP,
+		State:  netlink.NUD_PERMANENT,
+		Family: nh.family,
+	}
+
+	if nlnh.Family > 0 {
+		nlnh.HardwareAddr = dstMac
+		nlnh.Flags = netlink.NTF_SELF
+	}
+
+	if nh.linkDst != "" {
+		nlnh.LinkIndex = iface.Attrs().Index
+	}
+
+	// If the kernel deletion fails for the neighbor entry still remove it
+	// from the namespace cache, otherwise kernel update can fail if the
+	// neighbor moves back to the same host again.
+	if err := nlh.NeighDel(nlnh); err != nil && !errors.Is(err, os.ErrNotExist) {
+		log.G(context.TODO()).Warnf("Deleting neighbor IP %s, mac %s failed, %v", dstIP, dstMac, err)
+	}
 
 
+	// Delete the dynamic entry in the bridge
+	if nlnh.Family > 0 {
 		nlnh := &netlink.Neigh{
 		nlnh := &netlink.Neigh{
 			IP:     dstIP,
 			IP:     dstIP,
-			State:  netlink.NUD_PERMANENT,
 			Family: nh.family,
 			Family: nh.family,
 		}
 		}
 
 
-		if nlnh.Family > 0 {
-			nlnh.HardwareAddr = dstMac
-			nlnh.Flags = netlink.NTF_SELF
-		}
-
+		nlnh.HardwareAddr = dstMac
+		nlnh.Flags = netlink.NTF_MASTER
 		if nh.linkDst != "" {
 		if nh.linkDst != "" {
 			nlnh.LinkIndex = iface.Attrs().Index
 			nlnh.LinkIndex = iface.Attrs().Index
 		}
 		}
-
-		// If the kernel deletion fails for the neighbor entry still remove it
-		// from the namespace cache, otherwise kernel update can fail if the
-		// neighbor moves back to the same host again.
 		if err := nlh.NeighDel(nlnh); err != nil && !errors.Is(err, os.ErrNotExist) {
 		if err := nlh.NeighDel(nlnh); err != nil && !errors.Is(err, os.ErrNotExist) {
-			log.G(context.TODO()).Warnf("Deleting neighbor IP %s, mac %s failed, %v", dstIP, dstMac, err)
-		}
-
-		// Delete the dynamic entry in the bridge
-		if nlnh.Family > 0 {
-			nlnh := &netlink.Neigh{
-				IP:     dstIP,
-				Family: nh.family,
-			}
-
-			nlnh.HardwareAddr = dstMac
-			nlnh.Flags = netlink.NTF_MASTER
-			if nh.linkDst != "" {
-				nlnh.LinkIndex = iface.Attrs().Index
-			}
-			if err := nlh.NeighDel(nlnh); err != nil && !errors.Is(err, os.ErrNotExist) {
-				log.G(context.TODO()).WithError(err).Warn("error while deleting neighbor entry")
-			}
+			log.G(context.TODO()).WithError(err).Warn("error while deleting neighbor entry")
 		}
 		}
 	}
 	}
 
 
@@ -117,7 +114,7 @@ func (n *Namespace) DeleteNeighbor(dstIP net.IP, dstMac net.HardwareAddr, osDele
 		}
 		}
 	}
 	}
 	n.Unlock()
 	n.Unlock()
-	log.G(context.TODO()).Debugf("Neighbor entry deleted for IP %v, mac %v osDelete:%t", dstIP, dstMac, osDelete)
+	log.G(context.TODO()).Debugf("Neighbor entry deleted for IP %v, mac %v", dstIP, dstMac)
 
 
 	return nil
 	return nil
 }
 }