@@ -379,7 +379,7 @@ void kiblnd_destroy_peer(struct kib_peer *peer)
atomic_dec(&net->ibn_npeers);
}
-struct kib_peer *kiblnd_find_peer_locked(lnet_nid_t nid)
+struct kib_peer *kiblnd_find_peer_locked(struct lnet_ni *ni, lnet_nid_t nid)
{
/*
* the caller is responsible for accounting the additional reference
@@ -391,7 +391,14 @@ struct kib_peer *kiblnd_find_peer_locked(lnet_nid_t nid)
list_for_each_entry(peer, peer_list, ibp_list) {
LASSERT(!kiblnd_peer_idle(peer));
- if (peer->ibp_nid != nid)
+ /*
+ * Match a peer if its NID and the NID of the local NI it
+ * communicates over are the same. Otherwise don't match
+ * the peer, which will result in a new lnd peer being
+ * created.
+ */
+ if (peer->ibp_nid != nid ||
+ peer->ibp_ni->ni_nid != ni->ni_nid)
continue;
CDEBUG(D_NET, "got peer [%p] -> %s (%d) version: %x\n",
@@ -1041,7 +1048,7 @@ static void kiblnd_query(struct lnet_ni *ni, lnet_nid_t nid, time64_t *when)
read_lock_irqsave(glock, flags);
- peer = kiblnd_find_peer_locked(nid);
+ peer = kiblnd_find_peer_locked(ni, nid);
if (peer)
last_alive = peer->ibp_last_alive;
@@ -1019,7 +1019,7 @@ void kiblnd_destroy_peer(struct kib_peer *peer);
bool kiblnd_reconnect_peer(struct kib_peer *peer);
void kiblnd_destroy_dev(struct kib_dev *dev);
void kiblnd_unlink_peer_locked(struct kib_peer *peer);
-struct kib_peer *kiblnd_find_peer_locked(lnet_nid_t nid);
+struct kib_peer *kiblnd_find_peer_locked(struct lnet_ni *ni, lnet_nid_t nid);
int kiblnd_close_stale_conns_locked(struct kib_peer *peer,
int version, __u64 incarnation);
int kiblnd_close_peer_conns_locked(struct kib_peer *peer, int why);
@@ -1370,7 +1370,7 @@ kiblnd_launch_tx(struct lnet_ni *ni, struct kib_tx *tx, lnet_nid_t nid)
*/
read_lock_irqsave(g_lock, flags);
- peer = kiblnd_find_peer_locked(nid);
+ peer = kiblnd_find_peer_locked(ni, nid);
if (peer && !list_empty(&peer->ibp_conns)) {
/* Found a peer with an established connection */
conn = kiblnd_get_conn_locked(peer);
@@ -1388,7 +1388,7 @@ kiblnd_launch_tx(struct lnet_ni *ni, struct kib_tx *tx, lnet_nid_t nid)
/* Re-try with a write lock */
write_lock(g_lock);
- peer = kiblnd_find_peer_locked(nid);
+ peer = kiblnd_find_peer_locked(ni, nid);
if (peer) {
if (list_empty(&peer->ibp_conns)) {
/* found a peer, but it's still connecting... */
@@ -1426,7 +1426,7 @@ kiblnd_launch_tx(struct lnet_ni *ni, struct kib_tx *tx, lnet_nid_t nid)
write_lock_irqsave(g_lock, flags);
- peer2 = kiblnd_find_peer_locked(nid);
+ peer2 = kiblnd_find_peer_locked(ni, nid);
if (peer2) {
if (list_empty(&peer2->ibp_conns)) {
/* found a peer, but it's still connecting... */
@@ -2388,7 +2388,7 @@ kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob)
write_lock_irqsave(g_lock, flags);
- peer2 = kiblnd_find_peer_locked(nid);
+ peer2 = kiblnd_find_peer_locked(ni, nid);
if (peer2) {
if (!peer2->ibp_version) {
peer2->ibp_version = version;