From 724fe0e0e3faa18d2c3a532de3aaf603b3e896c0 Mon Sep 17 00:00:00 2001 From: Sonia Sharma Date: Fri, 26 Oct 2018 10:08:06 -0400 Subject: [PATCH] LU-11763 lnet: Change "lctl network configure" to always take net device info 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 Reviewed-on: https://review.whamcloud.com/34764 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Amir Shehata --- lnet/lnet/api-ni.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- lustre/ptlrpc/events.c | 9 +++++---- lustre/utils/portals.c | 2 -- 3 files changed, 47 insertions(+), 9 deletions(-) diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index fc4ece1..0f219a8 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -37,6 +37,7 @@ #include #include #include +#include #include @@ -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 diff --git a/lustre/ptlrpc/events.c b/lustre/ptlrpc/events.c index 443bc32..70a62ef 100644 --- a/lustre/ptlrpc/events.c +++ b/lustre/ptlrpc/events.c @@ -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; } diff --git a/lustre/utils/portals.c b/lustre/utils/portals.c index 9466ea4..8673c7f 100644 --- a/lustre/utils/portals.c +++ b/lustre/utils/portals.c @@ -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; -- 1.8.3.1