2 * Route map northbound CLI implementation.
4 * Copyright (C) 2019 Network Device Education Foundation, Inc. ("NetDEF")
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 #include "lib/command.h"
26 #include "lib/northbound_cli.h"
27 #include "lib/routemap.h"
29 #include "lib/routemap_cli_clippy.c"
31 #define ROUTE_MAP_CMD_STR \
32 "Create route-map or enter route-map command mode\n" \
34 #define ROUTE_MAP_OP_CMD_STR \
35 "Route map denies set operations\n" \
36 "Route map permits set operations\n"
37 #define ROUTE_MAP_SEQUENCE_CMD_STR \
38 "Sequence to insert to/delete from existing route-map entry\n"
41 route_map
, route_map_cmd
,
42 "route-map RMAP_NAME$name <deny|permit>$action (1-65535)$sequence",
45 ROUTE_MAP_SEQUENCE_CMD_STR
)
47 char xpath_action
[XPATH_MAXLEN
+ 64];
48 char xpath_index
[XPATH_MAXLEN
+ 32];
49 char xpath
[XPATH_MAXLEN
];
52 snprintf(xpath
, sizeof(xpath
),
53 "/frr-route-map:lib/route-map[name='%s']", name
);
54 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
56 snprintf(xpath_index
, sizeof(xpath_index
), "%s/entry[sequence='%lu']",
58 nb_cli_enqueue_change(vty
, xpath_index
, NB_OP_CREATE
, NULL
);
60 snprintf(xpath_action
, sizeof(xpath_action
), "%s/action", xpath_index
);
61 nb_cli_enqueue_change(vty
, xpath_action
, NB_OP_MODIFY
, action
);
63 rv
= nb_cli_apply_changes(vty
, NULL
);
64 if (rv
== CMD_SUCCESS
)
65 VTY_PUSH_XPATH(RMAP_NODE
, xpath_index
);
71 no_route_map_all
, no_route_map_all_cmd
,
72 "no route-map RMAP_NAME$name",
76 char xpath
[XPATH_MAXLEN
];
78 snprintf(xpath
, sizeof(xpath
),
79 "/frr-route-map:lib/route-map[name='%s']", name
);
80 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
82 return nb_cli_apply_changes(vty
, NULL
);
86 no_route_map
, no_route_map_cmd
,
87 "no route-map RMAP_NAME$name <deny|permit>$action (1-65535)$sequence",
91 ROUTE_MAP_SEQUENCE_CMD_STR
)
93 char xpath
[XPATH_MAXLEN
];
95 snprintf(xpath
, sizeof(xpath
),
96 "/frr-route-map:lib/route-map[name='%s']/entry[sequence='%lu']",
99 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
101 return nb_cli_apply_changes(vty
, NULL
);
104 int route_map_instance_cmp(const struct lyd_node
*dnode1
,
105 const struct lyd_node
*dnode2
)
107 uint16_t seq1
= yang_dnode_get_uint16(dnode1
, "./sequence");
108 uint16_t seq2
= yang_dnode_get_uint16(dnode2
, "./sequence");
113 void route_map_instance_show(struct vty
*vty
, const struct lyd_node
*dnode
,
116 const char *name
= yang_dnode_get_string(dnode
, "../name");
117 const char *action
= yang_dnode_get_string(dnode
, "./action");
118 const char *sequence
= yang_dnode_get_string(dnode
, "./sequence");
120 vty_out(vty
, "route-map %s %s %s\n", name
, action
, sequence
);
124 void route_map_instance_show_end(struct vty
*vty
, const struct lyd_node
*dnode
)
126 vty_out(vty
, "exit\n");
131 match_interface
, match_interface_cmd
,
132 "match interface IFNAME",
134 "Match first hop interface of route\n"
138 "./match-condition[condition='frr-route-map:interface']";
139 char xpath_value
[XPATH_MAXLEN
];
141 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
142 snprintf(xpath_value
, sizeof(xpath_value
),
143 "%s/rmap-match-condition/interface", xpath
);
144 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, ifname
);
146 return nb_cli_apply_changes(vty
, NULL
);
150 no_match_interface
, no_match_interface_cmd
,
151 "no match interface [IFNAME]",
154 "Match first hop interface of route\n"
158 "./match-condition[condition='frr-route-map:interface']";
160 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
162 return nb_cli_apply_changes(vty
, NULL
);
166 match_ip_address
, match_ip_address_cmd
,
167 "match ip address ACCESSLIST4_NAME$name",
170 "Match address of route\n"
171 "IP Access-list name\n")
174 "./match-condition[condition='frr-route-map:ipv4-address-list']";
175 char xpath_value
[XPATH_MAXLEN
+ 32];
177 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
178 snprintf(xpath_value
, sizeof(xpath_value
),
179 "%s/rmap-match-condition/list-name", xpath
);
180 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, name
);
182 return nb_cli_apply_changes(vty
, NULL
);
186 no_match_ip_address
, no_match_ip_address_cmd
,
187 "no match ip address [ACCESSLIST4_NAME]",
191 "Match address of route\n"
192 "IP Access-list name\n")
195 "./match-condition[condition='frr-route-map:ipv4-address-list']";
197 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
199 return nb_cli_apply_changes(vty
, NULL
);
203 match_ip_address_prefix_list
,
204 match_ip_address_prefix_list_cmd
,
205 "match ip address prefix-list PREFIXLIST_NAME$name",
208 "Match address of route\n"
209 "Match entries of prefix-lists\n"
210 "IP prefix-list name\n")
213 "./match-condition[condition='frr-route-map:ipv4-prefix-list']";
214 char xpath_value
[XPATH_MAXLEN
];
216 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
217 snprintf(xpath_value
, sizeof(xpath_value
),
218 "%s/rmap-match-condition/list-name", xpath
);
219 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, name
);
221 return nb_cli_apply_changes(vty
, NULL
);
225 no_match_ip_address_prefix_list
, no_match_ip_address_prefix_list_cmd
,
226 "no match ip address prefix-list [PREFIXLIST_NAME]",
230 "Match address of route\n"
231 "Match entries of prefix-lists\n"
232 "IP prefix-list name\n")
235 "./match-condition[condition='frr-route-map:ipv4-prefix-list']";
237 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
239 return nb_cli_apply_changes(vty
, NULL
);
243 match_ip_next_hop
, match_ip_next_hop_cmd
,
244 "match ip next-hop ACCESSLIST4_NAME$name",
247 "Match next-hop address of route\n"
248 "IP Access-list name\n")
251 "./match-condition[condition='frr-route-map:ipv4-next-hop-list']";
252 char xpath_value
[XPATH_MAXLEN
+ 32];
254 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
255 snprintf(xpath_value
, sizeof(xpath_value
),
256 "%s/rmap-match-condition/list-name", xpath
);
257 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, name
);
259 return nb_cli_apply_changes(vty
, NULL
);
263 no_match_ip_next_hop
, no_match_ip_next_hop_cmd
,
264 "no match ip next-hop [ACCESSLIST4_NAME]",
268 "Match address of route\n"
269 "IP Access-list name\n")
272 "./match-condition[condition='frr-route-map:ipv4-next-hop-list']";
274 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
276 return nb_cli_apply_changes(vty
, NULL
);
280 match_ip_next_hop_prefix_list
,
281 match_ip_next_hop_prefix_list_cmd
,
282 "match ip next-hop prefix-list PREFIXLIST_NAME$name",
285 "Match next-hop address of route\n"
286 "Match entries of prefix-lists\n"
287 "IP prefix-list name\n")
290 "./match-condition[condition='frr-route-map:ipv4-next-hop-prefix-list']";
291 char xpath_value
[XPATH_MAXLEN
];
293 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
294 snprintf(xpath_value
, sizeof(xpath_value
),
295 "%s/rmap-match-condition/list-name", xpath
);
296 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, name
);
298 return nb_cli_apply_changes(vty
, NULL
);
302 no_match_ip_next_hop_prefix_list
,
303 no_match_ip_next_hop_prefix_list_cmd
,
304 "no match ip next-hop prefix-list [PREFIXLIST_NAME]",
308 "Match next-hop address of route\n"
309 "Match entries of prefix-lists\n"
310 "IP prefix-list name\n")
313 "./match-condition[condition='frr-route-map:ipv4-next-hop-prefix-list']";
315 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
317 return nb_cli_apply_changes(vty
, NULL
);
321 match_ip_next_hop_type
, match_ip_next_hop_type_cmd
,
322 "match ip next-hop type <blackhole>$type",
325 "Match next-hop address of route\n"
326 "Match entries by type\n"
330 "./match-condition[condition='frr-route-map:ipv4-next-hop-type']";
331 char xpath_value
[XPATH_MAXLEN
];
333 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
334 snprintf(xpath_value
, sizeof(xpath_value
),
335 "%s/rmap-match-condition/ipv4-next-hop-type", xpath
);
336 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, type
);
338 return nb_cli_apply_changes(vty
, NULL
);
342 no_match_ip_next_hop_type
, no_match_ip_next_hop_type_cmd
,
343 "no match ip next-hop type [<blackhole>]",
344 NO_STR MATCH_STR IP_STR
345 "Match next-hop address of route\n"
346 "Match entries by type\n"
350 "./match-condition[condition='frr-route-map:ipv4-next-hop-type']";
352 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
354 return nb_cli_apply_changes(vty
, NULL
);
358 match_ipv6_address
, match_ipv6_address_cmd
,
359 "match ipv6 address ACCESSLIST6_NAME$name",
362 "Match IPv6 address of route\n"
363 "IPv6 access-list name\n")
366 "./match-condition[condition='frr-route-map:ipv6-address-list']";
367 char xpath_value
[XPATH_MAXLEN
];
369 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
370 snprintf(xpath_value
, sizeof(xpath_value
),
371 "%s/rmap-match-condition/list-name", xpath
);
372 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, name
);
374 return nb_cli_apply_changes(vty
, NULL
);
378 no_match_ipv6_address
, no_match_ipv6_address_cmd
,
379 "no match ipv6 address [ACCESSLIST6_NAME]",
383 "Match IPv6 address of route\n"
384 "IPv6 access-list name\n")
387 "./match-condition[condition='frr-route-map:ipv6-address-list']";
389 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
391 return nb_cli_apply_changes(vty
, NULL
);
395 match_ipv6_address_prefix_list
, match_ipv6_address_prefix_list_cmd
,
396 "match ipv6 address prefix-list PREFIXLIST_NAME$name",
399 "Match address of route\n"
400 "Match entries of prefix-lists\n"
401 "IP prefix-list name\n")
404 "./match-condition[condition='frr-route-map:ipv6-prefix-list']";
405 char xpath_value
[XPATH_MAXLEN
];
407 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
408 snprintf(xpath_value
, sizeof(xpath_value
),
409 "%s/rmap-match-condition/list-name", xpath
);
410 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, name
);
412 return nb_cli_apply_changes(vty
, NULL
);
416 no_match_ipv6_address_prefix_list
,
417 no_match_ipv6_address_prefix_list_cmd
,
418 "no match ipv6 address prefix-list [PREFIXLIST_NAME]",
422 "Match address of route\n"
423 "Match entries of prefix-lists\n"
424 "IP prefix-list name\n")
427 "./match-condition[condition='frr-route-map:ipv6-prefix-list']";
429 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
431 return nb_cli_apply_changes(vty
, NULL
);
435 match_ipv6_next_hop_type
, match_ipv6_next_hop_type_cmd
,
436 "match ipv6 next-hop type <blackhole>$type",
438 "Match next-hop address of route\n"
439 "Match entries by type\n"
443 "./match-condition[condition='frr-route-map:ipv6-next-hop-type']";
444 char xpath_value
[XPATH_MAXLEN
];
446 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
447 snprintf(xpath_value
, sizeof(xpath_value
),
448 "%s/rmap-match-condition/ipv6-next-hop-type", xpath
);
449 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, type
);
451 return nb_cli_apply_changes(vty
, NULL
);
455 no_match_ipv6_next_hop_type
, no_match_ipv6_next_hop_type_cmd
,
456 "no match ipv6 next-hop type [<blackhole>]",
457 NO_STR MATCH_STR IPV6_STR
458 "Match address of route\n"
459 "Match entries by type\n"
463 "./match-condition[condition='frr-route-map:ipv6-next-hop-type']";
465 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
467 return nb_cli_apply_changes(vty
, NULL
);
471 match_metric
, match_metric_cmd
,
472 "match metric (0-4294967295)$metric",
474 "Match metric of route\n"
478 "./match-condition[condition='frr-route-map:match-metric']";
479 char xpath_value
[XPATH_MAXLEN
];
481 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
482 snprintf(xpath_value
, sizeof(xpath_value
),
483 "%s/rmap-match-condition/metric", xpath
);
484 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, metric_str
);
486 return nb_cli_apply_changes(vty
, NULL
);
490 no_match_metric
, no_match_metric_cmd
,
491 "no match metric [(0-4294967295)]",
494 "Match metric of route\n"
498 "./match-condition[condition='frr-route-map:match-metric']";
500 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
502 return nb_cli_apply_changes(vty
, NULL
);
506 match_tag
, match_tag_cmd
,
507 "match tag (1-4294967295)$tag",
509 "Match tag of route\n"
513 "./match-condition[condition='frr-route-map:match-tag']";
514 char xpath_value
[XPATH_MAXLEN
];
516 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
517 snprintf(xpath_value
, sizeof(xpath_value
),
518 "%s/rmap-match-condition/tag", xpath
);
519 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, tag_str
);
521 return nb_cli_apply_changes(vty
, NULL
);
525 no_match_tag
, no_match_tag_cmd
,
526 "no match tag [(1-4294967295)]",
529 "Match tag of route\n"
533 "./match-condition[condition='frr-route-map:match-tag']";
535 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
537 return nb_cli_apply_changes(vty
, NULL
);
540 void route_map_condition_show(struct vty
*vty
, const struct lyd_node
*dnode
,
543 const char *condition
= yang_dnode_get_string(dnode
, "./condition");
544 const struct lyd_node
*ln
;
547 if (IS_MATCH_INTERFACE(condition
)) {
548 vty_out(vty
, " match interface %s\n",
549 yang_dnode_get_string(
550 dnode
, "./rmap-match-condition/interface"));
551 } else if (IS_MATCH_IPv4_ADDRESS_LIST(condition
)) {
552 vty_out(vty
, " match ip address %s\n",
553 yang_dnode_get_string(
554 dnode
, "./rmap-match-condition/list-name"));
555 } else if (IS_MATCH_IPv4_NEXTHOP_LIST(condition
)) {
556 vty_out(vty
, " match ip next-hop %s\n",
557 yang_dnode_get_string(
558 dnode
, "./rmap-match-condition/list-name"));
559 } else if (IS_MATCH_IPv6_NEXTHOP_LIST(condition
)) {
560 vty_out(vty
, " match ipv6 next-hop %s\n",
561 yang_dnode_get_string(
562 dnode
, "./rmap-match-condition/list-name"));
563 } else if (IS_MATCH_IPv4_PREFIX_LIST(condition
)) {
564 vty_out(vty
, " match ip address prefix-list %s\n",
565 yang_dnode_get_string(
566 dnode
, "./rmap-match-condition/list-name"));
567 } else if (IS_MATCH_IPv4_NEXTHOP_PREFIX_LIST(condition
)) {
568 vty_out(vty
, " match ip next-hop prefix-list %s\n",
569 yang_dnode_get_string(
570 dnode
, "./rmap-match-condition/list-name"));
571 } else if (IS_MATCH_IPv6_NEXTHOP_PREFIX_LIST(condition
)) {
572 vty_out(vty
, " match ipv6 next-hop prefix-list %s\n",
573 yang_dnode_get_string(
574 dnode
, "./rmap-match-condition/list-name"));
575 } else if (IS_MATCH_IPv6_ADDRESS_LIST(condition
)) {
576 vty_out(vty
, " match ipv6 address %s\n",
577 yang_dnode_get_string(
578 dnode
, "./rmap-match-condition/list-name"));
579 } else if (IS_MATCH_IPv6_PREFIX_LIST(condition
)) {
580 vty_out(vty
, " match ipv6 address prefix-list %s\n",
581 yang_dnode_get_string(
582 dnode
, "./rmap-match-condition/list-name"));
583 } else if (IS_MATCH_IPv4_NEXTHOP_TYPE(condition
)) {
584 vty_out(vty
, " match ip next-hop type %s\n",
585 yang_dnode_get_string(
587 "./rmap-match-condition/ipv4-next-hop-type"));
588 } else if (IS_MATCH_IPv6_NEXTHOP_TYPE(condition
)) {
589 vty_out(vty
, " match ipv6 next-hop type %s\n",
590 yang_dnode_get_string(
592 "./rmap-match-condition/ipv6-next-hop-type"));
593 } else if (IS_MATCH_METRIC(condition
)) {
594 vty_out(vty
, " match metric %s\n",
595 yang_dnode_get_string(dnode
,
596 "./rmap-match-condition/metric"));
597 } else if (IS_MATCH_TAG(condition
)) {
598 vty_out(vty
, " match tag %s\n",
599 yang_dnode_get_string(dnode
,
600 "./rmap-match-condition/tag"));
601 } else if (IS_MATCH_IPv4_PREFIX_LEN(condition
)) {
602 vty_out(vty
, " match ip address prefix-len %s\n",
603 yang_dnode_get_string(
605 "./rmap-match-condition/frr-zebra-route-map:ipv4-prefix-length"));
606 } else if (IS_MATCH_IPv6_PREFIX_LEN(condition
)) {
607 vty_out(vty
, " match ipv6 address prefix-len %s\n",
608 yang_dnode_get_string(
610 "./rmap-match-condition/frr-zebra-route-map:ipv6-prefix-length"));
611 } else if (IS_MATCH_IPv4_NH_PREFIX_LEN(condition
)) {
612 vty_out(vty
, " match ip next-hop prefix-len %s\n",
613 yang_dnode_get_string(
615 "./rmap-match-condition/frr-zebra-route-map:ipv4-prefix-length"));
616 } else if (IS_MATCH_SRC_PROTO(condition
)) {
617 vty_out(vty
, " match source-protocol %s\n",
618 yang_dnode_get_string(
620 "./rmap-match-condition/frr-zebra-route-map:source-protocol"));
621 } else if (IS_MATCH_SRC_INSTANCE(condition
)) {
622 vty_out(vty
, " match source-instance %s\n",
623 yang_dnode_get_string(
625 "./rmap-match-condition/frr-zebra-route-map:source-instance"));
626 } else if (IS_MATCH_LOCAL_PREF(condition
)) {
627 vty_out(vty
, " match local-preference %s\n",
628 yang_dnode_get_string(
630 "./rmap-match-condition/frr-bgp-route-map:local-preference"));
631 } else if (IS_MATCH_ALIAS(condition
)) {
632 vty_out(vty
, " match alias %s\n",
633 yang_dnode_get_string(
635 "./rmap-match-condition/frr-bgp-route-map:alias"));
636 } else if (IS_MATCH_SCRIPT(condition
)) {
637 vty_out(vty
, " match script %s\n",
638 yang_dnode_get_string(
640 "./rmap-match-condition/frr-bgp-route-map:script"));
641 } else if (IS_MATCH_ORIGIN(condition
)) {
642 vty_out(vty
, " match origin %s\n",
643 yang_dnode_get_string(
645 "./rmap-match-condition/frr-bgp-route-map:origin"));
646 } else if (IS_MATCH_RPKI(condition
)) {
647 vty_out(vty
, " match rpki %s\n",
648 yang_dnode_get_string(
650 "./rmap-match-condition/frr-bgp-route-map:rpki"));
651 } else if (IS_MATCH_RPKI_EXTCOMMUNITY(condition
)) {
652 vty_out(vty
, " match rpki-extcommunity %s\n",
653 yang_dnode_get_string(
655 "./rmap-match-condition/frr-bgp-route-map:rpki-extcommunity"));
656 } else if (IS_MATCH_PROBABILITY(condition
)) {
657 vty_out(vty
, " match probability %s\n",
658 yang_dnode_get_string(
660 "./rmap-match-condition/frr-bgp-route-map:probability"));
661 } else if (IS_MATCH_SRC_VRF(condition
)) {
662 vty_out(vty
, " match source-vrf %s\n",
663 yang_dnode_get_string(
665 "./rmap-match-condition/frr-bgp-route-map:source-vrf"));
666 } else if (IS_MATCH_PEER(condition
)) {
668 if ((ln
= yang_dnode_get(
670 "./rmap-match-condition/frr-bgp-route-map:peer-ipv4-address"))
672 acl
= yang_dnode_get_string(ln
, NULL
);
674 (ln
= yang_dnode_get(
676 "./rmap-match-condition/frr-bgp-route-map:peer-ipv6-address"))
678 acl
= yang_dnode_get_string(ln
, NULL
);
680 (ln
= yang_dnode_get(
682 "./rmap-match-condition/frr-bgp-route-map:peer-interface"))
684 acl
= yang_dnode_get_string(ln
, NULL
);
685 else if (yang_dnode_get(
687 "./rmap-match-condition/frr-bgp-route-map:peer-local")
691 vty_out(vty
, " match peer %s\n", acl
);
692 } else if (IS_MATCH_AS_LIST(condition
)) {
693 vty_out(vty
, " match as-path %s\n",
694 yang_dnode_get_string(
696 "./rmap-match-condition/frr-bgp-route-map:list-name"));
697 } else if (IS_MATCH_EVPN_ROUTE_TYPE(condition
)) {
698 vty_out(vty
, " match evpn route-type %s\n",
699 yang_dnode_get_string(
701 "./rmap-match-condition/frr-bgp-route-map:evpn-route-type"));
702 } else if (IS_MATCH_EVPN_DEFAULT_ROUTE(condition
)) {
703 vty_out(vty
, " match evpn default-route\n");
704 } else if (IS_MATCH_EVPN_VNI(condition
)) {
705 vty_out(vty
, " match evpn vni %s\n",
706 yang_dnode_get_string(
708 "./rmap-match-condition/frr-bgp-route-map:evpn-vni"));
709 } else if (IS_MATCH_EVPN_DEFAULT_ROUTE(condition
)) {
710 vty_out(vty
, " match evpn default-route %s\n",
711 yang_dnode_get_string(
713 "./rmap-match-condition/frr-bgp-route-map:evpn-default-route"));
714 } else if (IS_MATCH_EVPN_RD(condition
)) {
715 vty_out(vty
, " match evpn rd %s\n",
716 yang_dnode_get_string(
718 "./rmap-match-condition/frr-bgp-route-map:route-distinguisher"));
719 } else if (IS_MATCH_MAC_LIST(condition
)) {
720 vty_out(vty
, " match mac address %s\n",
721 yang_dnode_get_string(
723 "./rmap-match-condition/frr-bgp-route-map:list-name"));
724 } else if (IS_MATCH_ROUTE_SRC(condition
)) {
725 vty_out(vty
, " match ip route-source %s\n",
726 yang_dnode_get_string(
728 "./rmap-match-condition/frr-bgp-route-map:list-name"));
729 } else if (IS_MATCH_ROUTE_SRC_PL(condition
)) {
730 vty_out(vty
, " match ip route-source prefix-list %s\n",
731 yang_dnode_get_string(
733 "./rmap-match-condition/frr-bgp-route-map:list-name"));
734 } else if (IS_MATCH_COMMUNITY(condition
)) {
735 vty_out(vty
, " match community %s",
736 yang_dnode_get_string(
738 "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name"));
739 if (yang_dnode_get_bool(
741 "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match"))
742 vty_out(vty
, " exact-match");
744 } else if (IS_MATCH_LCOMMUNITY(condition
)) {
745 vty_out(vty
, " match large-community %s",
746 yang_dnode_get_string(
748 "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name"));
749 if (yang_dnode_get_bool(
751 "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match"))
752 vty_out(vty
, " exact-match");
754 } else if (IS_MATCH_EXTCOMMUNITY(condition
)) {
755 vty_out(vty
, " match extcommunity %s\n",
756 yang_dnode_get_string(
758 "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name"));
759 } else if (IS_MATCH_IPV4_NH(condition
)) {
760 vty_out(vty
, " match ip next-hop address %s\n",
761 yang_dnode_get_string(
763 "./rmap-match-condition/frr-bgp-route-map:ipv4-address"));
764 } else if (IS_MATCH_IPV6_NH(condition
)) {
765 vty_out(vty
, " match ipv6 next-hop address %s\n",
766 yang_dnode_get_string(
768 "./rmap-match-condition/frr-bgp-route-map:ipv6-address"));
773 set_ip_nexthop
, set_ip_nexthop_cmd
,
774 "set ip next-hop A.B.C.D$addr",
778 "IP address of next hop\n")
781 "./set-action[action='frr-route-map:ipv4-next-hop']";
782 char xpath_value
[XPATH_MAXLEN
];
784 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
785 snprintf(xpath_value
, sizeof(xpath_value
),
786 "%s/rmap-set-action/ipv4-address", xpath
);
787 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, addr_str
);
789 return nb_cli_apply_changes(vty
, NULL
);
793 no_set_ip_nexthop
, no_set_ip_nexthop_cmd
,
794 "no set ip next-hop [A.B.C.D]",
799 "IP address of next hop\n")
802 "./set-action[action='frr-route-map:ipv4-next-hop']";
804 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
806 return nb_cli_apply_changes(vty
, NULL
);
810 set_ipv6_nexthop_local
, set_ipv6_nexthop_local_cmd
,
811 "set ipv6 next-hop local X:X::X:X$addr",
814 "IPv6 next-hop address\n"
815 "IPv6 local address\n"
816 "IPv6 address of next hop\n")
819 "./set-action[action='frr-route-map:ipv6-next-hop']";
820 char xpath_value
[XPATH_MAXLEN
];
822 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
823 snprintf(xpath_value
, sizeof(xpath_value
),
824 "%s/rmap-set-action/ipv6-address", xpath
);
825 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, addr_str
);
827 return nb_cli_apply_changes(vty
, NULL
);
831 no_set_ipv6_nexthop_local
, no_set_ipv6_nexthop_local_cmd
,
832 "no set ipv6 next-hop local [X:X::X:X]",
836 "IPv6 next-hop address\n"
837 "IPv6 local address\n"
838 "IPv6 address of next hop\n")
841 "./set-action[action='frr-route-map:ipv6-next-hop']";
843 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
845 return nb_cli_apply_changes(vty
, NULL
);
849 set_metric
, set_metric_cmd
,
850 "set metric <(-4294967295-4294967295)$metric|rtt$rtt|+rtt$artt|-rtt$srtt>",
852 "Metric value for destination routing protocol\n"
853 "Metric value (use +/- for additions or subtractions)\n"
854 "Assign round trip time\n"
855 "Add round trip time\n"
856 "Subtract round trip time\n")
858 const char *xpath
= "./set-action[action='frr-route-map:set-metric']";
859 char xpath_value
[XPATH_MAXLEN
];
862 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
864 snprintf(xpath_value
, sizeof(xpath_value
),
865 "%s/rmap-set-action/use-round-trip-time", xpath
);
866 snprintf(value
, sizeof(value
), "true");
868 snprintf(xpath_value
, sizeof(xpath_value
),
869 "%s/rmap-set-action/add-round-trip-time", xpath
);
870 snprintf(value
, sizeof(value
), "true");
872 snprintf(xpath_value
, sizeof(xpath_value
),
873 "%s/rmap-set-action/subtract-round-trip-time", xpath
);
874 snprintf(value
, sizeof(value
), "true");
875 } else if (metric_str
&& metric_str
[0] == '+') {
876 snprintf(xpath_value
, sizeof(xpath_value
),
877 "%s/rmap-set-action/add-metric", xpath
);
878 snprintf(value
, sizeof(value
), "%s", ++metric_str
);
879 } else if (metric_str
&& metric_str
[0] == '-') {
880 snprintf(xpath_value
, sizeof(xpath_value
),
881 "%s/rmap-set-action/subtract-metric", xpath
);
882 snprintf(value
, sizeof(value
), "%s", ++metric_str
);
884 snprintf(xpath_value
, sizeof(xpath_value
),
885 "%s/rmap-set-action/value", xpath
);
886 snprintf(value
, sizeof(value
), "%s", metric_str
);
888 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, value
);
890 return nb_cli_apply_changes(vty
, NULL
);
894 no_set_metric
, no_set_metric_cmd
,
895 "no set metric [OPTVAL]",
898 "Metric value for destination routing protocol\n"
901 const char *xpath
= "./set-action[action='frr-route-map:set-metric']";
903 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
904 return nb_cli_apply_changes(vty
, NULL
);
908 set_tag
, set_tag_cmd
,
909 "set tag (1-4294967295)$tag",
911 "Tag value for routing protocol\n"
914 const char *xpath
= "./set-action[action='frr-route-map:set-tag']";
915 char xpath_value
[XPATH_MAXLEN
];
917 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
918 snprintf(xpath_value
, sizeof(xpath_value
), "%s/rmap-set-action/tag",
920 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, tag_str
);
922 return nb_cli_apply_changes(vty
, NULL
);
926 no_set_tag
, no_set_tag_cmd
,
927 "no set tag [(1-4294967295)]",
930 "Tag value for routing protocol\n"
933 const char *xpath
= "./set-action[action='frr-route-map:set-tag']";
935 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
937 return nb_cli_apply_changes(vty
, NULL
);
940 DEFUN_YANG (set_srte_color
,
942 "set sr-te color (1-4294967295)",
946 "Color of the SR-TE Policies to match with\n")
949 "./set-action[action='frr-route-map:set-sr-te-color']";
950 char xpath_value
[XPATH_MAXLEN
];
953 char *arg
= argv_find(argv
, argc
, "(1-4294967295)", &idx
)
957 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
958 snprintf(xpath_value
, sizeof(xpath_value
),
959 "%s/rmap-set-action/policy", xpath
);
960 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, arg
);
962 return nb_cli_apply_changes(vty
, NULL
);
965 DEFUN_YANG (no_set_srte_color
,
966 no_set_srte_color_cmd
,
967 "no set sr-te color [(1-4294967295)]",
972 "Color of the SR-TE Policies to match with\n")
975 "./set-action[action='frr-route-map:set-sr-te-color']";
977 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
979 return nb_cli_apply_changes(vty
, NULL
);
983 void route_map_action_show(struct vty
*vty
, const struct lyd_node
*dnode
,
986 const char *action
= yang_dnode_get_string(dnode
, "./action");
987 const struct lyd_node
*ln
;
990 if (IS_SET_IPv4_NH(action
)) {
991 vty_out(vty
, " set ip next-hop %s\n",
992 yang_dnode_get_string(
993 dnode
, "./rmap-set-action/ipv4-address"));
994 } else if (IS_SET_IPv6_NH(action
)) {
995 vty_out(vty
, " set ipv6 next-hop local %s\n",
996 yang_dnode_get_string(
997 dnode
, "./rmap-set-action/ipv6-address"));
998 } else if (IS_SET_METRIC(action
)) {
999 if (yang_dnode_get(dnode
,
1000 "./rmap-set-action/use-round-trip-time")) {
1001 vty_out(vty
, " set metric rtt\n");
1002 } else if (yang_dnode_get(
1004 "./rmap-set-action/add-round-trip-time")) {
1005 vty_out(vty
, " set metric +rtt\n");
1009 "./rmap-set-action/subtract-round-trip-time")) {
1010 vty_out(vty
, " set metric -rtt\n");
1011 } else if (yang_dnode_get(dnode
,
1012 "./rmap-set-action/add-metric")) {
1013 vty_out(vty
, " set metric +%s\n",
1014 yang_dnode_get_string(
1015 dnode
, "./rmap-set-action/add-metric"));
1016 } else if (yang_dnode_get(
1018 "./rmap-set-action/subtract-metric")) {
1019 vty_out(vty
, " set metric -%s\n",
1020 yang_dnode_get_string(
1022 "./rmap-set-action/subtract-metric"));
1024 vty_out(vty
, " set metric %s\n",
1025 yang_dnode_get_string(
1026 dnode
, "./rmap-set-action/value"));
1028 } else if (IS_SET_TAG(action
)) {
1029 vty_out(vty
, " set tag %s\n",
1030 yang_dnode_get_string(dnode
, "./rmap-set-action/tag"));
1031 } else if (IS_SET_SR_TE_COLOR(action
)) {
1032 vty_out(vty
, " set sr-te color %s\n",
1033 yang_dnode_get_string(dnode
,
1034 "./rmap-set-action/policy"));
1035 } else if (IS_SET_SRC(action
)) {
1036 if (yang_dnode_exists(
1038 "./rmap-set-action/frr-zebra-route-map:ipv4-src-address"))
1039 vty_out(vty
, " set src %s\n",
1040 yang_dnode_get_string(
1042 "./rmap-set-action/frr-zebra-route-map:ipv4-src-address"));
1044 vty_out(vty
, " set src %s\n",
1045 yang_dnode_get_string(
1047 "./rmap-set-action/frr-zebra-route-map:ipv6-src-address"));
1048 } else if (IS_SET_METRIC_TYPE(action
)) {
1049 vty_out(vty
, " set metric-type %s\n",
1050 yang_dnode_get_string(
1052 "./rmap-set-action/frr-ospf-route-map:metric-type"));
1053 } else if (IS_SET_FORWARDING_ADDR(action
)) {
1054 vty_out(vty
, " set forwarding-address %s\n",
1055 yang_dnode_get_string(
1057 "./rmap-set-action/frr-ospf6-route-map:ipv6-address"));
1058 } else if (IS_SET_WEIGHT(action
)) {
1059 vty_out(vty
, " set weight %s\n",
1060 yang_dnode_get_string(
1062 "./rmap-set-action/frr-bgp-route-map:weight"));
1063 } else if (IS_SET_TABLE(action
)) {
1064 vty_out(vty
, " set table %s\n",
1065 yang_dnode_get_string(
1067 "./rmap-set-action/frr-bgp-route-map:table"));
1068 } else if (IS_SET_LOCAL_PREF(action
)) {
1069 vty_out(vty
, " set local-preference %s\n",
1070 yang_dnode_get_string(
1072 "./rmap-set-action/frr-bgp-route-map:local-pref"));
1073 } else if (IS_SET_LABEL_INDEX(action
)) {
1074 vty_out(vty
, " set label-index %s\n",
1075 yang_dnode_get_string(
1077 "./rmap-set-action/frr-bgp-route-map:label-index"));
1078 } else if (IS_SET_DISTANCE(action
)) {
1079 vty_out(vty
, " set distance %s\n",
1080 yang_dnode_get_string(
1082 "./rmap-set-action/frr-bgp-route-map:distance"));
1083 } else if (IS_SET_ORIGIN(action
)) {
1084 vty_out(vty
, " set origin %s\n",
1085 yang_dnode_get_string(
1087 "./rmap-set-action/frr-bgp-route-map:origin"));
1088 } else if (IS_SET_ATOMIC_AGGREGATE(action
)) {
1089 vty_out(vty
, " set atomic-aggregate\n");
1090 } else if (IS_SET_AIGP_METRIC(action
)) {
1091 vty_out(vty
, " set aigp-metric %s\n",
1092 yang_dnode_get_string(
1094 "./rmap-set-action/frr-bgp-route-map:aigp-metric"));
1095 } else if (IS_SET_ORIGINATOR_ID(action
)) {
1096 vty_out(vty
, " set originator-id %s\n",
1097 yang_dnode_get_string(
1099 "./rmap-set-action/frr-bgp-route-map:originator-id"));
1100 } else if (IS_SET_COMM_LIST_DEL(action
)) {
1102 if ((ln
= yang_dnode_get(
1104 "./rmap-set-action/frr-bgp-route-map:comm-list-name"))
1106 acl
= yang_dnode_get_string(ln
, NULL
);
1110 vty_out(vty
, " set comm-list %s delete\n", acl
);
1111 } else if (IS_SET_LCOMM_LIST_DEL(action
)) {
1113 if ((ln
= yang_dnode_get(
1115 "./rmap-set-action/frr-bgp-route-map:comm-list-name"))
1117 acl
= yang_dnode_get_string(ln
, NULL
);
1121 vty_out(vty
, " set large-comm-list %s delete\n", acl
);
1122 } else if (IS_SET_LCOMMUNITY(action
)) {
1123 if (yang_dnode_exists(
1125 "./rmap-set-action/frr-bgp-route-map:large-community-string"))
1126 vty_out(vty
, " set large-community %s\n",
1127 yang_dnode_get_string(
1129 "./rmap-set-action/frr-bgp-route-map:large-community-string"));
1132 == yang_dnode_get_bool(
1134 "./rmap-set-action/frr-bgp-route-map:large-community-none"))
1135 vty_out(vty
, " set large-community none\n");
1137 } else if (IS_SET_COMMUNITY(action
)) {
1138 if (yang_dnode_exists(
1140 "./rmap-set-action/frr-bgp-route-map:community-string"))
1141 vty_out(vty
, " set community %s\n",
1142 yang_dnode_get_string(
1144 "./rmap-set-action/frr-bgp-route-map:community-string"));
1147 == yang_dnode_get_bool(
1149 "./rmap-set-action/frr-bgp-route-map:community-none"))
1150 vty_out(vty
, " set community none\n");
1152 } else if (IS_SET_EXTCOMMUNITY_RT(action
)) {
1153 vty_out(vty
, " set extcommunity rt %s\n",
1154 yang_dnode_get_string(
1156 "./rmap-set-action/frr-bgp-route-map:extcommunity-rt"));
1157 } else if (IS_SET_EXTCOMMUNITY_SOO(action
)) {
1158 vty_out(vty
, " set extcommunity soo %s\n",
1159 yang_dnode_get_string(
1161 "./rmap-set-action/frr-bgp-route-map:extcommunity-soo"));
1162 } else if (IS_SET_EXTCOMMUNITY_LB(action
)) {
1163 enum ecommunity_lb_type lb_type
;
1164 char str
[VTY_BUFSIZ
];
1167 lb_type
= yang_dnode_get_enum(
1169 "./rmap-set-action/frr-bgp-route-map:extcommunity-lb/lb-type");
1171 case EXPLICIT_BANDWIDTH
:
1172 bandwidth
= yang_dnode_get_uint16(
1174 "./rmap-set-action/frr-bgp-route-map:extcommunity-lb/bandwidth");
1175 snprintf(str
, sizeof(str
), "%d", bandwidth
);
1177 case CUMULATIVE_BANDWIDTH
:
1178 snprintf(str
, sizeof(str
), "%s", "cumulative");
1180 case COMPUTED_BANDWIDTH
:
1181 snprintf(str
, sizeof(str
), "%s", "num-multipaths");
1184 if (yang_dnode_get_bool(
1186 "./rmap-set-action/frr-bgp-route-map:extcommunity-lb/two-octet-as-specific"))
1187 strlcat(str
, " non-transitive", sizeof(str
));
1189 vty_out(vty
, " set extcommunity bandwidth %s\n", str
);
1190 } else if (IS_SET_EXTCOMMUNITY_NONE(action
)) {
1191 if (yang_dnode_get_bool(
1193 "./rmap-set-action/frr-bgp-route-map:extcommunity-none"))
1194 vty_out(vty
, " set extcommunity none\n");
1195 } else if (IS_SET_AGGREGATOR(action
)) {
1196 vty_out(vty
, " set aggregator as %s %s\n",
1197 yang_dnode_get_string(
1199 "./rmap-set-action/frr-bgp-route-map:aggregator/aggregator-asn"),
1200 yang_dnode_get_string(
1202 "./rmap-set-action/frr-bgp-route-map:aggregator/aggregator-address"));
1203 } else if (IS_SET_AS_EXCLUDE(action
)) {
1204 vty_out(vty
, " set as-path exclude %s\n",
1205 yang_dnode_get_string(
1207 "./rmap-set-action/frr-bgp-route-map:exclude-as-path"));
1208 } else if (IS_SET_AS_REPLACE(action
)) {
1209 vty_out(vty
, " set as-path replace %s\n",
1210 yang_dnode_get_string(
1212 "./rmap-set-action/frr-bgp-route-map:replace-as-path"));
1213 } else if (IS_SET_AS_PREPEND(action
)) {
1214 if (yang_dnode_exists(
1216 "./rmap-set-action/frr-bgp-route-map:prepend-as-path"))
1217 vty_out(vty
, " set as-path prepend %s\n",
1218 yang_dnode_get_string(
1220 "./rmap-set-action/frr-bgp-route-map:prepend-as-path"));
1222 vty_out(vty
, " set as-path prepend last-as %u\n",
1223 yang_dnode_get_uint8(
1225 "./rmap-set-action/frr-bgp-route-map:last-as"));
1227 } else if (IS_SET_IPV6_NH_GLOBAL(action
)) {
1228 vty_out(vty
, " set ipv6 next-hop global %s\n",
1229 yang_dnode_get_string(
1231 "./rmap-set-action/frr-bgp-route-map:ipv6-address"));
1232 } else if (IS_SET_IPV6_VPN_NH(action
)) {
1233 vty_out(vty
, " set ipv6 vpn next-hop %s\n",
1234 yang_dnode_get_string(
1236 "./rmap-set-action/frr-bgp-route-map:ipv6-address"));
1237 } else if (IS_SET_IPV6_PEER_ADDR(action
)) {
1239 == yang_dnode_get_bool(
1241 "./rmap-set-action/frr-bgp-route-map:preference"))
1242 vty_out(vty
, " set ipv6 next-hop peer-address\n");
1243 } else if (IS_SET_IPV6_PREFER_GLOBAL(action
)) {
1245 == yang_dnode_get_bool(
1247 "./rmap-set-action/frr-bgp-route-map:preference"))
1248 vty_out(vty
, " set ipv6 next-hop prefer-global\n");
1249 } else if (IS_SET_IPV4_VPN_NH(action
)) {
1250 vty_out(vty
, " set ipv4 vpn next-hop %s\n",
1251 yang_dnode_get_string(
1253 "./rmap-set-action/frr-bgp-route-map:ipv4-address"));
1254 } else if (IS_SET_BGP_IPV4_NH(action
)) {
1255 vty_out(vty
, " set ip next-hop %s\n",
1256 yang_dnode_get_string(
1258 "./rmap-set-action/frr-bgp-route-map:ipv4-nexthop"));
1259 } else if (IS_SET_BGP_EVPN_GATEWAY_IP_IPV4(action
)) {
1260 vty_out(vty
, " set evpn gateway-ip ipv4 %s\n",
1261 yang_dnode_get_string(
1263 "./rmap-set-action/frr-bgp-route-map:evpn-gateway-ip-ipv4"));
1264 } else if (IS_SET_BGP_EVPN_GATEWAY_IP_IPV6(action
)) {
1265 vty_out(vty
, " set evpn gateway-ip ipv6 %s\n",
1266 yang_dnode_get_string(
1268 "./rmap-set-action/frr-bgp-route-map:evpn-gateway-ip-ipv6"));
1269 } else if (IS_SET_BGP_L3VPN_NEXTHOP_ENCAPSULATION(action
)) {
1270 vty_out(vty
, " set l3vpn next-hop encapsulation %s\n",
1271 yang_dnode_get_string(
1273 "./rmap-set-action/frr-bgp-route-map:l3vpn-nexthop-encapsulation"));
1278 rmap_onmatch_next
, rmap_onmatch_next_cmd
,
1280 "Exit policy on matches\n"
1283 nb_cli_enqueue_change(vty
, "./exit-policy", NB_OP_MODIFY
, "next");
1285 return nb_cli_apply_changes(vty
, NULL
);
1289 no_rmap_onmatch_next
,
1290 no_rmap_onmatch_next_cmd
,
1293 "Exit policy on matches\n"
1296 nb_cli_enqueue_change(vty
, "./exit-policy", NB_OP_DESTROY
, NULL
);
1298 return nb_cli_apply_changes(vty
, NULL
);
1302 rmap_onmatch_goto
, rmap_onmatch_goto_cmd
,
1303 "on-match goto (1-65535)$rm_num",
1304 "Exit policy on matches\n"
1305 "Goto Clause number\n"
1308 nb_cli_enqueue_change(vty
, "./exit-policy", NB_OP_MODIFY
, "goto");
1309 nb_cli_enqueue_change(vty
, "./goto-value", NB_OP_MODIFY
, rm_num_str
);
1311 return nb_cli_apply_changes(vty
, NULL
);
1315 no_rmap_onmatch_goto
, no_rmap_onmatch_goto_cmd
,
1318 "Exit policy on matches\n"
1319 "Goto Clause number\n")
1321 nb_cli_enqueue_change(vty
, "./exit-policy", NB_OP_DESTROY
, NULL
);
1323 return nb_cli_apply_changes(vty
, NULL
);
1326 /* Cisco/GNU Zebra compatibility aliases */
1328 rmap_onmatch_goto
, rmap_continue_cmd
,
1329 "continue (1-65535)$rm_num",
1330 "Continue on a different entry within the route-map\n"
1331 "Route-map entry sequence number\n")
1334 no_rmap_onmatch_goto
, no_rmap_continue_cmd
,
1335 "no continue [(1-65535)]",
1337 "Continue on a different entry within the route-map\n"
1338 "Route-map entry sequence number\n")
1340 void route_map_exit_policy_show(struct vty
*vty
, const struct lyd_node
*dnode
,
1343 int exit_policy
= yang_dnode_get_enum(dnode
, NULL
);
1345 switch (exit_policy
) {
1346 case 0: /* permit-or-deny */
1347 /* NOTHING: default option. */
1350 vty_out(vty
, " on-match next\n");
1353 vty_out(vty
, " on-match goto %s\n",
1354 yang_dnode_get_string(dnode
, "../goto-value"));
1360 rmap_call
, rmap_call_cmd
,
1362 "Jump to another Route-Map after match+set\n"
1363 "Target route-map name\n")
1365 nb_cli_enqueue_change(vty
, "./call", NB_OP_MODIFY
, name
);
1367 return nb_cli_apply_changes(vty
, NULL
);
1371 no_rmap_call
, no_rmap_call_cmd
,
1374 "Jump to another Route-Map after match+set\n"
1375 "Target route-map name\n")
1377 nb_cli_enqueue_change(vty
, "./call", NB_OP_DESTROY
, NULL
);
1379 return nb_cli_apply_changes(vty
, NULL
);
1382 void route_map_call_show(struct vty
*vty
, const struct lyd_node
*dnode
,
1385 vty_out(vty
, " call %s\n", yang_dnode_get_string(dnode
, NULL
));
1389 rmap_description
, rmap_description_cmd
,
1390 "description LINE...",
1391 "Route-map comment\n"
1392 "Comment describing this route-map rule\n")
1397 desc
= argv_concat(argv
, argc
, 1);
1398 nb_cli_enqueue_change(vty
, "./description", NB_OP_MODIFY
, desc
);
1399 rv
= nb_cli_apply_changes(vty
, NULL
);
1400 XFREE(MTYPE_TMP
, desc
);
1405 DEFUN_YANG (no_rmap_description
,
1406 no_rmap_description_cmd
,
1409 "Route-map comment\n")
1411 nb_cli_enqueue_change(vty
, "./description", NB_OP_DESTROY
, NULL
);
1413 return nb_cli_apply_changes(vty
, NULL
);
1416 void route_map_description_show(struct vty
*vty
, const struct lyd_node
*dnode
,
1419 vty_out(vty
, " description %s\n", yang_dnode_get_string(dnode
, NULL
));
1423 route_map_optimization
, route_map_optimization_cmd
,
1424 "[no] route-map RMAP_NAME$name optimization",
1427 "Configure route-map optimization\n")
1429 char xpath
[XPATH_MAXLEN
];
1431 snprintf(xpath
, sizeof(xpath
),
1432 "/frr-route-map:lib/route-map[name='%s']", name
);
1433 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
1436 xpath
, sizeof(xpath
),
1437 "/frr-route-map:lib/route-map[name='%s']/optimization-disabled",
1439 nb_cli_enqueue_change(vty
, xpath
, NB_OP_MODIFY
, no
? "true" : "false");
1441 return nb_cli_apply_changes(vty
, NULL
);
1444 void route_map_optimization_disabled_show(struct vty
*vty
,
1445 const struct lyd_node
*dnode
,
1448 const char *name
= yang_dnode_get_string(dnode
, "../name");
1449 const bool disabled
= yang_dnode_get_bool(dnode
, NULL
);
1451 vty_out(vty
, "%sroute-map %s optimization\n", disabled
? "no " : "",
1455 static int route_map_config_write(struct vty
*vty
)
1457 const struct lyd_node
*dnode
;
1460 dnode
= yang_dnode_get(running_config
->dnode
,
1461 "/frr-route-map:lib");
1463 nb_cli_show_dnode_cmds(vty
, dnode
, false);
1470 /* Route map node structure. */
1471 static int route_map_config_write(struct vty
*vty
);
1472 static struct cmd_node rmap_node
= {
1475 .parent_node
= CONFIG_NODE
,
1476 .prompt
= "%s(config-route-map)# ",
1477 .config_write
= route_map_config_write
,
1480 static void rmap_autocomplete(vector comps
, struct cmd_token
*token
)
1482 struct route_map
*map
;
1484 for (map
= route_map_master
.head
; map
; map
= map
->next
)
1485 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, map
->name
));
1488 static const struct cmd_variable_handler rmap_var_handlers
[] = {
1489 {.varname
= "route_map", .completions
= rmap_autocomplete
},
1490 {.tokenname
= "ROUTEMAP_NAME", .completions
= rmap_autocomplete
},
1491 {.tokenname
= "RMAP_NAME", .completions
= rmap_autocomplete
},
1492 {.completions
= NULL
}
1495 void route_map_cli_init(void)
1497 /* Auto complete handler. */
1498 cmd_variable_handler_register(rmap_var_handlers
);
1501 install_node(&rmap_node
);
1502 install_default(RMAP_NODE
);
1503 install_element(CONFIG_NODE
, &route_map_cmd
);
1504 install_element(CONFIG_NODE
, &no_route_map_cmd
);
1505 install_element(CONFIG_NODE
, &no_route_map_all_cmd
);
1506 install_element(CONFIG_NODE
, &route_map_optimization_cmd
);
1508 /* Install the on-match stuff */
1509 install_element(RMAP_NODE
, &rmap_onmatch_next_cmd
);
1510 install_element(RMAP_NODE
, &no_rmap_onmatch_next_cmd
);
1511 install_element(RMAP_NODE
, &rmap_onmatch_goto_cmd
);
1512 install_element(RMAP_NODE
, &no_rmap_onmatch_goto_cmd
);
1513 install_element(RMAP_NODE
, &rmap_continue_cmd
);
1514 install_element(RMAP_NODE
, &no_rmap_continue_cmd
);
1516 /* Install the call stuff. */
1517 install_element(RMAP_NODE
, &rmap_call_cmd
);
1518 install_element(RMAP_NODE
, &no_rmap_call_cmd
);
1520 /* Install description commands. */
1521 install_element(RMAP_NODE
, &rmap_description_cmd
);
1522 install_element(RMAP_NODE
, &no_rmap_description_cmd
);
1524 /* Install 'match' commands. */
1525 install_element(RMAP_NODE
, &match_interface_cmd
);
1526 install_element(RMAP_NODE
, &no_match_interface_cmd
);
1528 install_element(RMAP_NODE
, &match_ip_address_cmd
);
1529 install_element(RMAP_NODE
, &no_match_ip_address_cmd
);
1531 install_element(RMAP_NODE
, &match_ip_address_prefix_list_cmd
);
1532 install_element(RMAP_NODE
, &no_match_ip_address_prefix_list_cmd
);
1534 install_element(RMAP_NODE
, &match_ip_next_hop_cmd
);
1535 install_element(RMAP_NODE
, &no_match_ip_next_hop_cmd
);
1537 install_element(RMAP_NODE
, &match_ip_next_hop_prefix_list_cmd
);
1538 install_element(RMAP_NODE
, &no_match_ip_next_hop_prefix_list_cmd
);
1540 install_element(RMAP_NODE
, &match_ip_next_hop_type_cmd
);
1541 install_element(RMAP_NODE
, &no_match_ip_next_hop_type_cmd
);
1543 install_element(RMAP_NODE
, &match_ipv6_address_cmd
);
1544 install_element(RMAP_NODE
, &no_match_ipv6_address_cmd
);
1546 install_element(RMAP_NODE
, &match_ipv6_address_prefix_list_cmd
);
1547 install_element(RMAP_NODE
, &no_match_ipv6_address_prefix_list_cmd
);
1549 install_element(RMAP_NODE
, &match_ipv6_next_hop_type_cmd
);
1550 install_element(RMAP_NODE
, &no_match_ipv6_next_hop_type_cmd
);
1552 install_element(RMAP_NODE
, &match_metric_cmd
);
1553 install_element(RMAP_NODE
, &no_match_metric_cmd
);
1555 install_element(RMAP_NODE
, &match_tag_cmd
);
1556 install_element(RMAP_NODE
, &no_match_tag_cmd
);
1558 /* Install 'set' commands. */
1559 install_element(RMAP_NODE
, &set_ip_nexthop_cmd
);
1560 install_element(RMAP_NODE
, &no_set_ip_nexthop_cmd
);
1562 install_element(RMAP_NODE
, &set_ipv6_nexthop_local_cmd
);
1563 install_element(RMAP_NODE
, &no_set_ipv6_nexthop_local_cmd
);
1565 install_element(RMAP_NODE
, &set_metric_cmd
);
1566 install_element(RMAP_NODE
, &no_set_metric_cmd
);
1568 install_element(RMAP_NODE
, &set_tag_cmd
);
1569 install_element(RMAP_NODE
, &no_set_tag_cmd
);
1571 install_element(RMAP_NODE
, &set_srte_color_cmd
);
1572 install_element(RMAP_NODE
, &no_set_srte_color_cmd
);