Whamcloud - gitweb
LU-7988 hsm: only browse entries of hsd.request when needed
[fs/lustre-release.git] / lnet / lnet / config.c
index a40f17b..1105231 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, 2014, Intel Corporation.
+ * Copyright (c) 2012, 2015, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -108,6 +108,9 @@ lnet_ni_free(struct lnet_ni *ni)
        if (ni->ni_cpts != NULL)
                cfs_expr_list_values_free(ni->ni_cpts, ni->ni_ncpts);
 
+       if (ni->ni_lnd_tunables != NULL)
+               LIBCFS_FREE(ni->ni_lnd_tunables, sizeof(*ni->ni_lnd_tunables));
+
        for (i = 0; i < LNET_MAX_INTERFACES &&
                    ni->ni_interfaces[i] != NULL; i++) {
                LIBCFS_FREE(ni->ni_interfaces[i],
@@ -327,7 +330,7 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
                                goto failed;
                        }
 
-                       /* Allocate a seperate piece of memory and copy
+                       /* Allocate a separate piece of memory and copy
                         * into it the string, so we don't have
                         * a depencency on the tokens string.  This way we
                         * can free the tokens at the end of the function.
@@ -466,7 +469,7 @@ lnet_str2tbs_sep(struct list_head *tbs, char *str)
        /* Split 'str' into separate commands */
        for (;;) {
                 /* skip leading whitespace */
-                while (cfs_iswhite(*str))
+               while (isspace(*str))
                         str++;
 
                /* scan for separator or comment */
@@ -479,11 +482,11 @@ lnet_str2tbs_sep(struct list_head *tbs, char *str)
                        ltb = lnet_new_text_buf(nob);
                        if (ltb == NULL) {
                                lnet_free_text_bufs(&pending);
-                               return -1;
+                               return -ENOMEM;
                        }
 
                         for (i = 0; i < nob; i++)
-                                if (cfs_iswhite(str[i]))
+                               if (isspace(str[i]))
                                         ltb->ltb_text[i] = ' ';
                                 else
                                         ltb->ltb_text[i] = str[i];
@@ -612,7 +615,7 @@ lnet_str2tbs_expand(struct list_head *tbs, char *str)
 
  failed:
        lnet_free_text_bufs(&pending);
-       return -1;
+       return -EINVAL;
 }
 
 static int
@@ -646,7 +649,7 @@ lnet_parse_priority(char *str, unsigned int *priority, char **token)
                /* Update the caller's token pointer so it treats the found
                   priority as the token to report in the error message. */
                *token += sep - str + 1;
-               return -1;
+               return -EINVAL;
        }
 
        CDEBUG(D_NET, "gateway %s, priority %d, nob %d\n", str, *priority, nob);
@@ -676,7 +679,7 @@ lnet_parse_route (char *str, int *im_a_router)
        char             *token = str;
        int               ntokens = 0;
        int               myrc = -1;
-       unsigned int      hops;
+       __u32             hops;
        int               got_hops = 0;
        unsigned int      priority = 0;
 
@@ -690,7 +693,7 @@ lnet_parse_route (char *str, int *im_a_router)
        sep = str;
        for (;;) {
                /* scan for token start */
-                while (cfs_iswhite(*sep))
+               while (isspace(*sep))
                        sep++;
                if (*sep == 0) {
                        if (ntokens < (got_hops ? 3 : 2))
@@ -702,7 +705,7 @@ lnet_parse_route (char *str, int *im_a_router)
                token = sep++;
 
                /* scan for token end */
-                while (*sep != 0 && !cfs_iswhite(*sep))
+               while (*sep != 0 && !isspace(*sep))
                        sep++;
                if (*sep != 0)
                        *sep++ = 0;
@@ -759,8 +762,10 @@ lnet_parse_route (char *str, int *im_a_router)
                }
        }
 
+       /* if there are no hops set then we want to flag this value as
+        * unset since hops is an optional parameter */
        if (!got_hops)
-               hops = 1;
+               hops = LNET_UNDEFINED_HOPS;
 
        LASSERT(!list_empty(&nets));
        LASSERT(!list_empty(&gateways));
@@ -857,7 +862,7 @@ lnet_match_network_token(char *token, int len, __u32 *ipaddrs, int nip)
        for (rc = i = 0; !rc && i < nip; i++)
                rc = cfs_ip_addr_match(ipaddrs[i], &list);
 
-       cfs_ip_addr_free(&list);
+       cfs_expr_list_free_list(&list);
 
         return rc;
 }
@@ -882,7 +887,7 @@ lnet_match_network_tokens(char *net_entry, __u32 *ipaddrs, int nip)
         sep = tokens;
         for (;;) {
                 /* scan for token start */
-                while (cfs_iswhite(*sep))
+               while (isspace(*sep))
                         sep++;
                 if (*sep == 0)
                         break;
@@ -890,7 +895,7 @@ lnet_match_network_tokens(char *net_entry, __u32 *ipaddrs, int nip)
                 token = sep++;
 
                 /* scan for token end */
-                while (*sep != 0 && !cfs_iswhite(*sep))
+               while (*sep != 0 && !isspace(*sep))
                         sep++;
                 if (*sep != 0)
                         *sep++ = 0;
@@ -1153,7 +1158,7 @@ lnet_ipaddr_enumerate (__u32 **ipaddrsp)
         __u32     *ipaddrs2;
         int        nip;
         char     **ifnames;
-        int        nif = libcfs_ipif_enumerate(&ifnames);
+       int        nif = lnet_ipif_enumerate(&ifnames);
         int        i;
         int        rc;
 
@@ -1163,7 +1168,7 @@ lnet_ipaddr_enumerate (__u32 **ipaddrsp)
         LIBCFS_ALLOC(ipaddrs, nif * sizeof(*ipaddrs));
         if (ipaddrs == NULL) {
                 CERROR("Can't allocate ipaddrs[%d]\n", nif);
-                libcfs_ipif_free_enumeration(ifnames, nif);
+               lnet_ipif_free_enumeration(ifnames, nif);
                 return -ENOMEM;
         }
 
@@ -1171,7 +1176,7 @@ lnet_ipaddr_enumerate (__u32 **ipaddrsp)
                 if (!strcmp(ifnames[i], "lo"))
                         continue;
 
-                rc = libcfs_ipif_query(ifnames[i], &up,
+               rc = lnet_ipif_query(ifnames[i], &up,
                                        &ipaddrs[nip], &netmask);
                 if (rc != 0) {
                         CWARN("Can't query interface %s: %d\n",
@@ -1188,7 +1193,7 @@ lnet_ipaddr_enumerate (__u32 **ipaddrsp)
                 nip++;
         }
 
-        libcfs_ipif_free_enumeration(ifnames, nif);
+       lnet_ipif_free_enumeration(ifnames, nif);
 
         if (nip == nif) {
                 *ipaddrsp = ipaddrs;