@@ -1391,6 +1391,17 @@ void lnet_usr_translate_stats(struct lnet_ioctl_element_msg_stats *msg_stats,
lnet_net_unlock(cpt);
return PTR_ERR(lpni);
}
+
+ /* If we're being asked to send to the loopback interface, there
+ * is no need to go through any selection. We can just shortcut
+ * the entire process and send over lolnd
+ */
+ if (LNET_NETTYP(LNET_NIDNET(dst_nid)) == LOLND) {
+ lnet_peer_ni_decref_locked(lpni);
+ best_ni = the_lnet.ln_loni;
+ goto send;
+ }
+
/*
* Now that we have a peer_ni, check if we want to discover
* the peer. Traffic to the LNET_RESERVED_PORTAL should not
@@ -211,6 +211,15 @@
init_waitqueue_head(&lp->lp_dc_waitq);
spin_lock_init(&lp->lp_lock);
lp->lp_primary_nid = nid;
+
+ /* Turn off discovery for loopback peer. If you're creating a peer
+ * for the loopback interface then that was initiated when we
+ * attempted to send a message over the loopback. There is no need
+ * to ever use a different interface when sending messages to
+ * myself.
+ */
+ if (LNET_NETTYP(LNET_NIDNET(nid)) == LOLND)
+ lp->lp_state = LNET_PEER_NO_DISCOVERY;
lp->lp_cpt = lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER);
CDEBUG(D_NET, "%p nid %s\n", lp, libcfs_nid2str(lp->lp_primary_nid));