Whamcloud - gitweb
LU-11763 lnet: Change "lctl network configure" to always take net device info lnet-sysfs
authorSonia Sharma <sharmaso@whamcloud.com>
Fri, 26 Oct 2018 14:08:06 +0000 (10:08 -0400)
committerSonia Sharma <sharmaso@whamcloud.com>
Thu, 30 May 2019 02:34:04 +0000 (22:34 -0400)
Currently, if the network interface is not specified
in the lustre.conf file, then the "lctl network configure"
command configures network at LND level using default
interface values for socklnd and o2iblnd.

With this patch, lnet_get_networks() is modified such
that if the network device info is not provided, then
it will get the first available network interface,
say "intf" and pass "tcp(intf)" to lnet_parse_networks().
If no network device is found, then it will pass NULL.

Test-Parameters: trivial
Change-Id: I3e3d8fac5f9837330d8787f36826ef9b2b4ea93e
Signed-off-by: Sonia Sharma <sharmaso@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/34764
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Amir Shehata <ashehata@whamcloud.com>
lnet/lnet/api-ni.c
lustre/ptlrpc/events.c
lustre/utils/portals.c

index fc4ece1..0f219a8 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/ktime.h>
 #include <linux/moduleparam.h>
 #include <linux/uaccess.h>
+#include <linux/inetdevice.h>
 
 #include <lnet/lib-lnet.h>
 
@@ -515,10 +516,42 @@ lnet_get_routes(void)
 }
 
 static char *
+get_first_intf(void)
+{
+       struct net_device *dev;
+
+       rtnl_lock();
+
+       for_each_netdev(&init_net, dev) {
+               struct in_device *in_dev;
+               if (strcmp(dev->name, "lo") == 0) /* skip the loopback IF */
+                       continue;
+
+               if (!(dev_get_flags(dev) & IFF_UP)) {
+                       CWARN("Ignoring interface %s (down)\n", dev->name);
+                       continue;
+               }
+
+               in_dev = __in_dev_get_rtnl(dev);
+               if (!in_dev) {
+                       CWARN("Interface %s has no IPv4 status.\n", dev->name);
+                       continue;
+               }
+
+               rtnl_unlock();
+               return dev->name;
+       }
+
+       rtnl_unlock();
+       return NULL;
+}
+
+static char *
 lnet_get_networks(void)
 {
-       char   *nets;
-       int     rc;
+       static char network[LNET_MAX_STR_LEN];
+       char *nets, *intf;
+       int rc;
 
        if (*networks != 0 && *ip2nets != 0) {
                LCONSOLE_ERROR_MSG(0x101, "Please specify EITHER 'networks' or "
@@ -534,7 +567,13 @@ lnet_get_networks(void)
        if (*networks != 0)
                return networks;
 
-       return "tcp";
+       intf = get_first_intf();
+       if (!intf)
+               return NULL;
+
+       snprintf(network, sizeof(network), "tcp(%s)", intf);
+
+       return network;
 }
 
 static void
index 443bc32..70a62ef 100644 (file)
@@ -594,9 +594,9 @@ int ptlrpc_ni_init(void)
         CDEBUG(D_NET, "My pid is: %x\n", pid);
 
         /* We're not passing any limits yet... */
-        rc = LNetNIInit(pid);
-        if (rc < 0) {
-                CDEBUG (D_NET, "Can't init network interface: %d\n", rc);
+       rc = LNetNIInit(pid);
+       if (rc < 0) {
+               CDEBUG(D_NET, "Can't init network interface: %d\n", rc);
                return rc;
         }
 
@@ -611,7 +611,8 @@ int ptlrpc_ni_init(void)
                 return 0;
 
         CERROR ("Failed to allocate event queue: %d\n", rc);
-        LNetNIFini();
+
+       LNetNIFini();
 
        return rc;
 }
index 9466ea4..8673c7f 100644 (file)
@@ -292,7 +292,6 @@ int ptl_initialize(int argc, char **argv)
         return 0;
 }
 
-
 int jt_ptl_network(int argc, char **argv)
 {
        struct libcfs_ioctl_data data;
@@ -327,7 +326,6 @@ int jt_ptl_network(int argc, char **argv)
        } else if (!strcmp(argv[1], "configure") || !strcmp(argv[1], "up")) {
                LIBCFS_IOC_INIT(data);
                rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_CONFIGURE, &data);
-
                if (rc == 0) {
                        printf("LNET configured\n");
                        return 0;