Whamcloud - gitweb
LU-6245 libcfs: move cfs_ip_addr_* function from kernel libcfs to LNet 85/15085/4
authorJames Simmons <uja.ornl@yahoo.com>
Sat, 30 May 2015 00:10:35 +0000 (20:10 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 19 Jun 2015 07:06:27 +0000 (07:06 +0000)
Both of cfs_ip_addr_parse and cfs_ip_addr_match which are located in
libcfs kernel module are used only for LNet so move this into the
nidstring handling code where it belongs. Also create user land
versions of these functions in the libcfs user land library.

Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Change-Id: Idb1be9c6ab3328f2f85e92847b5a367d91a903da
Reviewed-on: http://review.whamcloud.com/15085
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: frank zago <fzago@cray.com>
Tested-by: Jenkins
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
libcfs/include/libcfs/libcfs_string.h
libcfs/libcfs/libcfs_string.c
libcfs/libcfs/util/nidstrings.c
libcfs/libcfs/util/string.c
lnet/include/lnet/nidstr.h
lnet/lnet/nidstrings.c

index 53493b3..6374770 100644 (file)
@@ -101,7 +101,5 @@ void cfs_expr_list_free(struct cfs_expr_list *expr_list);
 int cfs_expr_list_parse(char *str, int len, unsigned min, unsigned max,
                        struct cfs_expr_list **elpp);
 void cfs_expr_list_free_list(struct list_head *list);
-int cfs_ip_addr_parse(char *str, int len, struct list_head *list);
-int cfs_ip_addr_match(__u32 addr, struct list_head *list);
 
 #endif
index 2a3009f..06ce845 100644 (file)
@@ -589,65 +589,3 @@ cfs_expr_list_free_list(struct list_head *list)
        }
 }
 EXPORT_SYMBOL(cfs_expr_list_free_list);
-
-int
-cfs_ip_addr_parse(char *str, int len, struct list_head *list)
-{
-       struct cfs_expr_list    *el;
-       struct cfs_lstr         src;
-       int                     rc;
-       int                     i;
-
-       src.ls_str = str;
-       src.ls_len = len;
-       i = 0;
-
-       while (src.ls_str != NULL) {
-               struct cfs_lstr res;
-
-               if (!cfs_gettok(&src, '.', &res)) {
-                       rc = -EINVAL;
-                       goto out;
-               }
-
-               rc = cfs_expr_list_parse(res.ls_str, res.ls_len, 0, 255, &el);
-               if (rc != 0)
-                       goto out;
-
-               list_add_tail(&el->el_link, list);
-               i++;
-       }
-
-       if (i == 4)
-               return 0;
-
-       rc = -EINVAL;
- out:
-       cfs_expr_list_free_list(list);
-
-       return rc;
-}
-EXPORT_SYMBOL(cfs_ip_addr_parse);
-
-/**
- * Matches address (\a addr) against address set encoded in \a list.
- *
- * \retval 1 if \a addr matches
- * \retval 0 otherwise
- */
-int
-cfs_ip_addr_match(__u32 addr, struct list_head *list)
-{
-       struct cfs_expr_list *el;
-       int i = 0;
-
-       list_for_each_entry_reverse(el, list, el_link) {
-               if (!cfs_expr_list_match(addr & 0xff, el))
-                       return 0;
-               addr >>= 8;
-               i++;
-       }
-
-       return i == 4;
-}
-EXPORT_SYMBOL(cfs_ip_addr_match);
index e9149ec..b150a0d 100644 (file)
@@ -155,6 +155,44 @@ libcfs_ip_str2addr(const char *str, int nob, __u32 *addr)
        return 0;
 }
 
+int
+cfs_ip_addr_parse(char *str, int len, struct list_head *list)
+{
+       struct cfs_expr_list *el;
+       struct cfs_lstr src;
+       int rc;
+       int i;
+
+       src.ls_str = str;
+       src.ls_len = len;
+       i = 0;
+
+       while (src.ls_str != NULL) {
+               struct cfs_lstr res;
+
+               if (!cfs_gettok(&src, '.', &res)) {
+                       rc = -EINVAL;
+                       goto out;
+               }
+
+               rc = cfs_expr_list_parse(res.ls_str, res.ls_len, 0, 255, &el);
+               if (rc != 0)
+                       goto out;
+
+               list_add_tail(&el->el_link, list);
+               i++;
+       }
+
+       if (i == 4)
+               return 0;
+
+       rc = -EINVAL;
+out:
+       cfs_expr_list_free_list(list);
+
+       return rc;
+}
+
 static int
 libcfs_ip_addr_range_print(char *buffer, int count, struct list_head *list)
 {
@@ -170,6 +208,28 @@ libcfs_ip_addr_range_print(char *buffer, int count, struct list_head *list)
        return i;
 }
 
