Whamcloud - gitweb
LU-10391 lnet: extend prefered nids in struct lnet_peer_ni 96/43596/9
authorMr NeilBrown <neilb@suse.de>
Sat, 11 Sep 2021 14:16:49 +0000 (10:16 -0400)
committerOleg Drokin <green@whamcloud.com>
Sat, 20 Nov 2021 06:24:20 +0000 (06:24 +0000)
union lpni_pref in struct lnet_peer_ni how has 'struct lnet_nid'
rather than lnet_nid_t.

Also, lnet_peer_ni_set_no_mr_pref_nid() allows the pref nid to be NULL
and is a no-op in that case.

Rather then updating the user-space cfs_match_nid_net() in
libcfs/utils/nidstrings.c, remove it as it is unused.

Test-Parameters: trivial
Test-Parameters: serverversion=2.12 serverdistro=el7.9 testlist=runtests
Test-Parameters: clientversion=2.12 testlist=runtests
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I9a2453185aa5d708e6939dadc1e954c9dbd24efc
Reviewed-on: https://review.whamcloud.com/43596
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Amir Shehata <ashehata@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/libcfs/util/nidstrings.c
lnet/include/lnet/lib-lnet.h
lnet/include/lnet/lib-types.h
lnet/include/uapi/linux/lnet/nidstr.h
lnet/lnet/api-ni.c
lnet/lnet/lib-move.c
lnet/lnet/nidstrings.c
lnet/lnet/peer.c
lnet/lnet/udsp.c

index 94d4088..bf3bc05 100644 (file)
@@ -1229,19 +1229,6 @@ int cfs_match_nid(lnet_nid_t nid, struct list_head *nidlist)
        return 0;
 }
 
        return 0;
 }
 
-static struct netstrfns *
-type2net_info(__u32 net_type)
-{
-       int i;
-
-       for (i = 0; i < libcfs_nnetstrfns; i++) {
-               if (libcfs_netstrfns[i].nf_type == net_type)
-                       return &libcfs_netstrfns[i];
-       }
-
-       return NULL;
-}
-
 int
 cfs_match_net(__u32 net_id, __u32 net_type, struct list_head *net_num_list)
 {
 int
 cfs_match_net(__u32 net_id, __u32 net_type, struct list_head *net_num_list)
 {
@@ -1270,30 +1257,6 @@ cfs_match_net(__u32 net_id, __u32 net_type, struct list_head *net_num_list)
        return 1;
 }
 
        return 1;
 }
 
-int
-cfs_match_nid_net(lnet_nid_t nid, __u32 net_type,
-                 struct list_head *net_num_list,
-                 struct list_head *addr)
-{
-       __u32 address;
-       struct netstrfns *fns;
-
-       if (!addr || !net_num_list)
-               return 0;
-
-       fns = type2net_info(LNET_NETTYP(LNET_NIDNET(nid)));
-       if (!fns || !net_num_list || !addr)
-               return 0;
-
-       address = LNET_NIDADDR(nid);
-
-       /* if either the address or net number don't match then no match */
-       if (!fns->nf_match_addr(address, addr) ||
-           !cfs_match_net(LNET_NIDNET(nid), net_type, net_num_list))
-               return 0;
-
-       return 1;
-}
 /**
  * Print the network part of the nidrange \a nr into the specified \a buffer.
  *
 /**
  * Print the network part of the nidrange \a nr into the specified \a buffer.
  *
index cc2f3e1..2c5b004 100644 (file)
@@ -526,6 +526,7 @@ extern int lnet_cpt_of_nid_locked(struct lnet_nid *nid, struct lnet_ni *ni);
 extern int lnet_cpt_of_nid(lnet_nid_t nid, struct lnet_ni *ni);
 extern int lnet_nid2cpt(struct lnet_nid *nid, struct lnet_ni *ni);
 extern struct lnet_ni *lnet_nid2ni_locked(lnet_nid_t nid, int cpt);
 extern int lnet_cpt_of_nid(lnet_nid_t nid, struct lnet_ni *ni);
 extern int lnet_nid2cpt(struct lnet_nid *nid, struct lnet_ni *ni);
 extern struct lnet_ni *lnet_nid2ni_locked(lnet_nid_t nid, int cpt);
+extern struct lnet_ni *lnet_nid_to_ni_locked(struct lnet_nid *nid, int cpt);
 extern struct lnet_ni *lnet_nid2ni_addref(lnet_nid_t nid);
 extern struct lnet_ni *lnet_net2ni_locked(__u32 net, int cpt);
 extern struct lnet_ni *lnet_net2ni_addref(__u32 net);
 extern struct lnet_ni *lnet_nid2ni_addref(lnet_nid_t nid);
 extern struct lnet_ni *lnet_net2ni_locked(__u32 net, int cpt);
 extern struct lnet_ni *lnet_net2ni_addref(__u32 net);
@@ -580,9 +581,11 @@ extern void lnet_peer_ni_set_healthv(lnet_nid_t nid, int value, bool all);
 extern void lnet_peer_ni_add_to_recoveryq_locked(struct lnet_peer_ni *lpni,
                                                 struct list_head *queue,
                                                 time64_t now);
 extern void lnet_peer_ni_add_to_recoveryq_locked(struct lnet_peer_ni *lpni,
                                                 struct list_head *queue,
                                                 time64_t now);
-extern int lnet_peer_add_pref_nid(struct lnet_peer_ni *lpni, lnet_nid_t nid);
+extern int lnet_peer_add_pref_nid(struct lnet_peer_ni *lpni,
+                                 struct lnet_nid *nid);
 extern void lnet_peer_clr_pref_nids(struct lnet_peer_ni *lpni);
 extern void lnet_peer_clr_pref_nids(struct lnet_peer_ni *lpni);
-extern int lnet_peer_del_pref_nid(struct lnet_peer_ni *lpni, lnet_nid_t nid);
+extern int lnet_peer_del_pref_nid(struct lnet_peer_ni *lpni,
+                                 struct lnet_nid *nid);
 void lnet_peer_ni_set_selection_priority(struct lnet_peer_ni *lpni,
                                         __u32 priority);
 extern void lnet_ni_add_to_recoveryq_locked(struct lnet_ni *ni,
 void lnet_peer_ni_set_selection_priority(struct lnet_peer_ni *lpni,
                                         __u32 priority);
 extern void lnet_ni_add_to_recoveryq_locked(struct lnet_ni *ni,
@@ -607,7 +610,7 @@ int lnet_dyn_del_ni(struct lnet_ioctl_config_ni *conf);
 int lnet_clear_lazy_portal(struct lnet_ni *ni, int portal, char *reason);
 struct lnet_net *lnet_get_net_locked(__u32 net_id);
 void lnet_net_clr_pref_rtrs(struct lnet_net *net);
 int lnet_clear_lazy_portal(struct lnet_ni *ni, int portal, char *reason);
 struct lnet_net *lnet_get_net_locked(__u32 net_id);
 void lnet_net_clr_pref_rtrs(struct lnet_net *net);
-int lnet_net_add_pref_rtr(struct lnet_net *net, lnet_nid_t gw_nid);
+int lnet_net_add_pref_rtr(struct lnet_net *net, struct lnet_nid *gw_nid);
 
 int lnet_islocalnid4(lnet_nid_t nid);
 int lnet_islocalnid(struct lnet_nid *nid);
 
 int lnet_islocalnid4(lnet_nid_t nid);
 int lnet_islocalnid(struct lnet_nid *nid);
@@ -907,6 +910,9 @@ struct lnet_peer_ni *lnet_get_next_peer_ni_locked(struct lnet_peer *peer,
                                                  struct lnet_peer_ni *prev);
 struct lnet_peer_ni *lnet_nid2peerni_locked(lnet_nid_t nid, lnet_nid_t pref,
                                        int cpt);
                                                  struct lnet_peer_ni *prev);
 struct lnet_peer_ni *lnet_nid2peerni_locked(lnet_nid_t nid, lnet_nid_t pref,
                                        int cpt);
+struct lnet_peer_ni *lnet_peerni_by_nid_locked(struct lnet_nid *nid,
+                                              struct lnet_nid *pref,
+                                              int cpt);
 struct lnet_peer_ni *lnet_nid2peerni_ex(struct lnet_nid *nid, int cpt);
 struct lnet_peer_ni *lnet_peer_get_ni_locked(struct lnet_peer *lp,
                                             lnet_nid_t nid);
 struct lnet_peer_ni *lnet_nid2peerni_ex(struct lnet_nid *nid, int cpt);
 struct lnet_peer_ni *lnet_peer_get_ni_locked(struct lnet_peer *lp,
                                             lnet_nid_t nid);
@@ -928,13 +934,16 @@ int lnet_peer_tables_create(void);
 void lnet_debug_peer(lnet_nid_t nid);
 struct lnet_peer_net *lnet_peer_get_net_locked(struct lnet_peer *peer,
                                               __u32 net_id);
 void lnet_debug_peer(lnet_nid_t nid);
 struct lnet_peer_net *lnet_peer_get_net_locked(struct lnet_peer *peer,
                                               __u32 net_id);
-bool lnet_peer_is_pref_nid_locked(struct lnet_peer_ni *lpni, lnet_nid_t nid);
-int lnet_peer_add_pref_nid(struct lnet_peer_ni *lpni, lnet_nid_t nid);
+bool lnet_peer_is_pref_nid_locked(struct lnet_peer_ni *lpni,
+                                 struct lnet_nid *nid);
+int lnet_peer_add_pref_nid(struct lnet_peer_ni *lpni, struct lnet_nid *nid);
 void lnet_peer_clr_pref_nids(struct lnet_peer_ni *lpni);
 void lnet_peer_clr_pref_nids(struct lnet_peer_ni *lpni);
-bool lnet_peer_is_pref_rtr_locked(struct lnet_peer_ni *lpni, lnet_nid_t gw_nid);
+bool lnet_peer_is_pref_rtr_locked(struct lnet_peer_ni *lpni,
+                                 struct lnet_nid *gw_nid);
 void lnet_peer_clr_pref_rtrs(struct lnet_peer_ni *lpni);
 void lnet_peer_clr_pref_rtrs(struct lnet_peer_ni *lpni);
-int lnet_peer_add_pref_rtr(struct lnet_peer_ni *lpni, lnet_nid_t nid);
-int lnet_peer_ni_set_non_mr_pref_nid(struct lnet_peer_ni *lpni, lnet_nid_t nid);
+int lnet_peer_add_pref_rtr(struct lnet_peer_ni *lpni, struct lnet_nid *nid);
+int lnet_peer_ni_set_non_mr_pref_nid(struct lnet_peer_ni *lpni,
+                                    struct lnet_nid *nid);
 int lnet_add_peer_ni(lnet_nid_t key_nid, lnet_nid_t nid, bool mr, bool temp);
 int lnet_del_peer_ni(lnet_nid_t key_nid, lnet_nid_t nid);
 int lnet_get_peer_info(struct lnet_ioctl_peer_cfg *cfg, void __user *bulk);
 int lnet_add_peer_ni(lnet_nid_t key_nid, lnet_nid_t nid, bool mr, bool temp);
 int lnet_del_peer_ni(lnet_nid_t key_nid, lnet_nid_t nid);
 int lnet_get_peer_info(struct lnet_ioctl_peer_cfg *cfg, void __user *bulk);
index d375c3e..9150b74 100644 (file)
@@ -559,7 +559,7 @@ struct lnet_ping_buffer {
 
 struct lnet_nid_list {
        struct list_head nl_list;
 
 struct lnet_nid_list {
        struct list_head nl_list;
-       lnet_nid_t nl_nid;
+       struct lnet_nid nl_nid;
 };
 
 struct lnet_peer_ni {
 };
 
 struct lnet_peer_ni {
@@ -626,7 +626,7 @@ struct lnet_peer_ni {
        time64_t                lpni_last_alive;
        /* preferred local nids: if only one, use lpni_pref.nid */
        union lpni_pref {
        time64_t                lpni_last_alive;
        /* preferred local nids: if only one, use lpni_pref.nid */
        union lpni_pref {
-               lnet_nid_t      nid;
+               struct lnet_nid nid;
                struct list_head nids;
        } lpni_pref;
        /* list of router nids preferred for this peer NI */
                struct list_head nids;
        } lpni_pref;
        /* list of router nids preferred for this peer NI */
