X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lnet%2Flnet%2Fudsp.c;h=bd8efdaef02240291ec6169d5e3ecb47045fd8dc;hb=refs%2Fchanges%2F81%2F50081%2F4;hp=1b0db21e1333eff98c629a69ec9e5d8bbc6ed79d;hpb=6248e1cd7fb70f4138d19866c4b444b5f77af227;p=fs%2Flustre-release.git diff --git a/lnet/lnet/udsp.c b/lnet/lnet/udsp.c index 1b0db21..bd8efda 100644 --- a/lnet/lnet/udsp.c +++ b/lnet/lnet/udsp.c @@ -212,7 +212,8 @@ lnet_udsp_apply_rule_on_ni(struct udsp_info *udi) 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); @@ -220,7 +221,7 @@ lnet_udsp_apply_rule_on_ni(struct udsp_info *udi) 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); @@ -238,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; - lnet_nid_t gw_nid, gw_prim_nid; + struct lnet_nid *gw_nid, *gw_prim_nid; int rc = 0; int i; @@ -247,15 +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 */ - 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); @@ -265,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; - 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); @@ -284,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), - 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; } @@ -415,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; - lnet_nid_t gw_nid; + struct lnet_nid *gw_nid; int rc = 0; int i; @@ -423,8 +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) { - 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); @@ -434,7 +439,7 @@ lnet_udsp_apply_rte_list_on_lpni(struct lnet_peer_ni *lpni, 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) { @@ -443,16 +448,16 @@ 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", - 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; } } @@ -476,7 +481,8 @@ lnet_udsp_apply_ni_list(struct lnet_peer_ni *lpni, 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); @@ -487,7 +493,7 @@ lnet_udsp_apply_ni_list(struct lnet_peer_ni *lpni, 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); @@ -495,16 +501,16 @@ lnet_udsp_apply_ni_list(struct lnet_peer_ni *lpni, } } 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; } } @@ -524,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; - 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); @@ -602,7 +609,7 @@ lnet_udsp_apply_rule_on_lpnis(struct udsp_info *udi) 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) { @@ -622,7 +629,7 @@ lnet_udsp_apply_rule_on_lpnis(struct udsp_info *udi) &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) @@ -988,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_pref_rtr_nid[i] = ne->nl_nid; + info->cud_pref_rtr_nid[i] = + lnet_nid_to_nid4(&ne->nl_nid); else break; i++; @@ -1009,16 +1017,17 @@ lnet_udsp_get_peer_info(struct lnet_ioctl_construct_udsp_info *info, info->cud_nid_priority = lpni->lpni_sel_priority; CDEBUG(D_NET, "lpni %s has %d pref nids\n", - libcfs_nid2str(lpni->lpni_nid), + 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++; @@ -1028,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) - 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++; @@ -1042,17 +1052,19 @@ lnet_udsp_get_construct_info(struct lnet_ioctl_construct_udsp_info *info) { struct lnet_ni *ni; struct lnet_peer_ni *lpni; + struct lnet_nid nid; lnet_net_lock(0); + lnet_nid4_to_nid(info->cud_nid, &nid); if (!info->cud_peer) { - ni = lnet_nid2ni_locked(info->cud_nid, 0); + ni = lnet_nid_to_ni_locked(&nid, 0); if (ni) lnet_udsp_get_ni_info(info, ni); } else { - lpni = lnet_find_peer_ni_locked(info->cud_nid); + lpni = lnet_peer_ni_find_locked(&nid); if (!lpni) { CDEBUG(D_NET, "nid %s is not found\n", - libcfs_nid2str(info->cud_nid)); + libcfs_nidstr(&nid)); } else { lnet_udsp_get_peer_info(info, lpni); lnet_peer_ni_decref_locked(lpni); @@ -1079,7 +1091,7 @@ lnet_udsp_alloc(void) INIT_LIST_HEAD(&udsp->udsp_rte.ud_addr_range); INIT_LIST_HEAD(&udsp->udsp_rte.ud_net_id.udn_net_num_range); - CDEBUG(D_MALLOC, "udsp alloc %p\n", udsp); + LIBCFS_ALLOC_POST(udsp, sizeof(*udsp), "alloc"); return udsp; } @@ -1112,7 +1124,7 @@ lnet_udsp_free(struct lnet_udsp *udsp) lnet_udsp_nid_descr_free(&udsp->udsp_dst); lnet_udsp_nid_descr_free(&udsp->udsp_rte); - CDEBUG(D_MALLOC, "udsp free %p\n", udsp); + LIBCFS_FREE_PRE(udsp, sizeof(*udsp), "kfreed"); kmem_cache_free(lnet_udsp_cachep, udsp); } @@ -1474,8 +1486,19 @@ copy_ioc_udsp_descr(struct lnet_ud_nid_descr *nid_descr, char *type, CDEBUG(D_NET, "%u\n", nid_descr->ud_net_id.udn_net_type); /* allocate the total memory required to copy this NID descriptor */ - alloc_size = (sizeof(struct cfs_expr_list) * (expr_count + 1)) + - (sizeof(struct cfs_range_expr) * (range_count)); + if (ioc_nid->iud_net.ud_net_num_expr.le_count) { + if (ioc_nid->iud_net.ud_net_num_expr.le_count != 1) { + CERROR("Unexpected number of net numeric ranges \"%u\". Cannot add UDSP rule.\n", + ioc_nid->iud_net.ud_net_num_expr.le_count); + return -EINVAL; + } + alloc_size = (sizeof(struct cfs_expr_list) * (expr_count + 1)) + + (sizeof(struct cfs_range_expr) * (range_count)); + } else { + alloc_size = (sizeof(struct cfs_expr_list) * (expr_count)) + + (sizeof(struct cfs_range_expr) * (range_count)); + } + LIBCFS_ALLOC(buf, alloc_size); if (!buf) return -ENOMEM;