+/**
+ * Matches address (\a addr) against address set encoded in \a list.
+ *
+ * \retval 1 if \a addr matches
+ * \retval 0 otherwise
+ */
+int
+cfs_ip_addr_match(__u32 addr, struct list_head *list)
+{
+       struct cfs_expr_list *el;
+       int i = 0;
+
+       list_for_each_entry_reverse(el, list, el_link) {
+               if (!cfs_expr_list_match(addr & 0xff, el))
+                       return 0;
+               addr >>= 8;
+               i++;
+       }
+
+       return i == 4;
+}
+
 static void
 libcfs_decnum_addr2str(__u32 addr, char *str, size_t size)
 {
index f4c6f45..e5ef108 100644 (file)
@@ -431,63 +431,3 @@ cfs_expr_list_free_list(struct list_head *list)
                cfs_expr_list_free(el);
        }
 }
-
-int
-cfs_ip_addr_parse(char *str, int len, struct list_head *list)
-{
-       struct cfs_expr_list    *el;
-       struct cfs_lstr         src;
-       int                     rc;
-       int                     i;
-
-       src.ls_str = str;
-       src.ls_len = len;
-       i = 0;
-
-       while (src.ls_str != NULL) {
-               struct cfs_lstr res;
-
-               if (!cfs_gettok(&src, '.', &res)) {
-                       rc = -EINVAL;
-                       goto out;
-               }
-
-               rc = cfs_expr_list_parse(res.ls_str, res.ls_len, 0, 255, &el);
-               if (rc != 0)
-                       goto out;
-
-               list_add_tail(&el->el_link, list);
-               i++;
-       }
-
-       if (i == 4)
-               return 0;
-
-       rc = -EINVAL;
- out:
-       cfs_expr_list_free_list(list);
-
-       return rc;
-}
-
-/**
- * Matches address (\a addr) against address set encoded in \a list.
- *
- * \retval 1 if \a addr matches
- * \retval 0 otherwise
- */
-int
-cfs_ip_addr_match(__u32 addr, struct list_head *list)
-{
-       struct cfs_expr_list *el;
-       int i = 0;
-
-       list_for_each_entry_reverse(el, list, el_link) {
-               if (!cfs_expr_list_match(addr & 0xff, el))
-                       return 0;
-               addr >>= 8;
-               i++;
-       }
-
-       return i == 4;
-}
index a0ed3e6..efdb5c9 100644 (file)
@@ -87,6 +87,9 @@ void cfs_free_nidlist(struct list_head *list);
 int cfs_parse_nidlist(char *str, int len, struct list_head *list);
 int cfs_print_nidlist(char *buffer, int count, struct list_head *list);
 int cfs_match_nid(lnet_nid_t nid, struct list_head *list);
+
+int cfs_ip_addr_parse(char *str, int len, struct list_head *list);
+int cfs_ip_addr_match(__u32 addr, struct list_head *list);
 bool cfs_nidrange_is_contiguous(struct list_head *nidlist);
 void cfs_nidrange_find_min_max(struct list_head *nidlist, char *min_nid,
                               char *max_nid, size_t nidstr_length);
index 103ef2c..916a6b6 100644 (file)
@@ -123,6 +123,45 @@ libcfs_ip_str2addr(const char *str, int nob, __u32 *addr)
        return 0;
 }
 
+/* Used by lnet/config.c so it can't be static */
+int
+cfs_ip_addr_parse(char *str, int len, struct list_head *list)
+{
+       struct cfs_expr_list *el;
+       struct cfs_lstr src;
+       int rc;
+       int i;
+
+       src.ls_str = str;
+       src.ls_len = len;
+       i = 0;
+
+       while (src.ls_str != NULL) {
+               struct cfs_lstr res;
+
+               if (!cfs_gettok(&src, '.', &res)) {
+                       rc = -EINVAL;
+                       goto out;
+               }
+
+               rc = cfs_expr_list_parse(res.ls_str, res.ls_len, 0, 255, &el);
+               if (rc != 0)
+                       goto out;
+
+               list_add_tail(&el->el_link, list);
+               i++;
+       }
+
+       if (i == 4)
+               return 0;
+
+       rc = -EINVAL;
+out:
+       cfs_expr_list_free_list(list);
+
+       return rc;
+}
+
 static int
 libcfs_ip_addr_range_print(char *buffer, int count, struct list_head *list)
 {
@@ -139,6 +178,28 @@ libcfs_ip_addr_range_print(char *buffer, int count, struct list_head *list)
 }
 
 /**
+ * Matches address (\a addr) against address set encoded in \a list.
+ *
+ * \retval 1 if \a addr matches
+ * \retval 0 otherwise
+ */
+int
+cfs_ip_addr_match(__u32 addr, struct list_head *list)
+{
+       struct cfs_expr_list *el;
+       int i = 0;
+
+       list_for_each_entry_reverse(el, list, el_link) {
+               if (!cfs_expr_list_match(addr & 0xff, el))
+                       return 0;
+               addr >>= 8;
+               i++;
+       }
+
+       return i == 4;
+}
+
+/**
  * Print the network part of the nidrange \a nr into the specified \a buffer.
  *
  * \retval number of characters written