2 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
4 * Copyright (c) 2011, 2017, Intel Corporation.
6 * Copyright (c) 2018-2020 Data Direct Networks.
8 * This file is part of Lustre, https://wiki.whamcloud.com/
10 * Portals is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation.
14 * Portals is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * version 2 along with this program; If not, see
21 * http://www.gnu.org/licenses/gpl-2.0.html
25 * User Defined Selection Policies (UDSP) are introduced to add
26 * ability of fine traffic control. The policies are instantiated
27 * on LNet constructs and allow preference of some constructs
28 * over others as an extension of the selection algorithm.
29 * The order of operation is defined by the selection algorithm logical flow:
31 * 1. Iterate over all the networks that a peer can be reached on
32 * and select the best local network
33 * - The remote network with the highest priority is examined
35 * - The local network with the highest priority is selected
37 * - The local NI with the highest priority is selected
39 * 2. If the peer is a remote peer and has no local networks,
40 * - then select the remote peer network with the highest priority
42 * - Select the highest priority remote peer_ni on the network selected
44 * - Now that the peer's network and NI are decided, select the router
45 * in round robin from the peer NI's preferred router list.
47 * - Select the highest priority local NI on the local net of the
50 * 3. Otherwise for local peers, select the peer_ni from the peer.
51 * - highest priority peer NI is selected
53 * - Select the peer NI which has the local NI selected on its
57 * Accordingly, the User Interface allows for the following:
58 * - Adding a local network udsp: if multiple local networks are
59 * available, each one can have a priority.
60 * - Adding a local NID udsp: after a local network is chosen,
61 * if there are multiple NIs, each one can have a priority.
62 * - Adding a remote NID udsp: assign priority to a peer NID.
63 * - Adding a NID pair udsp: allows to specify local NIDs
64 * to be added on the list on the specified peer NIs
65 * When selecting a peer NI, the one with the
66 * local NID being used on its list is preferred.
67 * - Adding a Router udsp: similar to the NID pair udsp.
68 * Specified router NIDs are added on the list on the specified peer NIs.
69 * When sending to a remote peer, remote net is selected and the peer NID
70 * is selected. The router which has its nid on the peer NI list
72 * - Deleting a udsp: use the specified policy index to remove it
73 * from the policy list.
75 * Generally, the syntax is as follows
76 * lnetctl udsp add: add a udsp
77 * --src: ip2nets syntax specifying the local NID to match
78 * --dst: ip2nets syntax specifying the remote NID to match
79 * --rte: ip2nets syntax specifying the router NID to match
80 * --priority: priority value (0 - highest priority)
81 * --idx: index of where to insert the rule.
82 * By default, appends to the end of the rule list.
83 * lnetctl udsp del: delete a udsp
84 * --idx: index of the Policy.
85 * lnetctl udsp show: show udsps
86 * --idx: index of the policy to show.
88 * Author: Amir Shehata
91 #include <linux/uaccess.h>
93 #include <lnet/udsp.h>
94 #include <libcfs/libcfs.h>
97 struct lnet_peer_ni *udi_lpni;
98 struct lnet_peer_net *udi_lpn;
99 struct lnet_ni *udi_ni;
100 struct lnet_net *udi_net;
101 struct lnet_ud_nid_descr *udi_match;
102 struct lnet_ud_nid_descr *udi_action;
104 enum lnet_udsp_action_type udi_type;
109 typedef int (*udsp_apply_rule)(struct udsp_info *);
112 UDSP_APPLY_ON_PEERS = 0,
113 UDSP_APPLY_PRIO_ON_NIS = 1,
114 UDSP_APPLY_RTE_ON_NETS = 2,
115 UDSP_APPLY_MAX_ENUM = 3,
118 #define RULE_NOT_APPLICABLE -1
121 lnet_udsp_is_net_rule(struct lnet_ud_nid_descr *match)
123 return list_empty(&match->ud_addr_range);
127 lnet_udsp_expr_list_equal(struct list_head *e1,
128 struct list_head *e2)
130 struct cfs_expr_list *expr1;
131 struct cfs_expr_list *expr2;
132 struct cfs_range_expr *range1, *range2;
134 if (list_empty(e1) && list_empty(e2))
137 if (lnet_get_list_len(e1) != lnet_get_list_len(e2))
140 expr2 = list_first_entry(e2, struct cfs_expr_list, el_link);
142 list_for_each_entry(expr1, e1, el_link) {
143 if (lnet_get_list_len(&expr1->el_exprs) !=
144 lnet_get_list_len(&expr2->el_exprs))
147 range2 = list_first_entry(&expr2->el_exprs,
148 struct cfs_range_expr,
151 list_for_each_entry(range1, &expr1->el_exprs, re_link) {
152 if (range1->re_lo != range2->re_lo ||
153 range1->re_hi != range2->re_hi ||
154 range1->re_stride != range2->re_stride)
156 range2 = list_next_entry(range2, re_link);
158 expr2 = list_next_entry(expr2, el_link);
165 lnet_udsp_nid_descr_equal(struct lnet_ud_nid_descr *e1,
166 struct lnet_ud_nid_descr *e2)
168 if (e1->ud_net_id.udn_net_type != e2->ud_net_id.udn_net_type ||
169 !lnet_udsp_expr_list_equal(&e1->ud_net_id.udn_net_num_range,
170 &e2->ud_net_id.udn_net_num_range) ||
171 !lnet_udsp_expr_list_equal(&e1->ud_addr_range, &e2->ud_addr_range))
178 lnet_udsp_action_equal(struct lnet_udsp *e1, struct lnet_udsp *e2)
180 if (e1->udsp_action_type != e2->udsp_action_type)
183 if (e1->udsp_action_type == EN_LNET_UDSP_ACTION_PRIORITY &&
184 e1->udsp_action.udsp_priority != e2->udsp_action.udsp_priority)
191 lnet_udsp_equal(struct lnet_udsp *e1, struct lnet_udsp *e2)
193 /* check each NID descr */
194 if (!lnet_udsp_nid_descr_equal(&e1->udsp_src, &e2->udsp_src) ||
195 !lnet_udsp_nid_descr_equal(&e1->udsp_dst, &e2->udsp_dst) ||
196 !lnet_udsp_nid_descr_equal(&e1->udsp_rte, &e2->udsp_rte))
202 /* it is enough to look at the net type of the descriptor. If the criteria
203 * is present the net must be specified
206 lnet_udsp_criteria_present(struct lnet_ud_nid_descr *descr)
208 return (descr->ud_net_id.udn_net_type != 0);
212 lnet_udsp_apply_rule_on_ni(struct udsp_info *udi)
215 struct lnet_ni *ni = udi->udi_ni;
216 struct lnet_ud_nid_descr *ni_match = udi->udi_match;
217 __u32 priority = (udi->udi_revert) ? -1 : udi->udi_priority;
219 rc = cfs_match_nid_net(
221 ni_match->ud_net_id.udn_net_type,
222 &ni_match->ud_net_id.udn_net_num_range,
223 &ni_match->ud_addr_range);
227 CDEBUG(D_NET, "apply udsp on ni %s\n",
228 libcfs_nidstr(&ni->ni_nid));
230 /* Detected match. Set NIDs priority */
231 lnet_ni_set_sel_priority_locked(ni, priority);
237 lnet_udsp_apply_rte_list_on_net(struct lnet_net *net,
238 struct lnet_ud_nid_descr *rte_action,
241 struct lnet_remotenet *rnet;
242 struct list_head *rn_list;
243 struct lnet_route *route;
244 struct lnet_peer_ni *lpni;
245 bool cleared = false;
246 struct lnet_nid *gw_nid, *gw_prim_nid;
250 for (i = 0; i < LNET_REMOTE_NETS_HASH_SIZE; i++) {
251 rn_list = &the_lnet.ln_remote_nets_hash[i];
252 list_for_each_entry(rnet, rn_list, lrn_list) {
253 list_for_each_entry(route, &rnet->lrn_routes, lr_list) {
254 /* look if gw nid on the same net matches */
256 &route->lr_gateway->lp_primary_nid;
258 while ((lpni = lnet_get_next_peer_ni_locked(route->lr_gateway,
261 if (!lnet_get_net_locked(lpni->lpni_peer_net->lpn_net_id))
263 gw_nid = &lpni->lpni_nid;
264 rc = cfs_match_nid_net(
266 rte_action->ud_net_id.udn_net_type,
267 &rte_action->ud_net_id.udn_net_num_range,
268 &rte_action->ud_addr_range);
272 /* match gw primary nid on a remote network */
274 gw_nid = gw_prim_nid;
275 rc = cfs_match_nid_net(
277 rte_action->ud_net_id.udn_net_type,
278 &rte_action->ud_net_id.udn_net_num_range,
279 &rte_action->ud_addr_range);
283 lnet_net_unlock(LNET_LOCK_EX);
284 if (!cleared || revert) {
285 lnet_net_clr_pref_rtrs(net);
288 lnet_net_lock(LNET_LOCK_EX);
292 /* match. Add to pref NIDs */
293 CDEBUG(D_NET, "udsp net->gw: %s->%s\n",
294 libcfs_net2str(net->net_id),
295 libcfs_nidstr(gw_prim_nid));
296 rc = lnet_net_add_pref_rtr(net, gw_prim_nid);
297 lnet_net_lock(LNET_LOCK_EX);
298 /* success if EEXIST return */
299 if (rc && rc != -EEXIST) {
300 CERROR("Failed to add %s to %s pref rtr list\n",
301 libcfs_nidstr(gw_prim_nid),
302 libcfs_net2str(net->net_id));
313 lnet_udsp_apply_rte_rule_on_nets(struct udsp_info *udi)
316 int last_failure = 0;
317 struct lnet_net *net;
318 struct lnet_ud_nid_descr *match = udi->udi_match;
319 struct lnet_ud_nid_descr *rte_action = udi->udi_action;
321 list_for_each_entry(net, &the_lnet.ln_nets, net_list) {
322 if (LNET_NETTYP(net->net_id) != match->ud_net_id.udn_net_type)
325 rc = cfs_match_net(net->net_id,
326 match->ud_net_id.udn_net_type,
327 &match->ud_net_id.udn_net_num_range);
331 CDEBUG(D_NET, "apply rule on %s\n",
332 libcfs_net2str(net->net_id));
333 rc = lnet_udsp_apply_rte_list_on_net(net, rte_action,
343 lnet_udsp_apply_rte_rule_on_net(struct udsp_info *udi)
346 struct lnet_net *net = udi->udi_net;
347 struct lnet_ud_nid_descr *match = udi->udi_match;
348 struct lnet_ud_nid_descr *rte_action = udi->udi_action;
350 rc = cfs_match_net(net->net_id,
351 match->ud_net_id.udn_net_type,
352 &match->ud_net_id.udn_net_num_range);
356 CDEBUG(D_NET, "apply rule on %s\n",
357 libcfs_net2str(net->net_id));
358 rc = lnet_udsp_apply_rte_list_on_net(net, rte_action,
365 lnet_udsp_apply_prio_rule_on_net(struct udsp_info *udi)
368 struct lnet_ud_nid_descr *match = udi->udi_match;
369 struct lnet_net *net = udi->udi_net;
370 __u32 priority = (udi->udi_revert) ? -1 : udi->udi_priority;
372 if (!lnet_udsp_is_net_rule(match))
373 return RULE_NOT_APPLICABLE;
375 rc = cfs_match_net(net->net_id,
376 match->ud_net_id.udn_net_type,
377 &match->ud_net_id.udn_net_num_range);
381 CDEBUG(D_NET, "apply rule on %s\n",
382 libcfs_net2str(net->net_id));
384 lnet_net_set_sel_priority_locked(net, priority);
390 lnet_udsp_apply_rule_on_nis(struct udsp_info *udi)
394 struct lnet_net *net;
395 struct lnet_ud_nid_descr *ni_match = udi->udi_match;
396 int last_failure = 0;
398 list_for_each_entry(net, &the_lnet.ln_nets, net_list) {
399 if (LNET_NETTYP(net->net_id) != ni_match->ud_net_id.udn_net_type)
403 if (!lnet_udsp_apply_prio_rule_on_net(udi))
406 list_for_each_entry(ni, &net->net_ni_list, ni_netlist) {
408 rc = lnet_udsp_apply_rule_on_ni(udi);
418 lnet_udsp_apply_rte_list_on_lpni(struct lnet_peer_ni *lpni,
419 struct lnet_ud_nid_descr *rte_action,
422 struct lnet_remotenet *rnet;
423 struct list_head *rn_list;
424 struct lnet_route *route;
425 bool cleared = false;
426 struct lnet_nid *gw_nid;
430 for (i = 0; i < LNET_REMOTE_NETS_HASH_SIZE; i++) {
431 rn_list = &the_lnet.ln_remote_nets_hash[i];
432 list_for_each_entry(rnet, rn_list, lrn_list) {
433 list_for_each_entry(route, &rnet->lrn_routes, lr_list) {
434 gw_nid = &route->lr_gateway->lp_primary_nid;
435 rc = cfs_match_nid_net(
437 rte_action->ud_net_id.udn_net_type,
438 &rte_action->ud_net_id.udn_net_num_range,
439 &rte_action->ud_addr_range);
442 lnet_net_unlock(LNET_LOCK_EX);
443 if (!cleared || revert) {
444 CDEBUG(D_NET, "%spref rtr nids from lpni %s\n",
445 (revert) ? "revert " : "clear ",
446 libcfs_nidstr(&lpni->lpni_nid));
447 lnet_peer_clr_pref_rtrs(lpni);
450 lnet_net_lock(LNET_LOCK_EX);
454 CDEBUG(D_NET, "add gw nid %s as preferred for peer %s\n",
455 libcfs_nidstr(gw_nid),
456 libcfs_nidstr(&lpni->lpni_nid));
457 /* match. Add to pref NIDs */
458 rc = lnet_peer_add_pref_rtr(lpni, gw_nid);
459 lnet_net_lock(LNET_LOCK_EX);
460 /* success if EEXIST return */
461 if (rc && rc != -EEXIST) {
462 CERROR("Failed to add %s to %s pref rtr list\n",
463 libcfs_nidstr(gw_nid),
464 libcfs_nidstr(&lpni->lpni_nid));
475 lnet_udsp_apply_ni_list(struct lnet_peer_ni *lpni,
476 struct lnet_ud_nid_descr *ni_action,
481 struct lnet_net *net;
482 bool cleared = false;
484 list_for_each_entry(net, &the_lnet.ln_nets, net_list) {
485 if (LNET_NETTYP(net->net_id) != ni_action->ud_net_id.udn_net_type)
487 list_for_each_entry(ni, &net->net_ni_list, ni_netlist) {
488 rc = cfs_match_nid_net(
490 ni_action->ud_net_id.udn_net_type,
491 &ni_action->ud_net_id.udn_net_num_range,
492 &ni_action->ud_addr_range);
495 lnet_net_unlock(LNET_LOCK_EX);
496 if (!cleared || revert) {
497 lnet_peer_clr_pref_nids(lpni);
498 CDEBUG(D_NET, "%spref nids from lpni %s\n",
499 (revert) ? "revert " : "clear ",
500 libcfs_nidstr(&lpni->lpni_nid));
503 lnet_net_lock(LNET_LOCK_EX);
507 CDEBUG(D_NET, "add nid %s as preferred for peer %s\n",
508 libcfs_nidstr(&ni->ni_nid),
509 libcfs_nidstr(&lpni->lpni_nid));
510 /* match. Add to pref NIDs */
511 rc = lnet_peer_add_pref_nid(lpni, &ni->ni_nid);
512 lnet_net_lock(LNET_LOCK_EX);
513 /* success if EEXIST return */
514 if (rc && rc != -EEXIST) {
515 CERROR("Failed to add %s to %s pref nid list\n",
516 libcfs_nidstr(&ni->ni_nid),
517 libcfs_nidstr(&lpni->lpni_nid));
527 lnet_udsp_apply_rule_on_lpni(struct udsp_info *udi)
530 struct lnet_peer_ni *lpni = udi->udi_lpni;
531 struct lnet_ud_nid_descr *lp_match = udi->udi_match;
532 struct lnet_ud_nid_descr *action = udi->udi_action;
533 __u32 priority = (udi->udi_revert) ? -1 : udi->udi_priority;
534 bool local = udi->udi_local;
535 enum lnet_udsp_action_type type = udi->udi_type;
537 rc = cfs_match_nid_net(
539 lp_match->ud_net_id.udn_net_type,
540 &lp_match->ud_net_id.udn_net_num_range,
541 &lp_match->ud_addr_range);
543 /* check if looking for a net match */
546 lnet_get_list_len(&lp_match->ud_addr_range) ||
547 !cfs_match_net(udi->udi_lpn->lpn_net_id,
548 lp_match->ud_net_id.udn_net_type,
549 &lp_match->ud_net_id.udn_net_num_range))) {
553 if (type == EN_LNET_UDSP_ACTION_PREFERRED_LIST && local) {
554 rc = lnet_udsp_apply_ni_list(lpni, action,
558 } else if (type == EN_LNET_UDSP_ACTION_PREFERRED_LIST &&
560 rc = lnet_udsp_apply_rte_list_on_lpni(lpni, action,
565 lnet_peer_ni_set_selection_priority(lpni, priority);
572 lnet_udsp_apply_rule_on_lpn(struct udsp_info *udi)
575 struct lnet_ud_nid_descr *match = udi->udi_match;
576 struct lnet_peer_net *lpn = udi->udi_lpn;
577 __u32 priority = (udi->udi_revert) ? -1 : udi->udi_priority;
579 if (udi->udi_type == EN_LNET_UDSP_ACTION_PREFERRED_LIST ||
580 !lnet_udsp_is_net_rule(match))
581 return RULE_NOT_APPLICABLE;
583 rc = cfs_match_net(lpn->lpn_net_id,
584 match->ud_net_id.udn_net_type,
585 &match->ud_net_id.udn_net_num_range);
589 CDEBUG(D_NET, "apply rule on lpn %s\n",
590 libcfs_net2str(lpn->lpn_net_id));
591 lnet_peer_net_set_sel_priority_locked(lpn, priority);
597 lnet_udsp_apply_rule_on_lpnis(struct udsp_info *udi)
599 /* iterate over all the peers in the system and find if any of the
600 * peers match the criteria. If they do, clear the preferred list
601 * and add the new list
603 int lncpt = cfs_percpt_number(the_lnet.ln_peer_tables);
604 struct lnet_ud_nid_descr *lp_match = udi->udi_match;
605 struct lnet_peer_table *ptable;
606 struct lnet_peer_net *lpn;
607 struct lnet_peer_ni *lpni;
608 struct lnet_peer *lp;
609 int last_failure = 0;
613 for (cpt = 0; cpt < lncpt; cpt++) {
614 ptable = the_lnet.ln_peer_tables[cpt];
615 list_for_each_entry(lp, &ptable->pt_peer_list, lp_peer_list) {
616 CDEBUG(D_NET, "udsp examining lp %s\n",
617 libcfs_nidstr(&lp->lp_primary_nid));
618 list_for_each_entry(lpn,
621 CDEBUG(D_NET, "udsp examining lpn %s\n",
622 libcfs_net2str(lpn->lpn_net_id));
624 if (LNET_NETTYP(lpn->lpn_net_id) !=
625 lp_match->ud_net_id.udn_net_type)
630 if (!lnet_udsp_apply_rule_on_lpn(udi))
633 list_for_each_entry(lpni,
636 CDEBUG(D_NET, "udsp examining lpni %s\n",
637 libcfs_nidstr(&lpni->lpni_nid));
638 udi->udi_lpni = lpni;
639 rc = lnet_udsp_apply_rule_on_lpni(udi);
651 lnet_udsp_apply_single_policy(struct lnet_udsp *udsp, struct udsp_info *udi,
652 udsp_apply_rule *cbs)
656 if (lnet_udsp_criteria_present(&udsp->udsp_dst) &&
657 lnet_udsp_criteria_present(&udsp->udsp_src)) {
659 if (!cbs[UDSP_APPLY_ON_PEERS])
662 if (udsp->udsp_action_type !=
663 EN_LNET_UDSP_ACTION_PREFERRED_LIST) {
664 CERROR("Bad action type. Expected %d got %d\n",
665 EN_LNET_UDSP_ACTION_PREFERRED_LIST,
666 udsp->udsp_action_type);
669 udi->udi_match = &udsp->udsp_dst;
670 udi->udi_action = &udsp->udsp_src;
671 udi->udi_type = EN_LNET_UDSP_ACTION_PREFERRED_LIST;
672 udi->udi_local = true;
674 CDEBUG(D_NET, "applying udsp (%p) dst->src\n",
676 rc = cbs[UDSP_APPLY_ON_PEERS](udi);
679 } else if (lnet_udsp_criteria_present(&udsp->udsp_dst) &&
680 lnet_udsp_criteria_present(&udsp->udsp_rte)) {
682 if (!cbs[UDSP_APPLY_ON_PEERS])
685 if (udsp->udsp_action_type !=
686 EN_LNET_UDSP_ACTION_PREFERRED_LIST) {
687 CERROR("Bad action type. Expected %d got %d\n",
688 EN_LNET_UDSP_ACTION_PREFERRED_LIST,
689 udsp->udsp_action_type);
693 if (lnet_udsp_criteria_present(&udsp->udsp_src)) {
694 CERROR("only one of src or dst can be specified\n");
697 udi->udi_match = &udsp->udsp_dst;
698 udi->udi_action = &udsp->udsp_rte;
699 udi->udi_type = EN_LNET_UDSP_ACTION_PREFERRED_LIST;
700 udi->udi_local = false;
702 CDEBUG(D_NET, "applying udsp (%p) dst->rte\n",
704 rc = cbs[UDSP_APPLY_ON_PEERS](udi);
707 } else if (lnet_udsp_criteria_present(&udsp->udsp_dst)) {
708 /* destination priority rule */
709 if (!cbs[UDSP_APPLY_ON_PEERS])
712 if (udsp->udsp_action_type !=
713 EN_LNET_UDSP_ACTION_PRIORITY) {
714 CERROR("Bad action type. Expected %d got %d\n",
715 EN_LNET_UDSP_ACTION_PRIORITY,
716 udsp->udsp_action_type);
719 udi->udi_match = &udsp->udsp_dst;
720 udi->udi_type = EN_LNET_UDSP_ACTION_PRIORITY;
721 if (udsp->udsp_action_type !=
722 EN_LNET_UDSP_ACTION_PRIORITY) {
723 udi->udi_priority = 0;
725 udi->udi_priority = udsp->udsp_action.udsp_priority;
727 udi->udi_local = true;
729 CDEBUG(D_NET, "applying udsp (%p) on destination\n",
731 rc = cbs[UDSP_APPLY_ON_PEERS](udi);
734 } else if (lnet_udsp_criteria_present(&udsp->udsp_src)) {
735 /* source priority rule */
736 if (!cbs[UDSP_APPLY_PRIO_ON_NIS])
739 if (udsp->udsp_action_type !=
740 EN_LNET_UDSP_ACTION_PRIORITY) {
741 CERROR("Bad action type. Expected %d got %d\n",
742 EN_LNET_UDSP_ACTION_PRIORITY,
743 udsp->udsp_action_type);
746 udi->udi_match = &udsp->udsp_src;
747 udi->udi_type = EN_LNET_UDSP_ACTION_PRIORITY;
748 if (udsp->udsp_action_type !=
749 EN_LNET_UDSP_ACTION_PRIORITY) {
750 udi->udi_priority = 0;
752 udi->udi_priority = udsp->udsp_action.udsp_priority;
754 udi->udi_local = true;
756 CDEBUG(D_NET, "applying udsp (%p) on source\n",
758 rc = cbs[UDSP_APPLY_PRIO_ON_NIS](udi);
760 CERROR("Bad UDSP policy\n");
768 lnet_udsp_apply_policies_helper(struct lnet_udsp *udsp, struct udsp_info *udi,
769 udsp_apply_rule *cbs)
772 int last_failure = 0;
775 return lnet_udsp_apply_single_policy(udsp, udi, cbs);
777 list_for_each_entry_reverse(udsp,
778 &the_lnet.ln_udsp_list,
780 rc = lnet_udsp_apply_single_policy(udsp, udi, cbs);
789 lnet_udsp_apply_policies_on_ni(struct lnet_ni *ni)
791 struct udsp_info udi;
792 udsp_apply_rule cbs[UDSP_APPLY_MAX_ENUM] = {NULL};
794 memset(&udi, 0, sizeof(udi));
798 cbs[UDSP_APPLY_PRIO_ON_NIS] = lnet_udsp_apply_rule_on_ni;
800 return lnet_udsp_apply_policies_helper(NULL, &udi, cbs);
804 lnet_udsp_apply_policies_on_net(struct lnet_net *net)
806 struct udsp_info udi;
807 udsp_apply_rule cbs[UDSP_APPLY_MAX_ENUM] = {NULL};
809 memset(&udi, 0, sizeof(udi));
813 cbs[UDSP_APPLY_PRIO_ON_NIS] = lnet_udsp_apply_prio_rule_on_net;
814 cbs[UDSP_APPLY_RTE_ON_NETS] = lnet_udsp_apply_rte_rule_on_net;
816 return lnet_udsp_apply_policies_helper(NULL, &udi, cbs);
820 lnet_udsp_apply_policies_on_lpni(struct lnet_peer_ni *lpni)
822 struct udsp_info udi;
823 udsp_apply_rule cbs[UDSP_APPLY_MAX_ENUM] = {NULL};
825 memset(&udi, 0, sizeof(udi));
829 cbs[UDSP_APPLY_ON_PEERS] = lnet_udsp_apply_rule_on_lpni;
831 return lnet_udsp_apply_policies_helper(NULL, &udi, cbs);
835 lnet_udsp_apply_policies_on_lpn(struct lnet_peer_net *lpn)
837 struct udsp_info udi;
838 udsp_apply_rule cbs[UDSP_APPLY_MAX_ENUM] = {NULL};
840 memset(&udi, 0, sizeof(udi));
844 cbs[UDSP_APPLY_ON_PEERS] = lnet_udsp_apply_rule_on_lpn;
846 return lnet_udsp_apply_policies_helper(NULL, &udi, cbs);
850 lnet_udsp_apply_policies(struct lnet_udsp *udsp, bool revert)
853 struct udsp_info udi;
854 udsp_apply_rule cbs[UDSP_APPLY_MAX_ENUM] = {NULL};
856 memset(&udi, 0, sizeof(udi));
858 cbs[UDSP_APPLY_ON_PEERS] = lnet_udsp_apply_rule_on_lpnis;
859 cbs[UDSP_APPLY_PRIO_ON_NIS] = lnet_udsp_apply_rule_on_nis;
860 cbs[UDSP_APPLY_RTE_ON_NETS] = lnet_udsp_apply_rte_rule_on_nets;
862 udi.udi_revert = revert;
864 lnet_net_lock(LNET_LOCK_EX);
865 rc = lnet_udsp_apply_policies_helper(udsp, &udi, cbs);
866 lnet_net_unlock(LNET_LOCK_EX);
872 lnet_udsp_get_policy(int idx)
875 struct lnet_udsp *udsp = NULL;
878 CDEBUG(D_NET, "Get UDSP at idx = %d\n", idx);
883 list_for_each_entry(udsp, &the_lnet.ln_udsp_list, udsp_on_list) {
884 CDEBUG(D_NET, "iterating over upsp %d:%d:%d\n",
885 udsp->udsp_idx, i, idx);
893 CDEBUG(D_NET, "Found UDSP (%p)\n", udsp);
902 lnet_udsp_add_policy(struct lnet_udsp *new, int idx)
904 struct lnet_udsp *udsp;
905 struct lnet_udsp *insert = NULL;
908 list_for_each_entry(udsp, &the_lnet.ln_udsp_list, udsp_on_list) {
909 CDEBUG(D_NET, "found udsp i = %d:%d, idx = %d\n",
910 i, udsp->udsp_idx, idx);
916 if (lnet_udsp_equal(udsp, new)) {
917 if (!lnet_udsp_action_equal(udsp, new) &&
918 udsp->udsp_action_type == EN_LNET_UDSP_ACTION_PRIORITY &&
919 new->udsp_action_type == EN_LNET_UDSP_ACTION_PRIORITY) {
920 udsp->udsp_action.udsp_priority = new->udsp_action.udsp_priority;
921 CDEBUG(D_NET, "udsp: %p index %d updated priority to %d\n",
924 udsp->udsp_action.udsp_priority);
932 list_add(&new->udsp_on_list, insert->udsp_on_list.prev);
934 list_for_each_entry(udsp,
935 &the_lnet.ln_udsp_list,
944 list_add_tail(&new->udsp_on_list, &the_lnet.ln_udsp_list);
948 CDEBUG(D_NET, "udsp: %p added at index %d\n", new, new->udsp_idx);
950 CDEBUG(D_NET, "udsp list:\n");
951 list_for_each_entry(udsp, &the_lnet.ln_udsp_list, udsp_on_list)
952 CDEBUG(D_NET, "udsp %p:%d\n", udsp, udsp->udsp_idx);
958 lnet_udsp_del_policy(int idx)
960 struct lnet_udsp *udsp;
961 struct lnet_udsp *tmp;
962 bool removed = false;
965 lnet_udsp_destroy(false);
969 CDEBUG(D_NET, "del udsp at idx = %d\n", idx);
971 list_for_each_entry_safe(udsp,
973 &the_lnet.ln_udsp_list,
977 if (udsp->udsp_idx == idx && !removed) {
978 list_del_init(&udsp->udsp_on_list);
979 lnet_udsp_apply_policies(udsp, true);
980 lnet_udsp_free(udsp);
989 lnet_udsp_get_ni_info(struct lnet_ioctl_construct_udsp_info *info,
992 struct lnet_nid_list *ne;
993 struct lnet_net *net = ni->ni_net;
998 info->cud_nid_priority = ni->ni_sel_priority;
1000 info->cud_net_priority = ni->ni_net->net_sel_priority;
1001 list_for_each_entry(ne, &net->net_rtr_pref_nids, nl_list) {
1002 if (i < LNET_MAX_SHOW_NUM_NID)
1003 info->cud_pref_rtr_nid[i] =
1004 lnet_nid_to_nid4(&ne->nl_nid);
1013 lnet_udsp_get_peer_info(struct lnet_ioctl_construct_udsp_info *info,
1014 struct lnet_peer_ni *lpni)
1016 struct lnet_nid_list *ne;
1019 /* peer tree structure needs to be in existence */
1020 LASSERT(lpni && lpni->lpni_peer_net &&
1021 lpni->lpni_peer_net->lpn_peer);
1023 info->cud_nid_priority = lpni->lpni_sel_priority;
1024 CDEBUG(D_NET, "lpni %s has %d pref nids\n",
1025 libcfs_nidstr(&lpni->lpni_nid),
1026 lpni->lpni_pref_nnids);
1027 if (lpni->lpni_pref_nnids == 1) {
1028 info->cud_pref_nid[0] = lnet_nid_to_nid4(&lpni->lpni_pref.nid);
1029 } else if (lpni->lpni_pref_nnids > 1) {
1030 struct list_head *list = &lpni->lpni_pref.nids;
1032 list_for_each_entry(ne, list, nl_list) {
1033 if (i < LNET_MAX_SHOW_NUM_NID)
1034 info->cud_pref_nid[i] =
1035 lnet_nid_to_nid4(&ne->nl_nid);
1043 list_for_each_entry(ne, &lpni->lpni_rtr_pref_nids, nl_list) {
1044 if (i < LNET_MAX_SHOW_NUM_NID)
1045 info->cud_pref_rtr_nid[i] =
1046 lnet_nid_to_nid4(&ne->nl_nid);
1052 info->cud_net_priority = lpni->lpni_peer_net->lpn_sel_priority;
1056 lnet_udsp_get_construct_info(struct lnet_ioctl_construct_udsp_info *info)
1059 struct lnet_peer_ni *lpni;
1060 struct lnet_nid nid;
1063 lnet_nid4_to_nid(info->cud_nid, &nid);
1064 if (!info->cud_peer) {
1065 ni = lnet_nid_to_ni_locked(&nid, 0);
1067 lnet_udsp_get_ni_info(info, ni);
1069 lpni = lnet_peer_ni_find_locked(&nid);
1071 CDEBUG(D_NET, "nid %s is not found\n",
1072 libcfs_nidstr(&nid));
1074 lnet_udsp_get_peer_info(info, lpni);
1075 lnet_peer_ni_decref_locked(lpni);
1082 lnet_udsp_alloc(void)
1084 struct lnet_udsp *udsp;
1086 udsp = kmem_cache_alloc(lnet_udsp_cachep, GFP_NOFS | __GFP_ZERO);
1091 INIT_LIST_HEAD(&udsp->udsp_on_list);
1092 INIT_LIST_HEAD(&udsp->udsp_src.ud_addr_range);
1093 INIT_LIST_HEAD(&udsp->udsp_src.ud_net_id.udn_net_num_range);
1094 INIT_LIST_HEAD(&udsp->udsp_dst.ud_addr_range);
1095 INIT_LIST_HEAD(&udsp->udsp_dst.ud_net_id.udn_net_num_range);
1096 INIT_LIST_HEAD(&udsp->udsp_rte.ud_addr_range);
1097 INIT_LIST_HEAD(&udsp->udsp_rte.ud_net_id.udn_net_num_range);
1099 LIBCFS_ALLOC_POST(udsp, sizeof(*udsp), "alloc");
1104 lnet_udsp_nid_descr_free(struct lnet_ud_nid_descr *nid_descr)
1106 struct list_head *net_range = &nid_descr->ud_net_id.udn_net_num_range;
1108 if (!lnet_udsp_criteria_present(nid_descr))
1111 /* memory management is a bit tricky here. When we allocate the
1112 * memory to store the NID descriptor we allocate a large buffer
1113 * for all the data, so we need to free the entire buffer at
1114 * once. If the net is present the net_range->next points to that
1115 * buffer otherwise if the ud_addr_range is present then it's the
1116 * ud_addr_range.next
1118 if (!list_empty(net_range))
1119 LIBCFS_FREE(net_range->next, nid_descr->ud_mem_size);
1120 else if (!list_empty(&nid_descr->ud_addr_range))
1121 LIBCFS_FREE(nid_descr->ud_addr_range.next,
1122 nid_descr->ud_mem_size);
1126 lnet_udsp_free(struct lnet_udsp *udsp)
1128 lnet_udsp_nid_descr_free(&udsp->udsp_src);
1129 lnet_udsp_nid_descr_free(&udsp->udsp_dst);
1130 lnet_udsp_nid_descr_free(&udsp->udsp_rte);
1132 LIBCFS_FREE_PRE(udsp, sizeof(*udsp), "kfreed");
1133 kmem_cache_free(lnet_udsp_cachep, udsp);
1137 lnet_udsp_destroy(bool shutdown)
1139 struct lnet_udsp *udsp, *tmp;
1141 CDEBUG(D_NET, "Destroying UDSPs in the system\n");
1143 list_for_each_entry_safe(udsp, tmp, &the_lnet.ln_udsp_list,
1145 list_del(&udsp->udsp_on_list);
1147 lnet_udsp_apply_policies(udsp, true);
1148 lnet_udsp_free(udsp);
1153 lnet_size_marshaled_nid_descr(struct lnet_ud_nid_descr *descr)
1155 struct cfs_expr_list *expr;
1157 int range_count = 0;
1158 size_t size = sizeof(struct lnet_ioctl_udsp_descr);
1160 if (!lnet_udsp_criteria_present(descr))
1163 /* we always have one net expression */
1164 if (!list_empty(&descr->ud_net_id.udn_net_num_range)) {
1165 expr = list_first_entry(&descr->ud_net_id.udn_net_num_range,
1166 struct cfs_expr_list, el_link);
1168 /* count the number of cfs_range_expr in the net expression */
1169 range_count = lnet_get_list_len(&expr->el_exprs);
1172 /* count the number of cfs_range_expr in the address expressions */
1173 list_for_each_entry(expr, &descr->ud_addr_range, el_link) {
1175 range_count += lnet_get_list_len(&expr->el_exprs);
1178 size += (sizeof(struct lnet_expressions) * expr_count);
1179 size += (sizeof(struct lnet_range_expr) * range_count);
1185 lnet_get_udsp_size(struct lnet_udsp *udsp)
1187 size_t size = sizeof(struct lnet_ioctl_udsp);
1189 size += lnet_size_marshaled_nid_descr(&udsp->udsp_src);
1190 size += lnet_size_marshaled_nid_descr(&udsp->udsp_dst);
1191 size += lnet_size_marshaled_nid_descr(&udsp->udsp_rte);
1193 CDEBUG(D_NET, "get udsp (%p) size: %d\n", udsp, (int)size);
1199 copy_exprs(struct cfs_expr_list *expr, void __user **bulk,
1202 struct cfs_range_expr *range;
1203 struct lnet_range_expr range_expr;
1205 /* copy over the net range expressions to the bulk */
1206 list_for_each_entry(range, &expr->el_exprs, re_link) {
1207 range_expr.re_lo = range->re_lo;
1208 range_expr.re_hi = range->re_hi;
1209 range_expr.re_stride = range->re_stride;
1210 CDEBUG(D_NET, "Copy Range %u:%u:%u\n",
1211 range_expr.re_lo, range_expr.re_hi,
1212 range_expr.re_stride);
1213 if (copy_to_user(*bulk, &range_expr, sizeof(range_expr))) {
1214 CDEBUG(D_NET, "Failed to copy range_expr\n");
1217 *bulk += sizeof(range_expr);
1218 *bulk_size -= sizeof(range_expr);
1225 copy_nid_range(struct lnet_ud_nid_descr *nid_descr, char *type,
1226 void __user **bulk, __u32 *bulk_size)
1228 struct lnet_ioctl_udsp_descr ioc_udsp_descr;
1229 struct cfs_expr_list *expr;
1230 struct lnet_expressions ioc_expr;
1235 memset(&ioc_udsp_descr, 0, sizeof(ioc_udsp_descr));
1236 ioc_udsp_descr.iud_src_hdr.ud_descr_type = *(__u32 *)type;
1238 /* if criteria not present, copy over the static part of the NID
1241 if (!lnet_udsp_criteria_present(nid_descr)) {
1242 CDEBUG(D_NET, "Descriptor %u:%u:%u:%u\n",
1243 ioc_udsp_descr.iud_src_hdr.ud_descr_type,
1244 ioc_udsp_descr.iud_src_hdr.ud_descr_count,
1245 ioc_udsp_descr.iud_net.ud_net_type,
1246 ioc_udsp_descr.iud_net.ud_net_num_expr.le_count);
1247 if (copy_to_user(*bulk, &ioc_udsp_descr,
1248 sizeof(ioc_udsp_descr))) {
1249 CDEBUG(D_NET, "failed to copy ioc_udsp_descr\n");
1252 *bulk += sizeof(ioc_udsp_descr);
1253 *bulk_size -= sizeof(ioc_udsp_descr);
1257 expr_count = lnet_get_list_len(&nid_descr->ud_addr_range);
1259 /* copy the net information */
1260 if (!list_empty(&nid_descr->ud_net_id.udn_net_num_range)) {
1261 expr = list_first_entry(&nid_descr->ud_net_id.udn_net_num_range,
1262 struct cfs_expr_list, el_link);
1263 net_expr_count = lnet_get_list_len(&expr->el_exprs);
1268 /* set the total expression count */
1269 ioc_udsp_descr.iud_src_hdr.ud_descr_count = expr_count;
1270 ioc_udsp_descr.iud_net.ud_net_type =
1271 nid_descr->ud_net_id.udn_net_type;
1272 ioc_udsp_descr.iud_net.ud_net_num_expr.le_count = net_expr_count;
1274 CDEBUG(D_NET, "Descriptor %u:%u:%u:%u\n",
1275 ioc_udsp_descr.iud_src_hdr.ud_descr_type,
1276 ioc_udsp_descr.iud_src_hdr.ud_descr_count,
1277 ioc_udsp_descr.iud_net.ud_net_type,
1278 ioc_udsp_descr.iud_net.ud_net_num_expr.le_count);
1280 /* copy over the header info to the bulk */
1281 if (copy_to_user(*bulk, &ioc_udsp_descr, sizeof(ioc_udsp_descr))) {
1282 CDEBUG(D_NET, "Failed to copy data\n");
1285 *bulk += sizeof(ioc_udsp_descr);
1286 *bulk_size -= sizeof(ioc_udsp_descr);
1288 /* copy over the net num expression if it exists */
1289 if (net_expr_count) {
1290 rc = copy_exprs(expr, bulk, bulk_size);
1295 /* copy the address range */
1296 list_for_each_entry(expr, &nid_descr->ud_addr_range, el_link) {
1297 ioc_expr.le_count = lnet_get_list_len(&expr->el_exprs);
1298 if (copy_to_user(*bulk, &ioc_expr, sizeof(ioc_expr))) {
1299 CDEBUG(D_NET, "failex to copy ioc_expr\n");
1302 *bulk += sizeof(ioc_expr);
1303 *bulk_size -= sizeof(ioc_expr);
1305 rc = copy_exprs(expr, bulk, bulk_size);
1314 lnet_udsp_marshal(struct lnet_udsp *udsp, struct lnet_ioctl_udsp *ioc_udsp)
1323 bulk = ioc_udsp->iou_bulk;
1324 bulk_size = ioc_udsp->iou_hdr.ioc_len +
1325 ioc_udsp->iou_bulk_size;
1327 CDEBUG(D_NET, "marshal udsp (%p)\n", udsp);
1328 CDEBUG(D_NET, "MEM -----> bulk: %p:0x%x\n", bulk, bulk_size);
1329 /* make sure user space allocated enough buffer to marshal the
1332 if (bulk_size != lnet_get_udsp_size(udsp)) {
1337 ioc_udsp->iou_idx = udsp->udsp_idx;
1338 ioc_udsp->iou_action_type = udsp->udsp_action_type;
1339 ioc_udsp->iou_action.priority = udsp->udsp_action.udsp_priority;
1341 bulk_size -= sizeof(*ioc_udsp);
1343 rc = copy_nid_range(&udsp->udsp_src, "SRC", &bulk, &bulk_size);
1347 rc = copy_nid_range(&udsp->udsp_dst, "DST", &bulk, &bulk_size);
1351 rc = copy_nid_range(&udsp->udsp_rte, "RTE", &bulk, &bulk_size);
1355 CDEBUG(D_NET, "MEM <----- bulk: %p\n", bulk);
1357 /* we should've consumed the entire buffer */
1358 LASSERT(bulk_size == 0);
1362 CERROR("Failed to marshal udsp: %d\n", rc);
1367 copy_range_info(void **bulk, void **buf, struct list_head *list,
1370 struct lnet_range_expr *range_expr;
1371 struct cfs_range_expr *range;
1372 struct cfs_expr_list *exprs;
1373 int range_count = count;
1376 if (range_count == 0)
1379 if (range_count == -1) {
1380 struct lnet_expressions *e;
1383 range_count = e->le_count;
1384 *bulk += sizeof(*e);
1388 INIT_LIST_HEAD(&exprs->el_link);
1389 INIT_LIST_HEAD(&exprs->el_exprs);
1390 list_add_tail(&exprs->el_link, list);
1391 *buf += sizeof(*exprs);
1393 for (i = 0; i < range_count; i++) {
1396 INIT_LIST_HEAD(&range->re_link);
1397 range->re_lo = range_expr->re_lo;
1398 range->re_hi = range_expr->re_hi;
1399 range->re_stride = range_expr->re_stride;
1400 CDEBUG(D_NET, "Copy Range %u:%u:%u\n",
1404 list_add_tail(&range->re_link, &exprs->el_exprs);
1405 *bulk += sizeof(*range_expr);
1406 *buf += sizeof(*range);
1411 copy_ioc_udsp_descr(struct lnet_ud_nid_descr *nid_descr, char *type,
1412 void **bulk, __u32 *bulk_size)
1414 struct lnet_ioctl_udsp_descr *ioc_nid = *bulk;
1415 struct lnet_expressions *exprs;
1418 int range_count = 0;
1421 int remaining_size = *bulk_size;
1425 size_t range_expr_s = sizeof(struct lnet_range_expr);
1426 size_t lnet_exprs_s = sizeof(struct lnet_expressions);
1428 CDEBUG(D_NET, "%s: bulk = %p:%u\n", type, *bulk, *bulk_size);
1430 /* criteria not present, skip over the static part of the
1431 * bulk, which is included for each NID descriptor
1433 if (ioc_nid->iud_net.ud_net_type == 0) {
1434 remaining_size -= sizeof(*ioc_nid);
1435 if (remaining_size < 0) {
1436 CERROR("Truncated userspace udsp buffer given\n");
1439 *bulk += sizeof(*ioc_nid);
1440 *bulk_size = remaining_size;
1444 descr_type = ioc_nid->iud_src_hdr.ud_descr_type;
1445 if (descr_type != *(__u32 *)type) {
1446 CERROR("Bad NID descriptor type. Expected %s, given %c%c%c\n",
1447 type, (__u8)descr_type, (__u8)(descr_type << 4),
1448 (__u8)(descr_type << 8));
1452 /* calculate the total size to verify we have enough buffer.
1453 * Start of by finding how many ranges there are for the net
1456 range_count = ioc_nid->iud_net.ud_net_num_expr.le_count;
1457 size = sizeof(*ioc_nid) + (range_count * range_expr_s);
1458 remaining_size -= size;
1459 if (remaining_size < 0) {
1460 CERROR("Truncated userspace udsp buffer given\n");
1464 CDEBUG(D_NET, "Total net num ranges in %s: %d:%u\n", type,
1466 /* the number of expressions for the NID. IE 4 for IP, 1 for GNI */
1467 expr_count = ioc_nid->iud_src_hdr.ud_descr_count;
1468 CDEBUG(D_NET, "addr as %d exprs\n", expr_count);
1469 /* point tmp to the beginning of the NID expressions */
1471 for (i = 0; i < expr_count; i++) {
1472 /* get the number of ranges per expression */
1474 range_count += exprs->le_count;
1475 size = (range_expr_s * exprs->le_count) + lnet_exprs_s;
1476 remaining_size -= size;
1477 CDEBUG(D_NET, "expr %d:%d:%u:%d:%d\n", i, exprs->le_count,
1478 size, remaining_size, range_count);
1479 if (remaining_size < 0) {
1480 CERROR("Truncated userspace udsp buffer given\n");
1486 *bulk_size = remaining_size;
1488 /* copy over the net type */
1489 nid_descr->ud_net_id.udn_net_type = ioc_nid->iud_net.ud_net_type;
1491 CDEBUG(D_NET, "%u\n", nid_descr->ud_net_id.udn_net_type);
1493 /* allocate the total memory required to copy this NID descriptor */
1494 if (ioc_nid->iud_net.ud_net_num_expr.le_count) {
1495 if (ioc_nid->iud_net.ud_net_num_expr.le_count != 1) {
1496 CERROR("Unexpected number of net numeric ranges \"%u\". Cannot add UDSP rule.\n",
1497 ioc_nid->iud_net.ud_net_num_expr.le_count);
1500 alloc_size = (sizeof(struct cfs_expr_list) * (expr_count + 1)) +
1501 (sizeof(struct cfs_range_expr) * (range_count));
1503 alloc_size = (sizeof(struct cfs_expr_list) * (expr_count)) +
1504 (sizeof(struct cfs_range_expr) * (range_count));
1507 LIBCFS_ALLOC(buf, alloc_size);
1511 /* store the amount of memory allocated so we can free it later on */
1512 nid_descr->ud_mem_size = alloc_size;
1514 /* copy over the net number range */
1515 range_count = ioc_nid->iud_net.ud_net_num_expr.le_count;
1516 *bulk += sizeof(*ioc_nid);
1517 CDEBUG(D_NET, "bulk = %p\n", *bulk);
1518 copy_range_info(bulk, &buf, &nid_descr->ud_net_id.udn_net_num_range,
1520 CDEBUG(D_NET, "bulk = %p\n", *bulk);
1522 /* copy over the NID descriptor */
1523 for (i = 0; i < expr_count; i++) {
1524 copy_range_info(bulk, &buf, &nid_descr->ud_addr_range, -1);
1525 CDEBUG(D_NET, "bulk = %p\n", *bulk);
1532 lnet_udsp_demarshal_add(void *bulk, __u32 bulk_size)
1534 struct lnet_ioctl_udsp *ioc_udsp;
1535 struct lnet_udsp *udsp;
1539 if (bulk_size < sizeof(*ioc_udsp))
1542 udsp = lnet_udsp_alloc();
1548 udsp->udsp_action_type = ioc_udsp->iou_action_type;
1549 udsp->udsp_action.udsp_priority = ioc_udsp->iou_action.priority;
1550 idx = ioc_udsp->iou_idx;
1552 CDEBUG(D_NET, "demarshal descr %u:%u:%d:%u\n", udsp->udsp_action_type,
1553 udsp->udsp_action.udsp_priority, idx, bulk_size);
1555 bulk += sizeof(*ioc_udsp);
1556 bulk_size -= sizeof(*ioc_udsp);
1558 rc = copy_ioc_udsp_descr(&udsp->udsp_src, "SRC", &bulk, &bulk_size);
1562 rc = copy_ioc_udsp_descr(&udsp->udsp_dst, "DST", &bulk, &bulk_size);
1566 rc = copy_ioc_udsp_descr(&udsp->udsp_rte, "RTE", &bulk, &bulk_size);
1570 return lnet_udsp_add_policy(udsp, idx);
1573 lnet_udsp_free(udsp);