+ final_hop = false;
+ if (msg->msg_routing && (send_case & LOCAL_DST))
+ final_hop = true;
+
+ /* Determine whether to allow MR forwarding for this message.
+ * NB: MR forwarding is allowed if the message originator and the
+ * destination are both MR capable, and the destination lpni that was
+ * originally chosen by the originator is unhealthy or down.
+ * We check the MR capability of the destination further below
+ */
+ mr_forwarding_allowed = false;
+ if (final_hop) {
+ struct lnet_peer *src_lp;
+ struct lnet_peer_ni *src_lpni;
+
+ src_lpni = lnet_nid2peerni_locked(msg->msg_hdr.src_nid,
+ LNET_NID_ANY, cpt);
+ /* We don't fail the send if we hit any errors here. We'll just
+ * try to send it via non-multi-rail criteria
+ */
+ if (!IS_ERR(src_lpni)) {
+ src_lp = lpni->lpni_peer_net->lpn_peer;
+ if (lnet_peer_is_multi_rail(src_lp) &&
+ !lnet_is_peer_ni_alive(lpni))
+ mr_forwarding_allowed = true;
+
+ }
+ CDEBUG(D_NET, "msg %p MR forwarding %s\n", msg,
+ mr_forwarding_allowed ? "allowed" : "not allowed");
+ }
+