@@ -4308,59 +4308,6 @@ void lnet_monitor_thr_stop(void)
goto drop;
}
- if (lnet_drop_asym_route && for_me &&
- LNET_NIDNET(src_nid) != LNET_NIDNET(from_nid)) {
- struct lnet_net *net;
- struct lnet_remotenet *rnet;
- bool found = true;
-
- /* we are dealing with a routed message,
- * so see if route to reach src_nid goes through from_nid
- */
- lnet_net_lock(cpt);
- net = lnet_get_net_locked(LNET_NIDNET(ni->ni_nid));
- if (!net) {
- lnet_net_unlock(cpt);
- CERROR("net %s not found\n",
- libcfs_net2str(LNET_NIDNET(ni->ni_nid)));
- return -EPROTO;
- }
-
- rnet = lnet_find_rnet_locked(LNET_NIDNET(src_nid));
- if (rnet) {
- struct lnet_peer *gw = NULL;
- struct lnet_peer_ni *lpni = NULL;
- struct lnet_route *route;
-
- list_for_each_entry(route, &rnet->lrn_routes, lr_list) {
- found = false;
- gw = route->lr_gateway;
- if (route->lr_lnet != net->net_id)
- continue;
- /* if the nid is one of the gateway's NIDs
- * then this is a valid gateway
- */
- while ((lpni = lnet_get_next_peer_ni_locked(gw, NULL, lpni)) != NULL) {
- if (lpni->lpni_nid == from_nid) {
- found = true;
- break;
- }
- }
- }
- }
- lnet_net_unlock(cpt);
- if (!found) {
- /* we would not use from_nid to route a message to
- * src_nid
- * => asymmetric routing detected but forbidden
- */
- CERROR("%s, src %s: Dropping asymmetrical route %s\n",
- libcfs_nid2str(from_nid),
- libcfs_nid2str(src_nid), lnet_msgtyp2str(type));
- goto drop;
- }
- }
-
msg = kmem_cache_zalloc(lnet_msg_cachep, GFP_NOFS);
if (!msg) {
CERROR("%s, src %s: Dropping %s (out of memory)\n",
@@ -4410,6 +4357,33 @@ void lnet_monitor_thr_stop(void)
goto drop;
}
+ if (lnet_drop_asym_route && for_me &&
+ LNET_NIDNET(src_nid) != LNET_NIDNET(from_nid)) {
+ u32 src_net_id = LNET_NIDNET(src_nid);
+ struct lnet_peer *gw = lpni->lpni_peer_net->lpn_peer;
+ struct lnet_route *route;
+ bool found = false;
+
+ list_for_each_entry(route, &gw->lp_routes, lr_gwlist) {
+ if (route->lr_net == src_net_id) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ lnet_net_unlock(cpt);
+ /* we would not use from_nid to route a message to
+ * src_nid
+ * => asymmetric routing detected but forbidden
+ */
+ CERROR("%s, src %s: Dropping asymmetrical route %s\n",
+ libcfs_nid2str(from_nid),
+ libcfs_nid2str(src_nid), lnet_msgtyp2str(type));
+ kfree(msg);
+ goto drop;
+ }
+ }
+
if (the_lnet.ln_routing)
lpni->lpni_last_alive = ktime_get_seconds();