From: Mr NeilBrown Date: Wed, 18 Aug 2021 21:01:48 +0000 (-0400) Subject: LU-10391 lnet: change lr_nid to struct lnet_nid X-Git-Tag: 2.14.55~79 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=d1e2f6fc688762222c63095173cfb5d19a93d377 LU-10391 lnet: change lr_nid to struct lnet_nid The nid in 'struct lnet_route' is now a struct lnet_nid'. 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 Change-Id: I2e2f2e9c8d2cbdbc87b408ee4589952f2df02880 Reviewed-on: https://review.whamcloud.com/43593 Tested-by: jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Chris Horn Reviewed-by: Oleg Drokin --- diff --git a/lnet/include/lnet/lib-lnet.h b/lnet/include/lnet/lib-lnet.h index 97ad91e..45389e0 100644 --- a/lnet/include/lnet/lib-lnet.h +++ b/lnet/include/lnet/lib-lnet.h @@ -557,7 +557,7 @@ int lnet_notify(struct lnet_ni *ni, lnet_nid_t peer, bool alive, bool reset, time64_t when); void lnet_notify_locked(struct lnet_peer_ni *lp, int notifylnd, int alive, time64_t when); -int lnet_add_route(__u32 net, __u32 hops, lnet_nid_t gateway_nid, +int lnet_add_route(__u32 net, __u32 hops, struct lnet_nid *gateway, __u32 priority, __u32 sensitivity); int lnet_del_route(__u32 net, lnet_nid_t gw_nid); void lnet_move_route(struct lnet_route *route, struct lnet_peer *lp, @@ -609,7 +609,8 @@ 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_islocalnid(lnet_nid_t nid); +int lnet_islocalnid4(lnet_nid_t nid); +int lnet_islocalnid(struct lnet_nid *nid); int lnet_islocalnet(__u32 net); int lnet_islocalnet_locked(__u32 net); @@ -906,9 +907,11 @@ 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 *lnet_nid2peerni_ex(lnet_nid_t nid, 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_peer_ni_get_locked(struct lnet_peer *lp, + struct lnet_nid *nid); struct lnet_peer_ni *lnet_find_peer_ni_locked(lnet_nid_t nid); struct lnet_peer_ni *lnet_peer_ni_find_locked(struct lnet_nid *nid); struct lnet_peer *lnet_find_peer(lnet_nid_t nid); diff --git a/lnet/include/lnet/lib-types.h b/lnet/include/lnet/lib-types.h index 908ea85..85c69f2 100644 --- a/lnet/include/lnet/lib-types.h +++ b/lnet/include/lnet/lib-types.h @@ -883,7 +883,7 @@ struct lnet_route { struct list_head lr_list; /* chain on net */ struct list_head lr_gwlist; /* chain on gateway */ struct lnet_peer *lr_gateway; /* router node */ - lnet_nid_t lr_nid; /* NID used to add route */ + struct lnet_nid lr_nid; /* NID used to add route */ __u32 lr_net; /* remote network number */ __u32 lr_lnet; /* local network number */ int lr_seq; /* sequence for round-robin */ diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index 45abed8..db521ee 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -1713,7 +1713,7 @@ lnet_nid_to_ni_addref(struct lnet_nid *nid) EXPORT_SYMBOL(lnet_nid_to_ni_addref); int -lnet_islocalnid(lnet_nid_t nid) +lnet_islocalnid4(lnet_nid_t nid) { struct lnet_ni *ni; int cpt; @@ -1726,6 +1726,19 @@ lnet_islocalnid(lnet_nid_t nid) } int +lnet_islocalnid(struct lnet_nid *nid) +{ + struct lnet_ni *ni; + int cpt; + + cpt = lnet_net_lock_current(); + ni = lnet_nid_to_ni_locked(nid, cpt); + lnet_net_unlock(cpt); + + return ni != NULL; +} + +int lnet_count_acceptor_nets(void) { /* Return the # of NIs that need the acceptor. */ @@ -3922,6 +3935,7 @@ LNetCtl(unsigned int cmd, void *arg) struct lnet_ioctl_config_data *config; struct lnet_process_id id = {0}; struct lnet_ni *ni; + struct lnet_nid nid; int rc; BUILD_BUG_ON(sizeof(struct lnet_ioctl_net_config) + @@ -3949,10 +3963,11 @@ LNetCtl(unsigned int cmd, void *arg) config->cfg_config_u.cfg_route.rtr_sensitivity; } + lnet_nid4_to_nid(config->cfg_nid, &nid); mutex_lock(&the_lnet.ln_api_mutex); rc = lnet_add_route(config->cfg_net, config->cfg_config_u.cfg_route.rtr_hop, - config->cfg_nid, + &nid, config->cfg_config_u.cfg_route. rtr_priority, sensitivity); mutex_unlock(&the_lnet.ln_api_mutex); diff --git a/lnet/lnet/config.c b/lnet/lnet/config.c index c4a2cc2..57dd989 100644 --- a/lnet/lnet/config.c +++ b/lnet/lnet/config.c @@ -1078,8 +1078,8 @@ lnet_parse_route(char *str, int *im_a_router) struct list_head *tmp1; struct list_head *tmp2; __u32 net; - lnet_nid_t nid; - struct lnet_text_buf *ltb; + struct lnet_nid nid; + struct lnet_text_buf *ltb; int rc; char *sep; char *token = str; @@ -1157,8 +1157,8 @@ lnet_parse_route(char *str, int *im_a_router) if (rc < 0) goto token_error; - nid = libcfs_str2nid(ltb->ltb_text); - if (nid == LNET_NID_ANY || nid == LNET_NID_LO_0) + if (libcfs_strnid(&nid, ltb->ltb_text) != 0 || + nid_is_lo0(&nid)) goto token_error; } } @@ -1179,20 +1179,19 @@ lnet_parse_route(char *str, int *im_a_router) list_for_each(tmp2, &gateways) { ltb = list_entry(tmp2, struct lnet_text_buf, ltb_list); - nid = libcfs_str2nid(ltb->ltb_text); - LASSERT(nid != LNET_NID_ANY); + LASSERT(libcfs_strnid(&nid, ltb->ltb_text) == 0); - if (lnet_islocalnid(nid)) { + if (lnet_islocalnid(&nid)) { *im_a_router = 1; continue; } - rc = lnet_add_route(net, hops, nid, priority, 1); + rc = lnet_add_route(net, hops, &nid, priority, 1); if (rc != 0 && rc != -EEXIST && rc != -EHOSTUNREACH) { CERROR("Can't create route " "to %s via %s\n", libcfs_net2str(net), - libcfs_nid2str(nid)); + libcfs_nidstr(&nid)); goto out; } } diff --git a/lnet/lnet/lib-move.c b/lnet/lnet/lib-move.c index b5fad9c..c4219c8 100644 --- a/lnet/lnet/lib-move.c +++ b/lnet/lnet/lib-move.c @@ -4567,7 +4567,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid, return -EPROTO; } - if (lnet_islocalnid(dest_nid)) { + if (lnet_islocalnid4(dest_nid)) { /* dest is another local NI; sender should have used * this node's NID on its own network */ CERROR("%s, src %s: Bad dest nid %s " diff --git a/lnet/lnet/peer.c b/lnet/lnet/peer.c index dac7953..6e29a32 100644 --- a/lnet/lnet/peer.c +++ b/lnet/lnet/peer.c @@ -149,15 +149,13 @@ lnet_peer_tables_create(void) } static struct lnet_peer_ni * -lnet_peer_ni_alloc(lnet_nid_t nid4) +lnet_peer_ni_alloc(struct lnet_nid *nid) { struct lnet_peer_ni *lpni; struct lnet_net *net; - struct lnet_nid nid; int cpt; - lnet_nid4_to_nid(nid4, &nid); - cpt = lnet_nid_cpt_hash(&nid, LNET_CPT_NUMBER); + cpt = lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER); LIBCFS_CPT_ALLOC(lpni, lnet_cpt_table(), cpt, sizeof(*lpni)); if (!lpni) @@ -180,11 +178,11 @@ lnet_peer_ni_alloc(lnet_nid_t nid4) else lpni->lpni_ns_status = LNET_NI_STATUS_UP; lpni->lpni_ping_feats = LNET_PING_FEAT_INVAL; - lpni->lpni_nid = nid; + lpni->lpni_nid = *nid; lpni->lpni_cpt = cpt; atomic_set(&lpni->lpni_healthv, LNET_MAX_HEALTH_VALUE); - net = lnet_get_net_locked(LNET_NID_NET(&nid)); + net = lnet_get_net_locked(LNET_NID_NET(nid)); lpni->lpni_net = net; if (net) { lpni->lpni_txcredits = net->net_tunables.lct_peer_tx_credits; @@ -246,12 +244,10 @@ lnet_destroy_peer_net_locked(struct lnet_peer_net *lpn) } static struct lnet_peer * -lnet_peer_alloc(lnet_nid_t nid4) +lnet_peer_alloc(struct lnet_nid *nid) { struct lnet_peer *lp; - struct lnet_nid nid; - lnet_nid4_to_nid(nid4, &nid); LIBCFS_CPT_ALLOC(lp, lnet_cpt_table(), CFS_CPT_ANY, sizeof(*lp)); if (!lp) return NULL; @@ -265,7 +261,7 @@ lnet_peer_alloc(lnet_nid_t nid4) INIT_LIST_HEAD(&lp->lp_rtr_list); init_waitqueue_head(&lp->lp_dc_waitq); spin_lock_init(&lp->lp_lock); - lp->lp_primary_nid = nid; + lp->lp_primary_nid = *nid; lp->lp_disc_src_nid = LNET_ANY_NID; lp->lp_disc_dst_nid = LNET_ANY_NID; if (lnet_peers_start_down()) @@ -287,9 +283,9 @@ lnet_peer_alloc(lnet_nid_t nid4) * to ever use a different interface when sending messages to * myself. */ - if (nid_is_lo0(&nid)) + if (nid_is_lo0(nid)) lp->lp_state = LNET_PEER_NO_DISCOVERY; - lp->lp_cpt = lnet_nid_cpt_hash(&nid, LNET_CPT_NUMBER); + lp->lp_cpt = lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER); CDEBUG(D_NET, "%p nid %s\n", lp, libcfs_nidstr(&lp->lp_primary_nid)); @@ -768,6 +764,24 @@ lnet_peer_get_ni_locked(struct lnet_peer *lp, lnet_nid_t nid) return NULL; } +struct lnet_peer_ni * +lnet_peer_ni_get_locked(struct lnet_peer *lp, struct lnet_nid *nid) +{ + struct lnet_peer_net *lpn; + struct lnet_peer_ni *lpni; + + lpn = lnet_peer_get_net_locked(lp, LNET_NID_NET(nid)); + if (!lpn) + return NULL; + + list_for_each_entry(lpni, &lpn->lpn_peer_nis, lpni_peer_nis) { + if (nid_same(&lpni->lpni_nid, nid)) + return lpni; + } + + return NULL; +} + struct lnet_peer * lnet_find_peer(lnet_nid_t nid) { @@ -1605,20 +1619,21 @@ lnet_peer_attach_peer_ni(struct lnet_peer *lp, * Call with the lnet_api_mutex held. */ static int -lnet_peer_add(lnet_nid_t nid, unsigned flags) +lnet_peer_add(lnet_nid_t nid4, unsigned int flags) { + struct lnet_nid nid; struct lnet_peer *lp; struct lnet_peer_net *lpn; struct lnet_peer_ni *lpni; int rc = 0; - LASSERT(nid != LNET_NID_ANY); + LASSERT(nid4 != LNET_NID_ANY); /* * No need for the lnet_net_lock here, because the * lnet_api_mutex is held. */ - lpni = lnet_find_peer_ni_locked(nid); + lpni = lnet_find_peer_ni_locked(nid4); if (lpni) { /* A peer with this NID already exists. */ lp = lpni->lpni_peer_net->lpn_peer; @@ -1630,13 +1645,13 @@ lnet_peer_add(lnet_nid_t nid, unsigned flags) * that an existing peer is being modified. */ if (lp->lp_state & LNET_PEER_CONFIGURED) { - if (lnet_nid_to_nid4(&lp->lp_primary_nid) != nid) + if (lnet_nid_to_nid4(&lp->lp_primary_nid) != nid4) rc = -EEXIST; else if ((lp->lp_state ^ flags) & LNET_PEER_MULTI_RAIL) rc = -EPERM; goto out; } else if (!(flags & LNET_PEER_CONFIGURED)) { - if (lnet_nid_to_nid4(&lp->lp_primary_nid) == nid) { + if (lnet_nid_to_nid4(&lp->lp_primary_nid) == nid4) { rc = -EEXIST; goto out; } @@ -1647,13 +1662,14 @@ lnet_peer_add(lnet_nid_t nid, unsigned flags) /* Create peer, peer_net, and peer_ni. */ rc = -ENOMEM; - lp = lnet_peer_alloc(nid); + lnet_nid4_to_nid(nid4, &nid); + lp = lnet_peer_alloc(&nid); if (!lp) goto out; - lpn = lnet_peer_net_alloc(LNET_NIDNET(nid)); + lpn = lnet_peer_net_alloc(LNET_NID_NET(&nid)); if (!lpn) goto out_free_lp; - lpni = lnet_peer_ni_alloc(nid); + lpni = lnet_peer_ni_alloc(&nid); if (!lpni) goto out_free_lpn; @@ -1665,7 +1681,7 @@ out_free_lp: LIBCFS_FREE(lp, sizeof(*lp)); out: CDEBUG(D_NET, "peer %s NID flags %#x: %d\n", - libcfs_nid2str(nid), flags, rc); + libcfs_nid2str(nid4), flags, rc); return rc; } @@ -1680,14 +1696,17 @@ out: * non-multi-rail peer. */ static int -lnet_peer_add_nid(struct lnet_peer *lp, lnet_nid_t nid, unsigned flags) +lnet_peer_add_nid(struct lnet_peer *lp, lnet_nid_t nid4, unsigned int flags) { struct lnet_peer_net *lpn; struct lnet_peer_ni *lpni; + struct lnet_nid nid; int rc = 0; LASSERT(lp); - LASSERT(nid != LNET_NID_ANY); + LASSERT(nid4 != LNET_NID_ANY); + + lnet_nid4_to_nid(nid4, &nid); /* A configured peer can only be updated through configuration. */ if (!(flags & LNET_PEER_CONFIGURED)) { @@ -1713,7 +1732,7 @@ lnet_peer_add_nid(struct lnet_peer *lp, lnet_nid_t nid, unsigned flags) goto out; } - lpni = lnet_find_peer_ni_locked(nid); + lpni = lnet_find_peer_ni_locked(nid4); if (lpni) { /* * A peer_ni already exists. This is only a problem if @@ -1760,14 +1779,14 @@ lnet_peer_add_nid(struct lnet_peer *lp, lnet_nid_t nid, unsigned flags) } lnet_peer_del(lp2); lnet_peer_ni_decref_locked(lpni); - lpni = lnet_peer_ni_alloc(nid); + lpni = lnet_peer_ni_alloc(&nid); if (!lpni) { rc = -ENOMEM; goto out_free_lpni; } } } else { - lpni = lnet_peer_ni_alloc(nid); + lpni = lnet_peer_ni_alloc(&nid); if (!lpni) { rc = -ENOMEM; goto out_free_lpni; @@ -1778,9 +1797,9 @@ lnet_peer_add_nid(struct lnet_peer *lp, lnet_nid_t nid, unsigned flags) * Get the peer_net. Check that we're not adding a second * peer_ni on a peer_net of a non-multi-rail peer. */ - lpn = lnet_peer_get_net_locked(lp, LNET_NIDNET(nid)); + lpn = lnet_peer_get_net_locked(lp, LNET_NIDNET(nid4)); if (!lpn) { - lpn = lnet_peer_net_alloc(LNET_NIDNET(nid)); + lpn = lnet_peer_net_alloc(LNET_NIDNET(nid4)); if (!lpn) { rc = -ENOMEM; goto out_free_lpni; @@ -1796,7 +1815,7 @@ out_free_lpni: lnet_peer_ni_decref_locked(lpni); out: CDEBUG(D_NET, "peer %s NID %s flags %#x: %d\n", - libcfs_nidstr(&lp->lp_primary_nid), libcfs_nid2str(nid), + libcfs_nidstr(&lp->lp_primary_nid), libcfs_nid2str(nid4), flags, rc); return rc; } @@ -1843,7 +1862,7 @@ out: * lpni creation initiated due to traffic either sending or receiving. */ static int -lnet_peer_ni_traffic_add(lnet_nid_t nid, lnet_nid_t pref) +lnet_peer_ni_traffic_add(struct lnet_nid *nid, lnet_nid_t pref) { struct lnet_peer *lp; struct lnet_peer_net *lpn; @@ -1851,13 +1870,13 @@ lnet_peer_ni_traffic_add(lnet_nid_t nid, lnet_nid_t pref) unsigned flags = 0; int rc = 0; - if (nid == LNET_NID_ANY) { + if (LNET_NID_IS_ANY(nid)) { rc = -EINVAL; goto out; } /* lnet_net_lock is not needed here because ln_api_lock is held */ - lpni = lnet_find_peer_ni_locked(nid); + lpni = lnet_peer_ni_find_locked(nid); if (lpni) { /* * We must have raced with another thread. Since we @@ -1874,7 +1893,7 @@ lnet_peer_ni_traffic_add(lnet_nid_t nid, lnet_nid_t pref) lp = lnet_peer_alloc(nid); if (!lp) goto out; - lpn = lnet_peer_net_alloc(LNET_NIDNET(nid)); + lpn = lnet_peer_net_alloc(LNET_NID_NET(nid)); if (!lpn) goto out_free_lp; lpni = lnet_peer_ni_alloc(nid); @@ -1890,7 +1909,7 @@ out_free_lpn: out_free_lp: LIBCFS_FREE(lp, sizeof(*lp)); out: - CDEBUG(D_NET, "peer %s: %d\n", libcfs_nid2str(nid), rc); + CDEBUG(D_NET, "peer %s: %d\n", libcfs_nidstr(nid), rc); return rc; } @@ -2060,7 +2079,7 @@ lnet_destroy_peer_ni_locked(struct kref *ref) } struct lnet_peer_ni * -lnet_nid2peerni_ex(lnet_nid_t nid, int cpt) +lnet_nid2peerni_ex(struct lnet_nid *nid, int cpt) { struct lnet_peer_ni *lpni = NULL; int rc; @@ -2072,7 +2091,7 @@ lnet_nid2peerni_ex(lnet_nid_t nid, int cpt) * find if a peer_ni already exists. * If so then just return that. */ - lpni = lnet_find_peer_ni_locked(nid); + lpni = lnet_peer_ni_find_locked(nid); if (lpni) return lpni; @@ -2084,7 +2103,7 @@ lnet_nid2peerni_ex(lnet_nid_t nid, int cpt) goto out_net_relock; } - lpni = lnet_find_peer_ni_locked(nid); + lpni = lnet_peer_ni_find_locked(nid); LASSERT(lpni); out_net_relock: @@ -2098,19 +2117,21 @@ out_net_relock: * hold on the peer_ni. */ struct lnet_peer_ni * -lnet_nid2peerni_locked(lnet_nid_t nid, lnet_nid_t pref, int cpt) +lnet_nid2peerni_locked(lnet_nid_t nid4, lnet_nid_t pref, int cpt) { struct lnet_peer_ni *lpni = NULL; + struct lnet_nid nid; 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. */ - lpni = lnet_find_peer_ni_locked(nid); + lpni = lnet_find_peer_ni_locked(nid4); if (lpni) return lpni; @@ -2137,13 +2158,13 @@ lnet_nid2peerni_locked(lnet_nid_t nid, lnet_nid_t pref, int cpt) 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; } - lpni = lnet_find_peer_ni_locked(nid); + lpni = lnet_find_peer_ni_locked(nid4); LASSERT(lpni); out_mutex_unlock: @@ -3262,7 +3283,7 @@ __must_hold(&lp->lp_lock) /* re-add these routes */ lnet_add_route(route->lr_net, route->lr_hops, - route->lr_nid, + &route->lr_nid, route->lr_priority, sensitivity); LIBCFS_FREE(route, sizeof(*route)); diff --git a/lnet/lnet/router.c b/lnet/lnet/router.c index fc20a76..c297959 100644 --- a/lnet/lnet/router.c +++ b/lnet/lnet/router.c @@ -174,7 +174,7 @@ lnet_move_route(struct lnet_route *route, struct lnet_peer *lp, CDEBUG(D_NET, "deleting route %s->%s\n", libcfs_net2str(route->lr_net), - libcfs_nid2str(route->lr_nid)); + libcfs_nidstr(&route->lr_nid)); /* * use the gateway's lp_primary_nid to delete the route as the @@ -213,7 +213,7 @@ lnet_rtr_transfer_to_peer(struct lnet_peer *src, struct lnet_peer *target) CDEBUG(D_NET, "%s: %s->%s\n", libcfs_nidstr(&src->lp_primary_nid), libcfs_net2str(route->lr_net), - libcfs_nid2str(route->lr_nid)); + libcfs_nidstr(&route->lr_nid)); } list_splice_init(&src->lp_rtrq, &target->lp_rtrq); list_for_each_entry_safe(route, tmp, &src->lp_routes, lr_gwlist) { @@ -368,7 +368,7 @@ lnet_consolidate_routes_locked(struct lnet_peer *orig_lp, * intent here is not to confuse the user who added the route. */ list_for_each_entry(route, &orig_lp->lp_routes, lr_gwlist) { - lpni = lnet_peer_get_ni_locked(orig_lp, route->lr_nid); + lpni = lnet_peer_ni_get_locked(orig_lp, &route->lr_nid); if (!lpni) { lnet_net_lock(LNET_LOCK_EX); list_move(&route->lr_gwlist, &new_lp->lp_routes); @@ -660,7 +660,7 @@ lnet_add_route_to_rnet(struct lnet_remotenet *rnet, struct lnet_route *route) } int -lnet_add_route(__u32 net, __u32 hops, lnet_nid_t gateway, +lnet_add_route(__u32 net, __u32 hops, struct lnet_nid *gateway, __u32 priority, __u32 sensitivity) { struct list_head *route_entry; @@ -673,13 +673,13 @@ lnet_add_route(__u32 net, __u32 hops, lnet_nid_t gateway, int rc; CDEBUG(D_NET, "Add route: remote net %s hops %d priority %u gw %s\n", - libcfs_net2str(net), hops, priority, libcfs_nid2str(gateway)); + libcfs_net2str(net), hops, priority, libcfs_nidstr(gateway)); - if (gateway == LNET_NID_ANY || - gateway == LNET_NID_LO_0 || + if (LNET_NID_IS_ANY(gateway) || + nid_is_lo0(gateway) || net == LNET_NET_ANY || LNET_NETTYP(net) == LOLND || - LNET_NIDNET(gateway) == net || + LNET_NID_NET(gateway) == net || (hops != LNET_UNDEFINED_HOPS && (hops < 1 || hops > 255))) return -EINVAL; @@ -687,10 +687,10 @@ lnet_add_route(__u32 net, __u32 hops, lnet_nid_t gateway, if (lnet_islocalnet(net)) return -EEXIST; - if (!lnet_islocalnet(LNET_NIDNET(gateway))) { + if (!lnet_islocalnet(LNET_NID_NET(gateway))) { CERROR("Cannot add route with gateway %s. There is no local interface configured on LNet %s\n", - libcfs_nid2str(gateway), - libcfs_net2str(LNET_NIDNET(gateway))); + libcfs_nidstr(gateway), + libcfs_net2str(LNET_NID_NET(gateway))); return -EHOSTUNREACH; } @@ -699,7 +699,7 @@ lnet_add_route(__u32 net, __u32 hops, lnet_nid_t gateway, LIBCFS_ALLOC(rnet, sizeof(*rnet)); if (route == NULL || rnet == NULL) { CERROR("Out of memory creating route %s %d %s\n", - libcfs_net2str(net), hops, libcfs_nid2str(gateway)); + libcfs_net2str(net), hops, libcfs_nidstr(gateway)); if (route != NULL) LIBCFS_FREE(route, sizeof(*route)); if (rnet != NULL) @@ -710,9 +710,9 @@ lnet_add_route(__u32 net, __u32 hops, lnet_nid_t gateway, INIT_LIST_HEAD(&rnet->lrn_routes); rnet->lrn_net = net; /* store the local and remote net that the route represents */ - route->lr_lnet = LNET_NIDNET(gateway); + route->lr_lnet = LNET_NID_NET(gateway); route->lr_net = net; - route->lr_nid = gateway; + route->lr_nid = *gateway; route->lr_priority = priority; route->lr_hops = hops; if (lnet_peers_start_down()) @@ -736,7 +736,7 @@ lnet_add_route(__u32 net, __u32 hops, lnet_nid_t gateway, rc = PTR_ERR(lpni); CERROR("Error %d creating route %s %d %s\n", rc, libcfs_net2str(net), hops, - libcfs_nid2str(gateway)); + libcfs_nidstr(gateway)); return rc; } @@ -764,8 +764,8 @@ lnet_add_route(__u32 net, __u32 hops, lnet_nid_t gateway, } /* our lookups must be true */ - LASSERT(lnet_nid_to_nid4(&route2->lr_gateway->lp_primary_nid) != - gateway); + LASSERT(!nid_same(&route2->lr_gateway->lp_primary_nid, + gateway)); } /* @@ -959,8 +959,8 @@ int lnet_get_rtr_pool_cfg(int cpt, struct lnet_ioctl_pool_cfg *pool_cfg) } int -lnet_get_route(int idx, __u32 *net, __u32 *hops, - lnet_nid_t *gateway, __u32 *flags, __u32 *priority, __u32 *sensitivity) +lnet_get_route(int idx, __u32 *net, __u32 *hops, lnet_nid_t *gateway, + __u32 *flags, __u32 *priority, __u32 *sensitivity) { struct lnet_remotenet *rnet; struct list_head *rn_list; @@ -983,7 +983,7 @@ lnet_get_route(int idx, __u32 *net, __u32 *hops, if (idx-- == 0) { *net = rnet->lrn_net; - *gateway = route->lr_nid; + *gateway = lnet_nid_to_nid4(&route->lr_nid); *hops = route->lr_hops; *priority = route->lr_priority; *sensitivity = route->lr_gateway-> @@ -1798,8 +1798,7 @@ lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, bool alive, bool reset, */ if (lnet_is_discovery_disabled(lp)) { list_for_each_entry(route, &lp->lp_routes, lr_gwlist) { - if (route->lr_nid == - lnet_nid_to_nid4(&lpni->lpni_nid)) + if (nid_same(&route->lr_nid, &lpni->lpni_nid)) lnet_set_route_aliveness(route, alive); } } diff --git a/lnet/lnet/router_proc.c b/lnet/lnet/router_proc.c index 349d1dfc..95fe1a5 100644 --- a/lnet/lnet/router_proc.c +++ b/lnet/lnet/router_proc.c @@ -224,7 +224,7 @@ proc_lnet_routes(struct ctl_table *table, int write, void __user *buffer, libcfs_net2str(net), hops, priority, alive ? "up" : "down", - libcfs_nid2str(route->lr_nid)); + libcfs_nidstr(&route->lr_nid)); LASSERT(tmpstr + tmpsiz - s > 0); }