[lustre-devel] [PATCH 11/19] lnet: Fail peer add for existing gw peer

James Simmons jsimmons at infradead.org
Sun Nov 28 15:27:46 PST 2021


From: Chris Horn <chris.horn at hpe.com>

If there's an existing peer entry for a peer that is being added
via CLI, and that existing peer was not created via the CLI, then
DLC will attempt to delete the existing peer before creating a new
one. The exit status of the peer deletion was not being checked.
This results in the ability to add duplicate peers for gateways,
because gateways cannot be deleted via lnetctl unless the routes
for that gateway have been removed first.

WC-bug-id: https://jira.whamcloud.com/browse/LU-15138
Lustre-commit: 79a4b69adb1e365b1 ("LU-15138 lnet: Fail peer add for existing gw peer")
Signed-off-by: Chris Horn <chris.horn at hpe.com>
Reviewed-on: https://review.whamcloud.com/45337
Reviewed-by: Alexander Boyko <alexander.boyko at hpe.com>
Reviewed-by: Andriy Skulysh <andriy.skulysh at hpe.com>
Reviewed-by: Oleg Drokin <green at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
 net/lnet/lnet/peer.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/net/lnet/lnet/peer.c b/net/lnet/lnet/peer.c
index 1853388..a9f33c0 100644
--- a/net/lnet/lnet/peer.c
+++ b/net/lnet/lnet/peer.c
@@ -499,12 +499,14 @@ static void lnet_peer_cancel_discovery(struct lnet_peer *lp)
 static int
 lnet_peer_del(struct lnet_peer *peer)
 {
+	int rc;
+
 	lnet_peer_cancel_discovery(peer);
 	lnet_net_lock(LNET_LOCK_EX);
-	lnet_peer_del_locked(peer);
+	rc = lnet_peer_del_locked(peer);
 	lnet_net_unlock(LNET_LOCK_EX);
 
-	return 0;
+	return rc;
 }
 
 /*
@@ -1648,7 +1650,9 @@ struct lnet_peer_net *
 			}
 		}
 		/* Delete and recreate as a configured peer. */
-		lnet_peer_del(lp);
+		rc = lnet_peer_del(lp);
+		if (rc)
+			goto out;
 	}
 
 	/* Create peer, peer_net, and peer_ni. */
@@ -3238,6 +3242,7 @@ static int lnet_peer_deletion(struct lnet_peer *lp)
 	struct list_head rlist;
 	struct lnet_route *route, *tmp;
 	int sensitivity = lp->lp_health_sensitivity;
+	int rc;
 
 	INIT_LIST_HEAD(&rlist);
 
@@ -3271,7 +3276,10 @@ static int lnet_peer_deletion(struct lnet_peer *lp)
 	lnet_net_unlock(LNET_LOCK_EX);
 
 	/* lnet_peer_del() deletes all the peer NIs owned by this peer */
-	lnet_peer_del(lp);
+	rc = lnet_peer_del(lp);
+	if (rc)
+		CNETERR("Internal error: Unable to delete peer %s rc %d\n",
+			libcfs_nidstr(&lp->lp_primary_nid), rc);
 
 	list_for_each_entry_safe(route, tmp,
 				 &rlist, lr_list) {
-- 
1.8.3.1



More information about the lustre-devel mailing list