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 #ifndef VTYSH_EXTRACT_PL
30 #include "lib/routemap_cli_clippy.c"
31 #endif /* VTYSH_EXTRACT_PL */
33 #define ROUTE_MAP_CMD_STR \
34 "Create route-map or enter route-map command mode\n" \
36 #define ROUTE_MAP_OP_CMD_STR \
37 "Route map denies set operations\n" \
38 "Route map permits set operations\n"
39 #define ROUTE_MAP_SEQUENCE_CMD_STR \
40 "Sequence to insert to/delete from existing route-map entry\n"
43 route_map
, route_map_cmd
,
44 "route-map RMAP_NAME$name <deny|permit>$action (1-65535)$sequence",
47 ROUTE_MAP_SEQUENCE_CMD_STR
)
49 char xpath_action
[XPATH_MAXLEN
+ 64];
50 char xpath_index
[XPATH_MAXLEN
+ 32];
51 char xpath
[XPATH_MAXLEN
];
54 snprintf(xpath
, sizeof(xpath
),
55 "/frr-route-map:lib/route-map[name='%s']", name
);
56 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
58 snprintf(xpath_index
, sizeof(xpath_index
), "%s/entry[sequence='%lu']",
60 nb_cli_enqueue_change(vty
, xpath_index
, NB_OP_CREATE
, NULL
);
62 snprintf(xpath_action
, sizeof(xpath_action
), "%s/action", xpath_index
);
63 nb_cli_enqueue_change(vty
, xpath_action
, NB_OP_MODIFY
, action
);
65 rv
= nb_cli_apply_changes(vty
, NULL
);
66 if (rv
== CMD_SUCCESS
)
67 VTY_PUSH_XPATH(RMAP_NODE
, xpath_index
);
73 no_route_map_all
, no_route_map_all_cmd
,
74 "no route-map RMAP_NAME$name",
78 char xpath
[XPATH_MAXLEN
];
80 snprintf(xpath
, sizeof(xpath
),
81 "/frr-route-map:lib/route-map[name='%s']", name
);
82 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
84 return nb_cli_apply_changes(vty
, NULL
);
88 no_route_map
, no_route_map_cmd
,
89 "no route-map RMAP_NAME$name <deny|permit>$action (1-65535)$sequence",
93 ROUTE_MAP_SEQUENCE_CMD_STR
)
95 char xpath
[XPATH_MAXLEN
];
97 snprintf(xpath
, sizeof(xpath
),
98 "/frr-route-map:lib/route-map[name='%s']/entry[sequence='%lu']",
101 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
103 return nb_cli_apply_changes(vty
, NULL
);
106 int route_map_instance_cmp(const struct lyd_node
*dnode1
,
107 const struct lyd_node
*dnode2
)
109 uint16_t seq1
= yang_dnode_get_uint16(dnode1
, "./sequence");
110 uint16_t seq2
= yang_dnode_get_uint16(dnode2
, "./sequence");
115 void route_map_instance_show(struct vty
*vty
, const struct lyd_node
*dnode
,
118 const char *name
= yang_dnode_get_string(dnode
, "../name");
119 const char *action
= yang_dnode_get_string(dnode
, "./action");
120 const char *sequence
= yang_dnode_get_string(dnode
, "./sequence");
122 vty_out(vty
, "route-map %s %s %s\n", name
, action
, sequence
);
126 void route_map_instance_show_end(struct vty
*vty
, const struct lyd_node
*dnode
)
128 vty_out(vty
, "exit\n");
133 match_interface
, match_interface_cmd
,
134 "match interface IFNAME",
136 "Match first hop interface of route\n"
140 "./match-condition[condition='frr-route-map:interface']";
141 char xpath_value
[XPATH_MAXLEN
];
143 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
144 snprintf(xpath_value
, sizeof(xpath_value
),
145 "%s/rmap-match-condition/interface", xpath
);
146 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, ifname
);
148 return nb_cli_apply_changes(vty
, NULL
);
152 no_match_interface
, no_match_interface_cmd
,
153 "no match interface [IFNAME]",
156 "Match first hop interface of route\n"
160 "./match-condition[condition='frr-route-map:interface']";
162 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
164 return nb_cli_apply_changes(vty
, NULL
);
168 match_ip_address
, match_ip_address_cmd
,
169 "match ip address ACCESSLIST4_NAME$name",
172 "Match address of route\n"
173 "IP Access-list name\n")
176 "./match-condition[condition='frr-route-map:ipv4-address-list']";
177 char xpath_value
[XPATH_MAXLEN
+ 32];
179 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
180 snprintf(xpath_value
, sizeof(xpath_value
),
181 "%s/rmap-match-condition/list-name", xpath
);
182 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, name
);
184 return nb_cli_apply_changes(vty
, NULL
);
188 no_match_ip_address
, no_match_ip_address_cmd
,
189 "no match ip address [ACCESSLIST4_NAME]",
193 "Match address of route\n"
194 "IP Access-list name\n")
197 "./match-condition[condition='frr-route-map:ipv4-address-list']";
199 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
201 return nb_cli_apply_changes(vty
, NULL
);
205 match_ip_address_prefix_list
,
206 match_ip_address_prefix_list_cmd
,
207 "match ip address prefix-list PREFIXLIST_NAME$name",
210 "Match address of route\n"
211 "Match entries of prefix-lists\n"
212 "IP prefix-list name\n")
215 "./match-condition[condition='frr-route-map:ipv4-prefix-list']";
216 char xpath_value
[XPATH_MAXLEN
];
218 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
219 snprintf(xpath_value
, sizeof(xpath_value
),
220 "%s/rmap-match-condition/list-name", xpath
);
221 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, name
);
223 return nb_cli_apply_changes(vty
, NULL
);
227 no_match_ip_address_prefix_list
, no_match_ip_address_prefix_list_cmd
,
228 "no match ip address prefix-list [PREFIXLIST_NAME]",
232 "Match address of route\n"
233 "Match entries of prefix-lists\n"
234 "IP prefix-list name\n")
237 "./match-condition[condition='frr-route-map:ipv4-prefix-list']";
239 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
241 return nb_cli_apply_changes(vty
, NULL
);
245 match_ip_next_hop
, match_ip_next_hop_cmd
,
246 "match ip next-hop ACCESSLIST4_NAME$name",
249 "Match next-hop address of route\n"
250 "IP Access-list name\n")
253 "./match-condition[condition='frr-route-map:ipv4-next-hop-list']";
254 char xpath_value
[XPATH_MAXLEN
+ 32];
256 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
257 snprintf(xpath_value
, sizeof(xpath_value
),
258 "%s/rmap-match-condition/list-name", xpath
);
259 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, name
);
261 return nb_cli_apply_changes(vty
, NULL
);
265 no_match_ip_next_hop
, no_match_ip_next_hop_cmd
,
266 "no match ip next-hop [ACCESSLIST4_NAME]",
270 "Match address of route\n"
271 "IP Access-list name\n")
274 "./match-condition[condition='frr-route-map:ipv4-next-hop-list']";
276 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
278 return nb_cli_apply_changes(vty
, NULL
);
282 match_ip_next_hop_prefix_list
,
283 match_ip_next_hop_prefix_list_cmd
,
284 "match ip next-hop prefix-list PREFIXLIST_NAME$name",
287 "Match next-hop address of route\n"
288 "Match entries of prefix-lists\n"
289 "IP prefix-list name\n")
292 "./match-condition[condition='frr-route-map:ipv4-next-hop-prefix-list']";
293 char xpath_value
[XPATH_MAXLEN
];
295 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
296 snprintf(xpath_value
, sizeof(xpath_value
),
297 "%s/rmap-match-condition/list-name", xpath
);
298 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, name
);
300 return nb_cli_apply_changes(vty
, NULL
);
304 no_match_ip_next_hop_prefix_list
,
305 no_match_ip_next_hop_prefix_list_cmd
,
306 "no match ip next-hop prefix-list [PREFIXLIST_NAME]",
310 "Match next-hop address of route\n"
311 "Match entries of prefix-lists\n"
312 "IP prefix-list name\n")
315 "./match-condition[condition='frr-route-map:ipv4-next-hop-prefix-list']";
317 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
319 return nb_cli_apply_changes(vty
, NULL
);
323 match_ip_next_hop_type
, match_ip_next_hop_type_cmd
,
324 "match ip next-hop type <blackhole>$type",
327 "Match next-hop address of route\n"
328 "Match entries by type\n"
332 "./match-condition[condition='frr-route-map:ipv4-next-hop-type']";
333 char xpath_value
[XPATH_MAXLEN
];
335 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
336 snprintf(xpath_value
, sizeof(xpath_value
),
337 "%s/rmap-match-condition/ipv4-next-hop-type", xpath
);
338 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, type
);
340 return nb_cli_apply_changes(vty
, NULL
);
344 no_match_ip_next_hop_type
, no_match_ip_next_hop_type_cmd
,
345 "no match ip next-hop type [<blackhole>]",
346 NO_STR MATCH_STR IP_STR
347 "Match next-hop address of route\n"
348 "Match entries by type\n"
352 "./match-condition[condition='frr-route-map:ipv4-next-hop-type']";
354 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
356 return nb_cli_apply_changes(vty
, NULL
);
360 match_ipv6_address
, match_ipv6_address_cmd
,
361 "match ipv6 address ACCESSLIST6_NAME$name",
364 "Match IPv6 address of route\n"
365 "IPv6 access-list name\n")
368 "./match-condition[condition='frr-route-map:ipv6-address-list']";
369 char xpath_value
[XPATH_MAXLEN
];
371 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
372 snprintf(xpath_value
, sizeof(xpath_value
),
373 "%s/rmap-match-condition/list-name", xpath
);
374 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, name
);
376 return nb_cli_apply_changes(vty
, NULL
);
380 no_match_ipv6_address
, no_match_ipv6_address_cmd
,
381 "no match ipv6 address [ACCESSLIST6_NAME]",
385 "Match IPv6 address of route\n"
386 "IPv6 access-list name\n")
389 "./match-condition[condition='frr-route-map:ipv6-address-list']";
391 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
393 return nb_cli_apply_changes(vty
, NULL
);
397 match_ipv6_address_prefix_list
, match_ipv6_address_prefix_list_cmd
,
398 "match ipv6 address prefix-list PREFIXLIST_NAME$name",
401 "Match address of route\n"
402 "Match entries of prefix-lists\n"
403 "IP prefix-list name\n")
406 "./match-condition[condition='frr-route-map:ipv6-prefix-list']";
407 char xpath_value
[XPATH_MAXLEN
];
409 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
410 snprintf(xpath_value
, sizeof(xpath_value
),
411 "%s/rmap-match-condition/list-name", xpath
);
412 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, name
);
414 return nb_cli_apply_changes(vty
, NULL
);
418 no_match_ipv6_address_prefix_list
,
419 no_match_ipv6_address_prefix_list_cmd
,
420 "no match ipv6 address prefix-list [PREFIXLIST_NAME]",
424 "Match address of route\n"
425 "Match entries of prefix-lists\n"
426 "IP prefix-list name\n")
429 "./match-condition[condition='frr-route-map:ipv6-prefix-list']";
431 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
433 return nb_cli_apply_changes(vty
, NULL
);
437 match_ipv6_next_hop_type
, match_ipv6_next_hop_type_cmd
,
438 "match ipv6 next-hop type <blackhole>$type",
440 "Match next-hop address of route\n"
441 "Match entries by type\n"
445 "./match-condition[condition='frr-route-map:ipv6-next-hop-type']";
446 char xpath_value
[XPATH_MAXLEN
];
448 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
449 snprintf(xpath_value
, sizeof(xpath_value
),
450 "%s/rmap-match-condition/ipv6-next-hop-type", xpath
);
451 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, type
);
453 return nb_cli_apply_changes(vty
, NULL
);
457 no_match_ipv6_next_hop_type
, no_match_ipv6_next_hop_type_cmd
,
458 "no match ipv6 next-hop type [<blackhole>]",
459 NO_STR MATCH_STR IPV6_STR
460 "Match address of route\n"
461 "Match entries by type\n"
465 "./match-condition[condition='frr-route-map:ipv6-next-hop-type']";
467 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
469 return nb_cli_apply_changes(vty
, NULL
);
473 match_metric
, match_metric_cmd
,
474 "match metric (0-4294967295)$metric",
476 "Match metric of route\n"
480 "./match-condition[condition='frr-route-map:match-metric']";
481 char xpath_value
[XPATH_MAXLEN
];
483 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
484 snprintf(xpath_value
, sizeof(xpath_value
),
485 "%s/rmap-match-condition/metric", xpath
);
486 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, metric_str
);
488 return nb_cli_apply_changes(vty
, NULL
);
492 no_match_metric
, no_match_metric_cmd
,
493 "no match metric [(0-4294967295)]",
496 "Match metric of route\n"
500 "./match-condition[condition='frr-route-map:match-metric']";
502 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
504 return nb_cli_apply_changes(vty
, NULL
);
508 match_tag
, match_tag_cmd
,
509 "match tag (1-4294967295)$tag",
511 "Match tag of route\n"
515 "./match-condition[condition='frr-route-map:match-tag']";
516 char xpath_value
[XPATH_MAXLEN
];
518 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
519 snprintf(xpath_value
, sizeof(xpath_value
),
520 "%s/rmap-match-condition/tag", xpath
);
521 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, tag_str
);
523 return nb_cli_apply_changes(vty
, NULL
);
527 no_match_tag
, no_match_tag_cmd
,
528 "no match tag [(1-4294967295)]",
531 "Match tag of route\n"
535 "./match-condition[condition='frr-route-map:match-tag']";
537 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
539 return nb_cli_apply_changes(vty
, NULL
);
542 void route_map_condition_show(struct vty
*vty
, const struct lyd_node
*dnode
,
545 const char *condition
= yang_dnode_get_string(dnode
, "./condition");
546 const struct lyd_node
*ln
;
549 if (IS_MATCH_INTERFACE(condition
)) {
550 vty_out(vty
, " match interface %s\n",
551 yang_dnode_get_string(
552 dnode
, "./rmap-match-condition/interface"));
553 } else if (IS_MATCH_IPv4_ADDRESS_LIST(condition
)) {
554 vty_out(vty
, " match ip address %s\n",
555 yang_dnode_get_string(
556 dnode
, "./rmap-match-condition/list-name"));
557 } else if (IS_MATCH_IPv4_NEXTHOP_LIST(condition
)) {
558 vty_out(vty
, " match ip next-hop %s\n",
559 yang_dnode_get_string(
560 dnode
, "./rmap-match-condition/list-name"));
561 } else if (IS_MATCH_IPv6_NEXTHOP_LIST(condition
)) {
562 vty_out(vty
, " match ipv6 next-hop %s\n",
563 yang_dnode_get_string(
564 dnode
, "./rmap-match-condition/list-name"));
565 } else if (IS_MATCH_IPv4_PREFIX_LIST(condition
)) {
566 vty_out(vty
, " match ip address prefix-list %s\n",
567 yang_dnode_get_string(
568 dnode
, "./rmap-match-condition/list-name"));
569 } else if (IS_MATCH_IPv4_NEXTHOP_PREFIX_LIST(condition
)) {
570 vty_out(vty
, " match ip next-hop prefix-list %s\n",
571 yang_dnode_get_string(
572 dnode
, "./rmap-match-condition/list-name"));
573 } else if (IS_MATCH_IPv6_NEXTHOP_PREFIX_LIST(condition
)) {
574 vty_out(vty
, " match ipv6 next-hop prefix-list %s\n",
575 yang_dnode_get_string(
576 dnode
, "./rmap-match-condition/list-name"));
577 } else if (IS_MATCH_IPv6_ADDRESS_LIST(condition
)) {
578 vty_out(vty
, " match ipv6 address %s\n",
579 yang_dnode_get_string(
580 dnode
, "./rmap-match-condition/list-name"));
581 } else if (IS_MATCH_IPv6_PREFIX_LIST(condition
)) {
582 vty_out(vty
, " match ipv6 address prefix-list %s\n",
583 yang_dnode_get_string(
584 dnode
, "./rmap-match-condition/list-name"));
585 } else if (IS_MATCH_IPv4_NEXTHOP_TYPE(condition
)) {
586 vty_out(vty
, " match ip next-hop type %s\n",
587 yang_dnode_get_string(
589 "./rmap-match-condition/ipv4-next-hop-type"));
590 } else if (IS_MATCH_IPv6_NEXTHOP_TYPE(condition
)) {
591 vty_out(vty
, " match ipv6 next-hop type %s\n",
592 yang_dnode_get_string(
594 "./rmap-match-condition/ipv6-next-hop-type"));
595 } else if (IS_MATCH_METRIC(condition
)) {
596 vty_out(vty
, " match metric %s\n",
597 yang_dnode_get_string(dnode
,
598 "./rmap-match-condition/metric"));
599 } else if (IS_MATCH_TAG(condition
)) {
600 vty_out(vty
, " match tag %s\n",
601 yang_dnode_get_string(dnode
,
602 "./rmap-match-condition/tag"));
603 } else if (IS_MATCH_IPv4_PREFIX_LEN(condition
)) {
604 vty_out(vty
, " match ip address prefix-len %s\n",
605 yang_dnode_get_string(
607 "./rmap-match-condition/frr-zebra-route-map:ipv4-prefix-length"));
608 } else if (IS_MATCH_IPv6_PREFIX_LEN(condition
)) {
609 vty_out(vty
, " match ipv6 address prefix-len %s\n",
610 yang_dnode_get_string(
612 "./rmap-match-condition/frr-zebra-route-map:ipv6-prefix-length"));
613 } else if (IS_MATCH_IPv4_NH_PREFIX_LEN(condition
)) {
614 vty_out(vty
, " match ip next-hop prefix-len %s\n",
615 yang_dnode_get_string(
617 "./rmap-match-condition/frr-zebra-route-map:ipv4-prefix-length"));
618 } else if (IS_MATCH_SRC_PROTO(condition
)) {
619 vty_out(vty
, " match source-protocol %s\n",
620 yang_dnode_get_string(
622 "./rmap-match-condition/frr-zebra-route-map:source-protocol"));
623 } else if (IS_MATCH_SRC_INSTANCE(condition
)) {
624 vty_out(vty
, " match source-instance %s\n",
625 yang_dnode_get_string(
627 "./rmap-match-condition/frr-zebra-route-map:source-instance"));
628 } else if (IS_MATCH_LOCAL_PREF(condition
)) {
629 vty_out(vty
, " match local-preference %s\n",
630 yang_dnode_get_string(
632 "./rmap-match-condition/frr-bgp-route-map:local-preference"));
633 } else if (IS_MATCH_ALIAS(condition
)) {
634 vty_out(vty
, " match alias %s\n",
635 yang_dnode_get_string(
637 "./rmap-match-condition/frr-bgp-route-map:alias"));
638 } else if (IS_MATCH_SCRIPT(condition
)) {
639 vty_out(vty
, " match script %s\n",
640 yang_dnode_get_string(
642 "./rmap-match-condition/frr-bgp-route-map:script"));
643 } else if (IS_MATCH_ORIGIN(condition
)) {
644 vty_out(vty
, " match origin %s\n",
645 yang_dnode_get_string(
647 "./rmap-match-condition/frr-bgp-route-map:origin"));
648 } else if (IS_MATCH_RPKI(condition
)) {
649 vty_out(vty
, " match rpki %s\n",
650 yang_dnode_get_string(
652 "./rmap-match-condition/frr-bgp-route-map:rpki"));
653 } else if (IS_MATCH_PROBABILITY(condition
)) {
654 vty_out(vty
, " match probability %s\n",
655 yang_dnode_get_string(
657 "./rmap-match-condition/frr-bgp-route-map:probability"));
658 } else if (IS_MATCH_SRC_VRF(condition
)) {
659 vty_out(vty
, " match source-vrf %s\n",
660 yang_dnode_get_string(
662 "./rmap-match-condition/frr-bgp-route-map:source-vrf"));
663 } else if (IS_MATCH_PEER(condition
)) {
665 if ((ln
= yang_dnode_get(
667 "./rmap-match-condition/frr-bgp-route-map:peer-ipv4-address"))
669 acl
= yang_dnode_get_string(ln
, NULL
);
671 (ln
= yang_dnode_get(
673 "./rmap-match-condition/frr-bgp-route-map:peer-ipv6-address"))
675 acl
= yang_dnode_get_string(ln
, NULL
);
677 (ln
= yang_dnode_get(
679 "./rmap-match-condition/frr-bgp-route-map:peer-interface"))
681 acl
= yang_dnode_get_string(ln
, NULL
);
682 else if (yang_dnode_get(
684 "./rmap-match-condition/frr-bgp-route-map:peer-local")
688 vty_out(vty
, " match peer %s\n", acl
);
689 } else if (IS_MATCH_AS_LIST(condition
)) {
690 vty_out(vty
, " match as-path %s\n",
691 yang_dnode_get_string(
693 "./rmap-match-condition/frr-bgp-route-map:list-name"));
694 } else if (IS_MATCH_EVPN_ROUTE_TYPE(condition
)) {
695 vty_out(vty
, " match evpn route-type %s\n",
696 yang_dnode_get_string(
698 "./rmap-match-condition/frr-bgp-route-map:evpn-route-type"));
699 } else if (IS_MATCH_EVPN_DEFAULT_ROUTE(condition
)) {
700 vty_out(vty
, " match evpn default-route\n");
701 } else if (IS_MATCH_EVPN_VNI(condition
)) {
702 vty_out(vty
, " match evpn vni %s\n",
703 yang_dnode_get_string(
705 "./rmap-match-condition/frr-bgp-route-map:evpn-vni"));
706 } else if (IS_MATCH_EVPN_DEFAULT_ROUTE(condition
)) {
707 vty_out(vty
, " match evpn default-route %s\n",
708 yang_dnode_get_string(
710 "./rmap-match-condition/frr-bgp-route-map:evpn-default-route"));
711 } else if (IS_MATCH_EVPN_RD(condition
)) {
712 vty_out(vty
, " match evpn rd %s\n",
713 yang_dnode_get_string(
715 "./rmap-match-condition/frr-bgp-route-map:route-distinguisher"));
716 } else if (IS_MATCH_MAC_LIST(condition
)) {
717 vty_out(vty
, " match mac address %s\n",
718 yang_dnode_get_string(
720 "./rmap-match-condition/frr-bgp-route-map:list-name"));
721 } else if (IS_MATCH_ROUTE_SRC(condition
)) {
722 vty_out(vty
, " match ip route-source %s\n",
723 yang_dnode_get_string(
725 "./rmap-match-condition/frr-bgp-route-map:list-name"));
726 } else if (IS_MATCH_ROUTE_SRC_PL(condition
)) {
727 vty_out(vty
, " match ip route-source prefix-list %s\n",
728 yang_dnode_get_string(
730 "./rmap-match-condition/frr-bgp-route-map:list-name"));
731 } else if (IS_MATCH_COMMUNITY(condition
)) {
732 vty_out(vty
, " match community %s",
733 yang_dnode_get_string(
735 "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name"));
736 if (yang_dnode_get_bool(
738 "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match"))
739 vty_out(vty
, " exact-match");
741 } else if (IS_MATCH_LCOMMUNITY(condition
)) {
742 vty_out(vty
, " match large-community %s",
743 yang_dnode_get_string(
745 "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name"));
746 if (yang_dnode_get_bool(
748 "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match"))
749 vty_out(vty
, " exact-match");
751 } else if (IS_MATCH_EXTCOMMUNITY(condition
)) {
752 vty_out(vty
, " match extcommunity %s\n",
753 yang_dnode_get_string(
755 "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name"));
756 } else if (IS_MATCH_IPV4_NH(condition
)) {
757 vty_out(vty
, " match ip next-hop address %s\n",
758 yang_dnode_get_string(
760 "./rmap-match-condition/frr-bgp-route-map:ipv4-address"));
761 } else if (IS_MATCH_IPV6_NH(condition
)) {
762 vty_out(vty
, " match ipv6 next-hop address %s\n",
763 yang_dnode_get_string(
765 "./rmap-match-condition/frr-bgp-route-map:ipv6-address"));
770 set_ip_nexthop
, set_ip_nexthop_cmd
,
771 "set ip next-hop A.B.C.D$addr",
775 "IP address of next hop\n")
778 "./set-action[action='frr-route-map:ipv4-next-hop']";
779 char xpath_value
[XPATH_MAXLEN
];
781 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
782 snprintf(xpath_value
, sizeof(xpath_value
),
783 "%s/rmap-set-action/ipv4-address", xpath
);
784 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, addr_str
);
786 return nb_cli_apply_changes(vty
, NULL
);
790 no_set_ip_nexthop
, no_set_ip_nexthop_cmd
,
791 "no set ip next-hop [A.B.C.D]",
796 "IP address of next hop\n")
799 "./set-action[action='frr-route-map:ipv4-next-hop']";
801 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
803 return nb_cli_apply_changes(vty
, NULL
);
807 set_ipv6_nexthop_local
, set_ipv6_nexthop_local_cmd
,
808 "set ipv6 next-hop local X:X::X:X$addr",
811 "IPv6 next-hop address\n"
812 "IPv6 local address\n"
813 "IPv6 address of next hop\n")
816 "./set-action[action='frr-route-map:ipv6-next-hop']";
817 char xpath_value
[XPATH_MAXLEN
];
819 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
820 snprintf(xpath_value
, sizeof(xpath_value
),
821 "%s/rmap-set-action/ipv6-address", xpath
);
822 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, addr_str
);
824 return nb_cli_apply_changes(vty
, NULL
);
828 no_set_ipv6_nexthop_local
, no_set_ipv6_nexthop_local_cmd
,
829 "no set ipv6 next-hop local [X:X::X:X]",
833 "IPv6 next-hop address\n"
834 "IPv6 local address\n"
835 "IPv6 address of next hop\n")
838 "./set-action[action='frr-route-map:ipv6-next-hop']";
840 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
842 return nb_cli_apply_changes(vty
, NULL
);
846 set_metric
, set_metric_cmd
,
847 "set metric <(-4294967295-4294967295)$metric|rtt$rtt|+rtt$artt|-rtt$srtt>",
849 "Metric value for destination routing protocol\n"
850 "Metric value (use +/- for additions or subtractions)\n"
851 "Assign round trip time\n"
852 "Add round trip time\n"
853 "Subtract round trip time\n")
855 const char *xpath
= "./set-action[action='frr-route-map:set-metric']";
856 char xpath_value
[XPATH_MAXLEN
];
859 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
861 snprintf(xpath_value
, sizeof(xpath_value
),
862 "%s/rmap-set-action/use-round-trip-time", xpath
);
863 snprintf(value
, sizeof(value
), "true");
865 snprintf(xpath_value
, sizeof(xpath_value
),
866 "%s/rmap-set-action/add-round-trip-time", xpath
);
867 snprintf(value
, sizeof(value
), "true");
869 snprintf(xpath_value
, sizeof(xpath_value
),
870 "%s/rmap-set-action/subtract-round-trip-time", xpath
);
871 snprintf(value
, sizeof(value
), "true");
872 } else if (metric_str
&& metric_str
[0] == '+') {
873 snprintf(xpath_value
, sizeof(xpath_value
),
874 "%s/rmap-set-action/add-metric", xpath
);
875 snprintf(value
, sizeof(value
), "%s", ++metric_str
);
876 } else if (metric_str
&& metric_str
[0] == '-') {
877 snprintf(xpath_value
, sizeof(xpath_value
),
878 "%s/rmap-set-action/subtract-metric", xpath
);
879 snprintf(value
, sizeof(value
), "%s", ++metric_str
);
881 snprintf(xpath_value
, sizeof(xpath_value
),
882 "%s/rmap-set-action/value", xpath
);
883 snprintf(value
, sizeof(value
), "%s", metric_str
);
885 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, value
);
887 return nb_cli_apply_changes(vty
, NULL
);
891 no_set_metric
, no_set_metric_cmd
,
892 "no set metric [OPTVAL]",
895 "Metric value for destination routing protocol\n"
898 const char *xpath
= "./set-action[action='frr-route-map:set-metric']";
900 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
901 return nb_cli_apply_changes(vty
, NULL
);
905 set_tag
, set_tag_cmd
,
906 "set tag (1-4294967295)$tag",
908 "Tag value for routing protocol\n"
911 const char *xpath
= "./set-action[action='frr-route-map:set-tag']";
912 char xpath_value
[XPATH_MAXLEN
];
914 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
915 snprintf(xpath_value
, sizeof(xpath_value
), "%s/rmap-set-action/tag",
917 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, tag_str
);
919 return nb_cli_apply_changes(vty
, NULL
);
923 no_set_tag
, no_set_tag_cmd
,
924 "no set tag [(1-4294967295)]",
927 "Tag value for routing protocol\n"
930 const char *xpath
= "./set-action[action='frr-route-map:set-tag']";
932 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
934 return nb_cli_apply_changes(vty
, NULL
);
937 DEFUN_YANG (set_srte_color
,
939 "set sr-te color (1-4294967295)",
943 "Color of the SR-TE Policies to match with\n")
946 "./set-action[action='frr-route-map:set-sr-te-color']";
947 char xpath_value
[XPATH_MAXLEN
];
950 char *arg
= argv_find(argv
, argc
, "(1-4294967295)", &idx
)
954 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
955 snprintf(xpath_value
, sizeof(xpath_value
),
956 "%s/rmap-set-action/policy", xpath
);
957 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, arg
);
959 return nb_cli_apply_changes(vty
, NULL
);
962 DEFUN_YANG (no_set_srte_color
,
963 no_set_srte_color_cmd
,
964 "no set sr-te color [(1-4294967295)]",
969 "Color of the SR-TE Policies to match with\n")
972 "./set-action[action='frr-route-map:set-sr-te-color']";
974 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
976 return nb_cli_apply_changes(vty
, NULL
);
980 void route_map_action_show(struct vty
*vty
, const struct lyd_node
*dnode
,
983 const char *action
= yang_dnode_get_string(dnode
, "./action");
984 const struct lyd_node
*ln
;
987 if (IS_SET_IPv4_NH(action
)) {
988 vty_out(vty
, " set ip next-hop %s\n",
989 yang_dnode_get_string(
990 dnode
, "./rmap-set-action/ipv4-address"));
991 } else if (IS_SET_IPv6_NH(action
)) {
992 vty_out(vty
, " set ipv6 next-hop local %s\n",
993 yang_dnode_get_string(
994 dnode
, "./rmap-set-action/ipv6-address"));
995 } else if (IS_SET_METRIC(action
)) {
996 if (yang_dnode_get(dnode
,
997 "./rmap-set-action/use-round-trip-time")) {
998 vty_out(vty
, " set metric rtt\n");
999 } else if (yang_dnode_get(
1001 "./rmap-set-action/add-round-trip-time")) {
1002 vty_out(vty
, " set metric +rtt\n");
1006 "./rmap-set-action/subtract-round-trip-time")) {
1007 vty_out(vty
, " set metric -rtt\n");
1008 } else if (yang_dnode_get(dnode
,
1009 "./rmap-set-action/add-metric")) {
1010 vty_out(vty
, " set metric +%s\n",
1011 yang_dnode_get_string(
1012 dnode
, "./rmap-set-action/add-metric"));
1013 } else if (yang_dnode_get(
1015 "./rmap-set-action/subtract-metric")) {
1016 vty_out(vty
, " set metric -%s\n",
1017 yang_dnode_get_string(
1019 "./rmap-set-action/subtract-metric"));
1021 vty_out(vty
, " set metric %s\n",
1022 yang_dnode_get_string(
1023 dnode
, "./rmap-set-action/value"));
1025 } else if (IS_SET_TAG(action
)) {
1026 vty_out(vty
, " set tag %s\n",
1027 yang_dnode_get_string(dnode
, "./rmap-set-action/tag"));
1028 } else if (IS_SET_SR_TE_COLOR(action
)) {
1029 vty_out(vty
, " set sr-te color %s\n",
1030 yang_dnode_get_string(dnode
,
1031 "./rmap-set-action/policy"));
1032 } else if (IS_SET_SRC(action
)) {
1033 if (yang_dnode_exists(
1035 "./rmap-set-action/frr-zebra-route-map:ipv4-src-address"))
1036 vty_out(vty
, " set src %s\n",
1037 yang_dnode_get_string(
1039 "./rmap-set-action/frr-zebra-route-map:ipv4-src-address"));
1041 vty_out(vty
, " set src %s\n",
1042 yang_dnode_get_string(
1044 "./rmap-set-action/frr-zebra-route-map:ipv6-src-address"));
1045 } else if (IS_SET_METRIC_TYPE(action
)) {
1046 vty_out(vty
, " set metric-type %s\n",
1047 yang_dnode_get_string(
1049 "./rmap-set-action/frr-ospf-route-map:metric-type"));
1050 } else if (IS_SET_FORWARDING_ADDR(action
)) {
1051 vty_out(vty
, " set forwarding-address %s\n",
1052 yang_dnode_get_string(
1054 "./rmap-set-action/frr-ospf6-route-map:ipv6-address"));
1055 } else if (IS_SET_WEIGHT(action
)) {
1056 vty_out(vty
, " set weight %s\n",
1057 yang_dnode_get_string(
1059 "./rmap-set-action/frr-bgp-route-map:weight"));
1060 } else if (IS_SET_TABLE(action
)) {
1061 vty_out(vty
, " set table %s\n",
1062 yang_dnode_get_string(
1064 "./rmap-set-action/frr-bgp-route-map:table"));
1065 } else if (IS_SET_LOCAL_PREF(action
)) {
1066 vty_out(vty
, " set local-preference %s\n",
1067 yang_dnode_get_string(
1069 "./rmap-set-action/frr-bgp-route-map:local-pref"));
1070 } else if (IS_SET_LABEL_INDEX(action
)) {
1071 vty_out(vty
, " set label-index %s\n",
1072 yang_dnode_get_string(
1074 "./rmap-set-action/frr-bgp-route-map:label-index"));
1075 } else if (IS_SET_DISTANCE(action
)) {
1076 vty_out(vty
, " set distance %s\n",
1077 yang_dnode_get_string(
1079 "./rmap-set-action/frr-bgp-route-map:distance"));
1080 } else if (IS_SET_ORIGIN(action
)) {
1081 vty_out(vty
, " set origin %s\n",
1082 yang_dnode_get_string(
1084 "./rmap-set-action/frr-bgp-route-map:origin"));
1085 } else if (IS_SET_ATOMIC_AGGREGATE(action
)) {
1086 vty_out(vty
, " set atomic-aggregate\n");
1087 } else if (IS_SET_ORIGINATOR_ID(action
)) {
1088 vty_out(vty
, " set originator-id %s\n",
1089 yang_dnode_get_string(
1091 "./rmap-set-action/frr-bgp-route-map:originator-id"));
1092 } else if (IS_SET_COMM_LIST_DEL(action
)) {
1094 if ((ln
= yang_dnode_get(
1096 "./rmap-set-action/frr-bgp-route-map:comm-list-name"))
1098 acl
= yang_dnode_get_string(ln
, NULL
);
1102 vty_out(vty
, " set comm-list %s delete\n", acl
);
1103 } else if (IS_SET_LCOMM_LIST_DEL(action
)) {
1105 if ((ln
= yang_dnode_get(
1107 "./rmap-set-action/frr-bgp-route-map:comm-list-name"))
1109 acl
= yang_dnode_get_string(ln
, NULL
);
1113 vty_out(vty
, " set large-comm-list %s delete\n", acl
);
1114 } else if (IS_SET_LCOMMUNITY(action
)) {
1115 if (yang_dnode_exists(
1117 "./rmap-set-action/frr-bgp-route-map:large-community-string"))
1118 vty_out(vty
, " set large-community %s\n",
1119 yang_dnode_get_string(
1121 "./rmap-set-action/frr-bgp-route-map:large-community-string"));
1124 == yang_dnode_get_bool(
1126 "./rmap-set-action/frr-bgp-route-map:large-community-none"))
1127 vty_out(vty
, " set large-community none\n");
1129 } else if (IS_SET_COMMUNITY(action
)) {
1130 if (yang_dnode_exists(
1132 "./rmap-set-action/frr-bgp-route-map:community-string"))
1133 vty_out(vty
, " set community %s\n",
1134 yang_dnode_get_string(
1136 "./rmap-set-action/frr-bgp-route-map:community-string"));
1139 == yang_dnode_get_bool(
1141 "./rmap-set-action/frr-bgp-route-map:community-none"))
1142 vty_out(vty
, " set community none\n");
1144 } else if (IS_SET_EXTCOMMUNITY_RT(action
)) {
1145 vty_out(vty
, " set extcommunity rt %s\n",
1146 yang_dnode_get_string(
1148 "./rmap-set-action/frr-bgp-route-map:extcommunity-rt"));
1149 } else if (IS_SET_EXTCOMMUNITY_SOO(action
)) {
1150 vty_out(vty
, " set extcommunity soo %s\n",
1151 yang_dnode_get_string(
1153 "./rmap-set-action/frr-bgp-route-map:extcommunity-soo"));
1154 } else if (IS_SET_EXTCOMMUNITY_LB(action
)) {
1155 enum ecommunity_lb_type lb_type
;
1156 char str
[VTY_BUFSIZ
];
1159 lb_type
= yang_dnode_get_enum(
1161 "./rmap-set-action/frr-bgp-route-map:extcommunity-lb/lb-type");
1163 case EXPLICIT_BANDWIDTH
:
1164 bandwidth
= yang_dnode_get_uint16(
1166 "./rmap-set-action/frr-bgp-route-map:extcommunity-lb/bandwidth");
1167 snprintf(str
, sizeof(str
), "%d", bandwidth
);
1169 case CUMULATIVE_BANDWIDTH
:
1170 snprintf(str
, sizeof(str
), "%s", "cumulative");
1172 case COMPUTED_BANDWIDTH
:
1173 snprintf(str
, sizeof(str
), "%s", "num-multipaths");
1176 if (yang_dnode_get_bool(
1178 "./rmap-set-action/frr-bgp-route-map:extcommunity-lb/two-octet-as-specific"))
1179 strlcat(str
, " non-transitive", sizeof(str
));
1181 vty_out(vty
, " set extcommunity bandwidth %s\n", str
);
1182 } else if (IS_SET_EXTCOMMUNITY_NONE(action
)) {
1183 if (yang_dnode_get_bool(
1185 "./rmap-set-action/frr-bgp-route-map:extcommunity-none"))
1186 vty_out(vty
, " set extcommunity none\n");
1187 } else if (IS_SET_AGGREGATOR(action
)) {
1188 vty_out(vty
, " set aggregator as %s %s\n",
1189 yang_dnode_get_string(
1191 "./rmap-set-action/frr-bgp-route-map:aggregator/aggregator-asn"),
1192 yang_dnode_get_string(
1194 "./rmap-set-action/frr-bgp-route-map:aggregator/aggregator-address"));
1195 } else if (IS_SET_AS_EXCLUDE(action
)) {
1196 vty_out(vty
, " set as-path exclude %s\n",
1197 yang_dnode_get_string(
1199 "./rmap-set-action/frr-bgp-route-map:exclude-as-path"));
1200 } else if (IS_SET_AS_PREPEND(action
)) {
1201 if (yang_dnode_exists(
1203 "./rmap-set-action/frr-bgp-route-map:prepend-as-path"))
1204 vty_out(vty
, " set as-path prepend %s\n",
1205 yang_dnode_get_string(
1207 "./rmap-set-action/frr-bgp-route-map:prepend-as-path"));
1209 vty_out(vty
, " set as-path prepend last-as %u\n",
1210 yang_dnode_get_uint8(
1212 "./rmap-set-action/frr-bgp-route-map:last-as"));
1214 } else if (IS_SET_IPV6_NH_GLOBAL(action
)) {
1215 vty_out(vty
, " set ipv6 next-hop global %s\n",
1216 yang_dnode_get_string(
1218 "./rmap-set-action/frr-bgp-route-map:ipv6-address"));
1219 } else if (IS_SET_IPV6_VPN_NH(action
)) {
1220 vty_out(vty
, " set ipv6 vpn next-hop %s\n",
1221 yang_dnode_get_string(
1223 "./rmap-set-action/frr-bgp-route-map:ipv6-address"));
1224 } else if (IS_SET_IPV6_PEER_ADDR(action
)) {
1226 == yang_dnode_get_bool(
1228 "./rmap-set-action/frr-bgp-route-map:preference"))
1229 vty_out(vty
, " set ipv6 next-hop peer-address\n");
1230 } else if (IS_SET_IPV6_PREFER_GLOBAL(action
)) {
1232 == yang_dnode_get_bool(
1234 "./rmap-set-action/frr-bgp-route-map:preference"))
1235 vty_out(vty
, " set ipv6 next-hop prefer-global\n");
1236 } else if (IS_SET_IPV4_VPN_NH(action
)) {
1237 vty_out(vty
, " set ipv4 vpn next-hop %s\n",
1238 yang_dnode_get_string(
1240 "./rmap-set-action/frr-bgp-route-map:ipv4-address"));
1241 } else if (IS_SET_BGP_IPV4_NH(action
)) {
1242 vty_out(vty
, " set ip next-hop %s\n",
1243 yang_dnode_get_string(
1245 "./rmap-set-action/frr-bgp-route-map:ipv4-nexthop"));
1246 } else if (IS_SET_BGP_EVPN_GATEWAY_IP_IPV4(action
)) {
1247 vty_out(vty
, " set evpn gateway-ip ipv4 %s\n",
1248 yang_dnode_get_string(
1250 "./rmap-set-action/frr-bgp-route-map:evpn-gateway-ip-ipv4"));
1251 } else if (IS_SET_BGP_EVPN_GATEWAY_IP_IPV6(action
)) {
1252 vty_out(vty
, " set evpn gateway-ip ipv6 %s\n",
1253 yang_dnode_get_string(
1255 "./rmap-set-action/frr-bgp-route-map:evpn-gateway-ip-ipv6"));
1260 rmap_onmatch_next
, rmap_onmatch_next_cmd
,
1262 "Exit policy on matches\n"
1265 nb_cli_enqueue_change(vty
, "./exit-policy", NB_OP_MODIFY
, "next");
1267 return nb_cli_apply_changes(vty
, NULL
);
1271 no_rmap_onmatch_next
,
1272 no_rmap_onmatch_next_cmd
,
1275 "Exit policy on matches\n"
1278 nb_cli_enqueue_change(vty
, "./exit-policy", NB_OP_DESTROY
, NULL
);
1280 return nb_cli_apply_changes(vty
, NULL
);
1284 rmap_onmatch_goto
, rmap_onmatch_goto_cmd
,
1285 "on-match goto (1-65535)$rm_num",
1286 "Exit policy on matches\n"
1287 "Goto Clause number\n"
1290 nb_cli_enqueue_change(vty
, "./exit-policy", NB_OP_MODIFY
, "goto");
1291 nb_cli_enqueue_change(vty
, "./goto-value", NB_OP_MODIFY
, rm_num_str
);
1293 return nb_cli_apply_changes(vty
, NULL
);
1297 no_rmap_onmatch_goto
, no_rmap_onmatch_goto_cmd
,
1300 "Exit policy on matches\n"
1301 "Goto Clause number\n")
1303 nb_cli_enqueue_change(vty
, "./exit-policy", NB_OP_DESTROY
, NULL
);
1305 return nb_cli_apply_changes(vty
, NULL
);
1308 /* Cisco/GNU Zebra compatibility aliases */
1310 rmap_onmatch_goto
, rmap_continue_cmd
,
1311 "continue (1-65535)$rm_num",
1312 "Continue on a different entry within the route-map\n"
1313 "Route-map entry sequence number\n")
1316 no_rmap_onmatch_goto
, no_rmap_continue_cmd
,
1317 "no continue [(1-65535)]",
1319 "Continue on a different entry within the route-map\n"
1320 "Route-map entry sequence number\n")
1322 void route_map_exit_policy_show(struct vty
*vty
, const struct lyd_node
*dnode
,
1325 int exit_policy
= yang_dnode_get_enum(dnode
, NULL
);
1327 switch (exit_policy
) {
1328 case 0: /* permit-or-deny */
1329 /* NOTHING: default option. */
1332 vty_out(vty
, " on-match next\n");
1335 vty_out(vty
, " on-match goto %s\n",
1336 yang_dnode_get_string(dnode
, "../goto-value"));
1342 rmap_call
, rmap_call_cmd
,
1344 "Jump to another Route-Map after match+set\n"
1345 "Target route-map name\n")
1347 nb_cli_enqueue_change(vty
, "./call", NB_OP_MODIFY
, name
);
1349 return nb_cli_apply_changes(vty
, NULL
);
1353 no_rmap_call
, no_rmap_call_cmd
,
1356 "Jump to another Route-Map after match+set\n"
1357 "Target route-map name\n")
1359 nb_cli_enqueue_change(vty
, "./call", NB_OP_DESTROY
, NULL
);
1361 return nb_cli_apply_changes(vty
, NULL
);
1364 void route_map_call_show(struct vty
*vty
, const struct lyd_node
*dnode
,
1367 vty_out(vty
, " call %s\n", yang_dnode_get_string(dnode
, NULL
));
1371 rmap_description
, rmap_description_cmd
,
1372 "description LINE...",
1373 "Route-map comment\n"
1374 "Comment describing this route-map rule\n")
1379 desc
= argv_concat(argv
, argc
, 1);
1380 nb_cli_enqueue_change(vty
, "./description", NB_OP_MODIFY
, desc
);
1381 rv
= nb_cli_apply_changes(vty
, NULL
);
1382 XFREE(MTYPE_TMP
, desc
);
1387 DEFUN_YANG (no_rmap_description
,
1388 no_rmap_description_cmd
,
1391 "Route-map comment\n")
1393 nb_cli_enqueue_change(vty
, "./description", NB_OP_DESTROY
, NULL
);
1395 return nb_cli_apply_changes(vty
, NULL
);
1398 void route_map_description_show(struct vty
*vty
, const struct lyd_node
*dnode
,
1401 vty_out(vty
, " description %s\n", yang_dnode_get_string(dnode
, NULL
));
1405 route_map_optimization
, route_map_optimization_cmd
,
1406 "[no] route-map RMAP_NAME$name optimization",
1409 "Configure route-map optimization\n")
1411 char xpath
[XPATH_MAXLEN
];
1413 snprintf(xpath
, sizeof(xpath
),
1414 "/frr-route-map:lib/route-map[name='%s']", name
);
1415 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
1418 xpath
, sizeof(xpath
),
1419 "/frr-route-map:lib/route-map[name='%s']/optimization-disabled",
1421 nb_cli_enqueue_change(vty
, xpath
, NB_OP_MODIFY
, no
? "true" : "false");
1423 return nb_cli_apply_changes(vty
, NULL
);
1426 void route_map_optimization_disabled_show(struct vty
*vty
,
1427 const struct lyd_node
*dnode
,
1430 const char *name
= yang_dnode_get_string(dnode
, "../name");
1431 const bool disabled
= yang_dnode_get_bool(dnode
, NULL
);
1433 vty_out(vty
, "%sroute-map %s optimization\n", disabled
? "no " : "",
1437 static int route_map_config_write(struct vty
*vty
)
1439 const struct lyd_node
*dnode
;
1442 dnode
= yang_dnode_get(running_config
->dnode
,
1443 "/frr-route-map:lib");
1445 nb_cli_show_dnode_cmds(vty
, dnode
, false);
1452 /* Route map node structure. */
1453 static int route_map_config_write(struct vty
*vty
);
1454 static struct cmd_node rmap_node
= {
1457 .parent_node
= CONFIG_NODE
,
1458 .prompt
= "%s(config-route-map)# ",
1459 .config_write
= route_map_config_write
,
1462 static void rmap_autocomplete(vector comps
, struct cmd_token
*token
)
1464 struct route_map
*map
;
1466 for (map
= route_map_master
.head
; map
; map
= map
->next
)
1467 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, map
->name
));
1470 static const struct cmd_variable_handler rmap_var_handlers
[] = {
1471 {.varname
= "route_map", .completions
= rmap_autocomplete
},
1472 {.tokenname
= "ROUTEMAP_NAME", .completions
= rmap_autocomplete
},
1473 {.tokenname
= "RMAP_NAME", .completions
= rmap_autocomplete
},
1474 {.completions
= NULL
}
1477 void route_map_cli_init(void)
1479 /* Auto complete handler. */
1480 cmd_variable_handler_register(rmap_var_handlers
);
1483 install_node(&rmap_node
);
1484 install_default(RMAP_NODE
);
1485 install_element(CONFIG_NODE
, &route_map_cmd
);
1486 install_element(CONFIG_NODE
, &no_route_map_cmd
);
1487 install_element(CONFIG_NODE
, &no_route_map_all_cmd
);
1488 install_element(CONFIG_NODE
, &route_map_optimization_cmd
);
1490 /* Install the on-match stuff */
1491 install_element(RMAP_NODE
, &rmap_onmatch_next_cmd
);
1492 install_element(RMAP_NODE
, &no_rmap_onmatch_next_cmd
);
1493 install_element(RMAP_NODE
, &rmap_onmatch_goto_cmd
);
1494 install_element(RMAP_NODE
, &no_rmap_onmatch_goto_cmd
);
1495 install_element(RMAP_NODE
, &rmap_continue_cmd
);
1496 install_element(RMAP_NODE
, &no_rmap_continue_cmd
);
1498 /* Install the call stuff. */
1499 install_element(RMAP_NODE
, &rmap_call_cmd
);
1500 install_element(RMAP_NODE
, &no_rmap_call_cmd
);
1502 /* Install description commands. */
1503 install_element(RMAP_NODE
, &rmap_description_cmd
);
1504 install_element(RMAP_NODE
, &no_rmap_description_cmd
);
1506 /* Install 'match' commands. */
1507 install_element(RMAP_NODE
, &match_interface_cmd
);
1508 install_element(RMAP_NODE
, &no_match_interface_cmd
);
1510 install_element(RMAP_NODE
, &match_ip_address_cmd
);
1511 install_element(RMAP_NODE
, &no_match_ip_address_cmd
);
1513 install_element(RMAP_NODE
, &match_ip_address_prefix_list_cmd
);
1514 install_element(RMAP_NODE
, &no_match_ip_address_prefix_list_cmd
);
1516 install_element(RMAP_NODE
, &match_ip_next_hop_cmd
);
1517 install_element(RMAP_NODE
, &no_match_ip_next_hop_cmd
);
1519 install_element(RMAP_NODE
, &match_ip_next_hop_prefix_list_cmd
);
1520 install_element(RMAP_NODE
, &no_match_ip_next_hop_prefix_list_cmd
);
1522 install_element(RMAP_NODE
, &match_ip_next_hop_type_cmd
);
1523 install_element(RMAP_NODE
, &no_match_ip_next_hop_type_cmd
);
1525 install_element(RMAP_NODE
, &match_ipv6_address_cmd
);
1526 install_element(RMAP_NODE
, &no_match_ipv6_address_cmd
);
1528 install_element(RMAP_NODE
, &match_ipv6_address_prefix_list_cmd
);
1529 install_element(RMAP_NODE
, &no_match_ipv6_address_prefix_list_cmd
);
1531 install_element(RMAP_NODE
, &match_ipv6_next_hop_type_cmd
);
1532 install_element(RMAP_NODE
, &no_match_ipv6_next_hop_type_cmd
);
1534 install_element(RMAP_NODE
, &match_metric_cmd
);
1535 install_element(RMAP_NODE
, &no_match_metric_cmd
);
1537 install_element(RMAP_NODE
, &match_tag_cmd
);
1538 install_element(RMAP_NODE
, &no_match_tag_cmd
);
1540 /* Install 'set' commands. */
1541 install_element(RMAP_NODE
, &set_ip_nexthop_cmd
);
1542 install_element(RMAP_NODE
, &no_set_ip_nexthop_cmd
);
1544 install_element(RMAP_NODE
, &set_ipv6_nexthop_local_cmd
);
1545 install_element(RMAP_NODE
, &no_set_ipv6_nexthop_local_cmd
);
1547 install_element(RMAP_NODE
, &set_metric_cmd
);
1548 install_element(RMAP_NODE
, &no_set_metric_cmd
);
1550 install_element(RMAP_NODE
, &set_tag_cmd
);
1551 install_element(RMAP_NODE
, &no_set_tag_cmd
);
1553 install_element(RMAP_NODE
, &set_srte_color_cmd
);
1554 install_element(RMAP_NODE
, &no_set_srte_color_cmd
);