Whamcloud - gitweb
LU-5874 lnet: reject invalid net configuration 12/12912/7
authorAmir Shehata <amir.shehata@intel.com>
Tue, 2 Dec 2014 02:06:39 +0000 (18:06 -0800)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 19 Jan 2015 17:51:39 +0000 (17:51 +0000)
Currently if there exists a route that goes over a
remote net and then this net is added dynamically as
a local net, then traffic stops because the code in
lnet_send() determines that the destination nid
can be reached from another local_ni, but the src_nid
is still stuck on the earlier NI, because the src_nid
is stored in the ptlrpc layer and is not updated
when a local NI is configured.

Signed-off-by: Amir Shehata <amir.shehata@intel.com>
Change-Id: Idd4ea9e131db127f541dd8d75b90ac509c16e2c3
Reviewed-on: http://review.whamcloud.com/12912
Tested-by: Jenkins
Reviewed-by: Isaac Huang <he.huang@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: James Simmons <uja.ornl@gmail.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lnet/lnet/api-ni.c

index 75ff383..04ccd26 100644 (file)
@@ -1992,6 +1992,7 @@ lnet_dyn_add_ni(lnet_pid_t requested_pid, char *nets,
        struct lnet_ni          *ni;
        struct list_head        net_head;
        int                     rc;
        struct lnet_ni          *ni;
        struct list_head        net_head;
        int                     rc;
+       lnet_remotenet_t        *rnet;
 
        INIT_LIST_HEAD(&net_head);
 
 
        INIT_LIST_HEAD(&net_head);
 
@@ -2007,12 +2008,25 @@ lnet_dyn_add_ni(lnet_pid_t requested_pid, char *nets,
                goto failed0;
        }
 
                goto failed0;
        }
 
+       ni = list_entry(net_head.next, struct lnet_ni, ni_list);
+
+       lnet_net_lock(LNET_LOCK_EX);
+       rnet = lnet_find_net_locked(LNET_NIDNET(ni->ni_nid));
+       lnet_net_unlock(LNET_LOCK_EX);
+       /* make sure that the net added doesn't invalidate the current
+        * configuration LNet is keeping */
+       if (rnet != NULL) {
+               CERROR("Adding net %s will invalidate routing configuration\n",
+                      nets);
+               rc = -EUSERS;
+               goto failed0;
+       }
+
        rc = lnet_ping_info_setup(&pinfo, &md_handle, 1 + lnet_get_ni_count(),
                                  false);
        if (rc != 0)
                goto failed0;
 
        rc = lnet_ping_info_setup(&pinfo, &md_handle, 1 + lnet_get_ni_count(),
                                  false);
        if (rc != 0)
                goto failed0;
 
-       ni = list_entry(net_head.next, struct lnet_ni, ni_list);
        list_del_init(&ni->ni_list);
 
        rc = lnet_startup_lndni(ni, peer_timeout, peer_cr,
        list_del_init(&ni->ni_list);
 
        rc = lnet_startup_lndni(ni, peer_timeout, peer_cr,