Whamcloud - gitweb
LU-5734 lnet: improve clean up code and API
[fs/lustre-release.git] / lnet / lnet / config.c
index 7dd588e..c5f7e96 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, Intel Corporation.
+ * Copyright (c) 2012, 2014, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -197,13 +197,19 @@ int
 lnet_parse_networks(struct list_head *nilist, char *networks)
 {
        struct cfs_expr_list *el = NULL;
-       int             tokensize = strlen(networks) + 1;
+       int             tokensize;
        char            *tokens;
        char            *str;
        char            *tmp;
        struct lnet_ni  *ni;
        __u32           net;
        int             nnets = 0;
+       struct list_head *temp_node;
+
+       if (networks == NULL) {
+               CERROR("networks string is undefined\n");
+               return -EINVAL;
+       }
 
        if (strlen(networks) > LNET_SINGLE_TEXTBUF_NOB) {
                /* _WAY_ conservative */
@@ -212,6 +218,8 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
                return -EINVAL;
        }
 
+       tokensize = strlen(networks) + 1;
+
        LIBCFS_ALLOC(tokens, tokensize);
        if (tokens == NULL) {
                CERROR("Can't allocate net tokens\n");
@@ -221,11 +229,6 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
        memcpy(tokens, networks, tokensize);
        str = tmp = tokens;
 
-       /* Add in the loopback network */
-       ni = lnet_ni_alloc(LNET_MKNET(LOLND, 0), NULL, nilist);
-       if (ni == NULL)
-               goto failed;
-
        while (str != NULL && *str != 0) {
                char    *comma = strchr(str, ',');
                char    *bracket = strchr(str, '(');
@@ -298,7 +301,6 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
                        goto failed_syntax;
                }
 
-               nnets++;
                ni = lnet_ni_alloc(net, el, nilist);
                if (ni == NULL)
                        goto failed;
@@ -374,10 +376,11 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
                }
        }
 
-       LASSERT(!list_empty(nilist));
+       list_for_each(temp_node, nilist)
+               nnets++;
 
        LIBCFS_FREE(tokens, tokensize);
-       return 0;
+       return nnets;
 
  failed_syntax:
        lnet_syntax("networks", networks, (int)(tmp - tokens), strlen(tmp));