Whamcloud - gitweb
LU-15983 lnet: Define KFILND network type
[fs/lustre-release.git] / lnet / lnet / nidstrings.c
index eb341d4..20901ed 100644 (file)
@@ -277,11 +277,11 @@ failed:
 static void
 free_addrranges(struct list_head *list)
 {
-       while (!list_empty(list)) {
-               struct addrrange *ar;
-
-               ar = list_entry(list->next, struct addrrange, ar_link);
+       struct addrrange *ar;
 
+       while ((ar = list_first_entry_or_null(list,
+                                             struct addrrange,
+                                             ar_link)) != NULL) {
                cfs_expr_list_free_list(&ar->ar_numaddr_ranges);
                list_del(&ar->ar_link);
                CFS_FREE_PTR(ar);
@@ -702,7 +702,7 @@ libcfs_num_match(__u32 addr, struct list_head *numaddr)
        struct cfs_expr_list *el;
 
        LASSERT(!list_empty(numaddr));
-       el = list_entry(numaddr->next, struct cfs_expr_list, el_link);
+       el = list_first_entry(numaddr, struct cfs_expr_list, el_link);
 
        return cfs_expr_list_match(addr, el);
 }
@@ -764,6 +764,16 @@ static struct netstrfns libcfs_netstrfns[] = {
          .nf_print_addrlist    = libcfs_num_addr_range_print,
          .nf_match_addr        = libcfs_num_match
        },
+       {
+         .nf_type              = KFILND,
+         .nf_name              = "kfi",
+         .nf_modname           = "kkfilnd",
+         .nf_addr2str          = libcfs_decnum_addr2str,
+         .nf_str2addr          = libcfs_num_str2addr,
+         .nf_parse_addrlist    = libcfs_num_parse,
+         .nf_print_addrlist    = libcfs_num_addr_range_print,
+         .nf_match_addr        = libcfs_num_match
+       },
 };
 
 static const size_t libcfs_nnetstrfns = ARRAY_SIZE(libcfs_netstrfns);
@@ -973,8 +983,8 @@ EXPORT_SYMBOL(libcfs_nid2str_r);
 char *
 libcfs_nidstr_r(const struct lnet_nid *nid, char *buf, size_t buf_size)
 {
-       __u32 nnum = be16_to_cpu(nid->nid_num);
-       __u32 lnd  = nid->nid_type;
+       __u32 nnum;
+       __u32 lnd;
        struct netstrfns *nf;
 
        if (LNET_NID_IS_ANY(nid)) {
@@ -983,6 +993,8 @@ libcfs_nidstr_r(const struct lnet_nid *nid, char *buf, size_t buf_size)
                return buf;
        }
 
+       nnum = be16_to_cpu(nid->nid_num);
+       lnd = nid->nid_type;
        nf = libcfs_lnd2netstrfns(lnd);
        if (nf) {
                size_t addr_len;