struct lnet_ud_nid_descr *ni_match = udi->udi_match;
__u32 priority = (udi->udi_revert) ? -1 : udi->udi_priority;
- rc = cfs_match_nid_net(ni->ni_nid,
+ rc = cfs_match_nid_net(
+ &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);
return 0;
CDEBUG(D_NET, "apply udsp on ni %s\n",
- libcfs_nid2str(ni->ni_nid));
+ libcfs_nidstr(&ni->ni_nid));
/* Detected match. Set NIDs priority */
lnet_ni_set_sel_priority_locked(ni, priority);
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 = 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 = 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 = 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);
if (!cleared || revert) {
CDEBUG(D_NET, "%spref rtr nids from lpni %s\n",
(revert) ? "revert " : "clear ",
- libcfs_nid2str(lpni->lpni_nid));
+ libcfs_nidstr(&lpni->lpni_nid));
lnet_peer_clr_pref_rtrs(lpni);
cleared = true;
if (revert) {
}
}
CDEBUG(D_NET, "add gw nid %s as preferred for peer %s\n",
- libcfs_nid2str(gw_nid),
- libcfs_nid2str(lpni->lpni_nid));
+ libcfs_nidstr(gw_nid),
+ libcfs_nidstr(&lpni->lpni_nid));
/* match. Add to pref NIDs */
rc = lnet_peer_add_pref_rtr(lpni, gw_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_nid),
- libcfs_nid2str(lpni->lpni_nid));
+ libcfs_nidstr(gw_nid),
+ libcfs_nidstr(&lpni->lpni_nid));
return rc;
}
}
if (LNET_NETTYP(net->net_id) != ni_action->ud_net_id.udn_net_type)
continue;
list_for_each_entry(ni, &net->net_ni_list, ni_netlist) {
- rc = cfs_match_nid_net(ni->ni_nid,
+ rc = cfs_match_nid_net(
+ &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);
lnet_peer_clr_pref_nids(lpni);
CDEBUG(D_NET, "%spref nids from lpni %s\n",
(revert) ? "revert " : "clear ",
- libcfs_nid2str(lpni->lpni_nid));
+ libcfs_nidstr(&lpni->lpni_nid));
cleared = true;
if (revert) {
lnet_net_lock(LNET_LOCK_EX);
}
}
CDEBUG(D_NET, "add nid %s as preferred for peer %s\n",
- libcfs_nid2str(ni->ni_nid),
- libcfs_nid2str(lpni->lpni_nid));
+ libcfs_nidstr(&ni->ni_nid),
+ libcfs_nidstr(&lpni->lpni_nid));
/* match. Add to pref NIDs */
- rc = lnet_peer_add_pref_nid(lpni, 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) {
CERROR("Failed to add %s to %s pref nid list\n",
- libcfs_nid2str(ni->ni_nid),
- libcfs_nid2str(lpni->lpni_nid));
+ libcfs_nidstr(&ni->ni_nid),
+ libcfs_nidstr(&lpni->lpni_nid));
return rc;
}
}
bool local = udi->udi_local;
enum lnet_udsp_action_type type = udi->udi_type;
- rc = cfs_match_nid_net(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);
ptable = the_lnet.ln_peer_tables[cpt];
list_for_each_entry(lp, &ptable->pt_peer_list, lp_peer_list) {
CDEBUG(D_NET, "udsp examining lp %s\n",
- libcfs_nid2str(lp->lp_primary_nid));
+ libcfs_nidstr(&lp->lp_primary_nid));
list_for_each_entry(lpn,
&lp->lp_peer_nets,
lpn_peer_nets) {
&lpn->lpn_peer_nis,
lpni_peer_nis) {
CDEBUG(D_NET, "udsp examining lpni %s\n",
- libcfs_nid2str(lpni->lpni_nid));
+ libcfs_nidstr(&lpni->lpni_nid));
udi->udi_lpni = lpni;
rc = lnet_udsp_apply_rule_on_lpni(udi);
if (rc)
return 0;
}
+static void
+lnet_udsp_get_ni_info(struct lnet_ioctl_construct_udsp_info *info,
+ struct lnet_ni *ni)
+{
+ struct lnet_nid_list *ne;
+ struct lnet_net *net = ni->ni_net;
+ int i = 0;
+
+ LASSERT(ni);
+
+ info->cud_nid_priority = ni->ni_sel_priority;
+ if (net) {
+ 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] =
+ lnet_nid_to_nid4(&ne->nl_nid);
+ else
+ break;
+ i++;
+ }
+ }
+}
+
+static void
+lnet_udsp_get_peer_info(struct lnet_ioctl_construct_udsp_info *info,
+ struct lnet_peer_ni *lpni)
+{
+ struct lnet_nid_list *ne;
+ int i = 0;
+
+ /* peer tree structure needs to be in existence */
+ LASSERT(lpni && lpni->lpni_peer_net &&
+ lpni->lpni_peer_net->lpn_peer);
+
+ info->cud_nid_priority = lpni->lpni_sel_priority;
+ CDEBUG(D_NET, "lpni %s has %d pref nids\n",
+ libcfs_nidstr(&lpni->lpni_nid),
+ lpni->lpni_pref_nnids);
+ if (lpni->lpni_pref_nnids == 1) {
+ 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] =
+ 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] =
+ lnet_nid_to_nid4(&ne->nl_nid);
+ else
+ break;
+ i++;
+ }
+
+ info->cud_net_priority = lpni->lpni_peer_net->lpn_sel_priority;
+}
+
+void
+lnet_udsp_get_construct_info(struct lnet_ioctl_construct_udsp_info *info)
+{
+ struct lnet_ni *ni;
+ struct lnet_peer_ni *lpni;
+
+ lnet_net_lock(0);
+ if (!info->cud_peer) {
+ ni = lnet_nid2ni_locked(info->cud_nid, 0);
+ if (ni)
+ lnet_udsp_get_ni_info(info, ni);
+ } else {
+ lpni = lnet_find_peer_ni_locked(info->cud_nid);
+ if (!lpni) {
+ CDEBUG(D_NET, "nid %s is not found\n",
+ libcfs_nid2str(info->cud_nid));
+ } else {
+ lnet_udsp_get_peer_info(info, lpni);
+ lnet_peer_ni_decref_locked(lpni);
+ }
+ }
+ lnet_net_unlock(0);
+}
+
struct lnet_udsp *
lnet_udsp_alloc(void)
{