index 57c1c33..d7e82a8 100644 (file)
@@ -102,7 +102,8 @@ 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_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_match_nid_net(lnet_nid_t nid, __u32 net, struct list_head *net_num_list,
+int cfs_match_nid_net(struct lnet_nid *nid, __u32 net,
+                     struct list_head *net_num_list,
                      struct list_head *addr);
 int cfs_match_net(__u32 net_id, __u32 net_type,
                  struct list_head *net_num_list);
                      struct list_head *addr);
 int cfs_match_net(__u32 net_id, __u32 net_type,
                  struct list_head *net_num_list);
index db521ee..f86a31f 100644 (file)
@@ -1462,7 +1462,7 @@ lnet_net_clr_pref_rtrs(struct lnet_net *net)
 
 int
 lnet_net_add_pref_rtr(struct lnet_net *net,
 
 int
 lnet_net_add_pref_rtr(struct lnet_net *net,
-                     lnet_nid_t gw_nid)
+                     struct lnet_nid *gw_nid)
 __must_hold(&the_lnet.ln_api_mutex)
 {
        struct lnet_nid_list *ne;
 __must_hold(&the_lnet.ln_api_mutex)
 {
        struct lnet_nid_list *ne;
@@ -1473,7 +1473,7 @@ __must_hold(&the_lnet.ln_api_mutex)
         * lock.
         */
        list_for_each_entry(ne, &net->net_rtr_pref_nids, nl_list) {
         * lock.
         */
        list_for_each_entry(ne, &net->net_rtr_pref_nids, nl_list) {
-               if (ne->nl_nid == gw_nid)
+               if (nid_same(&ne->nl_nid, gw_nid))
                        return -EEXIST;
        }
 
                        return -EEXIST;
        }
 
@@ -1481,7 +1481,7 @@ __must_hold(&the_lnet.ln_api_mutex)
        if (!ne)
                return -ENOMEM;
 
        if (!ne)
                return -ENOMEM;
 
-       ne->nl_nid = gw_nid;
+       ne->nl_nid = *gw_nid;
 
        /* Lock the cpt to protect against addition and checks in the
         * selection algorithm
 
        /* Lock the cpt to protect against addition and checks in the
         * selection algorithm
@@ -1494,11 +1494,11 @@ __must_hold(&the_lnet.ln_api_mutex)
 }
 
 bool
 }
 
 bool
-lnet_net_is_pref_rtr_locked(struct lnet_net *net, lnet_nid_t rtr_nid)
+lnet_net_is_pref_rtr_locked(struct lnet_net *net, struct lnet_nid *rtr_nid)
 {
        struct lnet_nid_list *ne;
 
 {
        struct lnet_nid_list *ne;
 
-       CDEBUG(D_NET, "%s: rtr pref emtpy: %d\n",
+       CDEBUG(D_NET, "%s: rtr pref empty: %d\n",
               libcfs_net2str(net->net_id),
               list_empty(&net->net_rtr_pref_nids));
 
               libcfs_net2str(net->net_id),
               list_empty(&net->net_rtr_pref_nids));
 
@@ -1507,9 +1507,9 @@ lnet_net_is_pref_rtr_locked(struct lnet_net *net, lnet_nid_t rtr_nid)
 
        list_for_each_entry(ne, &net->net_rtr_pref_nids, nl_list) {
                CDEBUG(D_NET, "Comparing pref %s with gw %s\n",
 
        list_for_each_entry(ne, &net->net_rtr_pref_nids, nl_list) {
                CDEBUG(D_NET, "Comparing pref %s with gw %s\n",
-                      libcfs_nid2str(ne->nl_nid),
-                      libcfs_nid2str(rtr_nid));
-               if (rtr_nid == ne->nl_nid)
+                      libcfs_nidstr(&ne->nl_nid),
+                      libcfs_nidstr(rtr_nid));
+               if (nid_same(rtr_nid, &ne->nl_nid))
                        return true;
        }
 
                        return true;
        }
 
index cdd84d6..0b3c922 100644 (file)
@@ -1326,9 +1326,8 @@ lnet_select_peer_ni(struct lnet_ni *best_ni, lnet_nid_t dst_nid,
                 * preferred, then let's use it
                 */
                if (best_ni) {
                 * preferred, then let's use it
                 */
                if (best_ni) {
-                       /* FIXME need to handle large-addr nid */
                        lpni_is_preferred = lnet_peer_is_pref_nid_locked(
                        lpni_is_preferred = lnet_peer_is_pref_nid_locked(
-                               lpni, lnet_nid_to_nid4(&best_ni->ni_nid));
+                               lpni, &best_ni->ni_nid);
                        CDEBUG(D_NET, "%s lpni_is_preferred = %d\n",
                               libcfs_nidstr(&best_ni->ni_nid),
                               lpni_is_preferred);
                        CDEBUG(D_NET, "%s lpni_is_preferred = %d\n",
                               libcfs_nidstr(&best_ni->ni_nid),
                               lpni_is_preferred);
@@ -1506,7 +1505,7 @@ lnet_find_route_locked(struct lnet_remotenet *rnet, __u32 src_net,
        struct lnet_route *route;
        int rc;
        bool best_rte_is_preferred = false;
        struct lnet_route *route;
        int rc;
        bool best_rte_is_preferred = false;
-       lnet_nid_t gw_pnid;
+       struct lnet_nid *gw_pnid;
 
        CDEBUG(D_NET, "Looking up a route to %s, from %s\n",
               libcfs_net2str(rnet->lrn_net), libcfs_net2str(src_net));
 
        CDEBUG(D_NET, "Looking up a route to %s, from %s\n",
               libcfs_net2str(rnet->lrn_net), libcfs_net2str(src_net));
@@ -1515,7 +1514,7 @@ lnet_find_route_locked(struct lnet_remotenet *rnet, __u32 src_net,
        list_for_each_entry(route, &rnet->lrn_routes, lr_list) {
                if (!lnet_is_route_alive(route))
                        continue;
        list_for_each_entry(route, &rnet->lrn_routes, lr_list) {
                if (!lnet_is_route_alive(route))
                        continue;
-               gw_pnid = lnet_nid_to_nid4(&route->lr_gateway->lp_primary_nid);
+               gw_pnid = &route->lr_gateway->lp_primary_nid;
 
                /* no protection on below fields, but it's harmless */
                if (last_route && (last_route->lr_seq - route->lr_seq < 0))
 
                /* no protection on below fields, but it's harmless */
                if (last_route && (last_route->lr_seq - route->lr_seq < 0))
@@ -1539,7 +1538,7 @@ lnet_find_route_locked(struct lnet_remotenet *rnet, __u32 src_net,
                        if (!lpni) {
                                CDEBUG(D_NET,
                                       "Gateway %s does not have a peer NI on net %s\n",
                        if (!lpni) {
                                CDEBUG(D_NET,
                                       "Gateway %s does not have a peer NI on net %s\n",
-                                      libcfs_nid2str(gw_pnid),
+                                      libcfs_nidstr(gw_pnid),
                                       libcfs_net2str(src_net));
                                continue;
                        }
                                       libcfs_net2str(src_net));
                                continue;
                        }
@@ -1555,7 +1554,7 @@ lnet_find_route_locked(struct lnet_remotenet *rnet, __u32 src_net,
                        best_gw_ni = lpni;
                        best_rte_is_preferred = true;
                        CDEBUG(D_NET, "preferred gw = %s\n",
                        best_gw_ni = lpni;
                        best_rte_is_preferred = true;
                        CDEBUG(D_NET, "preferred gw = %s\n",
-                              libcfs_nid2str(gw_pnid));
+                              libcfs_nidstr(gw_pnid));
                        continue;
                } else if ((!rc) && best_rte_is_preferred)
                        /* The best route we found so far is in the preferred
                        continue;
                } else if ((!rc) && best_rte_is_preferred)
                        /* The best route we found so far is in the preferred
@@ -1583,7 +1582,7 @@ lnet_find_route_locked(struct lnet_remotenet *rnet, __u32 src_net,
                if (!lpni) {
                        CDEBUG(D_NET,
                               "Gateway %s does not have a peer NI on net %s\n",
                if (!lpni) {
                        CDEBUG(D_NET,
                               "Gateway %s does not have a peer NI on net %s\n",
-                              libcfs_nid2str(gw_pnid),
+                              libcfs_nidstr(gw_pnid),
                               libcfs_net2str(src_net));
                        continue;
                }
                               libcfs_net2str(src_net));
                        continue;
                }
@@ -1985,8 +1984,7 @@ lnet_set_non_mr_pref_nid(struct lnet_peer_ni *lpni, struct lnet_ni *lni,
                CDEBUG(D_NET, "Setting preferred local NID %s on NMR peer %s\n",
                       libcfs_nidstr(&lni->ni_nid),
                       libcfs_nidstr(&lpni->lpni_nid));
                CDEBUG(D_NET, "Setting preferred local NID %s on NMR peer %s\n",
                       libcfs_nidstr(&lni->ni_nid),
                       libcfs_nidstr(&lpni->lpni_nid));
-               lnet_peer_ni_set_non_mr_pref_nid(
-                       lpni, lnet_nid_to_nid4(&lni->ni_nid));
+               lnet_peer_ni_set_non_mr_pref_nid(lpni, &lni->ni_nid);
        }
 }
 
        }
 }
 
@@ -2524,7 +2522,8 @@ lnet_find_existing_preferred_best_ni(struct lnet_peer_ni *lpni, int cpt)
                if (lpni_entry->lpni_pref_nnids == 0)
                        continue;
                LASSERT(lpni_entry->lpni_pref_nnids == 1);
                if (lpni_entry->lpni_pref_nnids == 0)
                        continue;
                LASSERT(lpni_entry->lpni_pref_nnids == 1);
-               best_ni = lnet_nid2ni_locked(lpni_entry->lpni_pref.nid, cpt);
+               best_ni = lnet_nid_to_ni_locked(&lpni_entry->lpni_pref.nid,
+                                               cpt);
                break;
        }
 
                break;
        }
 
@@ -4475,7 +4474,7 @@ lnet_msgtyp2str (int type)
 }
 
 int
 }
 
 int
-lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid,
+lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4,
           void *private, int rdma_req)
 {
        struct lnet_peer_ni *lpni;
           void *private, int rdma_req)
 {
        struct lnet_peer_ni *lpni;
@@ -4484,6 +4483,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid,
        lnet_pid_t dest_pid;
        lnet_nid_t dest_nid;
        lnet_nid_t src_nid;
        lnet_pid_t dest_pid;
        lnet_nid_t dest_nid;
        lnet_nid_t src_nid;
+       struct lnet_nid from_nid;
        bool push = false;
        int for_me;
        __u32 type;
        bool push = false;
        int for_me;
        __u32 type;
@@ -4492,6 +4492,8 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid,
 
        LASSERT (!in_interrupt ());
 
 
        LASSERT (!in_interrupt ());
 
+       lnet_nid4_to_nid(from_nid4, &from_nid);
+
        type = le32_to_cpu(hdr->type);
        src_nid = le64_to_cpu(hdr->src_nid);
        dest_nid = le64_to_cpu(hdr->dest_nid);
        type = le32_to_cpu(hdr->type);
        src_nid = le64_to_cpu(hdr->src_nid);
        dest_nid = le64_to_cpu(hdr->dest_nid);
@@ -4500,7 +4502,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid,
 
        /* FIXME handle large-addr nids */
        for_me = (lnet_nid_to_nid4(&ni->ni_nid) == dest_nid);
 
        /* FIXME handle large-addr nids */
        for_me = (lnet_nid_to_nid4(&ni->ni_nid) == dest_nid);
-       cpt = lnet_cpt_of_nid(from_nid, ni);
+       cpt = lnet_cpt_of_nid(from_nid4, ni);
 
        CDEBUG(D_NET, "TRACE: %s(%s) <- %s : %s - %s\n",
                libcfs_nid2str(dest_nid),
 
        CDEBUG(D_NET, "TRACE: %s(%s) <- %s : %s - %s\n",
                libcfs_nid2str(dest_nid),
@@ -4514,7 +4516,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid,
        case LNET_MSG_GET:
                if (payload_length > 0) {
                        CERROR("%s, src %s: bad %s payload %d (0 expected)\n",
        case LNET_MSG_GET:
                if (payload_length > 0) {
                        CERROR("%s, src %s: bad %s payload %d (0 expected)\n",
-                              libcfs_nid2str(from_nid),
+                              libcfs_nid2str(from_nid4),
                               libcfs_nid2str(src_nid),
                               lnet_msgtyp2str(type), payload_length);
                        return -EPROTO;
                               libcfs_nid2str(src_nid),
                               lnet_msgtyp2str(type), payload_length);
                        return -EPROTO;
@@ -4527,7 +4529,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid,
                    (__u32)(for_me ? LNET_MAX_PAYLOAD : LNET_MTU)) {
                        CERROR("%s, src %s: bad %s payload %d "
                               "(%d max expected)\n",
                    (__u32)(for_me ? LNET_MAX_PAYLOAD : LNET_MTU)) {
                        CERROR("%s, src %s: bad %s payload %d "
                               "(%d max expected)\n",
-                              libcfs_nid2str(from_nid),
+                              libcfs_nid2str(from_nid4),
                               libcfs_nid2str(src_nid),
                               lnet_msgtyp2str(type),
                               payload_length,
                               libcfs_nid2str(src_nid),
                               lnet_msgtyp2str(type),
                               payload_length,
@@ -4538,7 +4540,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid,
 
        default:
                CERROR("%s, src %s: Bad message type 0x%x\n",
 
        default:
                CERROR("%s, src %s: Bad message type 0x%x\n",
-                      libcfs_nid2str(from_nid),
+                      libcfs_nid2str(from_nid4),
                       libcfs_nid2str(src_nid), type);
                return -EPROTO;
        }
                       libcfs_nid2str(src_nid), type);
                return -EPROTO;
        }
@@ -4565,7 +4567,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid,
                        /* should have gone direct */
                        CERROR("%s, src %s: Bad dest nid %s "
                               "(should have been sent direct)\n",
                        /* should have gone direct */
                        CERROR("%s, src %s: Bad dest nid %s "
                               "(should have been sent direct)\n",
-                               libcfs_nid2str(from_nid),
+                               libcfs_nid2str(from_nid4),
                                libcfs_nid2str(src_nid),
                                libcfs_nid2str(dest_nid));
                        return -EPROTO;
                                libcfs_nid2str(src_nid),
                                libcfs_nid2str(dest_nid));
                        return -EPROTO;
@@ -4576,7 +4578,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid,
                         * this node's NID on its own network */
                        CERROR("%s, src %s: Bad dest nid %s "
                               "(it's my nid but on a different network)\n",
                         * this node's NID on its own network */
                        CERROR("%s, src %s: Bad dest nid %s "
                               "(it's my nid but on a different network)\n",
-                               libcfs_nid2str(from_nid),
+                               libcfs_nid2str(from_nid4),
                                libcfs_nid2str(src_nid),
                                libcfs_nid2str(dest_nid));
                        return -EPROTO;
                                libcfs_nid2str(src_nid),
                                libcfs_nid2str(dest_nid));
                        return -EPROTO;
@@ -4585,7 +4587,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid,
                if (rdma_req && type == LNET_MSG_GET) {
                        CERROR("%s, src %s: Bad optimized GET for %s "
                               "(final destination must be me)\n",
                if (rdma_req && type == LNET_MSG_GET) {
                        CERROR("%s, src %s: Bad optimized GET for %s "
                               "(final destination must be me)\n",
-                               libcfs_nid2str(from_nid),
+                               libcfs_nid2str(from_nid4),
                                libcfs_nid2str(src_nid),
                                libcfs_nid2str(dest_nid));
                        return -EPROTO;
                                libcfs_nid2str(src_nid),
                                libcfs_nid2str(dest_nid));
                        return -EPROTO;
@@ -4594,7 +4596,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid,
                if (!the_lnet.ln_routing) {
                        CERROR("%s, src %s: Dropping message for %s "
                               "(routing not enabled)\n",
                if (!the_lnet.ln_routing) {
                        CERROR("%s, src %s: Dropping message for %s "
                               "(routing not enabled)\n",
-                               libcfs_nid2str(from_nid),
+                               libcfs_nid2str(from_nid4),
                                libcfs_nid2str(src_nid),
                                libcfs_nid2str(dest_nid));
                        goto drop;
                                libcfs_nid2str(src_nid),
                                libcfs_nid2str(dest_nid));
                        goto drop;
@@ -4607,7 +4609,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid,
        if (!list_empty(&the_lnet.ln_test_peers) &&     /* normally we don't */
            fail_peer(src_nid, 0)) {                    /* shall we now? */
                CERROR("%s, src %s: Dropping %s to simulate failure\n",
        if (!list_empty(&the_lnet.ln_test_peers) &&     /* normally we don't */
            fail_peer(src_nid, 0)) {                    /* shall we now? */
                CERROR("%s, src %s: Dropping %s to simulate failure\n",
-                      libcfs_nid2str(from_nid), libcfs_nid2str(src_nid),
+                      libcfs_nid2str(from_nid4), libcfs_nid2str(src_nid),
                       lnet_msgtyp2str(type));
                goto drop;
        }
                       lnet_msgtyp2str(type));
                goto drop;
        }
@@ -4617,7 +4619,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid,
            lnet_drop_rule_match(hdr, lnet_nid_to_nid4(&ni->ni_nid), NULL)) {
                CDEBUG(D_NET,
                       "%s, src %s, dst %s: Dropping %s to simulate silent message loss\n",
            lnet_drop_rule_match(hdr, lnet_nid_to_nid4(&ni->ni_nid), NULL)) {
                CDEBUG(D_NET,
                       "%s, src %s, dst %s: Dropping %s to simulate silent message loss\n",
-                      libcfs_nid2str(from_nid), libcfs_nid2str(src_nid),
+                      libcfs_nid2str(from_nid4), libcfs_nid2str(src_nid),
                       libcfs_nid2str(dest_nid), lnet_msgtyp2str(type));
                goto drop;
        }
                       libcfs_nid2str(dest_nid), lnet_msgtyp2str(type));
                goto drop;
        }
@@ -4625,7 +4627,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid,
        msg = lnet_msg_alloc();
        if (msg == NULL) {
                CERROR("%s, src %s: Dropping %s (out of memory)\n",
        msg = lnet_msg_alloc();
        if (msg == NULL) {
                CERROR("%s, src %s: Dropping %s (out of memory)\n",
-                      libcfs_nid2str(from_nid), libcfs_nid2str(src_nid),
+                      libcfs_nid2str(from_nid4), libcfs_nid2str(src_nid),
                       lnet_msgtyp2str(type));
                goto drop;
        }
                       lnet_msgtyp2str(type));
                goto drop;
        }
@@ -4641,7 +4643,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid,
        msg->msg_offset = 0;
        msg->msg_hdr = *hdr;
        /* for building message event */
        msg->msg_offset = 0;
        msg->msg_hdr = *hdr;
        /* for building message event */
-       msg->msg_from = from_nid;
+       msg->msg_from = from_nid4;
        if (!for_me) {
                msg->msg_target.pid     = dest_pid;
                msg->msg_target.nid     = dest_nid;
        if (!for_me) {
                msg->msg_target.pid     = dest_pid;
                msg->msg_target.nid     = dest_nid;
@@ -4658,14 +4660,12 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid,
        }
 
        lnet_net_lock(cpt);
        }
 
        lnet_net_lock(cpt);
-       /* FIXME support large-addr nid */
-       lpni = lnet_nid2peerni_locked(from_nid, lnet_nid_to_nid4(&ni->ni_nid),
-                                     cpt);
+       lpni = lnet_peerni_by_nid_locked(&from_nid, &ni->ni_nid, cpt);
        if (IS_ERR(lpni)) {
                lnet_net_unlock(cpt);
                rc = PTR_ERR(lpni);
                CERROR("%s, src %s: Dropping %s (error %d looking up sender)\n",
        if (IS_ERR(lpni)) {
                lnet_net_unlock(cpt);
                rc = PTR_ERR(lpni);
                CERROR("%s, src %s: Dropping %s (error %d looking up sender)\n",
-                      libcfs_nid2str(from_nid), libcfs_nid2str(src_nid),
+                      libcfs_nid2str(from_nid4), libcfs_nid2str(src_nid),
                       lnet_msgtyp2str(type), rc);
                lnet_msg_free(msg);
                if (rc == -ESHUTDOWN)
                       lnet_msgtyp2str(type), rc);
                lnet_msg_free(msg);
                if (rc == -ESHUTDOWN)
@@ -4680,7 +4680,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid,
         */
        if (((lnet_drop_asym_route && for_me) ||
             !lpni->lpni_peer_net->lpn_peer->lp_alive) &&
         */
        if (((lnet_drop_asym_route && for_me) ||
             !lpni->lpni_peer_net->lpn_peer->lp_alive) &&
-           LNET_NIDNET(src_nid) != LNET_NIDNET(from_nid)) {
+           LNET_NIDNET(src_nid) != LNET_NIDNET(from_nid4)) {
                __u32 src_net_id = LNET_NIDNET(src_nid);
                struct lnet_peer *gw = lpni->lpni_peer_net->lpn_peer;
                struct lnet_route *route;
                __u32 src_net_id = LNET_NIDNET(src_nid);
                struct lnet_peer *gw = lpni->lpni_peer_net->lpn_peer;
                struct lnet_route *route;
@@ -4715,7 +4715,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid,
                         * => asymmetric routing detected but forbidden
                         */
                        CERROR("%s, src %s: Dropping asymmetrical route %s\n",
                         * => asymmetric routing detected but forbidden
                         */
                        CERROR("%s, src %s: Dropping asymmetrical route %s\n",
-                              libcfs_nid2str(from_nid),
+                              libcfs_nid2str(from_nid4),
                               libcfs_nid2str(src_nid), lnet_msgtyp2str(type));
                        lnet_msg_free(msg);
                        goto drop;
                               libcfs_nid2str(src_nid), lnet_msgtyp2str(type));
                        lnet_msg_free(msg);
                        goto drop;
index 84d6cec..eb341d4 100644 (file)
@@ -809,9 +809,9 @@ cfs_match_net(__u32 net_id, __u32 net_type, struct list_head *net_num_list)
 }
 
 int
 }
 
 int
-cfs_match_nid_net(lnet_nid_t nid, __u32 net_type,
-                 struct list_head *net_num_list,
-                 struct list_head *addr)
+cfs_match_nid_net(struct lnet_nid *nid, __u32 net_type,
+                  struct list_head *net_num_list,
+                  struct list_head *addr)
 {
        __u32 address;
        struct netstrfns *nf;
 {
        __u32 address;
        struct netstrfns *nf;
@@ -819,15 +819,16 @@ cfs_match_nid_net(lnet_nid_t nid, __u32 net_type,
        if (!addr || !net_num_list)
                return 0;
 
        if (!addr || !net_num_list)
                return 0;
 
-       nf = type2net_info(LNET_NETTYP(LNET_NIDNET(nid)));
+       nf = type2net_info(LNET_NETTYP(LNET_NID_NET(nid)));
        if (!nf || !net_num_list || !addr)
                return 0;
 
        if (!nf || !net_num_list || !addr)
                return 0;
 
-       address = LNET_NIDADDR(nid);
+       /* FIXME handle long-addr nid */
+       address = LNET_NIDADDR(lnet_nid_to_nid4(nid));
 
        /* if either the address or net number don't match then no match */
        if (!nf->nf_match_addr(address, addr) ||
 
        /* if either the address or net number don't match then no match */
        if (!nf->nf_match_addr(address, addr) ||
-           !cfs_match_net(LNET_NIDNET(nid), net_type, net_num_list))
+           !cfs_match_net(LNET_NID_NET(nid), net_type, net_num_list))
                return 0;
 
        return 1;
                return 0;
 
        return 1;
index 6e29a32..cdf8984 100644 (file)
@@ -997,7 +997,7 @@ lnet_push_update_to_peers(int force)
  */
 bool
 lnet_peer_is_pref_rtr_locked(struct lnet_peer_ni *lpni,
  */
 bool
 lnet_peer_is_pref_rtr_locked(struct lnet_peer_ni *lpni,
-                            lnet_nid_t gw_nid)
+                            struct lnet_nid *gw_nid)
 {
        struct lnet_nid_list *ne;
 
 {
        struct lnet_nid_list *ne;
 
@@ -1013,9 +1013,9 @@ lnet_peer_is_pref_rtr_locked(struct lnet_peer_ni *lpni,
         */
        list_for_each_entry(ne, &lpni->lpni_rtr_pref_nids, nl_list) {
                CDEBUG(D_NET, "Comparing pref %s with gw %s\n",
         */
        list_for_each_entry(ne, &lpni->lpni_rtr_pref_nids, nl_list) {
                CDEBUG(D_NET, "Comparing pref %s with gw %s\n",
-                      libcfs_nid2str(ne->nl_nid),
-                      libcfs_nid2str(gw_nid));
-               if (ne->nl_nid == gw_nid)
+                      libcfs_nidstr(&ne->nl_nid),
+                      libcfs_nidstr(gw_nid));
+               if (nid_same(&ne->nl_nid, gw_nid))
                        return true;
        }
 
                        return true;
        }
 
@@ -1044,7 +1044,7 @@ lnet_peer_clr_pref_rtrs(struct lnet_peer_ni *lpni)
 
 int
 lnet_peer_add_pref_rtr(struct lnet_peer_ni *lpni,
 
 int
 lnet_peer_add_pref_rtr(struct lnet_peer_ni *lpni,
-                      lnet_nid_t gw_nid)
+                      struct lnet_nid *gw_nid)
 {
        int cpt = lpni->lpni_cpt;
        struct lnet_nid_list *ne = NULL;
 {
        int cpt = lpni->lpni_cpt;
        struct lnet_nid_list *ne = NULL;
@@ -1057,7 +1057,7 @@ lnet_peer_add_pref_rtr(struct lnet_peer_ni *lpni,
        __must_hold(&the_lnet.ln_api_mutex);
 
        list_for_each_entry(ne, &lpni->lpni_rtr_pref_nids, nl_list) {
        __must_hold(&the_lnet.ln_api_mutex);
 
        list_for_each_entry(ne, &lpni->lpni_rtr_pref_nids, nl_list) {
-               if (ne->nl_nid == gw_nid)
+               if (nid_same(&ne->nl_nid, gw_nid))
                        return -EEXIST;
        }
 
                        return -EEXIST;
        }
 
@@ -1065,7 +1065,7 @@ lnet_peer_add_pref_rtr(struct lnet_peer_ni *lpni,
        if (!ne)
                return -ENOMEM;
 
        if (!ne)
                return -ENOMEM;
 
-       ne->nl_nid = gw_nid;
+       ne->nl_nid = *gw_nid;
 
        /* Lock the cpt to protect against addition and checks in the
         * selection algorithm
 
        /* Lock the cpt to protect against addition and checks in the
         * selection algorithm
@@ -1083,16 +1083,16 @@ lnet_peer_add_pref_rtr(struct lnet_peer_ni *lpni,
  * shared mmode.
  */
 bool
  * shared mmode.
  */
 bool
-lnet_peer_is_pref_nid_locked(struct lnet_peer_ni *lpni, lnet_nid_t nid)
+lnet_peer_is_pref_nid_locked(struct lnet_peer_ni *lpni, struct lnet_nid *nid)
 {
        struct lnet_nid_list *ne;
 
        if (lpni->lpni_pref_nnids == 0)
                return false;
        if (lpni->lpni_pref_nnids == 1)
 {
        struct lnet_nid_list *ne;
 
        if (lpni->lpni_pref_nnids == 0)
                return false;
        if (lpni->lpni_pref_nnids == 1)
-               return lpni->lpni_pref.nid == nid;
+               return nid_same(&lpni->lpni_pref.nid, nid);
        list_for_each_entry(ne, &lpni->lpni_pref.nids, nl_list) {
        list_for_each_entry(ne, &lpni->lpni_pref.nids, nl_list) {
-               if (ne->nl_nid == nid)
+               if (nid_same(&ne->nl_nid, nid))
                        return true;
        }
        return false;
                        return true;
        }
        return false;
@@ -1103,24 +1103,27 @@ lnet_peer_is_pref_nid_locked(struct lnet_peer_ni *lpni, lnet_nid_t nid)
  * defined. Only to be used for non-multi-rail peer_ni.
  */
 int
  * defined. Only to be used for non-multi-rail peer_ni.
  */
 int
-lnet_peer_ni_set_non_mr_pref_nid(struct lnet_peer_ni *lpni, lnet_nid_t nid)
+lnet_peer_ni_set_non_mr_pref_nid(struct lnet_peer_ni *lpni,
+                                 struct lnet_nid *nid)
 {
        int rc = 0;
 
 {
        int rc = 0;
 
+       if (!nid)
+               return -EINVAL;
        spin_lock(&lpni->lpni_lock);
        spin_lock(&lpni->lpni_lock);
-       if (nid == LNET_NID_ANY) {
+       if (LNET_NID_IS_ANY(nid)) {
                rc = -EINVAL;
        } else if (lpni->lpni_pref_nnids > 0) {
                rc = -EPERM;
        } else if (lpni->lpni_pref_nnids == 0) {
                rc = -EINVAL;
        } else if (lpni->lpni_pref_nnids > 0) {
                rc = -EPERM;
        } else if (lpni->lpni_pref_nnids == 0) {
-               lpni->lpni_pref.nid = nid;
+               lpni->lpni_pref.nid = *nid;
                lpni->lpni_pref_nnids = 1;
                lpni->lpni_state |= LNET_PEER_NI_NON_MR_PREF;
        }
        spin_unlock(&lpni->lpni_lock);
 
        CDEBUG(D_NET, "peer %s nid %s: %d\n",
                lpni->lpni_pref_nnids = 1;
                lpni->lpni_state |= LNET_PEER_NI_NON_MR_PREF;
        }
        spin_unlock(&lpni->lpni_lock);
 
        CDEBUG(D_NET, "peer %s nid %s: %d\n",
-              libcfs_nidstr(&lpni->lpni_nid), libcfs_nid2str(nid), rc);
+              libcfs_nidstr(&lpni->lpni_nid), libcfs_nidstr(nid), rc);
        return rc;
 }
 
        return rc;
 }
 
@@ -1168,20 +1171,21 @@ lnet_peer_clr_non_mr_pref_nids(struct lnet_peer *lp)
 }
 
 int
 }
 
 int
-lnet_peer_add_pref_nid(struct lnet_peer_ni *lpni, lnet_nid_t nid)
+lnet_peer_add_pref_nid(struct lnet_peer_ni *lpni, struct lnet_nid *nid)
 {
        struct lnet_peer *lp = lpni->lpni_peer_net->lpn_peer;
        struct lnet_nid_list *ne1 = NULL;
        struct lnet_nid_list *ne2 = NULL;
 {
        struct lnet_peer *lp = lpni->lpni_peer_net->lpn_peer;
        struct lnet_nid_list *ne1 = NULL;
        struct lnet_nid_list *ne2 = NULL;
-       lnet_nid_t tmp_nid = LNET_NID_ANY;
+       struct lnet_nid *tmp_nid = NULL;
        int rc = 0;
 
        int rc = 0;
 
-       if (nid == LNET_NID_ANY) {
+       if (LNET_NID_IS_ANY(nid)) {
                rc = -EINVAL;
                goto out;
        }
 
                rc = -EINVAL;
                goto out;
        }
 
-       if (lpni->lpni_pref_nnids == 1 && lpni->lpni_pref.nid == nid) {
+       if (lpni->lpni_pref_nnids == 1 &&
+           nid_same(&lpni->lpni_pref.nid, nid)) {
                rc = -EEXIST;
                goto out;
        }
                rc = -EEXIST;
                goto out;
        }
@@ -1198,12 +1202,12 @@ lnet_peer_add_pref_nid(struct lnet_peer_ni *lpni, lnet_nid_t nid)
                size_t alloc_size = sizeof(*ne1);
 
                if (lpni->lpni_pref_nnids == 1) {
                size_t alloc_size = sizeof(*ne1);
 
                if (lpni->lpni_pref_nnids == 1) {
-                       tmp_nid = lpni->lpni_pref.nid;
+                       tmp_nid = &lpni->lpni_pref.nid;
                        INIT_LIST_HEAD(&lpni->lpni_pref.nids);
                }
 
                list_for_each_entry(ne1, &lpni->lpni_pref.nids, nl_list) {
                        INIT_LIST_HEAD(&lpni->lpni_pref.nids);
                }
 
                list_for_each_entry(ne1, &lpni->lpni_pref.nids, nl_list) {
-                       if (ne1->nl_nid == nid) {
+                       if (nid_same(&ne1->nl_nid, nid)) {
                                rc = -EEXIST;
                                goto out;
                        }
                                rc = -EEXIST;
                                goto out;
                        }
@@ -1225,15 +1229,15 @@ lnet_peer_add_pref_nid(struct lnet_peer_ni *lpni, lnet_nid_t nid)
                                goto out;
                        }
                        INIT_LIST_HEAD(&ne2->nl_list);
                                goto out;
                        }
                        INIT_LIST_HEAD(&ne2->nl_list);
-                       ne2->nl_nid = tmp_nid;
+                       ne2->nl_nid = *tmp_nid;
                }
                }
-               ne1->nl_nid = nid;
+               ne1->nl_nid = *nid;
        }
 
        lnet_net_lock(LNET_LOCK_EX);
        spin_lock(&lpni->lpni_lock);
        if (lpni->lpni_pref_nnids == 0) {
        }
 
        lnet_net_lock(LNET_LOCK_EX);
        spin_lock(&lpni->lpni_lock);
        if (lpni->lpni_pref_nnids == 0) {
-               lpni->lpni_pref.nid = nid;
+               lpni->lpni_pref.nid = *nid;
        } else {
                if (ne2)
                        list_add_tail(&ne2->nl_list, &lpni->lpni_pref.nids);
        } else {
                if (ne2)
                        list_add_tail(&ne2->nl_list, &lpni->lpni_pref.nids);
@@ -1251,12 +1255,12 @@ out:
                spin_unlock(&lpni->lpni_lock);
        }
        CDEBUG(D_NET, "peer %s nid %s: %d\n",
                spin_unlock(&lpni->lpni_lock);
        }
        CDEBUG(D_NET, "peer %s nid %s: %d\n",
-              libcfs_nidstr(&lp->lp_primary_nid), libcfs_nid2str(nid), rc);
+              libcfs_nidstr(&lp->lp_primary_nid), libcfs_nidstr(nid), rc);
        return rc;
 }
 
 int
        return rc;
 }
 
 int
-lnet_peer_del_pref_nid(struct lnet_peer_ni *lpni, lnet_nid_t nid)
+lnet_peer_del_pref_nid(struct lnet_peer_ni *lpni, struct lnet_nid *nid)
 {
        struct lnet_peer *lp = lpni->lpni_peer_net->lpn_peer;
        struct lnet_nid_list *ne = NULL;
 {
        struct lnet_peer *lp = lpni->lpni_peer_net->lpn_peer;
        struct lnet_nid_list *ne = NULL;
@@ -1268,13 +1272,13 @@ lnet_peer_del_pref_nid(struct lnet_peer_ni *lpni, lnet_nid_t nid)
        }
 
        if (lpni->lpni_pref_nnids == 1) {
        }
 
        if (lpni->lpni_pref_nnids == 1) {
-               if (lpni->lpni_pref.nid != nid) {
+               if (!nid_same(&lpni->lpni_pref.nid, nid)) {
                        rc = -ENOENT;
                        goto out;
                }
        } else {
                list_for_each_entry(ne, &lpni->lpni_pref.nids, nl_list) {
                        rc = -ENOENT;
                        goto out;
                }
        } else {
                list_for_each_entry(ne, &lpni->lpni_pref.nids, nl_list) {
-                       if (ne->nl_nid == nid)
+                       if (nid_same(&ne->nl_nid, nid))
                                goto remove_nid_entry;
                }
                rc = -ENOENT;
                                goto remove_nid_entry;
                }
                rc = -ENOENT;
@@ -1286,7 +1290,7 @@ remove_nid_entry:
        lnet_net_lock(LNET_LOCK_EX);
        spin_lock(&lpni->lpni_lock);
        if (lpni->lpni_pref_nnids == 1)
        lnet_net_lock(LNET_LOCK_EX);
        spin_lock(&lpni->lpni_lock);
        if (lpni->lpni_pref_nnids == 1)
-               lpni->lpni_pref.nid = LNET_NID_ANY;
+               lpni->lpni_pref.nid = LNET_ANY_NID;
        else {
                list_del_init(&ne->nl_list);
                if (lpni->lpni_pref_nnids == 2) {
        else {
                list_del_init(&ne->nl_list);
                if (lpni->lpni_pref_nnids == 2) {
@@ -1310,7 +1314,7 @@ remove_nid_entry:
                LIBCFS_FREE(ne, sizeof(*ne));
 out:
        CDEBUG(D_NET, "peer %s nid %s: %d\n",
                LIBCFS_FREE(ne, sizeof(*ne));
 out:
        CDEBUG(D_NET, "peer %s nid %s: %d\n",
-              libcfs_nidstr(&lp->lp_primary_nid), libcfs_nid2str(nid), rc);
+              libcfs_nidstr(&lp->lp_primary_nid), libcfs_nidstr(nid), rc);
        return rc;
 }
 
        return rc;
 }
 
@@ -1325,7 +1329,7 @@ lnet_peer_clr_pref_nids(struct lnet_peer_ni *lpni)
 
        lnet_net_lock(LNET_LOCK_EX);
        if (lpni->lpni_pref_nnids == 1)
 
        lnet_net_lock(LNET_LOCK_EX);
        if (lpni->lpni_pref_nnids == 1)
-               lpni->lpni_pref.nid = LNET_NID_ANY;
+               lpni->lpni_pref.nid = LNET_ANY_NID;
        else if (lpni->lpni_pref_nnids > 1)
                list_splice_init(&lpni->lpni_pref.nids, &zombies);
        lpni->lpni_pref_nnids = 0;
        else if (lpni->lpni_pref_nnids > 1)
                list_splice_init(&lpni->lpni_pref.nids, &zombies);
        lpni->lpni_pref_nnids = 0;
@@ -1862,7 +1866,7 @@ out:
  * lpni creation initiated due to traffic either sending or receiving.
  */
 static int
  * lpni creation initiated due to traffic either sending or receiving.
  */
 static int
-lnet_peer_ni_traffic_add(struct lnet_nid *nid, lnet_nid_t pref)
+lnet_peer_ni_traffic_add(struct lnet_nid *nid, struct lnet_nid *pref)
 {
        struct lnet_peer *lp;
        struct lnet_peer_net *lpn;
 {
        struct lnet_peer *lp;
        struct lnet_peer_net *lpn;
@@ -1899,8 +1903,7 @@ lnet_peer_ni_traffic_add(struct lnet_nid *nid, lnet_nid_t pref)
        lpni = lnet_peer_ni_alloc(nid);
        if (!lpni)
                goto out_free_lpn;
        lpni = lnet_peer_ni_alloc(nid);
        if (!lpni)
                goto out_free_lpn;
-       if (pref != LNET_NID_ANY)
-               lnet_peer_ni_set_non_mr_pref_nid(lpni, pref);
+       lnet_peer_ni_set_non_mr_pref_nid(lpni, pref);
 
        return lnet_peer_attach_peer_ni(lp, lpn, lpni, flags);
 
 
        return lnet_peer_attach_peer_ni(lp, lpn, lpni, flags);
 
@@ -2097,7 +2100,7 @@ lnet_nid2peerni_ex(struct lnet_nid *nid, int cpt)
 
        lnet_net_unlock(cpt);
 
 
        lnet_net_unlock(cpt);
 
-       rc = lnet_peer_ni_traffic_add(nid, LNET_NID_ANY);
+       rc = lnet_peer_ni_traffic_add(nid, NULL);
        if (rc) {
                lpni = ERR_PTR(rc);
                goto out_net_relock;
        if (rc) {
                lpni = ERR_PTR(rc);
                goto out_net_relock;
@@ -2117,21 +2120,20 @@ out_net_relock:
  * hold on the peer_ni.
  */
 struct lnet_peer_ni *
  * hold on the peer_ni.
  */
 struct lnet_peer_ni *
-lnet_nid2peerni_locked(lnet_nid_t nid4, lnet_nid_t pref, int cpt)
+lnet_peerni_by_nid_locked(struct lnet_nid *nid,
+                       struct lnet_nid *pref, int cpt)
 {
        struct lnet_peer_ni *lpni = NULL;
 {
        struct lnet_peer_ni *lpni = NULL;
-       struct lnet_nid nid;
        int rc;
 
        if (the_lnet.ln_state != LNET_STATE_RUNNING)
                return ERR_PTR(-ESHUTDOWN);
 
        int rc;
 
        if (the_lnet.ln_state != LNET_STATE_RUNNING)
                return ERR_PTR(-ESHUTDOWN);
 
-       lnet_nid4_to_nid(nid4, &nid);
        /*
         * find if a peer_ni already exists.
         * If so then just return that.
         */
        /*
         * find if a peer_ni already exists.
         * If so then just return that.
         */
-       lpni = lnet_find_peer_ni_locked(nid4);
+       lpni = lnet_peer_ni_find_locked(nid);
        if (lpni)
                return lpni;
 
        if (lpni)
                return lpni;
 
@@ -2158,13 +2160,13 @@ lnet_nid2peerni_locked(lnet_nid_t nid4, lnet_nid_t pref, int cpt)
                goto out_mutex_unlock;
        }
 
                goto out_mutex_unlock;
        }
 
-       rc = lnet_peer_ni_traffic_add(&nid, pref);
+       rc = lnet_peer_ni_traffic_add(nid, pref);
        if (rc) {
                lpni = ERR_PTR(rc);
                goto out_mutex_unlock;
        }
 
        if (rc) {
                lpni = ERR_PTR(rc);
                goto out_mutex_unlock;
        }
 
-       lpni = lnet_find_peer_ni_locked(nid4);
+       lpni = lnet_peer_ni_find_locked(nid);
        LASSERT(lpni);
 
 out_mutex_unlock:
        LASSERT(lpni);
 
 out_mutex_unlock:
@@ -2181,6 +2183,19 @@ out_mutex_unlock:
        return lpni;
 }
 
        return lpni;
 }
 
+struct lnet_peer_ni *
+lnet_nid2peerni_locked(lnet_nid_t nid4, lnet_nid_t pref4, int cpt)
+{
+       struct lnet_nid nid, pref;
+
+       lnet_nid4_to_nid(nid4, &nid);
+       lnet_nid4_to_nid(pref4, &pref);
+       if (pref4 == LNET_NID_ANY)
+               return lnet_peerni_by_nid_locked(&nid, NULL, cpt);
+       else
+               return lnet_peerni_by_nid_locked(&nid, &pref, cpt);
+}
+
 bool
 lnet_peer_gw_discovery(struct lnet_peer *lp)
 {
 bool
 lnet_peer_gw_discovery(struct lnet_peer *lp)
 {
index ffb2cde..08c1a7f 100644 (file)
@@ -213,7 +213,7 @@ lnet_udsp_apply_rule_on_ni(struct udsp_info *udi)
        __u32 priority = (udi->udi_revert) ? -1 : udi->udi_priority;
 
        rc = cfs_match_nid_net(
        __u32 priority = (udi->udi_revert) ? -1 : udi->udi_priority;
 
        rc = cfs_match_nid_net(
-               lnet_nid_to_nid4(&ni->ni_nid),
+               &ni->ni_nid,
                ni_match->ud_net_id.udn_net_type,
                &ni_match->ud_net_id.udn_net_num_range,
                &ni_match->ud_addr_range);
                ni_match->ud_net_id.udn_net_type,
                &ni_match->ud_net_id.udn_net_num_range,
                &ni_match->ud_addr_range);
@@ -239,7 +239,7 @@ lnet_udsp_apply_rte_list_on_net(struct lnet_net *net,
        struct lnet_route *route;
        struct lnet_peer_ni *lpni;
        bool cleared = false;
        struct lnet_route *route;
        struct lnet_peer_ni *lpni;
        bool cleared = false;
-       lnet_nid_t gw_nid, gw_prim_nid;
+       struct lnet_nid *gw_nid, *gw_prim_nid;
        int rc = 0;
        int i;
 
        int rc = 0;
        int i;
 
@@ -248,16 +248,17 @@ lnet_udsp_apply_rte_list_on_net(struct lnet_net *net,
                list_for_each_entry(rnet, rn_list, lrn_list) {
                        list_for_each_entry(route, &rnet->lrn_routes, lr_list) {
                                /* look if gw nid on the same net matches */
                list_for_each_entry(rnet, rn_list, lrn_list) {
                        list_for_each_entry(route, &rnet->lrn_routes, lr_list) {
                                /* look if gw nid on the same net matches */
-                               gw_prim_nid = lnet_nid_to_nid4(
-                                       &route->lr_gateway->lp_primary_nid);
+                               gw_prim_nid =
+                                       &route->lr_gateway->lp_primary_nid;
                                lpni = NULL;
                                while ((lpni = lnet_get_next_peer_ni_locked(route->lr_gateway,
                                                                            NULL,
                                                                            lpni)) != NULL) {
                                        if (!lnet_get_net_locked(lpni->lpni_peer_net->lpn_net_id))
                                                continue;
                                lpni = NULL;
                                while ((lpni = lnet_get_next_peer_ni_locked(route->lr_gateway,
                                                                            NULL,
                                                                            lpni)) != NULL) {
                                        if (!lnet_get_net_locked(lpni->lpni_peer_net->lpn_net_id))
                                                continue;
-                                       gw_nid = lnet_nid_to_nid4(&lpni->lpni_nid);
-                                       rc = cfs_match_nid_net(gw_nid,
+                                       gw_nid = &lpni->lpni_nid;
+                                       rc = cfs_match_nid_net(
+                                               gw_nid,
                                                rte_action->ud_net_id.udn_net_type,
                                                &rte_action->ud_net_id.udn_net_num_range,
                                                &rte_action->ud_addr_range);
                                                rte_action->ud_net_id.udn_net_type,
                                                &rte_action->ud_net_id.udn_net_num_range,
                                                &rte_action->ud_addr_range);
@@ -267,7 +268,8 @@ lnet_udsp_apply_rte_list_on_net(struct lnet_net *net,
                                /* match gw primary nid on a remote network */
                                if (!rc) {
                                        gw_nid = gw_prim_nid;
                                /* match gw primary nid on a remote network */
                                if (!rc) {
                                        gw_nid = gw_prim_nid;
-                                       rc = cfs_match_nid_net(gw_nid,
+                                       rc = cfs_match_nid_net(
+                                               gw_nid,
                                                rte_action->ud_net_id.udn_net_type,
                                                &rte_action->ud_net_id.udn_net_num_range,
                                                &rte_action->ud_addr_range);
                                                rte_action->ud_net_id.udn_net_type,
                                                &rte_action->ud_net_id.udn_net_num_range,
                                                &rte_action->ud_addr_range);
@@ -286,13 +288,13 @@ lnet_udsp_apply_rte_list_on_net(struct lnet_net *net,
                                /* match. Add to pref NIDs */
                                CDEBUG(D_NET, "udsp net->gw: %s->%s\n",
                                       libcfs_net2str(net->net_id),
                                /* match. Add to pref NIDs */
                                CDEBUG(D_NET, "udsp net->gw: %s->%s\n",
                                       libcfs_net2str(net->net_id),
-                                      libcfs_nid2str(gw_prim_nid));
+                                      libcfs_nidstr(gw_prim_nid));
                                rc = lnet_net_add_pref_rtr(net, gw_prim_nid);
                                lnet_net_lock(LNET_LOCK_EX);
                                /* success if EEXIST return */
                                if (rc && rc != -EEXIST) {
                                        CERROR("Failed to add %s to %s pref rtr list\n",
                                rc = lnet_net_add_pref_rtr(net, gw_prim_nid);
                                lnet_net_lock(LNET_LOCK_EX);
                                /* success if EEXIST return */
                                if (rc && rc != -EEXIST) {
                                        CERROR("Failed to add %s to %s pref rtr list\n",
-                                              libcfs_nid2str(gw_prim_nid),
+                                              libcfs_nidstr(gw_prim_nid),
                                               libcfs_net2str(net->net_id));
                                        return rc;
                                }
                                               libcfs_net2str(net->net_id));
                                        return rc;
                                }
@@ -417,7 +419,7 @@ lnet_udsp_apply_rte_list_on_lpni(struct lnet_peer_ni *lpni,
        struct list_head *rn_list;
        struct lnet_route *route;
        bool cleared = false;
        struct list_head *rn_list;
        struct lnet_route *route;
        bool cleared = false;
-       lnet_nid_t gw_nid;
+       struct lnet_nid *gw_nid;
        int rc = 0;
        int i;
 
        int rc = 0;
        int i;
 
@@ -425,9 +427,9 @@ lnet_udsp_apply_rte_list_on_lpni(struct lnet_peer_ni *lpni,
                rn_list = &the_lnet.ln_remote_nets_hash[i];
                list_for_each_entry(rnet, rn_list, lrn_list) {
                        list_for_each_entry(route, &rnet->lrn_routes, lr_list) {
                rn_list = &the_lnet.ln_remote_nets_hash[i];
                list_for_each_entry(rnet, rn_list, lrn_list) {
                        list_for_each_entry(route, &rnet->lrn_routes, lr_list) {
-                               gw_nid = lnet_nid_to_nid4(
-                                       &route->lr_gateway->lp_primary_nid);
-                               rc = cfs_match_nid_net(gw_nid,
+                               gw_nid = &route->lr_gateway->lp_primary_nid;
+                               rc = cfs_match_nid_net(
+                                       gw_nid,
                                        rte_action->ud_net_id.udn_net_type,
                                        &rte_action->ud_net_id.udn_net_num_range,
                                        &rte_action->ud_addr_range);
                                        rte_action->ud_net_id.udn_net_type,
                                        &rte_action->ud_net_id.udn_net_num_range,
                                        &rte_action->ud_addr_range);
@@ -446,7 +448,7 @@ lnet_udsp_apply_rte_list_on_lpni(struct lnet_peer_ni *lpni,
                                        }
                                }
                                CDEBUG(D_NET, "add gw nid %s as preferred for peer %s\n",
                                        }
                                }
                                CDEBUG(D_NET, "add gw nid %s as preferred for peer %s\n",
-                                      libcfs_nid2str(gw_nid),
+                                      libcfs_nidstr(gw_nid),
                                       libcfs_nidstr(&lpni->lpni_nid));
                                /* match. Add to pref NIDs */
                                rc = lnet_peer_add_pref_rtr(lpni, gw_nid);
                                       libcfs_nidstr(&lpni->lpni_nid));
                                /* match. Add to pref NIDs */
                                rc = lnet_peer_add_pref_rtr(lpni, gw_nid);
@@ -454,7 +456,7 @@ lnet_udsp_apply_rte_list_on_lpni(struct lnet_peer_ni *lpni,
                                /* success if EEXIST return */
                                if (rc && rc != -EEXIST) {
                                        CERROR("Failed to add %s to %s pref rtr list\n",
                                /* success if EEXIST return */
                                if (rc && rc != -EEXIST) {
                                        CERROR("Failed to add %s to %s pref rtr list\n",
-                                              libcfs_nid2str(gw_nid),
+                                              libcfs_nidstr(gw_nid),
                                               libcfs_nidstr(&lpni->lpni_nid));
                                        return rc;
                                }
                                               libcfs_nidstr(&lpni->lpni_nid));
                                        return rc;
                                }
@@ -480,7 +482,7 @@ lnet_udsp_apply_ni_list(struct lnet_peer_ni *lpni,
                        continue;
                list_for_each_entry(ni, &net->net_ni_list, ni_netlist) {
                        rc = cfs_match_nid_net(
                        continue;
                list_for_each_entry(ni, &net->net_ni_list, ni_netlist) {
                        rc = cfs_match_nid_net(
-                               lnet_nid_to_nid4(&ni->ni_nid),
+                               &ni->ni_nid,
                                ni_action->ud_net_id.udn_net_type,
                                &ni_action->ud_net_id.udn_net_num_range,
                                &ni_action->ud_addr_range);
                                ni_action->ud_net_id.udn_net_type,
                                &ni_action->ud_net_id.udn_net_num_range,
                                &ni_action->ud_addr_range);
@@ -502,8 +504,7 @@ lnet_udsp_apply_ni_list(struct lnet_peer_ni *lpni,
                                libcfs_nidstr(&ni->ni_nid),
                                libcfs_nidstr(&lpni->lpni_nid));
                        /* match. Add to pref NIDs */
                                libcfs_nidstr(&ni->ni_nid),
                                libcfs_nidstr(&lpni->lpni_nid));
                        /* match. Add to pref NIDs */
-                       rc = lnet_peer_add_pref_nid(
-                               lpni, lnet_nid_to_nid4(&ni->ni_nid));
+                       rc = lnet_peer_add_pref_nid(lpni, &ni->ni_nid);
                        lnet_net_lock(LNET_LOCK_EX);
                        /* success if EEXIST return */
                        if (rc && rc != -EEXIST) {
                        lnet_net_lock(LNET_LOCK_EX);
                        /* success if EEXIST return */
                        if (rc && rc != -EEXIST) {
@@ -529,7 +530,8 @@ lnet_udsp_apply_rule_on_lpni(struct udsp_info *udi)
        bool local = udi->udi_local;
        enum lnet_udsp_action_type type = udi->udi_type;
 
        bool local = udi->udi_local;
        enum lnet_udsp_action_type type = udi->udi_type;
 
-       rc = cfs_match_nid_net(lnet_nid_to_nid4(&lpni->lpni_nid),
+       rc = cfs_match_nid_net(
+               &lpni->lpni_nid,
                lp_match->ud_net_id.udn_net_type,
                &lp_match->ud_net_id.udn_net_num_range,
                &lp_match->ud_addr_range);
                lp_match->ud_net_id.udn_net_type,
                &lp_match->ud_net_id.udn_net_num_range,
                &lp_match->ud_addr_range);
@@ -993,7 +995,8 @@ lnet_udsp_get_ni_info(struct lnet_ioctl_construct_udsp_info *info,
                info->cud_net_priority = ni->ni_net->net_sel_priority;
                list_for_each_entry(ne, &net->net_rtr_pref_nids, nl_list) {
                        if (i < LNET_MAX_SHOW_NUM_NID)
                info->cud_net_priority = ni->ni_net->net_sel_priority;
                list_for_each_entry(ne, &net->net_rtr_pref_nids, nl_list) {
                        if (i < LNET_MAX_SHOW_NUM_NID)
-                               info->cud_pref_rtr_nid[i] = ne->nl_nid;
+                               info->cud_pref_rtr_nid[i] =
+                                       lnet_nid_to_nid4(&ne->nl_nid);
                        else
                                break;
                        i++;
                        else
                                break;
                        i++;
@@ -1017,13 +1020,14 @@ lnet_udsp_get_peer_info(struct lnet_ioctl_construct_udsp_info *info,
               libcfs_nidstr(&lpni->lpni_nid),
               lpni->lpni_pref_nnids);
        if (lpni->lpni_pref_nnids == 1) {
               libcfs_nidstr(&lpni->lpni_nid),
               lpni->lpni_pref_nnids);
        if (lpni->lpni_pref_nnids == 1) {
-               info->cud_pref_nid[0] = lpni->lpni_pref.nid;
+               info->cud_pref_nid[0] = lnet_nid_to_nid4(&lpni->lpni_pref.nid);
        } else if (lpni->lpni_pref_nnids > 1) {
                struct list_head *list = &lpni->lpni_pref.nids;
 
                list_for_each_entry(ne, list, nl_list) {
                        if (i < LNET_MAX_SHOW_NUM_NID)
        } else if (lpni->lpni_pref_nnids > 1) {
                struct list_head *list = &lpni->lpni_pref.nids;
 
                list_for_each_entry(ne, list, nl_list) {
                        if (i < LNET_MAX_SHOW_NUM_NID)
-                               info->cud_pref_nid[i] = ne->nl_nid;
+                               info->cud_pref_nid[i] =
+                                       lnet_nid_to_nid4(&ne->nl_nid);
                        else
                                break;
                        i++;
                        else
                                break;
                        i++;
@@ -1033,7 +1037,8 @@ lnet_udsp_get_peer_info(struct lnet_ioctl_construct_udsp_info *info,
        i = 0;
        list_for_each_entry(ne, &lpni->lpni_rtr_pref_nids, nl_list) {
                if (i < LNET_MAX_SHOW_NUM_NID)
        i = 0;
        list_for_each_entry(ne, &lpni->lpni_rtr_pref_nids, nl_list) {
                if (i < LNET_MAX_SHOW_NUM_NID)
-                       info->cud_pref_rtr_nid[i] = ne->nl_nid;
+                       info->cud_pref_rtr_nid[i] =
+                               lnet_nid_to_nid4(&ne->nl_nid);
                else
                        break;
                i++;
                else
                        break;
                i++;