@@ -1830,52 +1830,73 @@ struct lnet_ni *
}
if (!route_found) {
- /* we've already looked up the initial lpni using dst_nid */
- lpni = sd->sd_best_lpni;
- /* the peer tree must be in existence */
- LASSERT(lpni && lpni->lpni_peer_net &&
- lpni->lpni_peer_net->lpn_peer);
- lp = lpni->lpni_peer_net->lpn_peer;
-
- list_for_each_entry(lpn, &lp->lp_peer_nets, lpn_peer_nets) {
- /* is this remote network reachable? */
- rnet = lnet_find_rnet_locked(lpn->lpn_net_id);
- if (!rnet)
- continue;
+ if (sd->sd_msg->msg_routing) {
+ /* If I'm routing this message then I need to find the
+ * next hop based on the destination NID
+ */
+ best_rnet = lnet_find_rnet_locked(LNET_NIDNET(sd->sd_dst_nid));
+ if (!best_rnet) {
+ CERROR("Unable to route message to %s - Route table may be misconfigured\n",
+ libcfs_nid2str(sd->sd_dst_nid));
+ return -EHOSTUNREACH;
+ }
+ } else {
+ /* we've already looked up the initial lpni using
+ * dst_nid
+ */
+ lpni = sd->sd_best_lpni;
+ /* the peer tree must be in existence */
+ LASSERT(lpni && lpni->lpni_peer_net &&
+ lpni->lpni_peer_net->lpn_peer);
+ lp = lpni->lpni_peer_net->lpn_peer;
+
+ list_for_each_entry(lpn, &lp->lp_peer_nets,
+ lpn_peer_nets) {
+ /* is this remote network reachable? */
+ rnet = lnet_find_rnet_locked(lpn->lpn_net_id);
+ if (!rnet)
+ continue;
+
+ if (!best_lpn) {
+ best_lpn = lpn;
+ best_rnet = rnet;
+ }
+
+ if (best_lpn->lpn_seq <= lpn->lpn_seq)
+ continue;
- if (!best_lpn) {
best_lpn = lpn;
best_rnet = rnet;
}
- if (best_lpn->lpn_seq <= lpn->lpn_seq)
- continue;
+ if (!best_lpn) {
+ CERROR("peer %s has no available nets\n",
+ libcfs_nid2str(sd->sd_dst_nid));
+ return -EHOSTUNREACH;
+ }
- best_lpn = lpn;
- best_rnet = rnet;
- }
+ sd->sd_best_lpni = lnet_find_best_lpni(sd->sd_best_ni,
+ sd->sd_dst_nid,
+ lp,
+ best_lpn->lpn_net_id);
+ if (!sd->sd_best_lpni) {
+ CERROR("peer %s is unreachable\n",
+ libcfs_nid2str(sd->sd_dst_nid));
+ return -EHOSTUNREACH;
+ }
- if (!best_lpn) {
- CERROR("peer %s has no available nets\n",
- libcfs_nid2str(sd->sd_dst_nid));
- return -EHOSTUNREACH;
- }
+ /* We're attempting to round robin over the remote peer
+ * NI's so update the final destination we selected
+ */
+ sd->sd_final_dst_lpni = sd->sd_best_lpni;
- sd->sd_best_lpni = lnet_find_best_lpni(sd->sd_best_ni,
- sd->sd_dst_nid,
- lp,
- best_lpn->lpn_net_id);
- if (!sd->sd_best_lpni) {
- CERROR("peer %s is unreachable\n",
- libcfs_nid2str(sd->sd_dst_nid));
- return -EHOSTUNREACH;
+ /* Increment the sequence number of the remote lpni so
+ * we can round robin over the different interfaces of
+ * the remote lpni
+ */
+ sd->sd_best_lpni->lpni_seq++;
}
- /* We're attempting to round robin over the remote peer
- * NI's so update the final destination we selected
- */
- sd->sd_final_dst_lpni = sd->sd_best_lpni;
-
/* find the best route. Restrict the selection on the net of the
* local NI if we've already picked the local NI to send from.
* Otherwise, let's pick any route we can find and then find
@@ -1903,12 +1924,6 @@ struct lnet_ni *
gw = best_route->lr_gateway;
LASSERT(gw == gwni->lpni_peer_net->lpn_peer);
local_lnet = best_route->lr_lnet;
-
- /* Increment the sequence number of the remote lpni so we
- * can round robin over the different interfaces of the
- * remote lpni
- */
- sd->sd_best_lpni->lpni_seq++;
}
/* Discover this gateway if it hasn't already been discovered.
@@ -1945,7 +1960,8 @@ struct lnet_ni *
if (sd->sd_rtr_nid == LNET_NID_ANY) {
LASSERT(best_route && last_route);
best_route->lr_seq = last_route->lr_seq + 1;
- best_lpn->lpn_seq++;
+ if (best_lpn)
+ best_lpn->lpn_seq++;
}
return 0;