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)
{
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.
*
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 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 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,
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);
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);
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);
-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);
-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);
struct lnet_nid_list {
struct list_head nl_list;
- lnet_nid_t nl_nid;
+ struct lnet_nid nl_nid;
};
struct lnet_peer_ni {
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 */
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);
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;
* 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;
}
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
}
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;
- 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));
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;
}
* 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, 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);
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));
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))
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;
}
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
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;
}
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);
}
}
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;
}
}
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;
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;
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);
/* 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),
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;
(__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,
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;
}
/* 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;
* 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;
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;
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;
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_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;
}
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;
}
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;
}
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",
- 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)
*/
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;
* => 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;
}
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;
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;
- 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) ||
- !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;
*/
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;
*/
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;
}
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;
__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;
}
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
* 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)
- 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) {
- if (ne->nl_nid == nid)
+ if (nid_same(&ne->nl_nid, nid))
return true;
}
return false;
* 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;
+ if (!nid)
+ return -EINVAL;
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) {
- 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",
- libcfs_nidstr(&lpni->lpni_nid), libcfs_nid2str(nid), rc);
+ libcfs_nidstr(&lpni->lpni_nid), libcfs_nidstr(nid), rc);
return rc;
}
}
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;
- lnet_nid_t tmp_nid = LNET_NID_ANY;
+ struct lnet_nid *tmp_nid = NULL;
int rc = 0;
- if (nid == LNET_NID_ANY) {
+ if (LNET_NID_IS_ANY(nid)) {
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;
}
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) {
- if (ne1->nl_nid == nid) {
+ if (nid_same(&ne1->nl_nid, nid)) {
rc = -EEXIST;
goto out;
}
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) {
- lpni->lpni_pref.nid = nid;
+ lpni->lpni_pref.nid = *nid;
} else {
if (ne2)
list_add_tail(&ne2->nl_list, &lpni->lpni_pref.nids);
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
-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;
}
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) {
- if (ne->nl_nid == nid)
+ if (nid_same(&ne->nl_nid, nid))
goto remove_nid_entry;
}
rc = -ENOENT;
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) {
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;
}
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;
* 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;
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);
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;
* 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_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(nid4);
+ lpni = lnet_peer_ni_find_locked(nid);
if (lpni)
return lpni;
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(nid4);
+ lpni = lnet_peer_ni_find_locked(nid);
LASSERT(lpni);
out_mutex_unlock:
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)
{
__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);
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;
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;
- 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);
/* 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);
/* 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",
- libcfs_nid2str(gw_prim_nid),
+ libcfs_nidstr(gw_prim_nid),
libcfs_net2str(net->net_id));
return rc;
}
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;
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);
}
}
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);
/* 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;
}
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);
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) {
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);
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++;
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)
- info->cud_pref_nid[i] = ne->nl_nid;
+ info->cud_pref_nid[i] =
+ lnet_nid_to_nid4(&ne->nl_nid);
else
break;
i++;
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++;