1 /* Route map function of bgpd.
2 * Copyright (C) 1998, 1999 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
32 #include "frrscript.h"
33 #ifdef HAVE_LIBPCREPOSIX
34 #include <pcreposix.h>
37 #endif /* HAVE_LIBPCREPOSIX */
39 #include "sockunion.h"
44 #include "lib/northbound_cli.h"
46 #include "bgpd/bgpd.h"
47 #include "bgpd/bgp_table.h"
48 #include "bgpd/bgp_attr.h"
49 #include "bgpd/bgp_aspath.h"
50 #include "bgpd/bgp_packet.h"
51 #include "bgpd/bgp_route.h"
52 #include "bgpd/bgp_zebra.h"
53 #include "bgpd/bgp_regex.h"
54 #include "bgpd/bgp_community.h"
55 #include "bgpd/bgp_community_alias.h"
56 #include "bgpd/bgp_clist.h"
57 #include "bgpd/bgp_filter.h"
58 #include "bgpd/bgp_mplsvpn.h"
59 #include "bgpd/bgp_ecommunity.h"
60 #include "bgpd/bgp_lcommunity.h"
61 #include "bgpd/bgp_vty.h"
62 #include "bgpd/bgp_debug.h"
63 #include "bgpd/bgp_evpn.h"
64 #include "bgpd/bgp_evpn_private.h"
65 #include "bgpd/bgp_evpn_vty.h"
66 #include "bgpd/bgp_mplsvpn.h"
67 #include "bgpd/bgp_pbr.h"
68 #include "bgpd/bgp_flowspec_util.h"
69 #include "bgpd/bgp_encap_types.h"
70 #include "bgpd/bgp_mpath.h"
71 #include "bgpd/bgp_script.h"
74 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
77 #ifndef VTYSH_EXTRACT_PL
78 #include "bgpd/bgp_routemap_clippy.c"
81 /* Memo of route-map commands.
90 ip route-source : Done
94 ipv6 route-source: (This will not be implemented by bgpd)
95 ipv6 prefix-list : Done
96 length : (This will not be implemented by bgpd)
98 route-type : (This will not be implemented by bgpd)
100 local-preference : Done
102 set as-path prepend : Done
103 as-path tag : Not yet
104 automatic-tag : (This will not be implemented by bgpd)
106 large-community : Done
107 large-comm-list : Done
110 default : (This will not be implemented by bgpd)
111 interface : (This will not be implemented by bgpd)
112 ip default : (This will not be implemented by bgpd)
114 ip precedence : (This will not be implemented by bgpd)
115 ip tos : (This will not be implemented by bgpd)
116 level : (This will not be implemented by bgpd)
117 local-preference : Done
119 metric-type : Not yet
127 set ipv6 next-hop global: Done
128 set ipv6 next-hop prefer-global: Done
129 set ipv6 next-hop local : Done
130 set as-path exclude : Done
134 /* generic value manipulation to be shared in multiple rules */
136 #define RMAP_VALUE_SET 0
137 #define RMAP_VALUE_ADD 1
138 #define RMAP_VALUE_SUB 2
146 static int route_value_match(struct rmap_value
*rv
, uint32_t value
)
148 if (rv
->variable
== 0 && value
== rv
->value
)
154 static uint32_t route_value_adjust(struct rmap_value
*rv
, uint32_t current
,
159 switch (rv
->variable
) {
168 switch (rv
->action
) {
170 if (current
> UINT32_MAX
- value
)
172 return current
+ value
;
174 if (current
<= value
)
176 return current
- value
;
182 static void *route_value_compile(const char *arg
)
184 uint8_t action
= RMAP_VALUE_SET
, var
= 0;
185 unsigned long larg
= 0;
187 struct rmap_value
*rv
;
190 action
= RMAP_VALUE_ADD
;
192 } else if (arg
[0] == '-') {
193 action
= RMAP_VALUE_SUB
;
197 if (all_digit(arg
)) {
199 larg
= strtoul(arg
, &endptr
, 10);
200 if (*arg
== 0 || *endptr
!= 0 || errno
|| larg
> UINT32_MAX
)
203 if (strcmp(arg
, "rtt") == 0)
209 rv
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(struct rmap_value
));
217 static void route_value_free(void *rule
)
219 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
222 /* generic as path object to be shared in multiple rules */
224 static void *route_aspath_compile(const char *arg
)
226 struct aspath
*aspath
;
228 aspath
= aspath_str2aspath(arg
);
234 static void route_aspath_free(void *rule
)
236 struct aspath
*aspath
= rule
;
240 struct bgp_match_peer_compiled
{
245 /* 'match peer (A.B.C.D|X:X::X:X|WORD)' */
247 /* Compares the peer specified in the 'match peer' clause with the peer
248 received in bgp_path_info->peer. If it is the same, or if the peer structure
249 received is a peer_group containing it, returns RMAP_MATCH. */
250 static enum route_map_cmd_result_t
251 route_match_peer(void *rule
, const struct prefix
*prefix
, void *object
)
253 struct bgp_match_peer_compiled
*pc
;
255 union sockunion su_def
= {
256 .sin
= {.sin_family
= AF_INET
, .sin_addr
.s_addr
= INADDR_ANY
}};
257 struct peer_group
*group
;
259 struct listnode
*node
, *nnode
;
263 peer
= ((struct bgp_path_info
*)object
)->peer
;
269 if (strcmp(peer
->conf_if
, pc
->interface
) == 0)
275 /* If su='0.0.0.0' (command 'match peer local'), and it's a
277 REDISTRIBUTE, AGGREGATE-ADDRESS or DEFAULT_GENERATED route
280 if (sockunion_same(su
, &su_def
)) {
282 if (CHECK_FLAG(peer
->rmap_type
, PEER_RMAP_TYPE_NETWORK
)
283 || CHECK_FLAG(peer
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
)
284 || CHECK_FLAG(peer
->rmap_type
, PEER_RMAP_TYPE_AGGREGATE
)
285 || CHECK_FLAG(peer
->rmap_type
, PEER_RMAP_TYPE_DEFAULT
))
292 if (!CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
293 if (sockunion_same(su
, &peer
->su
))
299 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
300 if (sockunion_same(su
, &peer
->su
))
309 static void *route_match_peer_compile(const char *arg
)
311 struct bgp_match_peer_compiled
*pc
;
314 pc
= XCALLOC(MTYPE_ROUTE_MAP_COMPILED
,
315 sizeof(struct bgp_match_peer_compiled
));
317 ret
= str2sockunion(strcmp(arg
, "local") ? arg
: "0.0.0.0", &pc
->su
);
319 pc
->interface
= XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
326 /* Free route map's compiled `ip address' value. */
327 static void route_match_peer_free(void *rule
)
329 struct bgp_match_peer_compiled
*pc
= rule
;
331 XFREE(MTYPE_ROUTE_MAP_COMPILED
, pc
->interface
);
333 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
336 /* Route map commands for ip address matching. */
337 static const struct route_map_rule_cmd route_match_peer_cmd
= {
340 route_match_peer_compile
,
341 route_match_peer_free
344 #ifdef HAVE_SCRIPTING
346 enum frrlua_rm_status
{
348 * Script function run failure. This will translate into a deny
352 * No Match was found for the route map function
356 * Match was found but no changes were made to the incoming data.
360 * Match was found and data was modified, so figure out what changed
362 LUA_RM_MATCH_AND_CHANGE
,
365 static enum route_map_cmd_result_t
366 route_match_script(void *rule
, const struct prefix
*prefix
, void *object
)
368 const char *scriptname
= rule
;
369 const char *routematch_function
= "route_match";
370 struct bgp_path_info
*path
= (struct bgp_path_info
*)object
;
372 struct frrscript
*fs
= frrscript_new(scriptname
);
374 if (frrscript_load(fs
, routematch_function
, NULL
)) {
376 "Issue loading script or function; defaulting to no match");
380 struct attr newattr
= *path
->attr
;
382 int result
= frrscript_call(
383 fs
, routematch_function
, ("prefix", prefix
),
384 ("attributes", &newattr
), ("peer", path
->peer
),
385 ("RM_FAILURE", LUA_RM_FAILURE
), ("RM_NOMATCH", LUA_RM_NOMATCH
),
386 ("RM_MATCH", LUA_RM_MATCH
),
387 ("RM_MATCH_AND_CHANGE", LUA_RM_MATCH_AND_CHANGE
));
390 zlog_err("Issue running script rule; defaulting to no match");
394 long long *action
= frrscript_get_result(fs
, routematch_function
,
395 "action", lua_tointegerp
);
397 int status
= RMAP_NOMATCH
;
402 "Executing route-map match script '%s' failed; defaulting to no match",
404 status
= RMAP_NOMATCH
;
407 status
= RMAP_NOMATCH
;
409 case LUA_RM_MATCH_AND_CHANGE
:
411 zlog_debug("Updating attribute based on script's values");
413 uint32_t locpref
= 0;
415 path
->attr
->med
= newattr
.med
;
417 if (path
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
))
418 locpref
= path
->attr
->local_pref
;
419 if (locpref
!= newattr
.local_pref
) {
420 SET_FLAG(path
->attr
->flag
,
421 ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
));
422 path
->attr
->local_pref
= newattr
.local_pref
;
430 XFREE(MTYPE_SCRIPT_RES
, action
);
432 frrscript_delete(fs
);
437 static void *route_match_script_compile(const char *arg
)
441 scriptname
= XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
446 static void route_match_script_free(void *rule
)
448 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
451 static const struct route_map_rule_cmd route_match_script_cmd
= {
454 route_match_script_compile
,
455 route_match_script_free
458 #endif /* HAVE_SCRIPTING */
460 /* `match ip address IP_ACCESS_LIST' */
462 /* Match function should return 1 if match is success else return
464 static enum route_map_cmd_result_t
465 route_match_ip_address(void *rule
, const struct prefix
*prefix
, void *object
)
467 struct access_list
*alist
;
469 if (prefix
->family
== AF_INET
) {
470 alist
= access_list_lookup(AFI_IP
, (char *)rule
);
474 return (access_list_apply(alist
, prefix
) == FILTER_DENY
481 /* Route map `ip address' match statement. `arg' should be
483 static void *route_match_ip_address_compile(const char *arg
)
485 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
488 /* Free route map's compiled `ip address' value. */
489 static void route_match_ip_address_free(void *rule
)
491 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
494 /* Route map commands for ip address matching. */
495 static const struct route_map_rule_cmd route_match_ip_address_cmd
= {
497 route_match_ip_address
,
498 route_match_ip_address_compile
,
499 route_match_ip_address_free
502 /* `match ip next-hop IP_ADDRESS' */
504 /* Match function return 1 if match is success else return zero. */
505 static enum route_map_cmd_result_t
506 route_match_ip_next_hop(void *rule
, const struct prefix
*prefix
, void *object
)
508 struct access_list
*alist
;
509 struct bgp_path_info
*path
;
510 struct prefix_ipv4 p
;
512 if (prefix
->family
== AF_INET
) {
515 p
.prefix
= path
->attr
->nexthop
;
516 p
.prefixlen
= IPV4_MAX_BITLEN
;
518 alist
= access_list_lookup(AFI_IP
, (char *)rule
);
522 return (access_list_apply(alist
, &p
) == FILTER_DENY
529 /* Route map `ip next-hop' match statement. `arg' is
531 static void *route_match_ip_next_hop_compile(const char *arg
)
533 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
536 /* Free route map's compiled `ip address' value. */
537 static void route_match_ip_next_hop_free(void *rule
)
539 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
542 /* Route map commands for ip next-hop matching. */
543 static const struct route_map_rule_cmd route_match_ip_next_hop_cmd
= {
545 route_match_ip_next_hop
,
546 route_match_ip_next_hop_compile
,
547 route_match_ip_next_hop_free
550 /* `match ip route-source ACCESS-LIST' */
552 /* Match function return 1 if match is success else return zero. */
553 static enum route_map_cmd_result_t
554 route_match_ip_route_source(void *rule
, const struct prefix
*pfx
, void *object
)
556 struct access_list
*alist
;
557 struct bgp_path_info
*path
;
559 struct prefix_ipv4 p
;
561 if (pfx
->family
== AF_INET
) {
565 if (!peer
|| sockunion_family(&peer
->su
) != AF_INET
)
569 p
.prefix
= peer
->su
.sin
.sin_addr
;
570 p
.prefixlen
= IPV4_MAX_BITLEN
;
572 alist
= access_list_lookup(AFI_IP
, (char *)rule
);
576 return (access_list_apply(alist
, &p
) == FILTER_DENY
583 /* Route map `ip route-source' match statement. `arg' is
585 static void *route_match_ip_route_source_compile(const char *arg
)
587 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
590 /* Free route map's compiled `ip address' value. */
591 static void route_match_ip_route_source_free(void *rule
)
593 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
596 /* Route map commands for ip route-source matching. */
597 static const struct route_map_rule_cmd route_match_ip_route_source_cmd
= {
599 route_match_ip_route_source
,
600 route_match_ip_route_source_compile
,
601 route_match_ip_route_source_free
604 static enum route_map_cmd_result_t
605 route_match_prefix_list_flowspec(afi_t afi
, struct prefix_list
*plist
,
606 const struct prefix
*p
)
609 struct bgp_pbr_entry_main api
;
611 memset(&api
, 0, sizeof(api
));
613 if (family2afi(p
->u
.prefix_flowspec
.family
) != afi
)
616 /* extract match from flowspec entries */
617 ret
= bgp_flowspec_match_rules_fill(
618 (uint8_t *)p
->u
.prefix_flowspec
.ptr
,
619 p
->u
.prefix_flowspec
.prefixlen
, &api
,
623 if (api
.match_bitmask
& PREFIX_DST_PRESENT
||
624 api
.match_bitmask_iprule
& PREFIX_DST_PRESENT
) {
625 if (family2afi((&api
.dst_prefix
)->family
) != afi
)
627 return prefix_list_apply(plist
, &api
.dst_prefix
) == PREFIX_DENY
630 } else if (api
.match_bitmask
& PREFIX_SRC_PRESENT
||
631 api
.match_bitmask_iprule
& PREFIX_SRC_PRESENT
) {
632 if (family2afi((&api
.src_prefix
)->family
) != afi
)
634 return (prefix_list_apply(plist
, &api
.src_prefix
) == PREFIX_DENY
641 static enum route_map_cmd_result_t
642 route_match_address_prefix_list(void *rule
, afi_t afi
,
643 const struct prefix
*prefix
, void *object
)
645 struct prefix_list
*plist
;
647 plist
= prefix_list_lookup(afi
, (char *)rule
);
651 if (prefix
->family
== AF_FLOWSPEC
)
652 return route_match_prefix_list_flowspec(afi
, plist
,
654 return (prefix_list_apply(plist
, prefix
) == PREFIX_DENY
? RMAP_NOMATCH
658 static enum route_map_cmd_result_t
659 route_match_ip_address_prefix_list(void *rule
, const struct prefix
*prefix
,
662 return route_match_address_prefix_list(rule
, AFI_IP
, prefix
, object
);
665 static void *route_match_ip_address_prefix_list_compile(const char *arg
)
667 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
670 static void route_match_ip_address_prefix_list_free(void *rule
)
672 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
675 static const struct route_map_rule_cmd
676 route_match_ip_address_prefix_list_cmd
= {
677 "ip address prefix-list",
678 route_match_ip_address_prefix_list
,
679 route_match_ip_address_prefix_list_compile
,
680 route_match_ip_address_prefix_list_free
683 /* `match ip next-hop prefix-list PREFIX_LIST' */
685 static enum route_map_cmd_result_t
686 route_match_ip_next_hop_prefix_list(void *rule
, const struct prefix
*prefix
,
689 struct prefix_list
*plist
;
690 struct bgp_path_info
*path
;
691 struct prefix_ipv4 p
;
693 if (prefix
->family
== AF_INET
) {
696 p
.prefix
= path
->attr
->nexthop
;
697 p
.prefixlen
= IPV4_MAX_BITLEN
;
699 plist
= prefix_list_lookup(AFI_IP
, (char *)rule
);
703 return (prefix_list_apply(plist
, &p
) == PREFIX_DENY
710 static void *route_match_ip_next_hop_prefix_list_compile(const char *arg
)
712 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
715 static void route_match_ip_next_hop_prefix_list_free(void *rule
)
717 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
720 static const struct route_map_rule_cmd
721 route_match_ip_next_hop_prefix_list_cmd
= {
722 "ip next-hop prefix-list",
723 route_match_ip_next_hop_prefix_list
,
724 route_match_ip_next_hop_prefix_list_compile
,
725 route_match_ip_next_hop_prefix_list_free
728 /* `match ipv6 next-hop prefix-list PREFIXLIST_NAME' */
729 static enum route_map_cmd_result_t
730 route_match_ipv6_next_hop_prefix_list(void *rule
, const struct prefix
*prefix
,
733 struct prefix_list
*plist
;
734 struct bgp_path_info
*path
;
735 struct prefix_ipv6 p
;
737 if (prefix
->family
== AF_INET6
) {
740 p
.prefix
= path
->attr
->mp_nexthop_global
;
741 p
.prefixlen
= IPV6_MAX_BITLEN
;
743 plist
= prefix_list_lookup(AFI_IP6
, (char *)rule
);
747 if (prefix_list_apply(plist
, &p
) == PREFIX_PERMIT
)
750 if (path
->attr
->mp_nexthop_len
751 == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
) {
752 p
.prefix
= path
->attr
->mp_nexthop_local
;
753 if (prefix_list_apply(plist
, &p
) == PREFIX_PERMIT
)
761 static void *route_match_ipv6_next_hop_prefix_list_compile(const char *arg
)
763 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
766 static void route_match_ipv6_next_hop_prefix_list_free(void *rule
)
768 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
771 static const struct route_map_rule_cmd
772 route_match_ipv6_next_hop_prefix_list_cmd
= {
773 "ipv6 next-hop prefix-list",
774 route_match_ipv6_next_hop_prefix_list
,
775 route_match_ipv6_next_hop_prefix_list_compile
,
776 route_match_ipv6_next_hop_prefix_list_free
779 /* `match ip next-hop type <blackhole>' */
781 static enum route_map_cmd_result_t
782 route_match_ip_next_hop_type(void *rule
, const struct prefix
*prefix
,
785 struct bgp_path_info
*path
;
787 if (prefix
->family
== AF_INET
) {
788 path
= (struct bgp_path_info
*)object
;
792 /* If nexthop interface's index can't be resolved and nexthop is
793 set to any address then mark it as type `blackhole`.
794 This logic works for matching kernel/static routes like:
795 `ip route add blackhole 10.0.0.1`. */
796 if (path
->attr
->nexthop
.s_addr
== INADDR_ANY
797 && !path
->attr
->nh_ifindex
)
803 static void *route_match_ip_next_hop_type_compile(const char *arg
)
805 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
808 static void route_match_ip_next_hop_type_free(void *rule
)
810 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
813 static const struct route_map_rule_cmd
814 route_match_ip_next_hop_type_cmd
= {
816 route_match_ip_next_hop_type
,
817 route_match_ip_next_hop_type_compile
,
818 route_match_ip_next_hop_type_free
821 /* `match ip route-source prefix-list PREFIX_LIST' */
823 static enum route_map_cmd_result_t
824 route_match_ip_route_source_prefix_list(void *rule
, const struct prefix
*prefix
,
827 struct prefix_list
*plist
;
828 struct bgp_path_info
*path
;
830 struct prefix_ipv4 p
;
832 if (prefix
->family
== AF_INET
) {
836 if (!peer
|| sockunion_family(&peer
->su
) != AF_INET
)
840 p
.prefix
= peer
->su
.sin
.sin_addr
;
841 p
.prefixlen
= IPV4_MAX_BITLEN
;
843 plist
= prefix_list_lookup(AFI_IP
, (char *)rule
);
847 return (prefix_list_apply(plist
, &p
) == PREFIX_DENY
854 static void *route_match_ip_route_source_prefix_list_compile(const char *arg
)
856 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
859 static void route_match_ip_route_source_prefix_list_free(void *rule
)
861 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
864 static const struct route_map_rule_cmd
865 route_match_ip_route_source_prefix_list_cmd
= {
866 "ip route-source prefix-list",
867 route_match_ip_route_source_prefix_list
,
868 route_match_ip_route_source_prefix_list_compile
,
869 route_match_ip_route_source_prefix_list_free
872 /* `match evpn default-route' */
874 /* Match function should return 1 if match is success else 0 */
875 static enum route_map_cmd_result_t
876 route_match_evpn_default_route(void *rule
, const struct prefix
*p
, void *object
)
878 if (is_evpn_prefix_default(p
))
884 /* Route map commands for default-route matching. */
885 static const struct route_map_rule_cmd
886 route_match_evpn_default_route_cmd
= {
887 "evpn default-route",
888 route_match_evpn_default_route
,
893 /* `match mac address MAC_ACCESS_LIST' */
895 /* Match function should return 1 if match is success else return
897 static enum route_map_cmd_result_t
898 route_match_mac_address(void *rule
, const struct prefix
*prefix
, void *object
)
900 struct access_list
*alist
;
903 alist
= access_list_lookup(AFI_L2VPN
, (char *)rule
);
907 if (prefix
->u
.prefix_evpn
.route_type
!= BGP_EVPN_MAC_IP_ROUTE
)
910 p
.family
= AF_ETHERNET
;
911 p
.prefixlen
= ETH_ALEN
* 8;
912 p
.u
.prefix_eth
= prefix
->u
.prefix_evpn
.macip_addr
.mac
;
914 return (access_list_apply(alist
, &p
) == FILTER_DENY
? RMAP_NOMATCH
918 /* Route map `mac address' match statement. `arg' should be
920 static void *route_match_mac_address_compile(const char *arg
)
922 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
925 /* Free route map's compiled `ip address' value. */
926 static void route_match_mac_address_free(void *rule
)
928 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
931 /* Route map commands for mac address matching. */
932 static const struct route_map_rule_cmd route_match_mac_address_cmd
= {
934 route_match_mac_address
,
935 route_match_mac_address_compile
,
936 route_match_mac_address_free
940 * Match function returns:
941 * ...RMAP_MATCH if match is found.
942 * ...RMAP_NOMATCH if match is not found.
943 * ...RMAP_NOOP to ignore this match check.
945 static enum route_map_cmd_result_t
946 route_match_vni(void *rule
, const struct prefix
*prefix
, void *object
)
949 unsigned int label_cnt
= 0;
950 struct bgp_path_info
*path
= NULL
;
951 struct prefix_evpn
*evp
= (struct prefix_evpn
*) prefix
;
953 vni
= *((vni_t
*)rule
);
954 path
= (struct bgp_path_info
*)object
;
957 * This rmap filter is valid for vxlan tunnel type only.
958 * For any other tunnel type, return noop to ignore
961 if (path
->attr
->encap_tunneltype
!= BGP_ENCAP_TYPE_VXLAN
)
965 * Apply filter to type 1, 2, 5 routes only.
966 * Other route types do not have vni label.
969 && (evp
->prefix
.route_type
!= BGP_EVPN_AD_ROUTE
970 && evp
->prefix
.route_type
!= BGP_EVPN_MAC_IP_ROUTE
971 && evp
->prefix
.route_type
!= BGP_EVPN_IP_PREFIX_ROUTE
))
974 if (path
->extra
== NULL
)
978 label_cnt
< BGP_MAX_LABELS
&& label_cnt
< path
->extra
->num_labels
;
980 if (vni
== label2vni(&path
->extra
->label
[label_cnt
]))
987 /* Route map `vni' match statement. */
988 static void *route_match_vni_compile(const char *arg
)
993 vni
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(vni_t
));
995 *vni
= strtoul(arg
, &end
, 10);
997 XFREE(MTYPE_ROUTE_MAP_COMPILED
, vni
);
1004 /* Free route map's compiled `vni' value. */
1005 static void route_match_vni_free(void *rule
)
1007 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
1010 /* Route map commands for vni matching. */
1011 static const struct route_map_rule_cmd route_match_evpn_vni_cmd
= {
1014 route_match_vni_compile
,
1015 route_match_vni_free
1018 /* `match evpn route-type' */
1020 /* Match function should return 1 if match is success else return
1022 static enum route_map_cmd_result_t
1023 route_match_evpn_route_type(void *rule
, const struct prefix
*pfx
, void *object
)
1025 uint8_t route_type
= 0;
1027 route_type
= *((uint8_t *)rule
);
1029 if (route_type
== pfx
->u
.prefix_evpn
.route_type
)
1032 return RMAP_NOMATCH
;
1035 /* Route map `route-type' match statement. */
1036 static void *route_match_evpn_route_type_compile(const char *arg
)
1038 uint8_t *route_type
= NULL
;
1040 route_type
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(uint8_t));
1042 if (strncmp(arg
, "ma", 2) == 0)
1043 *route_type
= BGP_EVPN_MAC_IP_ROUTE
;
1044 else if (strncmp(arg
, "mu", 2) == 0)
1045 *route_type
= BGP_EVPN_IMET_ROUTE
;
1047 *route_type
= BGP_EVPN_IP_PREFIX_ROUTE
;
1052 /* Free route map's compiled `route-type' value. */
1053 static void route_match_evpn_route_type_free(void *rule
)
1055 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
1058 /* Route map commands for evpn route-type matching. */
1059 static const struct route_map_rule_cmd route_match_evpn_route_type_cmd
= {
1061 route_match_evpn_route_type
,
1062 route_match_evpn_route_type_compile
,
1063 route_match_evpn_route_type_free
1068 /* Match function should return 1 if match is success else return zero. */
1069 static enum route_map_cmd_result_t
1070 route_match_rd(void *rule
, const struct prefix
*prefix
, void *object
)
1072 struct prefix_rd
*prd_rule
= NULL
;
1073 const struct prefix_rd
*prd_route
= NULL
;
1074 struct bgp_path_info
*path
= NULL
;
1076 if (prefix
->family
!= AF_EVPN
)
1077 return RMAP_NOMATCH
;
1079 prd_rule
= (struct prefix_rd
*)rule
;
1080 path
= (struct bgp_path_info
*)object
;
1082 if (path
->net
== NULL
|| path
->net
->pdest
== NULL
)
1083 return RMAP_NOMATCH
;
1085 prd_route
= (struct prefix_rd
*)bgp_dest_get_prefix(path
->net
->pdest
);
1086 if (memcmp(prd_route
->val
, prd_rule
->val
, ECOMMUNITY_SIZE
) == 0)
1089 return RMAP_NOMATCH
;
1092 /* Route map `rd' match statement. */
1093 static void *route_match_rd_compile(const char *arg
)
1095 struct prefix_rd
*prd
;
1098 prd
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(struct prefix_rd
));
1100 ret
= str2prefix_rd(arg
, prd
);
1102 XFREE(MTYPE_ROUTE_MAP_COMPILED
, prd
);
1109 /* Free route map's compiled `rd' value. */
1110 static void route_match_rd_free(void *rule
)
1112 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
1115 /* Route map commands for rd matching. */
1116 static const struct route_map_rule_cmd route_match_evpn_rd_cmd
= {
1119 route_match_rd_compile
,
1123 static enum route_map_cmd_result_t
1124 route_set_evpn_gateway_ip(void *rule
, const struct prefix
*prefix
, void *object
)
1126 struct ipaddr
*gw_ip
= rule
;
1127 struct bgp_path_info
*path
;
1128 struct prefix_evpn
*evp
;
1130 if (prefix
->family
!= AF_EVPN
)
1133 evp
= (struct prefix_evpn
*)prefix
;
1134 if (evp
->prefix
.route_type
!= BGP_EVPN_IP_PREFIX_ROUTE
)
1137 if ((is_evpn_prefix_ipaddr_v4(evp
) && IPADDRSZ(gw_ip
) != 4)
1138 || (is_evpn_prefix_ipaddr_v6(evp
) && IPADDRSZ(gw_ip
) != 16))
1143 /* Set gateway-ip value. */
1144 path
->attr
->evpn_overlay
.type
= OVERLAY_INDEX_GATEWAY_IP
;
1145 memcpy(&path
->attr
->evpn_overlay
.gw_ip
, &gw_ip
->ip
.addr
,
1152 * Route map `evpn gateway-ip' compile function.
1153 * Given string is converted to struct ipaddr structure
1155 static void *route_set_evpn_gateway_ip_compile(const char *arg
)
1157 struct ipaddr
*gw_ip
= NULL
;
1160 gw_ip
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(struct ipaddr
));
1162 ret
= str2ipaddr(arg
, gw_ip
);
1164 XFREE(MTYPE_ROUTE_MAP_COMPILED
, gw_ip
);
1170 /* Free route map's compiled `evpn gateway_ip' value. */
1171 static void route_set_evpn_gateway_ip_free(void *rule
)
1173 struct ipaddr
*gw_ip
= rule
;
1175 XFREE(MTYPE_ROUTE_MAP_COMPILED
, gw_ip
);
1178 /* Route map commands for set evpn gateway-ip ipv4. */
1179 struct route_map_rule_cmd route_set_evpn_gateway_ip_ipv4_cmd
= {
1180 "evpn gateway-ip ipv4", route_set_evpn_gateway_ip
,
1181 route_set_evpn_gateway_ip_compile
, route_set_evpn_gateway_ip_free
};
1183 /* Route map commands for set evpn gateway-ip ipv6. */
1184 struct route_map_rule_cmd route_set_evpn_gateway_ip_ipv6_cmd
= {
1185 "evpn gateway-ip ipv6", route_set_evpn_gateway_ip
,
1186 route_set_evpn_gateway_ip_compile
, route_set_evpn_gateway_ip_free
};
1188 /* Route map commands for VRF route leak with source vrf matching */
1189 static enum route_map_cmd_result_t
1190 route_match_vrl_source_vrf(void *rule
, const struct prefix
*prefix
,
1193 struct bgp_path_info
*path
;
1197 path
= (struct bgp_path_info
*)object
;
1199 if (strncmp(vrf_name
, "n/a", VRF_NAMSIZ
) == 0)
1200 return RMAP_NOMATCH
;
1202 if (path
->extra
== NULL
|| path
->extra
->bgp_orig
== NULL
)
1203 return RMAP_NOMATCH
;
1205 if (strncmp(vrf_name
, vrf_id_to_name(path
->extra
->bgp_orig
->vrf_id
),
1210 return RMAP_NOMATCH
;
1213 static void *route_match_vrl_source_vrf_compile(const char *arg
)
1215 uint8_t *vrf_name
= NULL
;
1217 vrf_name
= XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
1222 /* Free route map's compiled `route-type' value. */
1223 static void route_match_vrl_source_vrf_free(void *rule
)
1225 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
1228 static const struct route_map_rule_cmd route_match_vrl_source_vrf_cmd
= {
1230 route_match_vrl_source_vrf
,
1231 route_match_vrl_source_vrf_compile
,
1232 route_match_vrl_source_vrf_free
1236 static enum route_map_cmd_result_t
1237 route_match_alias(void *rule
, const struct prefix
*prefix
, void *object
)
1240 struct bgp_path_info
*path
= object
;
1245 if (path
->attr
->community
) {
1247 frrstr_split(path
->attr
->community
->str
, " ", &communities
,
1249 for (int i
= 0; i
< num
; i
++) {
1250 const char *com2alias
=
1251 bgp_community2alias(communities
[i
]);
1252 if (!found
&& strcmp(alias
, com2alias
) == 0)
1254 XFREE(MTYPE_TMP
, communities
[i
]);
1256 XFREE(MTYPE_TMP
, communities
);
1261 if (path
->attr
->lcommunity
) {
1263 frrstr_split(path
->attr
->lcommunity
->str
, " ", &communities
,
1265 for (int i
= 0; i
< num
; i
++) {
1266 const char *com2alias
=
1267 bgp_community2alias(communities
[i
]);
1268 if (!found
&& strcmp(alias
, com2alias
) == 0)
1270 XFREE(MTYPE_TMP
, communities
[i
]);
1272 XFREE(MTYPE_TMP
, communities
);
1277 return RMAP_NOMATCH
;
1280 static void *route_match_alias_compile(const char *arg
)
1283 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
1286 static void route_match_alias_free(void *rule
)
1288 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
1291 static const struct route_map_rule_cmd route_match_alias_cmd
= {
1292 "alias", route_match_alias
, route_match_alias_compile
,
1293 route_match_alias_free
};
1295 /* `match local-preference LOCAL-PREF' */
1297 /* Match function return 1 if match is success else return zero. */
1298 static enum route_map_cmd_result_t
1299 route_match_local_pref(void *rule
, const struct prefix
*prefix
, void *object
)
1301 uint32_t *local_pref
;
1302 struct bgp_path_info
*path
;
1307 if (path
->attr
->local_pref
== *local_pref
)
1310 return RMAP_NOMATCH
;
1314 * Route map `match local-preference' match statement.
1315 * `arg' is local-pref value
1317 static void *route_match_local_pref_compile(const char *arg
)
1319 uint32_t *local_pref
;
1320 char *endptr
= NULL
;
1321 unsigned long tmpval
;
1323 /* Locpref value shoud be integer. */
1324 if (!all_digit(arg
))
1328 tmpval
= strtoul(arg
, &endptr
, 10);
1329 if (*endptr
!= '\0' || errno
|| tmpval
> UINT32_MAX
)
1332 local_pref
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(uint32_t));
1334 *local_pref
= tmpval
;
1338 /* Free route map's compiled `match local-preference' value. */
1339 static void route_match_local_pref_free(void *rule
)
1341 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
1344 /* Route map commands for metric matching. */
1345 static const struct route_map_rule_cmd route_match_local_pref_cmd
= {
1347 route_match_local_pref
,
1348 route_match_local_pref_compile
,
1349 route_match_local_pref_free
1352 /* `match metric METRIC' */
1354 /* Match function return 1 if match is success else return zero. */
1355 static enum route_map_cmd_result_t
1356 route_match_metric(void *rule
, const struct prefix
*prefix
, void *object
)
1358 struct rmap_value
*rv
;
1359 struct bgp_path_info
*path
;
1363 return route_value_match(rv
, path
->attr
->med
);
1366 /* Route map commands for metric matching. */
1367 static const struct route_map_rule_cmd route_match_metric_cmd
= {
1370 route_value_compile
,
1374 /* `match as-path ASPATH' */
1376 /* Match function for as-path match. I assume given object is */
1377 static enum route_map_cmd_result_t
1378 route_match_aspath(void *rule
, const struct prefix
*prefix
, void *object
)
1381 struct as_list
*as_list
;
1382 struct bgp_path_info
*path
;
1384 as_list
= as_list_lookup((char *)rule
);
1385 if (as_list
== NULL
)
1386 return RMAP_NOMATCH
;
1390 /* Perform match. */
1391 return ((as_list_apply(as_list
, path
->attr
->aspath
) == AS_FILTER_DENY
)
1396 /* Compile function for as-path match. */
1397 static void *route_match_aspath_compile(const char *arg
)
1399 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
1402 /* Compile function for as-path match. */
1403 static void route_match_aspath_free(void *rule
)
1405 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
1408 /* Route map commands for aspath matching. */
1409 static const struct route_map_rule_cmd route_match_aspath_cmd
= {
1412 route_match_aspath_compile
,
1413 route_match_aspath_free
1416 /* `match community COMMUNIY' */
1417 struct rmap_community
{
1423 /* Match function for community match. */
1424 static enum route_map_cmd_result_t
1425 route_match_community(void *rule
, const struct prefix
*prefix
, void *object
)
1427 struct community_list
*list
;
1428 struct bgp_path_info
*path
;
1429 struct rmap_community
*rcom
= rule
;
1434 list
= community_list_lookup(bgp_clist
, rcom
->name
, rcom
->name_hash
,
1435 COMMUNITY_LIST_MASTER
);
1437 return RMAP_NOMATCH
;
1440 if (community_list_exact_match(path
->attr
->community
, list
))
1443 if (community_list_match(path
->attr
->community
, list
))
1447 return RMAP_NOMATCH
;
1450 /* Compile function for community match. */
1451 static void *route_match_community_compile(const char *arg
)
1453 struct rmap_community
*rcom
;
1457 rcom
= XCALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(struct rmap_community
));
1459 p
= strchr(arg
, ' ');
1462 rcom
->name
= XCALLOC(MTYPE_ROUTE_MAP_COMPILED
, len
+ 1);
1463 memcpy(rcom
->name
, arg
, len
);
1466 rcom
->name
= XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
1470 rcom
->name_hash
= bgp_clist_hash_key(rcom
->name
);
1474 /* Compile function for community match. */
1475 static void route_match_community_free(void *rule
)
1477 struct rmap_community
*rcom
= rule
;
1479 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rcom
->name
);
1480 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rcom
);
1484 * In routemap processing there is a need to add the
1485 * name as a rule_key in the dependency table. Routemap
1486 * lib is unaware of rule_key when exact-match clause
1487 * is in use. routemap lib uses the compiled output to
1488 * get the rule_key value.
1490 static void *route_match_get_community_key(void *rule
)
1492 struct rmap_community
*rcom
;
1499 /* Route map commands for community matching. */
1500 static const struct route_map_rule_cmd route_match_community_cmd
= {
1502 route_match_community
,
1503 route_match_community_compile
,
1504 route_match_community_free
,
1505 route_match_get_community_key
1508 /* Match function for lcommunity match. */
1509 static enum route_map_cmd_result_t
1510 route_match_lcommunity(void *rule
, const struct prefix
*prefix
, void *object
)
1512 struct community_list
*list
;
1513 struct bgp_path_info
*path
;
1514 struct rmap_community
*rcom
= rule
;
1518 list
= community_list_lookup(bgp_clist
, rcom
->name
, rcom
->name_hash
,
1519 LARGE_COMMUNITY_LIST_MASTER
);
1521 return RMAP_NOMATCH
;
1524 if (lcommunity_list_exact_match(path
->attr
->lcommunity
, list
))
1527 if (lcommunity_list_match(path
->attr
->lcommunity
, list
))
1531 return RMAP_NOMATCH
;
1534 /* Compile function for community match. */
1535 static void *route_match_lcommunity_compile(const char *arg
)
1537 struct rmap_community
*rcom
;
1541 rcom
= XCALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(struct rmap_community
));
1543 p
= strchr(arg
, ' ');
1546 rcom
->name
= XCALLOC(MTYPE_ROUTE_MAP_COMPILED
, len
+ 1);
1547 memcpy(rcom
->name
, arg
, len
);
1550 rcom
->name
= XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
1554 rcom
->name_hash
= bgp_clist_hash_key(rcom
->name
);
1558 /* Compile function for community match. */
1559 static void route_match_lcommunity_free(void *rule
)
1561 struct rmap_community
*rcom
= rule
;
1563 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rcom
->name
);
1564 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rcom
);
1567 /* Route map commands for community matching. */
1568 static const struct route_map_rule_cmd route_match_lcommunity_cmd
= {
1570 route_match_lcommunity
,
1571 route_match_lcommunity_compile
,
1572 route_match_lcommunity_free
,
1573 route_match_get_community_key
1577 /* Match function for extcommunity match. */
1578 static enum route_map_cmd_result_t
1579 route_match_ecommunity(void *rule
, const struct prefix
*prefix
, void *object
)
1581 struct community_list
*list
;
1582 struct bgp_path_info
*path
;
1583 struct rmap_community
*rcom
= rule
;
1587 list
= community_list_lookup(bgp_clist
, rcom
->name
, rcom
->name_hash
,
1588 EXTCOMMUNITY_LIST_MASTER
);
1590 return RMAP_NOMATCH
;
1592 if (ecommunity_list_match(path
->attr
->ecommunity
, list
))
1595 return RMAP_NOMATCH
;
1598 /* Compile function for extcommunity match. */
1599 static void *route_match_ecommunity_compile(const char *arg
)
1601 struct rmap_community
*rcom
;
1603 rcom
= XCALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(struct rmap_community
));
1604 rcom
->name
= XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
1605 rcom
->name_hash
= bgp_clist_hash_key(rcom
->name
);
1610 /* Compile function for extcommunity match. */
1611 static void route_match_ecommunity_free(void *rule
)
1613 struct rmap_community
*rcom
= rule
;
1615 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rcom
->name
);
1616 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rcom
);
1619 /* Route map commands for community matching. */
1620 static const struct route_map_rule_cmd route_match_ecommunity_cmd
= {
1622 route_match_ecommunity
,
1623 route_match_ecommunity_compile
,
1624 route_match_ecommunity_free
1627 /* `match nlri` and `set nlri` are replaced by `address-family ipv4`
1628 and `address-family vpnv4'. */
1630 /* `match origin' */
1631 static enum route_map_cmd_result_t
1632 route_match_origin(void *rule
, const struct prefix
*prefix
, void *object
)
1635 struct bgp_path_info
*path
;
1640 if (path
->attr
->origin
== *origin
)
1643 return RMAP_NOMATCH
;
1646 static void *route_match_origin_compile(const char *arg
)
1650 origin
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(uint8_t));
1652 if (strcmp(arg
, "igp") == 0)
1654 else if (strcmp(arg
, "egp") == 0)
1662 /* Free route map's compiled `ip address' value. */
1663 static void route_match_origin_free(void *rule
)
1665 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
1668 /* Route map commands for origin matching. */
1669 static const struct route_map_rule_cmd route_match_origin_cmd
= {
1672 route_match_origin_compile
,
1673 route_match_origin_free
1676 /* match probability { */
1678 static enum route_map_cmd_result_t
1679 route_match_probability(void *rule
, const struct prefix
*prefix
, void *object
)
1681 long r
= frr_weak_random();
1683 switch (*(long *)rule
) {
1689 if (r
< *(long *)rule
) {
1694 return RMAP_NOMATCH
;
1697 static void *route_match_probability_compile(const char *arg
)
1703 lobule
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(long));
1713 *lobule
= RAND_MAX
/ 100 * perc
;
1719 static void route_match_probability_free(void *rule
)
1721 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
1724 static const struct route_map_rule_cmd route_match_probability_cmd
= {
1726 route_match_probability
,
1727 route_match_probability_compile
,
1728 route_match_probability_free
1731 /* `match interface IFNAME' */
1732 /* Match function should return 1 if match is success else return
1734 static enum route_map_cmd_result_t
1735 route_match_interface(void *rule
, const struct prefix
*prefix
, void *object
)
1737 struct interface
*ifp
;
1738 struct bgp_path_info
*path
;
1742 if (!path
|| !path
->peer
|| !path
->peer
->bgp
)
1743 return RMAP_NOMATCH
;
1745 ifp
= if_lookup_by_name((char *)rule
, path
->peer
->bgp
->vrf_id
);
1747 if (ifp
== NULL
|| ifp
->ifindex
!= path
->attr
->nh_ifindex
)
1748 return RMAP_NOMATCH
;
1753 /* Route map `interface' match statement. `arg' should be
1755 static void *route_match_interface_compile(const char *arg
)
1757 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
1760 /* Free route map's compiled `interface' value. */
1761 static void route_match_interface_free(void *rule
)
1763 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
1766 /* Route map commands for ip address matching. */
1767 static const struct route_map_rule_cmd route_match_interface_cmd
= {
1769 route_match_interface
,
1770 route_match_interface_compile
,
1771 route_match_interface_free
1776 /* `set ip next-hop IP_ADDRESS' */
1778 /* Match function return 1 if match is success else return zero. */
1779 static enum route_map_cmd_result_t
1780 route_match_tag(void *rule
, const struct prefix
*prefix
, void *object
)
1783 struct bgp_path_info
*path
;
1788 return ((path
->attr
->tag
== *tag
) ? RMAP_MATCH
: RMAP_NOMATCH
);
1792 /* Route map commands for tag matching. */
1793 static const struct route_map_rule_cmd route_match_tag_cmd
= {
1796 route_map_rule_tag_compile
,
1797 route_map_rule_tag_free
,
1800 static enum route_map_cmd_result_t
1801 route_set_srte_color(void *rule
, const struct prefix
*prefix
, void *object
)
1803 uint32_t *srte_color
= rule
;
1804 struct bgp_path_info
*path
;
1808 path
->attr
->srte_color
= *srte_color
;
1809 path
->attr
->flag
|= ATTR_FLAG_BIT(BGP_ATTR_SRTE_COLOR
);
1814 /* Route map `sr-te color' compile function */
1815 static void *route_set_srte_color_compile(const char *arg
)
1819 color
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(uint32_t));
1825 /* Free route map's compiled `sr-te color' value. */
1826 static void route_set_srte_color_free(void *rule
)
1828 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
1831 /* Route map commands for sr-te color set. */
1832 struct route_map_rule_cmd route_set_srte_color_cmd
= {
1833 "sr-te color", route_set_srte_color
, route_set_srte_color_compile
,
1834 route_set_srte_color_free
};
1836 /* Set nexthop to object. ojbect must be pointer to struct attr. */
1837 struct rmap_ip_nexthop_set
{
1838 struct in_addr
*address
;
1843 static enum route_map_cmd_result_t
1844 route_set_ip_nexthop(void *rule
, const struct prefix
*prefix
, void *object
)
1846 struct rmap_ip_nexthop_set
*rins
= rule
;
1847 struct bgp_path_info
*path
;
1850 if (prefix
->family
== AF_INET6
)
1856 if (rins
->unchanged
) {
1857 SET_FLAG(path
->attr
->rmap_change_flags
,
1858 BATTR_RMAP_NEXTHOP_UNCHANGED
);
1859 } else if (rins
->peer_address
) {
1860 if ((CHECK_FLAG(peer
->rmap_type
, PEER_RMAP_TYPE_IN
)
1861 || CHECK_FLAG(peer
->rmap_type
, PEER_RMAP_TYPE_IMPORT
))
1863 && sockunion_family(peer
->su_remote
) == AF_INET
) {
1864 path
->attr
->nexthop
.s_addr
=
1865 sockunion2ip(peer
->su_remote
);
1866 path
->attr
->flag
|= ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP
);
1867 } else if (CHECK_FLAG(peer
->rmap_type
, PEER_RMAP_TYPE_OUT
)) {
1868 /* The next hop value will be set as part of
1869 * packet rewrite. Set the flags here to indicate
1870 * that rewrite needs to be done.
1871 * Also, clear the value.
1873 SET_FLAG(path
->attr
->rmap_change_flags
,
1874 BATTR_RMAP_NEXTHOP_PEER_ADDRESS
);
1875 path
->attr
->nexthop
.s_addr
= INADDR_ANY
;
1878 /* Set next hop value. */
1879 path
->attr
->flag
|= ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP
);
1880 path
->attr
->nexthop
= *rins
->address
;
1881 SET_FLAG(path
->attr
->rmap_change_flags
,
1882 BATTR_RMAP_IPV4_NHOP_CHANGED
);
1883 /* case for MP-BGP : MPLS VPN */
1884 path
->attr
->mp_nexthop_global_in
= *rins
->address
;
1885 path
->attr
->mp_nexthop_len
= sizeof(*rins
->address
);
1891 /* Route map `ip nexthop' compile function. Given string is converted
1892 to struct in_addr structure. */
1893 static void *route_set_ip_nexthop_compile(const char *arg
)
1895 struct rmap_ip_nexthop_set
*rins
;
1896 struct in_addr
*address
= NULL
;
1897 int peer_address
= 0;
1901 if (strcmp(arg
, "peer-address") == 0)
1903 else if (strcmp(arg
, "unchanged") == 0)
1906 address
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
,
1907 sizeof(struct in_addr
));
1908 ret
= inet_aton(arg
, address
);
1911 XFREE(MTYPE_ROUTE_MAP_COMPILED
, address
);
1916 rins
= XCALLOC(MTYPE_ROUTE_MAP_COMPILED
,
1917 sizeof(struct rmap_ip_nexthop_set
));
1919 rins
->address
= address
;
1920 rins
->peer_address
= peer_address
;
1921 rins
->unchanged
= unchanged
;
1926 /* Free route map's compiled `ip nexthop' value. */
1927 static void route_set_ip_nexthop_free(void *rule
)
1929 struct rmap_ip_nexthop_set
*rins
= rule
;
1931 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rins
->address
);
1933 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rins
);
1936 /* Route map commands for ip nexthop set. */
1937 static const struct route_map_rule_cmd route_set_ip_nexthop_cmd
= {
1939 route_set_ip_nexthop
,
1940 route_set_ip_nexthop_compile
,
1941 route_set_ip_nexthop_free
1944 /* `set local-preference LOCAL_PREF' */
1946 /* Set local preference. */
1947 static enum route_map_cmd_result_t
1948 route_set_local_pref(void *rule
, const struct prefix
*prefix
, void *object
)
1950 struct rmap_value
*rv
;
1951 struct bgp_path_info
*path
;
1952 uint32_t locpref
= 0;
1954 /* Fetch routemap's rule information. */
1958 /* Set local preference value. */
1959 if (path
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
))
1960 locpref
= path
->attr
->local_pref
;
1962 path
->attr
->flag
|= ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
);
1963 path
->attr
->local_pref
= route_value_adjust(rv
, locpref
, path
->peer
);
1968 /* Set local preference rule structure. */
1969 static const struct route_map_rule_cmd route_set_local_pref_cmd
= {
1971 route_set_local_pref
,
1972 route_value_compile
,
1976 /* `set weight WEIGHT' */
1979 static enum route_map_cmd_result_t
1980 route_set_weight(void *rule
, const struct prefix
*prefix
, void *object
)
1982 struct rmap_value
*rv
;
1983 struct bgp_path_info
*path
;
1985 /* Fetch routemap's rule information. */
1989 /* Set weight value. */
1990 path
->attr
->weight
= route_value_adjust(rv
, 0, path
->peer
);
1995 /* Set local preference rule structure. */
1996 static const struct route_map_rule_cmd route_set_weight_cmd
= {
1999 route_value_compile
,
2003 /* `set distance DISTANCE */
2004 static enum route_map_cmd_result_t
2005 route_set_distance(void *rule
, const struct prefix
*prefix
, void *object
)
2007 struct bgp_path_info
*path
= object
;
2008 struct rmap_value
*rv
= rule
;
2010 path
->attr
->distance
= rv
->value
;
2015 /* set distance rule structure */
2016 static const struct route_map_rule_cmd route_set_distance_cmd
= {
2019 route_value_compile
,
2023 /* `set metric METRIC' */
2025 /* Set metric to attribute. */
2026 static enum route_map_cmd_result_t
2027 route_set_metric(void *rule
, const struct prefix
*prefix
, void *object
)
2029 struct rmap_value
*rv
;
2030 struct bgp_path_info
*path
;
2033 /* Fetch routemap's rule information. */
2037 if (path
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
))
2038 med
= path
->attr
->med
;
2040 path
->attr
->med
= route_value_adjust(rv
, med
, path
->peer
);
2041 path
->attr
->flag
|= ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
);
2046 /* Set metric rule structure. */
2047 static const struct route_map_rule_cmd route_set_metric_cmd
= {
2050 route_value_compile
,
2054 /* `set table (1-4294967295)' */
2056 static enum route_map_cmd_result_t
2057 route_set_table_id(void *rule
, const struct prefix
*prefix
,
2061 struct rmap_value
*rv
;
2062 struct bgp_path_info
*path
;
2064 /* Fetch routemap's rule information. */
2068 path
->attr
->rmap_table_id
= rv
->value
;
2073 /* Set table_id rule structure. */
2074 static const struct route_map_rule_cmd route_set_table_id_cmd
= {
2077 route_value_compile
,
2081 /* `set as-path prepend ASPATH' */
2083 /* For AS path prepend mechanism. */
2084 static enum route_map_cmd_result_t
2085 route_set_aspath_prepend(void *rule
, const struct prefix
*prefix
, void *object
)
2087 struct aspath
*aspath
;
2089 struct bgp_path_info
*path
;
2093 if (path
->attr
->aspath
->refcnt
)
2094 new = aspath_dup(path
->attr
->aspath
);
2096 new = path
->attr
->aspath
;
2098 if ((uintptr_t)rule
> 10) {
2100 aspath_prepend(aspath
, new);
2102 as_t as
= aspath_leftmost(new);
2104 new = aspath_add_seq_n(new, as
, (uintptr_t)rule
);
2107 path
->attr
->aspath
= new;
2112 static void *route_set_aspath_prepend_compile(const char *arg
)
2116 if (sscanf(arg
, "last-as %u", &num
) == 1 && num
> 0 && num
<= 10)
2117 return (void *)(uintptr_t)num
;
2119 return route_aspath_compile(arg
);
2122 static void route_set_aspath_prepend_free(void *rule
)
2124 if ((uintptr_t)rule
> 10)
2125 route_aspath_free(rule
);
2129 /* Set as-path prepend rule structure. */
2130 static const struct route_map_rule_cmd route_set_aspath_prepend_cmd
= {
2132 route_set_aspath_prepend
,
2133 route_set_aspath_prepend_compile
,
2134 route_set_aspath_prepend_free
,
2137 /* `set as-path exclude ASn' */
2139 /* For ASN exclude mechanism.
2140 * Iterate over ASns requested and filter them from the given AS_PATH one by
2142 * Make a deep copy of existing AS_PATH, but for the first ASn only.
2144 static enum route_map_cmd_result_t
2145 route_set_aspath_exclude(void *rule
, const struct prefix
*dummy
, void *object
)
2147 struct aspath
*new_path
, *exclude_path
;
2148 struct bgp_path_info
*path
;
2150 exclude_path
= rule
;
2152 if (path
->attr
->aspath
->refcnt
)
2153 new_path
= aspath_dup(path
->attr
->aspath
);
2155 new_path
= path
->attr
->aspath
;
2156 path
->attr
->aspath
= aspath_filter_exclude(new_path
, exclude_path
);
2161 /* Set ASn exlude rule structure. */
2162 static const struct route_map_rule_cmd route_set_aspath_exclude_cmd
= {
2164 route_set_aspath_exclude
,
2165 route_aspath_compile
,
2169 /* `set community COMMUNITY' */
2170 struct rmap_com_set
{
2171 struct community
*com
;
2176 /* For community set mechanism. */
2177 static enum route_map_cmd_result_t
2178 route_set_community(void *rule
, const struct prefix
*prefix
, void *object
)
2180 struct rmap_com_set
*rcs
;
2181 struct bgp_path_info
*path
;
2183 struct community
*new = NULL
;
2184 struct community
*old
;
2185 struct community
*merge
;
2190 old
= attr
->community
;
2194 attr
->flag
&= ~(ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES
));
2195 attr
->community
= NULL
;
2196 /* See the longer comment down below. */
2197 if (old
&& old
->refcnt
== 0)
2198 community_free(&old
);
2202 /* "additive" case. */
2203 if (rcs
->additive
&& old
) {
2204 merge
= community_merge(community_dup(old
), rcs
->com
);
2206 new = community_uniq_sort(merge
);
2207 community_free(&merge
);
2209 new = community_dup(rcs
->com
);
2211 /* HACK: if the old community is not intern'd,
2212 * we should free it here, or all reference to it may be
2214 * Really need to cleanup attribute caching sometime.
2216 if (old
&& old
->refcnt
== 0)
2217 community_free(&old
);
2219 /* will be interned by caller if required */
2220 attr
->community
= new;
2222 attr
->flag
|= ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES
);
2227 /* Compile function for set community. */
2228 static void *route_set_community_compile(const char *arg
)
2230 struct rmap_com_set
*rcs
;
2231 struct community
*com
= NULL
;
2236 if (strcmp(arg
, "none") == 0)
2239 sp
= strstr(arg
, "additive");
2241 if (sp
&& sp
> arg
) {
2242 /* "additive" keyword is included. */
2247 com
= community_str2com(arg
);
2256 rcs
= XCALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(struct rmap_com_set
));
2258 rcs
->additive
= additive
;
2264 /* Free function for set community. */
2265 static void route_set_community_free(void *rule
)
2267 struct rmap_com_set
*rcs
= rule
;
2270 community_free(&rcs
->com
);
2271 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rcs
);
2274 /* Set community rule structure. */
2275 static const struct route_map_rule_cmd route_set_community_cmd
= {
2277 route_set_community
,
2278 route_set_community_compile
,
2279 route_set_community_free
,
2282 /* `set community COMMUNITY' */
2283 struct rmap_lcom_set
{
2284 struct lcommunity
*lcom
;
2290 /* For lcommunity set mechanism. */
2291 static enum route_map_cmd_result_t
2292 route_set_lcommunity(void *rule
, const struct prefix
*prefix
, void *object
)
2294 struct rmap_lcom_set
*rcs
;
2295 struct bgp_path_info
*path
;
2297 struct lcommunity
*new = NULL
;
2298 struct lcommunity
*old
;
2299 struct lcommunity
*merge
;
2304 old
= attr
->lcommunity
;
2308 attr
->flag
&= ~(ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES
));
2309 attr
->lcommunity
= NULL
;
2311 /* See the longer comment down below. */
2312 if (old
&& old
->refcnt
== 0)
2313 lcommunity_free(&old
);
2317 if (rcs
->additive
&& old
) {
2318 merge
= lcommunity_merge(lcommunity_dup(old
), rcs
->lcom
);
2320 new = lcommunity_uniq_sort(merge
);
2321 lcommunity_free(&merge
);
2323 new = lcommunity_dup(rcs
->lcom
);
2325 /* HACK: if the old large-community is not intern'd,
2326 * we should free it here, or all reference to it may be
2328 * Really need to cleanup attribute caching sometime.
2330 if (old
&& old
->refcnt
== 0)
2331 lcommunity_free(&old
);
2333 /* will be intern()'d or attr_flush()'d by bgp_update_main() */
2334 attr
->lcommunity
= new;
2336 attr
->flag
|= ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES
);
2341 /* Compile function for set community. */
2342 static void *route_set_lcommunity_compile(const char *arg
)
2344 struct rmap_lcom_set
*rcs
;
2345 struct lcommunity
*lcom
= NULL
;
2350 if (strcmp(arg
, "none") == 0)
2353 sp
= strstr(arg
, "additive");
2355 if (sp
&& sp
> arg
) {
2356 /* "additive" keyworkd is included. */
2361 lcom
= lcommunity_str2com(arg
);
2370 rcs
= XCALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(struct rmap_com_set
));
2372 rcs
->additive
= additive
;
2378 /* Free function for set lcommunity. */
2379 static void route_set_lcommunity_free(void *rule
)
2381 struct rmap_lcom_set
*rcs
= rule
;
2384 lcommunity_free(&rcs
->lcom
);
2386 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rcs
);
2389 /* Set community rule structure. */
2390 static const struct route_map_rule_cmd route_set_lcommunity_cmd
= {
2392 route_set_lcommunity
,
2393 route_set_lcommunity_compile
,
2394 route_set_lcommunity_free
,
2397 /* `set large-comm-list (<1-99>|<100-500>|WORD) delete' */
2399 /* For large community set mechanism. */
2400 static enum route_map_cmd_result_t
2401 route_set_lcommunity_delete(void *rule
, const struct prefix
*pfx
, void *object
)
2403 struct community_list
*list
;
2404 struct lcommunity
*merge
;
2405 struct lcommunity
*new;
2406 struct lcommunity
*old
;
2407 struct bgp_path_info
*path
;
2408 struct rmap_community
*rcom
= rule
;
2414 list
= community_list_lookup(bgp_clist
, rcom
->name
, rcom
->name_hash
,
2415 LARGE_COMMUNITY_LIST_MASTER
);
2416 old
= path
->attr
->lcommunity
;
2419 merge
= lcommunity_list_match_delete(lcommunity_dup(old
), list
);
2420 new = lcommunity_uniq_sort(merge
);
2421 lcommunity_free(&merge
);
2423 /* HACK: if the old community is not intern'd,
2424 * we should free it here, or all reference to it may be
2426 * Really need to cleanup attribute caching sometime.
2428 if (old
->refcnt
== 0)
2429 lcommunity_free(&old
);
2431 if (new->size
== 0) {
2432 path
->attr
->lcommunity
= NULL
;
2434 ~ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES
);
2435 lcommunity_free(&new);
2437 path
->attr
->lcommunity
= new;
2439 ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES
);
2446 /* Compile function for set lcommunity. */
2447 static void *route_set_lcommunity_delete_compile(const char *arg
)
2449 struct rmap_community
*rcom
;
2453 frrstr_split(arg
, " ", &splits
, &num
);
2455 rcom
= XCALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(struct rmap_community
));
2456 rcom
->name
= XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, splits
[0]);
2457 rcom
->name_hash
= bgp_clist_hash_key(rcom
->name
);
2459 for (int i
= 0; i
< num
; i
++)
2460 XFREE(MTYPE_TMP
, splits
[i
]);
2461 XFREE(MTYPE_TMP
, splits
);
2466 /* Free function for set lcommunity. */
2467 static void route_set_lcommunity_delete_free(void *rule
)
2469 struct rmap_community
*rcom
= rule
;
2471 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rcom
->name
);
2472 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rcom
);
2475 /* Set lcommunity rule structure. */
2476 static const struct route_map_rule_cmd route_set_lcommunity_delete_cmd
= {
2478 route_set_lcommunity_delete
,
2479 route_set_lcommunity_delete_compile
,
2480 route_set_lcommunity_delete_free
,
2484 /* `set comm-list (<1-99>|<100-500>|WORD) delete' */
2486 /* For community set mechanism. */
2487 static enum route_map_cmd_result_t
2488 route_set_community_delete(void *rule
, const struct prefix
*prefix
,
2491 struct community_list
*list
;
2492 struct community
*merge
;
2493 struct community
*new;
2494 struct community
*old
;
2495 struct bgp_path_info
*path
;
2496 struct rmap_community
*rcom
= rule
;
2502 list
= community_list_lookup(bgp_clist
, rcom
->name
, rcom
->name_hash
,
2503 COMMUNITY_LIST_MASTER
);
2504 old
= path
->attr
->community
;
2507 merge
= community_list_match_delete(community_dup(old
), list
);
2508 new = community_uniq_sort(merge
);
2509 community_free(&merge
);
2511 /* HACK: if the old community is not intern'd,
2512 * we should free it here, or all reference to it may be
2514 * Really need to cleanup attribute caching sometime.
2516 if (old
->refcnt
== 0)
2517 community_free(&old
);
2519 if (new->size
== 0) {
2520 path
->attr
->community
= NULL
;
2522 ~ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES
);
2523 community_free(&new);
2525 path
->attr
->community
= new;
2526 path
->attr
->flag
|= ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES
);
2533 /* Compile function for set community. */
2534 static void *route_set_community_delete_compile(const char *arg
)
2536 struct rmap_community
*rcom
;
2540 frrstr_split(arg
, " ", &splits
, &num
);
2542 rcom
= XCALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(struct rmap_community
));
2543 rcom
->name
= XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, splits
[0]);
2544 rcom
->name_hash
= bgp_clist_hash_key(rcom
->name
);
2546 for (int i
= 0; i
< num
; i
++)
2547 XFREE(MTYPE_TMP
, splits
[i
]);
2548 XFREE(MTYPE_TMP
, splits
);
2553 /* Free function for set community. */
2554 static void route_set_community_delete_free(void *rule
)
2556 struct rmap_community
*rcom
= rule
;
2558 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rcom
->name
);
2559 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rcom
);
2562 /* Set community rule structure. */
2563 static const struct route_map_rule_cmd route_set_community_delete_cmd
= {
2565 route_set_community_delete
,
2566 route_set_community_delete_compile
,
2567 route_set_community_delete_free
,
2570 /* `set extcommunity rt COMMUNITY' */
2572 struct rmap_ecom_set
{
2573 struct ecommunity
*ecom
;
2577 /* For community set mechanism. Used by _rt and _soo. */
2578 static enum route_map_cmd_result_t
2579 route_set_ecommunity(void *rule
, const struct prefix
*prefix
, void *object
)
2581 struct rmap_ecom_set
*rcs
;
2582 struct ecommunity
*new_ecom
;
2583 struct ecommunity
*old_ecom
;
2584 struct bgp_path_info
*path
;
2592 attr
->flag
&= ~(ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
));
2593 attr
->ecommunity
= NULL
;
2600 /* We assume additive for Extended Community. */
2601 old_ecom
= path
->attr
->ecommunity
;
2605 ecommunity_merge(ecommunity_dup(old_ecom
), rcs
->ecom
);
2607 /* old_ecom->refcnt = 1 => owned elsewhere, e.g.
2608 * bgp_update_receive()
2609 * ->refcnt = 0 => set by a previous route-map
2611 if (!old_ecom
->refcnt
)
2612 ecommunity_free(&old_ecom
);
2614 new_ecom
= ecommunity_dup(rcs
->ecom
);
2616 /* will be intern()'d or attr_flush()'d by bgp_update_main() */
2617 path
->attr
->ecommunity
= new_ecom
;
2619 path
->attr
->flag
|= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
);
2624 static void *route_set_ecommunity_none_compile(const char *arg
)
2626 struct rmap_ecom_set
*rcs
;
2629 if (strncmp(arg
, "none", 4) == 0)
2632 rcs
= XCALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(struct rmap_ecom_set
));
2639 static void *route_set_ecommunity_rt_compile(const char *arg
)
2641 struct rmap_ecom_set
*rcs
;
2642 struct ecommunity
*ecom
;
2644 ecom
= ecommunity_str2com(arg
, ECOMMUNITY_ROUTE_TARGET
, 0);
2648 rcs
= XCALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(struct rmap_ecom_set
));
2649 rcs
->ecom
= ecommunity_intern(ecom
);
2655 /* Free function for set community. Used by _rt and _soo */
2656 static void route_set_ecommunity_free(void *rule
)
2658 struct rmap_ecom_set
*rcs
= rule
;
2661 ecommunity_unintern(&rcs
->ecom
);
2663 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rcs
);
2666 static const struct route_map_rule_cmd route_set_ecommunity_none_cmd
= {
2668 route_set_ecommunity
,
2669 route_set_ecommunity_none_compile
,
2670 route_set_ecommunity_free
,
2673 /* Set community rule structure. */
2674 static const struct route_map_rule_cmd route_set_ecommunity_rt_cmd
= {
2676 route_set_ecommunity
,
2677 route_set_ecommunity_rt_compile
,
2678 route_set_ecommunity_free
,
2681 /* `set extcommunity soo COMMUNITY' */
2683 /* Compile function for set community. */
2684 static void *route_set_ecommunity_soo_compile(const char *arg
)
2686 struct rmap_ecom_set
*rcs
;
2687 struct ecommunity
*ecom
;
2689 ecom
= ecommunity_str2com(arg
, ECOMMUNITY_SITE_ORIGIN
, 0);
2693 rcs
= XCALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(struct rmap_ecom_set
));
2694 rcs
->ecom
= ecommunity_intern(ecom
);
2700 /* Set community rule structure. */
2701 static const struct route_map_rule_cmd route_set_ecommunity_soo_cmd
= {
2703 route_set_ecommunity
,
2704 route_set_ecommunity_soo_compile
,
2705 route_set_ecommunity_free
,
2708 /* `set extcommunity bandwidth' */
2710 struct rmap_ecomm_lb_set
{
2712 #define RMAP_ECOMM_LB_SET_VALUE 1
2713 #define RMAP_ECOMM_LB_SET_CUMUL 2
2714 #define RMAP_ECOMM_LB_SET_NUM_MPATH 3
2719 static enum route_map_cmd_result_t
2720 route_set_ecommunity_lb(void *rule
, const struct prefix
*prefix
, void *object
)
2722 struct rmap_ecomm_lb_set
*rels
= rule
;
2723 struct bgp_path_info
*path
;
2725 struct ecommunity ecom_lb
= {0};
2726 struct ecommunity_val lb_eval
;
2727 uint32_t bw_bytes
= 0;
2728 uint16_t mpath_count
= 0;
2729 struct ecommunity
*new_ecom
;
2730 struct ecommunity
*old_ecom
;
2735 if (!peer
|| !peer
->bgp
)
2738 /* Build link bandwidth extended community */
2739 as
= (peer
->bgp
->as
> BGP_AS_MAX
) ? BGP_AS_TRANS
: peer
->bgp
->as
;
2740 if (rels
->lb_type
== RMAP_ECOMM_LB_SET_VALUE
) {
2741 bw_bytes
= ((uint64_t)rels
->bw
* 1000 * 1000) / 8;
2742 } else if (rels
->lb_type
== RMAP_ECOMM_LB_SET_CUMUL
) {
2743 /* process this only for the best path. */
2744 if (!CHECK_FLAG(path
->flags
, BGP_PATH_SELECTED
))
2747 bw_bytes
= (uint32_t)bgp_path_info_mpath_cumbw(path
);
2751 } else if (rels
->lb_type
== RMAP_ECOMM_LB_SET_NUM_MPATH
) {
2753 /* process this only for the best path. */
2754 if (!CHECK_FLAG(path
->flags
, BGP_PATH_SELECTED
))
2757 bw_bytes
= ((uint64_t)peer
->bgp
->lb_ref_bw
* 1000 * 1000) / 8;
2758 mpath_count
= bgp_path_info_mpath_count(path
) + 1;
2759 bw_bytes
*= mpath_count
;
2762 encode_lb_extcomm(as
, bw_bytes
, rels
->non_trans
, &lb_eval
,
2763 CHECK_FLAG(peer
->flags
,
2764 PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE
));
2766 /* add to route or merge with existing */
2767 old_ecom
= path
->attr
->ecommunity
;
2769 new_ecom
= ecommunity_dup(old_ecom
);
2770 ecommunity_add_val(new_ecom
, &lb_eval
, true, true);
2771 if (!old_ecom
->refcnt
)
2772 ecommunity_free(&old_ecom
);
2775 ecom_lb
.unit_size
= ECOMMUNITY_SIZE
;
2776 ecom_lb
.val
= (uint8_t *)lb_eval
.val
;
2777 new_ecom
= ecommunity_dup(&ecom_lb
);
2780 /* new_ecom will be intern()'d or attr_flush()'d in call stack */
2781 path
->attr
->ecommunity
= new_ecom
;
2782 path
->attr
->flag
|= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
);
2784 /* Mark that route-map has set link bandwidth; used in attribute
2785 * setting decisions.
2787 SET_FLAG(path
->attr
->rmap_change_flags
, BATTR_RMAP_LINK_BW_SET
);
2792 static void *route_set_ecommunity_lb_compile(const char *arg
)
2794 struct rmap_ecomm_lb_set
*rels
;
2797 char bw_str
[40] = {0};
2799 bool non_trans
= false;
2802 p
= strchr(arg
, ' ');
2807 memcpy(bw_str
, arg
, len
);
2812 if (strcmp(str
, "cumulative") == 0)
2813 lb_type
= RMAP_ECOMM_LB_SET_CUMUL
;
2814 else if (strcmp(str
, "num-multipaths") == 0)
2815 lb_type
= RMAP_ECOMM_LB_SET_NUM_MPATH
;
2819 bw
= strtoul(str
, &end
, 10);
2822 lb_type
= RMAP_ECOMM_LB_SET_VALUE
;
2825 rels
= XCALLOC(MTYPE_ROUTE_MAP_COMPILED
,
2826 sizeof(struct rmap_ecomm_lb_set
));
2827 rels
->lb_type
= lb_type
;
2829 rels
->non_trans
= non_trans
;
2834 static void route_set_ecommunity_lb_free(void *rule
)
2836 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
2839 /* Set community rule structure. */
2840 struct route_map_rule_cmd route_set_ecommunity_lb_cmd
= {
2841 "extcommunity bandwidth",
2842 route_set_ecommunity_lb
,
2843 route_set_ecommunity_lb_compile
,
2844 route_set_ecommunity_lb_free
,
2847 /* `set origin ORIGIN' */
2849 /* For origin set. */
2850 static enum route_map_cmd_result_t
2851 route_set_origin(void *rule
, const struct prefix
*prefix
, void *object
)
2854 struct bgp_path_info
*path
;
2859 path
->attr
->origin
= *origin
;
2864 /* Compile function for origin set. */
2865 static void *route_set_origin_compile(const char *arg
)
2869 origin
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(uint8_t));
2871 if (strcmp(arg
, "igp") == 0)
2873 else if (strcmp(arg
, "egp") == 0)
2881 /* Compile function for origin set. */
2882 static void route_set_origin_free(void *rule
)
2884 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
2887 /* Set origin rule structure. */
2888 static const struct route_map_rule_cmd route_set_origin_cmd
= {
2891 route_set_origin_compile
,
2892 route_set_origin_free
,
2895 /* `set atomic-aggregate' */
2897 /* For atomic aggregate set. */
2898 static enum route_map_cmd_result_t
2899 route_set_atomic_aggregate(void *rule
, const struct prefix
*pfx
, void *object
)
2901 struct bgp_path_info
*path
;
2904 path
->attr
->flag
|= ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
);
2909 /* Compile function for atomic aggregate. */
2910 static void *route_set_atomic_aggregate_compile(const char *arg
)
2915 /* Compile function for atomic aggregate. */
2916 static void route_set_atomic_aggregate_free(void *rule
)
2921 /* Set atomic aggregate rule structure. */
2922 static const struct route_map_rule_cmd route_set_atomic_aggregate_cmd
= {
2924 route_set_atomic_aggregate
,
2925 route_set_atomic_aggregate_compile
,
2926 route_set_atomic_aggregate_free
,
2929 /* `set aggregator as AS A.B.C.D' */
2932 struct in_addr address
;
2935 static enum route_map_cmd_result_t
2936 route_set_aggregator_as(void *rule
, const struct prefix
*prefix
, void *object
)
2938 struct bgp_path_info
*path
;
2939 struct aggregator
*aggregator
;
2944 path
->attr
->aggregator_as
= aggregator
->as
;
2945 path
->attr
->aggregator_addr
= aggregator
->address
;
2946 path
->attr
->flag
|= ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR
);
2951 static void *route_set_aggregator_as_compile(const char *arg
)
2953 struct aggregator
*aggregator
;
2959 XCALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(struct aggregator
));
2960 if (sscanf(arg
, "%s %s", as
, address
) != 2) {
2961 XFREE(MTYPE_ROUTE_MAP_COMPILED
, aggregator
);
2965 aggregator
->as
= strtoul(as
, NULL
, 10);
2966 ret
= inet_aton(address
, &aggregator
->address
);
2968 XFREE(MTYPE_ROUTE_MAP_COMPILED
, aggregator
);
2974 static void route_set_aggregator_as_free(void *rule
)
2976 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
2979 static const struct route_map_rule_cmd route_set_aggregator_as_cmd
= {
2981 route_set_aggregator_as
,
2982 route_set_aggregator_as_compile
,
2983 route_set_aggregator_as_free
,
2986 /* Set tag to object. object must be pointer to struct bgp_path_info */
2987 static enum route_map_cmd_result_t
2988 route_set_tag(void *rule
, const struct prefix
*prefix
, void *object
)
2991 struct bgp_path_info
*path
;
2997 path
->attr
->tag
= *tag
;
3002 /* Route map commands for tag set. */
3003 static const struct route_map_rule_cmd route_set_tag_cmd
= {
3006 route_map_rule_tag_compile
,
3007 route_map_rule_tag_free
,
3010 /* Set label-index to object. object must be pointer to struct bgp_path_info */
3011 static enum route_map_cmd_result_t
3012 route_set_label_index(void *rule
, const struct prefix
*prefix
, void *object
)
3014 struct rmap_value
*rv
;
3015 struct bgp_path_info
*path
;
3016 uint32_t label_index
;
3018 /* Fetch routemap's rule information. */
3022 /* Set label-index value. */
3023 label_index
= rv
->value
;
3025 path
->attr
->label_index
= label_index
;
3026 path
->attr
->flag
|= ATTR_FLAG_BIT(BGP_ATTR_PREFIX_SID
);
3032 /* Route map commands for label-index set. */
3033 static const struct route_map_rule_cmd route_set_label_index_cmd
= {
3035 route_set_label_index
,
3036 route_value_compile
,
3040 /* `match ipv6 address IP_ACCESS_LIST' */
3042 static enum route_map_cmd_result_t
3043 route_match_ipv6_address(void *rule
, const struct prefix
*prefix
, void *object
)
3045 struct access_list
*alist
;
3047 if (prefix
->family
== AF_INET6
) {
3048 alist
= access_list_lookup(AFI_IP6
, (char *)rule
);
3050 return RMAP_NOMATCH
;
3052 return (access_list_apply(alist
, prefix
) == FILTER_DENY
3056 return RMAP_NOMATCH
;
3059 static void *route_match_ipv6_address_compile(const char *arg
)
3061 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
3064 static void route_match_ipv6_address_free(void *rule
)
3066 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
3069 /* Route map commands for ip address matching. */
3070 static const struct route_map_rule_cmd route_match_ipv6_address_cmd
= {
3072 route_match_ipv6_address
,
3073 route_match_ipv6_address_compile
,
3074 route_match_ipv6_address_free
3077 /* `match ipv6 next-hop ACCESSLIST6_NAME' */
3078 static enum route_map_cmd_result_t
3079 route_match_ipv6_next_hop(void *rule
, const struct prefix
*prefix
, void *object
)
3081 struct bgp_path_info
*path
;
3082 struct access_list
*alist
;
3083 struct prefix_ipv6 p
;
3085 if (prefix
->family
== AF_INET6
) {
3087 p
.family
= AF_INET6
;
3088 p
.prefix
= path
->attr
->mp_nexthop_global
;
3089 p
.prefixlen
= IPV6_MAX_BITLEN
;
3091 alist
= access_list_lookup(AFI_IP6
, (char *)rule
);
3093 return RMAP_NOMATCH
;
3095 if (access_list_apply(alist
, &p
) == FILTER_PERMIT
)
3098 if (path
->attr
->mp_nexthop_len
3099 == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
) {
3100 p
.prefix
= path
->attr
->mp_nexthop_local
;
3101 if (access_list_apply(alist
, &p
) == FILTER_PERMIT
)
3106 return RMAP_NOMATCH
;
3109 static void *route_match_ipv6_next_hop_compile(const char *arg
)
3111 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
3114 static void route_match_ipv6_next_hop_free(void *rule
)
3116 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
3119 static const struct route_map_rule_cmd route_match_ipv6_next_hop_cmd
= {
3121 route_match_ipv6_next_hop
,
3122 route_match_ipv6_next_hop_compile
,
3123 route_match_ipv6_next_hop_free
3126 /* `match ipv6 next-hop IP_ADDRESS' */
3128 static enum route_map_cmd_result_t
3129 route_match_ipv6_next_hop_address(void *rule
, const struct prefix
*prefix
,
3132 struct in6_addr
*addr
= rule
;
3133 struct bgp_path_info
*path
;
3137 if (IPV6_ADDR_SAME(&path
->attr
->mp_nexthop_global
, addr
))
3140 if (path
->attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
3141 && IPV6_ADDR_SAME(&path
->attr
->mp_nexthop_local
, rule
))
3144 return RMAP_NOMATCH
;
3147 static void *route_match_ipv6_next_hop_address_compile(const char *arg
)
3149 struct in6_addr
*address
;
3152 address
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(struct in6_addr
));
3154 ret
= inet_pton(AF_INET6
, arg
, address
);
3156 XFREE(MTYPE_ROUTE_MAP_COMPILED
, address
);
3163 static void route_match_ipv6_next_hop_address_free(void *rule
)
3165 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
3168 static const struct route_map_rule_cmd route_match_ipv6_next_hop_address_cmd
= {
3169 "ipv6 next-hop address",
3170 route_match_ipv6_next_hop_address
,
3171 route_match_ipv6_next_hop_address_compile
,
3172 route_match_ipv6_next_hop_address_free
3175 /* `match ip next-hop IP_ADDRESS' */
3177 static enum route_map_cmd_result_t
3178 route_match_ipv4_next_hop(void *rule
, const struct prefix
*prefix
, void *object
)
3180 struct in_addr
*addr
= rule
;
3181 struct bgp_path_info
*path
;
3185 if (path
->attr
->nexthop
.s_addr
== addr
->s_addr
3186 || (path
->attr
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV4
3187 && IPV4_ADDR_SAME(&path
->attr
->mp_nexthop_global_in
, addr
)))
3190 return RMAP_NOMATCH
;
3193 static void *route_match_ipv4_next_hop_compile(const char *arg
)
3195 struct in_addr
*address
;
3198 address
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(struct in_addr
));
3200 ret
= inet_pton(AF_INET
, arg
, address
);
3202 XFREE(MTYPE_ROUTE_MAP_COMPILED
, address
);
3209 static void route_match_ipv4_next_hop_free(void *rule
)
3211 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
3214 static const struct route_map_rule_cmd route_match_ipv4_next_hop_cmd
= {
3215 "ip next-hop address",
3216 route_match_ipv4_next_hop
,
3217 route_match_ipv4_next_hop_compile
,
3218 route_match_ipv4_next_hop_free
3221 /* `match ipv6 address prefix-list PREFIX_LIST' */
3223 static enum route_map_cmd_result_t
3224 route_match_ipv6_address_prefix_list(void *rule
, const struct prefix
*prefix
,
3227 return route_match_address_prefix_list(rule
, AFI_IP6
, prefix
, object
);
3230 static void *route_match_ipv6_address_prefix_list_compile(const char *arg
)
3232 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
3235 static void route_match_ipv6_address_prefix_list_free(void *rule
)
3237 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
3240 static const struct route_map_rule_cmd
3241 route_match_ipv6_address_prefix_list_cmd
= {
3242 "ipv6 address prefix-list",
3243 route_match_ipv6_address_prefix_list
,
3244 route_match_ipv6_address_prefix_list_compile
,
3245 route_match_ipv6_address_prefix_list_free
3248 /* `match ipv6 next-hop type <TYPE>' */
3250 static enum route_map_cmd_result_t
3251 route_match_ipv6_next_hop_type(void *rule
, const struct prefix
*prefix
,
3254 struct bgp_path_info
*path
;
3255 struct in6_addr
*addr
= rule
;
3257 if (prefix
->family
== AF_INET6
) {
3258 path
= (struct bgp_path_info
*)object
;
3260 return RMAP_NOMATCH
;
3262 if (IPV6_ADDR_SAME(&path
->attr
->mp_nexthop_global
, addr
)
3263 && !path
->attr
->nh_ifindex
)
3267 return RMAP_NOMATCH
;
3270 static void *route_match_ipv6_next_hop_type_compile(const char *arg
)
3272 struct in6_addr
*address
;
3275 address
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(struct in6_addr
));
3277 ret
= inet_pton(AF_INET6
, "::0", address
);
3279 XFREE(MTYPE_ROUTE_MAP_COMPILED
, address
);
3286 static void route_match_ipv6_next_hop_type_free(void *rule
)
3288 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
3291 static const struct route_map_rule_cmd
3292 route_match_ipv6_next_hop_type_cmd
= {
3293 "ipv6 next-hop type",
3294 route_match_ipv6_next_hop_type
,
3295 route_match_ipv6_next_hop_type_compile
,
3296 route_match_ipv6_next_hop_type_free
3299 /* `set ipv6 nexthop global IP_ADDRESS' */
3301 /* Set nexthop to object. ojbect must be pointer to struct attr. */
3302 static enum route_map_cmd_result_t
3303 route_set_ipv6_nexthop_global(void *rule
, const struct prefix
*p
, void *object
)
3305 struct in6_addr
*address
;
3306 struct bgp_path_info
*path
;
3308 /* Fetch routemap's rule information. */
3312 /* Set next hop value. */
3313 path
->attr
->mp_nexthop_global
= *address
;
3315 /* Set nexthop length. */
3316 if (path
->attr
->mp_nexthop_len
== 0)
3317 path
->attr
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL
;
3319 SET_FLAG(path
->attr
->rmap_change_flags
,
3320 BATTR_RMAP_IPV6_GLOBAL_NHOP_CHANGED
);
3325 /* Route map `ip next-hop' compile function. Given string is converted
3326 to struct in_addr structure. */
3327 static void *route_set_ipv6_nexthop_global_compile(const char *arg
)
3330 struct in6_addr
*address
;
3332 address
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(struct in6_addr
));
3334 ret
= inet_pton(AF_INET6
, arg
, address
);
3337 XFREE(MTYPE_ROUTE_MAP_COMPILED
, address
);
3344 /* Free route map's compiled `ip next-hop' value. */
3345 static void route_set_ipv6_nexthop_global_free(void *rule
)
3347 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
3350 /* Route map commands for ip nexthop set. */
3351 static const struct route_map_rule_cmd
3352 route_set_ipv6_nexthop_global_cmd
= {
3353 "ipv6 next-hop global",
3354 route_set_ipv6_nexthop_global
,
3355 route_set_ipv6_nexthop_global_compile
,
3356 route_set_ipv6_nexthop_global_free
3359 /* Set next-hop preference value. */
3360 static enum route_map_cmd_result_t
3361 route_set_ipv6_nexthop_prefer_global(void *rule
, const struct prefix
*prefix
,
3364 struct bgp_path_info
*path
;
3367 /* Fetch routemap's rule information. */
3371 if (CHECK_FLAG(peer
->rmap_type
, PEER_RMAP_TYPE_IN
)
3372 || CHECK_FLAG(peer
->rmap_type
, PEER_RMAP_TYPE_IMPORT
)) {
3373 /* Set next hop preference to global */
3374 path
->attr
->mp_nexthop_prefer_global
= true;
3375 SET_FLAG(path
->attr
->rmap_change_flags
,
3376 BATTR_RMAP_IPV6_PREFER_GLOBAL_CHANGED
);
3378 path
->attr
->mp_nexthop_prefer_global
= false;
3379 SET_FLAG(path
->attr
->rmap_change_flags
,
3380 BATTR_RMAP_IPV6_PREFER_GLOBAL_CHANGED
);
3386 static void *route_set_ipv6_nexthop_prefer_global_compile(const char *arg
)
3390 rins
= XCALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(int));
3396 /* Free route map's compiled `ip next-hop' value. */
3397 static void route_set_ipv6_nexthop_prefer_global_free(void *rule
)
3399 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
3402 /* Route map commands for ip nexthop set preferred. */
3403 static const struct route_map_rule_cmd
3404 route_set_ipv6_nexthop_prefer_global_cmd
= {
3405 "ipv6 next-hop prefer-global",
3406 route_set_ipv6_nexthop_prefer_global
,
3407 route_set_ipv6_nexthop_prefer_global_compile
,
3408 route_set_ipv6_nexthop_prefer_global_free
3411 /* `set ipv6 nexthop local IP_ADDRESS' */
3413 /* Set nexthop to object. ojbect must be pointer to struct attr. */
3414 static enum route_map_cmd_result_t
3415 route_set_ipv6_nexthop_local(void *rule
, const struct prefix
*p
, void *object
)
3417 struct in6_addr
*address
;
3418 struct bgp_path_info
*path
;
3420 /* Fetch routemap's rule information. */
3424 /* Set next hop value. */
3425 path
->attr
->mp_nexthop_local
= *address
;
3427 /* Set nexthop length. */
3428 if (path
->attr
->mp_nexthop_len
!= BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
3429 path
->attr
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
;
3431 SET_FLAG(path
->attr
->rmap_change_flags
,
3432 BATTR_RMAP_IPV6_LL_NHOP_CHANGED
);
3437 /* Route map `ip nexthop' compile function. Given string is converted
3438 to struct in_addr structure. */
3439 static void *route_set_ipv6_nexthop_local_compile(const char *arg
)
3442 struct in6_addr
*address
;
3444 address
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(struct in6_addr
));
3446 ret
= inet_pton(AF_INET6
, arg
, address
);
3449 XFREE(MTYPE_ROUTE_MAP_COMPILED
, address
);
3456 /* Free route map's compiled `ip nexthop' value. */
3457 static void route_set_ipv6_nexthop_local_free(void *rule
)
3459 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
3462 /* Route map commands for ip nexthop set. */
3463 static const struct route_map_rule_cmd
3464 route_set_ipv6_nexthop_local_cmd
= {
3465 "ipv6 next-hop local",
3466 route_set_ipv6_nexthop_local
,
3467 route_set_ipv6_nexthop_local_compile
,
3468 route_set_ipv6_nexthop_local_free
3471 /* `set ipv6 nexthop peer-address' */
3473 /* Set nexthop to object. ojbect must be pointer to struct attr. */
3474 static enum route_map_cmd_result_t
3475 route_set_ipv6_nexthop_peer(void *rule
, const struct prefix
*pfx
, void *object
)
3477 struct in6_addr peer_address
;
3478 struct bgp_path_info
*path
;
3481 /* Fetch routemap's rule information. */
3485 if ((CHECK_FLAG(peer
->rmap_type
, PEER_RMAP_TYPE_IN
)
3486 || CHECK_FLAG(peer
->rmap_type
, PEER_RMAP_TYPE_IMPORT
))
3488 && sockunion_family(peer
->su_remote
) == AF_INET6
) {
3489 peer_address
= peer
->su_remote
->sin6
.sin6_addr
;
3490 /* Set next hop value and length in attribute. */
3491 if (IN6_IS_ADDR_LINKLOCAL(&peer_address
)) {
3492 path
->attr
->mp_nexthop_local
= peer_address
;
3493 if (path
->attr
->mp_nexthop_len
3494 != BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
3495 path
->attr
->mp_nexthop_len
=
3496 BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
;
3498 path
->attr
->mp_nexthop_global
= peer_address
;
3499 if (path
->attr
->mp_nexthop_len
== 0)
3500 path
->attr
->mp_nexthop_len
=
3501 BGP_ATTR_NHLEN_IPV6_GLOBAL
;
3504 } else if (CHECK_FLAG(peer
->rmap_type
, PEER_RMAP_TYPE_OUT
)) {
3505 /* The next hop value will be set as part of packet
3507 * Set the flags here to indicate that rewrite needs to
3509 * Also, clear the value - we clear both global and
3511 * nexthops, whether we send one or both is determined
3514 SET_FLAG(path
->attr
->rmap_change_flags
,
3515 BATTR_RMAP_NEXTHOP_PEER_ADDRESS
);
3516 /* clear next hop value. */
3517 memset(&(path
->attr
->mp_nexthop_global
), 0,
3518 sizeof(struct in6_addr
));
3519 memset(&(path
->attr
->mp_nexthop_local
), 0,
3520 sizeof(struct in6_addr
));
3526 /* Route map `ip next-hop' compile function. Given string is converted
3527 to struct in_addr structure. */
3528 static void *route_set_ipv6_nexthop_peer_compile(const char *arg
)
3532 rins
= XCALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(int));
3538 /* Free route map's compiled `ip next-hop' value. */
3539 static void route_set_ipv6_nexthop_peer_free(void *rule
)
3541 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
3544 /* Route map commands for ip nexthop set. */
3545 static const struct route_map_rule_cmd route_set_ipv6_nexthop_peer_cmd
= {
3546 "ipv6 next-hop peer-address",
3547 route_set_ipv6_nexthop_peer
,
3548 route_set_ipv6_nexthop_peer_compile
,
3549 route_set_ipv6_nexthop_peer_free
3552 /* `set ipv4 vpn next-hop A.B.C.D' */
3554 static enum route_map_cmd_result_t
3555 route_set_vpnv4_nexthop(void *rule
, const struct prefix
*prefix
, void *object
)
3557 struct in_addr
*address
;
3558 struct bgp_path_info
*path
;
3560 /* Fetch routemap's rule information. */
3564 /* Set next hop value. */
3565 path
->attr
->mp_nexthop_global_in
= *address
;
3566 path
->attr
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV4
;
3571 static void *route_set_vpnv4_nexthop_compile(const char *arg
)
3574 struct in_addr
*address
;
3576 address
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(struct in_addr
));
3578 ret
= inet_aton(arg
, address
);
3581 XFREE(MTYPE_ROUTE_MAP_COMPILED
, address
);
3588 /* `set ipv6 vpn next-hop A.B.C.D' */
3590 static enum route_map_cmd_result_t
3591 route_set_vpnv6_nexthop(void *rule
, const struct prefix
*prefix
, void *object
)
3593 struct in6_addr
*address
;
3594 struct bgp_path_info
*path
;
3596 /* Fetch routemap's rule information. */
3600 /* Set next hop value. */
3601 memcpy(&path
->attr
->mp_nexthop_global
, address
,
3602 sizeof(struct in6_addr
));
3603 path
->attr
->mp_nexthop_len
= BGP_ATTR_NHLEN_VPNV6_GLOBAL
;
3608 static void *route_set_vpnv6_nexthop_compile(const char *arg
)
3611 struct in6_addr
*address
;
3613 address
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(struct in6_addr
));
3614 ret
= inet_pton(AF_INET6
, arg
, address
);
3617 XFREE(MTYPE_ROUTE_MAP_COMPILED
, address
);
3624 static void route_set_vpn_nexthop_free(void *rule
)
3626 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
3629 /* Route map commands for ipv4 next-hop set. */
3630 static const struct route_map_rule_cmd route_set_vpnv4_nexthop_cmd
= {
3631 "ipv4 vpn next-hop",
3632 route_set_vpnv4_nexthop
,
3633 route_set_vpnv4_nexthop_compile
,
3634 route_set_vpn_nexthop_free
3637 /* Route map commands for ipv6 next-hop set. */
3638 static const struct route_map_rule_cmd route_set_vpnv6_nexthop_cmd
= {
3639 "ipv6 vpn next-hop",
3640 route_set_vpnv6_nexthop
,
3641 route_set_vpnv6_nexthop_compile
,
3642 route_set_vpn_nexthop_free
3645 /* `set originator-id' */
3647 /* For origin set. */
3648 static enum route_map_cmd_result_t
3649 route_set_originator_id(void *rule
, const struct prefix
*prefix
, void *object
)
3651 struct in_addr
*address
;
3652 struct bgp_path_info
*path
;
3657 path
->attr
->flag
|= ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
);
3658 path
->attr
->originator_id
= *address
;
3663 /* Compile function for originator-id set. */
3664 static void *route_set_originator_id_compile(const char *arg
)
3667 struct in_addr
*address
;
3669 address
= XMALLOC(MTYPE_ROUTE_MAP_COMPILED
, sizeof(struct in_addr
));
3671 ret
= inet_aton(arg
, address
);
3674 XFREE(MTYPE_ROUTE_MAP_COMPILED
, address
);
3681 /* Compile function for originator_id set. */
3682 static void route_set_originator_id_free(void *rule
)
3684 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
3687 /* Set originator-id rule structure. */
3688 static const struct route_map_rule_cmd route_set_originator_id_cmd
= {
3690 route_set_originator_id
,
3691 route_set_originator_id_compile
,
3692 route_set_originator_id_free
,
3696 * This is the workhorse routine for processing in/out routemap
3699 static void bgp_route_map_process_peer(const char *rmap_name
,
3700 struct route_map
*map
, struct peer
*peer
,
3701 int afi
, int safi
, int route_update
)
3703 struct bgp_filter
*filter
;
3705 if (!peer
|| !rmap_name
)
3708 filter
= &peer
->filter
[afi
][safi
];
3710 * in is for non-route-server clients,
3711 * out is for all peers
3713 if (filter
->map
[RMAP_IN
].name
3714 && (strcmp(rmap_name
, filter
->map
[RMAP_IN
].name
) == 0)) {
3715 filter
->map
[RMAP_IN
].map
= map
;
3717 if (route_update
&& peer_established(peer
)) {
3718 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
],
3719 PEER_FLAG_SOFT_RECONFIG
)) {
3720 if (bgp_debug_update(peer
, NULL
, NULL
, 1))
3722 "Processing route_map %s(%s:%s) update on peer %s (inbound, soft-reconfig)",
3723 rmap_name
, afi2str(afi
),
3724 safi2str(safi
), peer
->host
);
3726 bgp_soft_reconfig_in(peer
, afi
, safi
);
3727 } else if (CHECK_FLAG(peer
->cap
,
3728 PEER_CAP_REFRESH_OLD_RCV
)
3729 || CHECK_FLAG(peer
->cap
,
3730 PEER_CAP_REFRESH_NEW_RCV
)) {
3731 if (bgp_debug_update(peer
, NULL
, NULL
, 1))
3733 "Processing route_map %s(%s:%s) update on peer %s (inbound, route-refresh)",
3734 rmap_name
, afi2str(afi
),
3735 safi2str(safi
), peer
->host
);
3736 bgp_route_refresh_send(
3737 peer
, afi
, safi
, 0, 0, 0,
3738 BGP_ROUTE_REFRESH_NORMAL
);
3744 * For outbound, unsuppress and default-originate map change (content or
3745 * map created), merely update the "config" here, the actual route
3746 * announcement happens at the group level.
3748 if (filter
->map
[RMAP_OUT
].name
3749 && (strcmp(rmap_name
, filter
->map
[RMAP_OUT
].name
) == 0))
3750 filter
->map
[RMAP_OUT
].map
= map
;
3752 if (filter
->usmap
.name
&& (strcmp(rmap_name
, filter
->usmap
.name
) == 0))
3753 filter
->usmap
.map
= map
;
3755 if (filter
->advmap
.aname
3756 && (strcmp(rmap_name
, filter
->advmap
.aname
) == 0)) {
3757 filter
->advmap
.amap
= map
;
3760 if (filter
->advmap
.cname
3761 && (strcmp(rmap_name
, filter
->advmap
.cname
) == 0)) {
3762 filter
->advmap
.cmap
= map
;
3765 if (peer
->default_rmap
[afi
][safi
].name
3766 && (strcmp(rmap_name
, peer
->default_rmap
[afi
][safi
].name
) == 0))
3767 peer
->default_rmap
[afi
][safi
].map
= map
;
3769 /* Notify BGP conditional advertisement scanner percess */
3770 peer
->advmap_config_change
[afi
][safi
] = true;
3773 static void bgp_route_map_update_peer_group(const char *rmap_name
,
3774 struct route_map
*map
,
3777 struct peer_group
*group
;
3778 struct listnode
*node
, *nnode
;
3779 struct bgp_filter
*filter
;
3786 /* All the peers have been updated correctly already. This is
3787 * just updating the placeholder data. No real update required.
3789 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
3790 FOREACH_AFI_SAFI (afi
, safi
) {
3791 filter
= &group
->conf
->filter
[afi
][safi
];
3793 for (direct
= RMAP_IN
; direct
< RMAP_MAX
; direct
++) {
3794 if ((filter
->map
[direct
].name
)
3795 && (strcmp(rmap_name
,
3796 filter
->map
[direct
].name
)
3798 filter
->map
[direct
].map
= map
;
3801 if (filter
->usmap
.name
3802 && (strcmp(rmap_name
, filter
->usmap
.name
) == 0))
3803 filter
->usmap
.map
= map
;
3809 * Note that if an extreme number (tens of thousands) of route-maps are in use
3810 * and if bgp has an extreme number of peers, network statements, etc then this
3811 * function can consume a lot of cycles. This is due to this function being
3812 * called for each route-map and within this function we walk the list of peers,
3813 * network statements, etc looking to see if they use this route-map.
3815 static void bgp_route_map_process_update(struct bgp
*bgp
, const char *rmap_name
,
3823 struct bgp_dest
*bn
;
3824 struct bgp_static
*bgp_static
;
3825 struct bgp_aggregate
*aggregate
;
3826 struct listnode
*node
, *nnode
;
3827 struct route_map
*map
;
3828 char buf
[INET6_ADDRSTRLEN
];
3830 map
= route_map_lookup_by_name(rmap_name
);
3832 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
3834 /* Ignore dummy peer-group structure */
3835 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
))
3838 FOREACH_AFI_SAFI (afi
, safi
) {
3839 /* process in/out/import/export/default-orig
3841 bgp_route_map_process_peer(rmap_name
, map
, peer
, afi
,
3842 safi
, route_update
);
3846 /* for outbound/default-orig route-maps, process for groups */
3847 update_group_policy_update(bgp
, BGP_POLICY_ROUTE_MAP
, rmap_name
,
3850 /* update peer-group config (template) */
3851 bgp_route_map_update_peer_group(rmap_name
, map
, bgp
);
3853 FOREACH_AFI_SAFI (afi
, safi
) {
3854 /* For table route-map updates. */
3855 if (!bgp_fibupd_safi(safi
))
3858 if (bgp
->table_map
[afi
][safi
].name
3859 && (strcmp(rmap_name
, bgp
->table_map
[afi
][safi
].name
)
3862 /* bgp->table_map[afi][safi].map is NULL.
3863 * i.e Route map creation event.
3864 * So update applied_counter.
3865 * If it is not NULL, i.e It may be routemap updation or
3866 * deletion. so no need to update the counter.
3868 if (!bgp
->table_map
[afi
][safi
].map
)
3869 route_map_counter_increment(map
);
3870 bgp
->table_map
[afi
][safi
].map
= map
;
3872 if (BGP_DEBUG(zebra
, ZEBRA
))
3874 "Processing route_map %s(%s:%s) update on table map",
3875 rmap_name
, afi2str(afi
),
3878 bgp_zebra_announce_table(bgp
, afi
, safi
);
3881 /* For network route-map updates. */
3882 for (bn
= bgp_table_top(bgp
->route
[afi
][safi
]); bn
;
3883 bn
= bgp_route_next(bn
)) {
3884 bgp_static
= bgp_dest_get_bgp_static_info(bn
);
3888 if (!bgp_static
->rmap
.name
3889 || (strcmp(rmap_name
, bgp_static
->rmap
.name
) != 0))
3892 if (!bgp_static
->rmap
.map
)
3893 route_map_counter_increment(map
);
3895 bgp_static
->rmap
.map
= map
;
3897 if (route_update
&& !bgp_static
->backdoor
) {
3898 const struct prefix
*bn_p
=
3899 bgp_dest_get_prefix(bn
);
3901 if (bgp_debug_zebra(bn_p
))
3903 "Processing route_map %s(%s:%s) update on static route %s",
3904 rmap_name
, afi2str(afi
),
3906 inet_ntop(bn_p
->family
,
3907 &bn_p
->u
.prefix
, buf
,
3909 bgp_static_update(bgp
, bn_p
, bgp_static
, afi
,
3914 /* For aggregate-address route-map updates. */
3915 for (bn
= bgp_table_top(bgp
->aggregate
[afi
][safi
]); bn
;
3916 bn
= bgp_route_next(bn
)) {
3917 aggregate
= bgp_dest_get_bgp_aggregate_info(bn
);
3923 /* Update suppress map pointer. */
3924 if (aggregate
->suppress_map_name
3925 && strmatch(aggregate
->suppress_map_name
,
3927 if (aggregate
->rmap
.map
== NULL
)
3928 route_map_counter_increment(map
);
3930 aggregate
->suppress_map
= map
;
3932 bgp_aggregate_toggle_suppressed(
3933 aggregate
, bgp
, bgp_dest_get_prefix(bn
),
3939 if (aggregate
->rmap
.name
3940 && strmatch(rmap_name
, aggregate
->rmap
.name
)) {
3941 if (aggregate
->rmap
.map
== NULL
)
3942 route_map_counter_increment(map
);
3944 aggregate
->rmap
.map
= map
;
3949 if (matched
&& route_update
) {
3950 const struct prefix
*bn_p
=
3951 bgp_dest_get_prefix(bn
);
3953 if (bgp_debug_zebra(bn_p
))
3955 "Processing route_map %s(%s:%s) update on aggregate-address route %s",
3956 rmap_name
, afi2str(afi
),
3958 inet_ntop(bn_p
->family
,
3959 &bn_p
->u
.prefix
, buf
,
3961 bgp_aggregate_route(bgp
, bn_p
, afi
, safi
,
3967 /* For redistribute route-map updates. */
3968 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3969 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
3970 struct list
*red_list
;
3971 struct bgp_redist
*red
;
3973 red_list
= bgp
->redist
[afi
][i
];
3977 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
3979 || (strcmp(rmap_name
, red
->rmap
.name
) != 0))
3983 route_map_counter_increment(map
);
3985 red
->rmap
.map
= map
;
3990 if (BGP_DEBUG(zebra
, ZEBRA
))
3992 "Processing route_map %s(%s:%s) update on redistributed routes",
3993 rmap_name
, afi2str(afi
),
3996 bgp_redistribute_resend(bgp
, afi
, i
,
4001 /* for type5 command route-maps */
4002 FOREACH_AFI_SAFI (afi
, safi
) {
4003 if (!bgp
->adv_cmd_rmap
[afi
][safi
].name
4004 || strcmp(rmap_name
, bgp
->adv_cmd_rmap
[afi
][safi
].name
)
4008 /* Make sure the route-map is populated here if not already done */
4009 bgp
->adv_cmd_rmap
[afi
][safi
].map
= map
;
4011 if (BGP_DEBUG(zebra
, ZEBRA
))
4013 "Processing route_map %s(%s:%s) update on advertise type5 route command",
4014 rmap_name
, afi2str(afi
), safi2str(safi
));
4016 if (route_update
&& advertise_type5_routes(bgp
, afi
)) {
4017 bgp_evpn_withdraw_type5_routes(bgp
, afi
, safi
);
4018 bgp_evpn_advertise_type5_routes(bgp
, afi
, safi
);
4023 static void bgp_route_map_process_update_cb(char *rmap_name
)
4025 struct listnode
*node
, *nnode
;
4028 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
4029 bgp_route_map_process_update(bgp
, rmap_name
, 1);
4031 #ifdef ENABLE_BGP_VNC
4032 vnc_routemap_update(bgp
, __func__
);
4036 vpn_policy_routemap_event(rmap_name
);
4039 int bgp_route_map_update_timer(struct thread
*thread
)
4041 bm
->t_rmap_update
= NULL
;
4043 route_map_walk_update_list(bgp_route_map_process_update_cb
);
4048 static void bgp_route_map_mark_update(const char *rmap_name
)
4050 struct listnode
*node
, *nnode
;
4053 /* If new update is received before the current timer timed out,
4054 * turn it off and start a new timer.
4056 THREAD_OFF(bm
->t_rmap_update
);
4058 /* rmap_update_timer of 0 means don't do route updates */
4059 if (bm
->rmap_update_timer
) {
4060 thread_add_timer(bm
->master
, bgp_route_map_update_timer
,
4061 NULL
, bm
->rmap_update_timer
,
4062 &bm
->t_rmap_update
);
4064 /* Signal the groups that a route-map update event has
4066 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
))
4067 update_group_policy_update(bgp
,
4068 BGP_POLICY_ROUTE_MAP
,
4071 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
4072 bgp_route_map_process_update(bgp
, rmap_name
, 0);
4073 #ifdef ENABLE_BGP_VNC
4074 vnc_routemap_update(bgp
, __func__
);
4078 vpn_policy_routemap_event(rmap_name
);
4082 static void bgp_route_map_add(const char *rmap_name
)
4084 if (route_map_mark_updated(rmap_name
) == 0)
4085 bgp_route_map_mark_update(rmap_name
);
4087 route_map_notify_dependencies(rmap_name
, RMAP_EVENT_MATCH_ADDED
);
4090 static void bgp_route_map_delete(const char *rmap_name
)
4092 if (route_map_mark_updated(rmap_name
) == 0)
4093 bgp_route_map_mark_update(rmap_name
);
4095 route_map_notify_dependencies(rmap_name
, RMAP_EVENT_MATCH_DELETED
);
4098 static void bgp_route_map_event(const char *rmap_name
)
4100 if (route_map_mark_updated(rmap_name
) == 0)
4101 bgp_route_map_mark_update(rmap_name
);
4103 route_map_notify_dependencies(rmap_name
, RMAP_EVENT_MATCH_ADDED
);
4106 DEFUN_YANG (match_mac_address
,
4107 match_mac_address_cmd
,
4108 "match mac address ACCESSLIST_MAC_NAME",
4111 "Match address of route\n"
4112 "MAC Access-list name\n")
4115 "./match-condition[condition='frr-bgp-route-map:mac-address-list']";
4116 char xpath_value
[XPATH_MAXLEN
];
4118 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
4119 snprintf(xpath_value
, sizeof(xpath_value
),
4120 "%s/rmap-match-condition/frr-bgp-route-map:list-name", xpath
);
4121 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, argv
[3]->arg
);
4123 return nb_cli_apply_changes(vty
, NULL
);
4126 DEFUN_YANG (no_match_mac_address
,
4127 no_match_mac_address_cmd
,
4128 "no match mac address ACCESSLIST_MAC_NAME",
4132 "Match address of route\n"
4133 "MAC acess-list name\n")
4136 "./match-condition[condition='frr-bgp-route-map:mac-address-list']";
4138 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
4139 return nb_cli_apply_changes(vty
, NULL
);
4143 * Helper to handle the case of the user passing in a number or type string
4145 static const char *parse_evpn_rt_type(const char *num_rt_type
)
4147 switch (num_rt_type
[0]) {
4162 /* Was already full type string */
4166 DEFUN_YANG (match_evpn_route_type
,
4167 match_evpn_route_type_cmd
,
4168 "match evpn route-type <macip|2|multicast|3|prefix|5>",
4172 EVPN_TYPE_2_HELP_STR
4173 EVPN_TYPE_2_HELP_STR
4174 EVPN_TYPE_3_HELP_STR
4175 EVPN_TYPE_3_HELP_STR
4176 EVPN_TYPE_5_HELP_STR
4177 EVPN_TYPE_5_HELP_STR
)
4180 "./match-condition[condition='frr-bgp-route-map:evpn-route-type']";
4181 char xpath_value
[XPATH_MAXLEN
];
4183 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
4184 snprintf(xpath_value
, sizeof(xpath_value
),
4185 "%s/rmap-match-condition/frr-bgp-route-map:evpn-route-type",
4187 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
,
4188 parse_evpn_rt_type(argv
[3]->arg
));
4190 return nb_cli_apply_changes(vty
, NULL
);
4193 DEFUN_YANG (no_match_evpn_route_type
,
4194 no_match_evpn_route_type_cmd
,
4195 "no match evpn route-type <macip|2|multicast|3|prefix|5>",
4200 EVPN_TYPE_2_HELP_STR
4201 EVPN_TYPE_2_HELP_STR
4202 EVPN_TYPE_3_HELP_STR
4203 EVPN_TYPE_3_HELP_STR
4204 EVPN_TYPE_5_HELP_STR
4205 EVPN_TYPE_5_HELP_STR
)
4208 "./match-condition[condition='frr-bgp-route-map:evpn-route-type']";
4210 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
4212 return nb_cli_apply_changes(vty
, NULL
);
4216 DEFUN_YANG (match_evpn_vni
,
4218 "match evpn vni " CMD_VNI_RANGE
,
4225 "./match-condition[condition='frr-bgp-route-map:evpn-vni']";
4226 char xpath_value
[XPATH_MAXLEN
];
4228 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
4229 snprintf(xpath_value
, sizeof(xpath_value
),
4230 "%s/rmap-match-condition/frr-bgp-route-map:evpn-vni", xpath
);
4231 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, argv
[3]->arg
);
4233 return nb_cli_apply_changes(vty
, NULL
);
4236 DEFUN_YANG (no_match_evpn_vni
,
4237 no_match_evpn_vni_cmd
,
4238 "no match evpn vni " CMD_VNI_RANGE
,
4246 "./match-condition[condition='frr-bgp-route-map:evpn-vni']";
4247 char xpath_value
[XPATH_MAXLEN
];
4249 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
4250 snprintf(xpath_value
, sizeof(xpath_value
),
4251 "%s/rmap-match-condition/frr-bgp-route-map:evpn-vni", xpath
);
4252 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_DESTROY
, argv
[3]->arg
);
4254 return nb_cli_apply_changes(vty
, NULL
);
4257 DEFUN_YANG (match_evpn_default_route
,
4258 match_evpn_default_route_cmd
,
4259 "match evpn default-route",
4262 "default EVPN type-5 route\n")
4265 "./match-condition[condition='frr-bgp-route-map:evpn-default-route']";
4266 char xpath_value
[XPATH_MAXLEN
];
4268 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
4270 snprintf(xpath_value
, sizeof(xpath_value
),
4271 "%s/rmap-match-condition/frr-bgp-route-map:evpn-default-route",
4273 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, NULL
);
4275 return nb_cli_apply_changes(vty
, NULL
);
4278 DEFUN_YANG (no_match_evpn_default_route
,
4279 no_match_evpn_default_route_cmd
,
4280 "no match evpn default-route",
4284 "default EVPN type-5 route\n")
4287 "./match-condition[condition='frr-bgp-route-map:evpn-default-route']";
4289 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
4291 return nb_cli_apply_changes(vty
, NULL
);
4294 DEFUN_YANG (match_evpn_rd
,
4296 "match evpn rd ASN:NN_OR_IP-ADDRESS:NN",
4299 "Route Distinguisher\n"
4300 "ASN:XX or A.B.C.D:XX\n")
4303 "./match-condition[condition='frr-bgp-route-map:evpn-rd']";
4304 char xpath_value
[XPATH_MAXLEN
];
4306 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
4308 xpath_value
, sizeof(xpath_value
),
4309 "%s/rmap-match-condition/frr-bgp-route-map:route-distinguisher",
4311 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, argv
[3]->arg
);
4313 return nb_cli_apply_changes(vty
, NULL
);
4316 DEFUN_YANG (no_match_evpn_rd
,
4317 no_match_evpn_rd_cmd
,
4318 "no match evpn rd ASN:NN_OR_IP-ADDRESS:NN",
4322 "Route Distinguisher\n"
4323 "ASN:XX or A.B.C.D:XX\n")
4326 "./match-condition[condition='frr-bgp-route-map:evpn-rd']";
4328 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
4329 return nb_cli_apply_changes(vty
, NULL
);
4332 DEFUN_YANG (set_evpn_gw_ip_ipv4
,
4333 set_evpn_gw_ip_ipv4_cmd
,
4334 "set evpn gateway-ip ipv4 A.B.C.D",
4337 "Set gateway IP for prefix advertisement route\n"
4339 "Gateway IP address in IPv4 format\n")
4344 "./set-action[action='frr-bgp-route-map:set-evpn-gateway-ip-ipv4']";
4345 char xpath_value
[XPATH_MAXLEN
];
4347 ret
= str2sockunion(argv
[4]->arg
, &su
);
4349 vty_out(vty
, "%% Malformed gateway IP\n");
4350 return CMD_WARNING_CONFIG_FAILED
;
4353 if (su
.sin
.sin_addr
.s_addr
== 0
4354 || IPV4_CLASS_DE(ntohl(su
.sin
.sin_addr
.s_addr
))) {
4356 "%% Gateway IP cannot be 0.0.0.0, multicast or reserved\n");
4357 return CMD_WARNING_CONFIG_FAILED
;
4360 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
4362 snprintf(xpath_value
, sizeof(xpath_value
),
4363 "%s/rmap-set-action/frr-bgp-route-map:evpn-gateway-ip-ipv4",
4366 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, argv
[4]->arg
);
4367 return nb_cli_apply_changes(vty
, NULL
);
4370 DEFUN_YANG (no_set_evpn_gw_ip_ipv4
,
4371 no_set_evpn_gw_ip_ipv4_cmd
,
4372 "no set evpn gateway-ip ipv4 A.B.C.D",
4376 "Set gateway IP for prefix advertisement route\n"
4378 "Gateway IP address in IPv4 format\n")
4383 "./set-action[action='frr-bgp-route-map:set-evpn-gateway-ip-ipv4']";
4385 ret
= str2sockunion(argv
[5]->arg
, &su
);
4387 vty_out(vty
, "%% Malformed gateway IP\n");
4388 return CMD_WARNING_CONFIG_FAILED
;
4391 if (su
.sin
.sin_addr
.s_addr
== 0
4392 || IPV4_CLASS_DE(ntohl(su
.sin
.sin_addr
.s_addr
))) {
4394 "%% Gateway IP cannot be 0.0.0.0, multicast or reserved\n");
4395 return CMD_WARNING_CONFIG_FAILED
;
4398 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
4400 return nb_cli_apply_changes(vty
, NULL
);
4403 DEFUN_YANG (set_evpn_gw_ip_ipv6
,
4404 set_evpn_gw_ip_ipv6_cmd
,
4405 "set evpn gateway-ip ipv6 X:X::X:X",
4408 "Set gateway IP for prefix advertisement route\n"
4410 "Gateway IP address in IPv6 format\n")
4415 "./set-action[action='frr-bgp-route-map:set-evpn-gateway-ip-ipv6']";
4416 char xpath_value
[XPATH_MAXLEN
];
4418 ret
= str2sockunion(argv
[4]->arg
, &su
);
4420 vty_out(vty
, "%% Malformed gateway IP\n");
4421 return CMD_WARNING_CONFIG_FAILED
;
4424 if (IN6_IS_ADDR_LINKLOCAL(&su
.sin6
.sin6_addr
)
4425 || IN6_IS_ADDR_MULTICAST(&su
.sin6
.sin6_addr
)) {
4427 "%% Gateway IP cannot be a linklocal or multicast address\n");
4428 return CMD_WARNING_CONFIG_FAILED
;
4431 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
4433 snprintf(xpath_value
, sizeof(xpath_value
),
4434 "%s/rmap-set-action/frr-bgp-route-map:evpn-gateway-ip-ipv6",
4437 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, argv
[4]->arg
);
4438 return nb_cli_apply_changes(vty
, NULL
);
4441 DEFUN_YANG (no_set_evpn_gw_ip_ipv6
,
4442 no_set_evpn_gw_ip_ipv6_cmd
,
4443 "no set evpn gateway-ip ipv6 X:X::X:X",
4447 "Set gateway IP for prefix advertisement route\n"
4449 "Gateway IP address in IPv4 format\n")
4454 "./set-action[action='frr-bgp-route-map:set-evpn-gateway-ip-ipv6']";
4456 ret
= str2sockunion(argv
[5]->arg
, &su
);
4458 vty_out(vty
, "%% Malformed gateway IP\n");
4459 return CMD_WARNING_CONFIG_FAILED
;
4462 if (IN6_IS_ADDR_LINKLOCAL(&su
.sin6
.sin6_addr
)
4463 || IN6_IS_ADDR_MULTICAST(&su
.sin6
.sin6_addr
)) {
4465 "%% Gateway IP cannot be a linklocal or multicast address\n");
4466 return CMD_WARNING_CONFIG_FAILED
;
4469 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
4471 return nb_cli_apply_changes(vty
, NULL
);
4474 DEFPY_YANG(match_vrl_source_vrf
,
4475 match_vrl_source_vrf_cmd
,
4476 "match source-vrf NAME$vrf_name",
4482 "./match-condition[condition='frr-bgp-route-map:source-vrf']";
4483 char xpath_value
[XPATH_MAXLEN
];
4485 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
4486 snprintf(xpath_value
, sizeof(xpath_value
),
4487 "%s/rmap-match-condition/frr-bgp-route-map:source-vrf", xpath
);
4488 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, vrf_name
);
4490 return nb_cli_apply_changes(vty
, NULL
);
4493 DEFPY_YANG(no_match_vrl_source_vrf
,
4494 no_match_vrl_source_vrf_cmd
,
4495 "no match source-vrf NAME$vrf_name",
4501 "./match-condition[condition='frr-bgp-route-map:source-vrf']";
4503 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
4504 return nb_cli_apply_changes(vty
, NULL
);
4507 DEFPY_YANG (match_peer
,
4509 "match peer <A.B.C.D$addrv4|X:X::X:X$addrv6|WORD$intf>",
4511 "Match peer address\n"
4512 "IP address of peer\n"
4513 "IPv6 address of peer\n"
4514 "Interface name of peer\n")
4517 "./match-condition[condition='frr-bgp-route-map:peer']";
4518 char xpath_value
[XPATH_MAXLEN
];
4520 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
4524 xpath_value
, sizeof(xpath_value
),
4525 "%s/rmap-match-condition/frr-bgp-route-map:peer-ipv4-address",
4527 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
,
4529 } else if (addrv6_str
) {
4531 xpath_value
, sizeof(xpath_value
),
4532 "%s/rmap-match-condition/frr-bgp-route-map:peer-ipv6-address",
4534 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
,
4538 xpath_value
, sizeof(xpath_value
),
4539 "%s/rmap-match-condition/frr-bgp-route-map:peer-interface",
4541 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, intf
);
4544 return nb_cli_apply_changes(vty
, NULL
);
4547 DEFUN_YANG (match_peer_local
,
4548 match_peer_local_cmd
,
4551 "Match peer address\n"
4552 "Static or Redistributed routes\n")
4555 "./match-condition[condition='frr-bgp-route-map:peer']";
4556 char xpath_value
[XPATH_MAXLEN
];
4558 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
4560 snprintf(xpath_value
, sizeof(xpath_value
),
4561 "%s/rmap-match-condition/frr-bgp-route-map:peer-local", xpath
);
4562 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, "true");
4564 return nb_cli_apply_changes(vty
, NULL
);
4567 DEFUN_YANG (no_match_peer
,
4569 "no match peer [<local|A.B.C.D|X:X::X:X|WORD>]",
4572 "Match peer address\n"
4573 "Static or Redistributed routes\n"
4574 "IP address of peer\n"
4575 "IPv6 address of peer\n"
4576 "Interface name of peer\n")
4579 "./match-condition[condition='frr-bgp-route-map:peer']";
4581 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
4583 return nb_cli_apply_changes(vty
, NULL
);
4586 #ifdef HAVE_SCRIPTING
4587 DEFUN_YANG (match_script
,
4589 "[no] match script WORD",
4592 "Execute script to determine match\n"
4593 "The script name to run, without .lua; e.g. 'myroutemap' to run myroutemap.lua\n")
4595 bool no
= strmatch(argv
[0]->text
, "no");
4597 argv_find(argv
, argc
, "WORD", &i
);
4598 const char *script
= argv
[i
]->arg
;
4600 "./match-condition[condition='frr-bgp-route-map:match-script']";
4601 char xpath_value
[XPATH_MAXLEN
];
4604 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
4605 snprintf(xpath_value
, sizeof(xpath_value
),
4606 "%s/rmap-match-condition/frr-bgp-route-map:script",
4608 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_DESTROY
,
4611 return nb_cli_apply_changes(vty
, NULL
);
4614 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
4615 snprintf(xpath_value
, sizeof(xpath_value
),
4616 "%s/rmap-match-condition/frr-bgp-route-map:script",
4618 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
,
4621 return nb_cli_apply_changes(vty
, NULL
);
4623 #endif /* HAVE_SCRIPTING */
4625 /* match probability */
4626 DEFUN_YANG (match_probability
,
4627 match_probability_cmd
,
4628 "match probability (0-100)",
4630 "Match portion of routes defined by percentage value\n"
4631 "Percentage of routes\n")
4636 "./match-condition[condition='frr-bgp-route-map:probability']";
4637 char xpath_value
[XPATH_MAXLEN
];
4639 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
4640 snprintf(xpath_value
, sizeof(xpath_value
),
4641 "%s/rmap-match-condition/frr-bgp-route-map:probability",
4643 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
,
4644 argv
[idx_number
]->arg
);
4646 return nb_cli_apply_changes(vty
, NULL
);
4650 DEFUN_YANG (no_match_probability
,
4651 no_match_probability_cmd
,
4652 "no match probability [(1-99)]",
4655 "Match portion of routes defined by percentage value\n"
4656 "Percentage of routes\n")
4660 "./match-condition[condition='frr-bgp-route-map:probability']";
4661 char xpath_value
[XPATH_MAXLEN
];
4663 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
4665 if (argc
<= idx_number
)
4666 return nb_cli_apply_changes(vty
, NULL
);
4668 snprintf(xpath_value
, sizeof(xpath_value
),
4669 "%s/rmap-match-condition/frr-bgp-route-map:probability",
4671 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_DESTROY
,
4672 argv
[idx_number
]->arg
);
4674 return nb_cli_apply_changes(vty
, NULL
);
4678 DEFPY_YANG (match_ip_route_source
,
4679 match_ip_route_source_cmd
,
4680 "match ip route-source ACCESSLIST4_NAME",
4683 "Match advertising source address of route\n"
4684 "IP Access-list name\n")
4687 "./match-condition[condition='frr-bgp-route-map:ip-route-source']";
4688 char xpath_value
[XPATH_MAXLEN
+ 32];
4691 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
4692 snprintf(xpath_value
, sizeof(xpath_value
),
4693 "%s/rmap-match-condition/frr-bgp-route-map:list-name",
4695 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
,
4696 argv
[idx_acl
]->arg
);
4698 return nb_cli_apply_changes(vty
, NULL
);
4702 DEFUN_YANG (no_match_ip_route_source
,
4703 no_match_ip_route_source_cmd
,
4704 "no match ip route-source [ACCESSLIST4_NAME]",
4708 "Match advertising source address of route\n"
4709 "IP Access-list name\n")
4712 "./match-condition[condition='frr-bgp-route-map:ip-route-source']";
4714 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
4715 return nb_cli_apply_changes(vty
, NULL
);
4718 DEFUN_YANG (match_ip_route_source_prefix_list
,
4719 match_ip_route_source_prefix_list_cmd
,
4720 "match ip route-source prefix-list PREFIXLIST_NAME",
4723 "Match advertising source address of route\n"
4724 "Match entries of prefix-lists\n"
4725 "IP prefix-list name\n")
4729 "./match-condition[condition='frr-bgp-route-map:ip-route-source-prefix-list']";
4730 char xpath_value
[XPATH_MAXLEN
+ 32];
4732 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
4733 snprintf(xpath_value
, sizeof(xpath_value
),
4734 "%s/rmap-match-condition/frr-bgp-route-map:list-name", xpath
);
4735 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
,
4736 argv
[idx_word
]->arg
);
4738 return nb_cli_apply_changes(vty
, NULL
);
4742 DEFUN_YANG (no_match_ip_route_source_prefix_list
,
4743 no_match_ip_route_source_prefix_list_cmd
,
4744 "no match ip route-source prefix-list [PREFIXLIST_NAME]",
4748 "Match advertising source address of route\n"
4749 "Match entries of prefix-lists\n"
4750 "IP prefix-list name\n")
4753 "./match-condition[condition='frr-bgp-route-map:ip-route-source-prefix-list']";
4755 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
4756 return nb_cli_apply_changes(vty
, NULL
);
4759 DEFUN_YANG (match_local_pref
,
4760 match_local_pref_cmd
,
4761 "match local-preference (0-4294967295)",
4763 "Match local-preference of route\n"
4769 "./match-condition[condition='frr-bgp-route-map:match-local-preference']";
4770 char xpath_value
[XPATH_MAXLEN
];
4772 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
4773 snprintf(xpath_value
, sizeof(xpath_value
),
4774 "%s/rmap-match-condition/frr-bgp-route-map:local-preference",
4776 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
,
4777 argv
[idx_number
]->arg
);
4779 return nb_cli_apply_changes(vty
, NULL
);
4783 DEFUN_YANG (no_match_local_pref
,
4784 no_match_local_pref_cmd
,
4785 "no match local-preference [(0-4294967295)]",
4788 "Match local preference of route\n"
4789 "Local preference value\n")
4791 int idx_localpref
= 3;
4793 "./match-condition[condition='frr-bgp-route-map:match-local-preference']";
4794 char xpath_value
[XPATH_MAXLEN
];
4796 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
4798 if (argc
<= idx_localpref
)
4799 return nb_cli_apply_changes(vty
, NULL
);
4801 snprintf(xpath_value
, sizeof(xpath_value
),
4802 "%s/rmap-match-condition/frr-bgp-route-map:local-preference",
4804 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_DESTROY
,
4805 argv
[idx_localpref
]->arg
);
4807 return nb_cli_apply_changes(vty
, NULL
);
4810 DEFUN_YANG(match_alias
, match_alias_cmd
, "match alias ALIAS_NAME",
4812 "Match BGP community alias name\n"
4813 "BGP community alias name\n")
4815 const char *alias
= argv
[2]->arg
;
4816 struct community_alias ca1
;
4817 struct community_alias
*lookup_alias
;
4820 "./match-condition[condition='frr-bgp-route-map:match-alias']";
4821 char xpath_value
[XPATH_MAXLEN
];
4823 memset(&ca1
, 0, sizeof(ca1
));
4824 strlcpy(ca1
.alias
, alias
, sizeof(ca1
.alias
));
4825 lookup_alias
= bgp_ca_alias_lookup(&ca1
);
4826 if (!lookup_alias
) {
4827 vty_out(vty
, "%% BGP alias name '%s' does not exist\n", alias
);
4828 return CMD_WARNING_CONFIG_FAILED
;
4831 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
4832 snprintf(xpath_value
, sizeof(xpath_value
),
4833 "%s/rmap-match-condition/frr-bgp-route-map:alias", xpath
);
4834 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, alias
);
4836 return nb_cli_apply_changes(vty
, NULL
);
4840 DEFUN_YANG(no_match_alias
, no_match_alias_cmd
, "no match alias [ALIAS_NAME]",
4842 "Match BGP community alias name\n"
4843 "BGP community alias name\n")
4847 "./match-condition[condition='frr-bgp-route-map:match-alias']";
4848 char xpath_value
[XPATH_MAXLEN
];
4850 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
4852 if (argc
<= idx_alias
)
4853 return nb_cli_apply_changes(vty
, NULL
);
4855 snprintf(xpath_value
, sizeof(xpath_value
),
4856 "%s/rmap-match-condition/frr-bgp-route-map:alias", xpath
);
4857 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_DESTROY
,
4858 argv
[idx_alias
]->arg
);
4860 return nb_cli_apply_changes(vty
, NULL
);
4863 DEFPY_YANG (match_community
,
4864 match_community_cmd
,
4865 "match community <(1-99)|(100-500)|COMMUNITY_LIST_NAME> [exact-match]",
4867 "Match BGP community list\n"
4868 "Community-list number (standard)\n"
4869 "Community-list number (expanded)\n"
4870 "Community-list name\n"
4871 "Do exact matching of communities\n")
4874 "./match-condition[condition='frr-bgp-route-map:match-community']";
4875 char xpath_value
[XPATH_MAXLEN
];
4876 char xpath_match
[XPATH_MAXLEN
];
4877 int idx_comm_list
= 2;
4879 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
4882 xpath_value
, sizeof(xpath_value
),
4883 "%s/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name",
4885 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, argv
[idx_comm_list
]->arg
);
4889 xpath_match
, sizeof(xpath_match
),
4890 "%s/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match",
4892 nb_cli_enqueue_change(vty
, xpath_match
, NB_OP_MODIFY
,
4896 xpath_match
, sizeof(xpath_match
),
4897 "%s/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match",
4899 nb_cli_enqueue_change(vty
, xpath_match
, NB_OP_MODIFY
,
4903 return nb_cli_apply_changes(vty
, NULL
);
4906 DEFUN_YANG (no_match_community
,
4907 no_match_community_cmd
,
4908 "no match community [<(1-99)|(100-500)|COMMUNITY_LIST_NAME> [exact-match]]",
4911 "Match BGP community list\n"
4912 "Community-list number (standard)\n"
4913 "Community-list number (expanded)\n"
4914 "Community-list name\n"
4915 "Do exact matching of communities\n")
4918 "./match-condition[condition='frr-bgp-route-map:match-community']";
4920 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
4921 return nb_cli_apply_changes(vty
, NULL
);
4924 DEFPY_YANG (match_lcommunity
,
4925 match_lcommunity_cmd
,
4926 "match large-community <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME> [exact-match]",
4928 "Match BGP large community list\n"
4929 "Large Community-list number (standard)\n"
4930 "Large Community-list number (expanded)\n"
4931 "Large Community-list name\n"
4932 "Do exact matching of communities\n")
4935 "./match-condition[condition='frr-bgp-route-map:match-large-community']";
4936 char xpath_value
[XPATH_MAXLEN
];
4937 char xpath_match
[XPATH_MAXLEN
];
4938 int idx_lcomm_list
= 2;
4940 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
4943 xpath_value
, sizeof(xpath_value
),
4944 "%s/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name",
4946 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, argv
[idx_lcomm_list
]->arg
);
4950 xpath_match
, sizeof(xpath_match
),
4951 "%s/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match",
4953 nb_cli_enqueue_change(vty
, xpath_match
, NB_OP_MODIFY
,
4957 xpath_match
, sizeof(xpath_match
),
4958 "%s/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match",
4960 nb_cli_enqueue_change(vty
, xpath_match
, NB_OP_MODIFY
,
4964 return nb_cli_apply_changes(vty
, NULL
);
4967 DEFUN_YANG (no_match_lcommunity
,
4968 no_match_lcommunity_cmd
,
4969 "no match large-community [<(1-99)|(100-500)|LCOMMUNITY_LIST_NAME> [exact-match]]",
4972 "Match BGP large community list\n"
4973 "Large Community-list number (standard)\n"
4974 "Large Community-list number (expanded)\n"
4975 "Large Community-list name\n"
4976 "Do exact matching of communities\n")
4979 "./match-condition[condition='frr-bgp-route-map:match-large-community']";
4981 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
4982 return nb_cli_apply_changes(vty
, NULL
);
4985 DEFPY_YANG (match_ecommunity
,
4986 match_ecommunity_cmd
,
4987 "match extcommunity <(1-99)|(100-500)|EXTCOMMUNITY_LIST_NAME>",
4989 "Match BGP/VPN extended community list\n"
4990 "Extended community-list number (standard)\n"
4991 "Extended community-list number (expanded)\n"
4992 "Extended community-list name\n")
4995 "./match-condition[condition='frr-bgp-route-map:match-extcommunity']";
4996 char xpath_value
[XPATH_MAXLEN
];
4997 int idx_comm_list
= 2;
4999 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
5002 xpath_value
, sizeof(xpath_value
),
5003 "%s/rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name",
5005 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, argv
[idx_comm_list
]->arg
);
5007 return nb_cli_apply_changes(vty
, NULL
);
5011 DEFUN_YANG (no_match_ecommunity
,
5012 no_match_ecommunity_cmd
,
5013 "no match extcommunity [<(1-99)|(100-500)|EXTCOMMUNITY_LIST_NAME>]",
5016 "Match BGP/VPN extended community list\n"
5017 "Extended community-list number (standard)\n"
5018 "Extended community-list number (expanded)\n"
5019 "Extended community-list name\n")
5022 "./match-condition[condition='frr-bgp-route-map:match-extcommunity']";
5024 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
5025 return nb_cli_apply_changes(vty
, NULL
);
5029 DEFUN_YANG (match_aspath
,
5031 "match as-path AS_PATH_FILTER_NAME",
5033 "Match BGP AS path list\n"
5034 "AS path access-list name\n")
5039 "./match-condition[condition='frr-bgp-route-map:as-path-list']";
5040 char xpath_value
[XPATH_MAXLEN
];
5042 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
5043 snprintf(xpath_value
, sizeof(xpath_value
),
5044 "%s/rmap-match-condition/frr-bgp-route-map:list-name", xpath
);
5045 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
,
5046 argv
[idx_word
]->arg
);
5048 return nb_cli_apply_changes(vty
, NULL
);
5052 DEFUN_YANG (no_match_aspath
,
5053 no_match_aspath_cmd
,
5054 "no match as-path [AS_PATH_FILTER_NAME]",
5057 "Match BGP AS path list\n"
5058 "AS path access-list name\n")
5061 "./match-condition[condition='frr-bgp-route-map:as-path-list']";
5063 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
5065 return nb_cli_apply_changes(vty
, NULL
);
5068 DEFUN_YANG (match_origin
,
5070 "match origin <egp|igp|incomplete>",
5075 "unknown heritage\n")
5078 const char *origin_type
;
5080 "./match-condition[condition='frr-bgp-route-map:match-origin']";
5081 char xpath_value
[XPATH_MAXLEN
];
5083 if (strncmp(argv
[idx_origin
]->arg
, "igp", 2) == 0)
5084 origin_type
= "igp";
5085 else if (strncmp(argv
[idx_origin
]->arg
, "egp", 1) == 0)
5086 origin_type
= "egp";
5087 else if (strncmp(argv
[idx_origin
]->arg
, "incomplete", 2) == 0)
5088 origin_type
= "incomplete";
5090 vty_out(vty
, "%% Invalid match origin type\n");
5091 return CMD_WARNING_CONFIG_FAILED
;
5094 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
5095 snprintf(xpath_value
, sizeof(xpath_value
),
5096 "%s/rmap-match-condition/frr-bgp-route-map:origin", xpath
);
5097 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, origin_type
);
5099 return nb_cli_apply_changes(vty
, NULL
);
5103 DEFUN_YANG (no_match_origin
,
5104 no_match_origin_cmd
,
5105 "no match origin [<egp|igp|incomplete>]",
5111 "unknown heritage\n")
5114 "./match-condition[condition='frr-bgp-route-map:match-origin']";
5115 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
5116 return nb_cli_apply_changes(vty
, NULL
);
5119 DEFUN_YANG (set_table_id
,
5121 "set table (1-4294967295)",
5123 "export route to non-main kernel table\n"
5124 "Kernel routing table id\n")
5127 const char *xpath
= "./set-action[action='frr-bgp-route-map:table']";
5128 char xpath_value
[XPATH_MAXLEN
];
5130 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
5131 snprintf(xpath_value
, sizeof(xpath_value
),
5132 "%s/rmap-set-action/frr-bgp-route-map:table", xpath
);
5133 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
,
5134 argv
[idx_number
]->arg
);
5135 return nb_cli_apply_changes(vty
, NULL
);
5138 DEFUN_YANG (no_set_table_id
,
5139 no_set_table_id_cmd
,
5143 "export route to non-main kernel table\n")
5145 const char *xpath
= "./set-action[action='frr-bgp-route-map:table']";
5146 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
5147 return nb_cli_apply_changes(vty
, NULL
);
5150 DEFUN_YANG (set_ip_nexthop_peer
,
5151 set_ip_nexthop_peer_cmd
,
5152 "[no] set ip next-hop peer-address",
5156 "Next hop address\n"
5157 "Use peer address (for BGP only)\n")
5159 char xpath_value
[XPATH_MAXLEN
];
5161 "./set-action[action='frr-bgp-route-map:set-ipv4-nexthop']";
5163 if (strmatch(argv
[0]->text
, "no"))
5164 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
5166 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
5167 snprintf(xpath_value
, sizeof(xpath_value
),
5168 "%s/rmap-set-action/frr-bgp-route-map:ipv4-nexthop",
5170 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
,
5173 return nb_cli_apply_changes(vty
, NULL
);
5176 DEFUN_YANG (set_ip_nexthop_unchanged
,
5177 set_ip_nexthop_unchanged_cmd
,
5178 "[no] set ip next-hop unchanged",
5182 "Next hop address\n"
5183 "Don't modify existing Next hop address\n")
5185 char xpath_value
[XPATH_MAXLEN
];
5187 "./set-action[action='frr-bgp-route-map:set-ipv4-nexthop']";
5189 if (strmatch(argv
[0]->text
, "no"))
5190 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
5192 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
5193 snprintf(xpath_value
, sizeof(xpath_value
),
5194 "%s/rmap-set-action/frr-bgp-route-map:ipv4-nexthop",
5196 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
,
5199 return nb_cli_apply_changes(vty
, NULL
);
5202 DEFUN_YANG (set_distance
,
5204 "set distance (0-255)",
5206 "BGP Administrative Distance to use\n"
5210 const char *xpath
= "./set-action[action='frr-bgp-route-map:distance']";
5211 char xpath_value
[XPATH_MAXLEN
];
5213 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
5214 snprintf(xpath_value
, sizeof(xpath_value
),
5215 "%s/rmap-set-action/frr-bgp-route-map:distance", xpath
);
5216 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
,
5217 argv
[idx_number
]->arg
);
5218 return nb_cli_apply_changes(vty
, NULL
);
5221 DEFUN_YANG (no_set_distance
,
5222 no_set_distance_cmd
,
5223 "no set distance [(0-255)]",
5225 "BGP Administrative Distance to use\n"
5228 const char *xpath
= "./set-action[action='frr-bgp-route-map:distance']";
5230 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
5231 return nb_cli_apply_changes(vty
, NULL
);
5234 DEFUN_YANG (set_local_pref
,
5236 "set local-preference WORD",
5238 "BGP local preference path attribute\n"
5239 "Preference value (0-4294967295)\n")
5243 "./set-action[action='frr-bgp-route-map:set-local-preference']";
5244 char xpath_value
[XPATH_MAXLEN
];
5246 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
5247 snprintf(xpath_value
, sizeof(xpath_value
),
5248 "%s/rmap-set-action/frr-bgp-route-map:local-pref", xpath
);
5249 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
,
5250 argv
[idx_number
]->arg
);
5251 return nb_cli_apply_changes(vty
, NULL
);
5254 DEFUN_YANG (no_set_local_pref
,
5255 no_set_local_pref_cmd
,
5256 "no set local-preference [WORD]",
5259 "BGP local preference path attribute\n"
5260 "Preference value (0-4294967295)\n")
5263 "./set-action[action='frr-bgp-route-map:set-local-preference']";
5265 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
5266 return nb_cli_apply_changes(vty
, NULL
);
5269 DEFUN_YANG (set_weight
,
5271 "set weight (0-4294967295)",
5273 "BGP weight for routing table\n"
5277 const char *xpath
= "./set-action[action='frr-bgp-route-map:weight']";
5278 char xpath_value
[XPATH_MAXLEN
];
5280 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
5281 snprintf(xpath_value
, sizeof(xpath_value
),
5282 "%s/rmap-set-action/frr-bgp-route-map:weight", xpath
);
5283 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
,
5284 argv
[idx_number
]->arg
);
5285 return nb_cli_apply_changes(vty
, NULL
);
5288 DEFUN_YANG (no_set_weight
,
5290 "no set weight [(0-4294967295)]",
5293 "BGP weight for routing table\n"
5296 const char *xpath
= "./set-action[action='frr-bgp-route-map:weight']";
5298 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
5299 return nb_cli_apply_changes(vty
, NULL
);
5302 DEFUN_YANG (set_label_index
,
5303 set_label_index_cmd
,
5304 "set label-index (0-1048560)",
5306 "Label index to associate with the prefix\n"
5307 "Label index value\n")
5311 "./set-action[action='frr-bgp-route-map:label-index']";
5312 char xpath_value
[XPATH_MAXLEN
];
5314 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
5315 snprintf(xpath_value
, sizeof(xpath_value
),
5316 "%s/rmap-set-action/frr-bgp-route-map:label-index", xpath
);
5317 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
,
5318 argv
[idx_number
]->arg
);
5319 return nb_cli_apply_changes(vty
, NULL
);
5322 DEFUN_YANG (no_set_label_index
,
5323 no_set_label_index_cmd
,
5324 "no set label-index [(0-1048560)]",
5327 "Label index to associate with the prefix\n"
5328 "Label index value\n")
5331 "./set-action[action='frr-bgp-route-map:label-index']";
5333 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
5334 return nb_cli_apply_changes(vty
, NULL
);
5337 DEFUN_YANG (set_aspath_prepend_asn
,
5338 set_aspath_prepend_asn_cmd
,
5339 "set as-path prepend (1-4294967295)...",
5341 "Transform BGP AS_PATH attribute\n"
5342 "Prepend to the as-path\n"
5349 str
= argv_concat(argv
, argc
, idx_asn
);
5352 "./set-action[action='frr-bgp-route-map:as-path-prepend']";
5353 char xpath_value
[XPATH_MAXLEN
];
5355 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
5356 snprintf(xpath_value
, sizeof(xpath_value
),
5357 "%s/rmap-set-action/frr-bgp-route-map:prepend-as-path", xpath
);
5358 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, str
);
5359 ret
= nb_cli_apply_changes(vty
, NULL
);
5360 XFREE(MTYPE_TMP
, str
);
5364 DEFUN_YANG (set_aspath_prepend_lastas
,
5365 set_aspath_prepend_lastas_cmd
,
5366 "set as-path prepend last-as (1-10)",
5368 "Transform BGP AS_PATH attribute\n"
5369 "Prepend to the as-path\n"
5370 "Use the last AS-number in the as-path\n"
5371 "Number of times to insert\n")
5376 "./set-action[action='frr-bgp-route-map:as-path-prepend']";
5377 char xpath_value
[XPATH_MAXLEN
];
5379 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
5380 snprintf(xpath_value
, sizeof(xpath_value
),
5381 "%s/rmap-set-action/frr-bgp-route-map:last-as", xpath
);
5382 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
,
5383 argv
[idx_num
]->arg
);
5384 return nb_cli_apply_changes(vty
, NULL
);
5387 DEFUN_YANG (no_set_aspath_prepend
,
5388 no_set_aspath_prepend_cmd
,
5389 "no set as-path prepend [(1-4294967295)]",
5392 "Transform BGP AS_PATH attribute\n"
5393 "Prepend to the as-path\n"
5397 "./set-action[action='frr-bgp-route-map:as-path-prepend']";
5399 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
5400 return nb_cli_apply_changes(vty
, NULL
);
5403 DEFUN_YANG (no_set_aspath_prepend_lastas
,
5404 no_set_aspath_prepend_lastas_cmd
,
5405 "no set as-path prepend last-as [(1-10)]",
5408 "Transform BGP AS_PATH attribute\n"
5409 "Prepend to the as-path\n"
5410 "Use the peers AS-number\n"
5411 "Number of times to insert\n")
5414 "./set-action[action='frr-bgp-route-map:as-path-prepend']";
5416 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
5417 return nb_cli_apply_changes(vty
, NULL
);
5420 DEFUN_YANG (set_aspath_exclude
,
5421 set_aspath_exclude_cmd
,
5422 "set as-path exclude (1-4294967295)...",
5424 "Transform BGP AS-path attribute\n"
5425 "Exclude from the as-path\n"
5432 str
= argv_concat(argv
, argc
, idx_asn
);
5435 "./set-action[action='frr-bgp-route-map:as-path-exclude']";
5436 char xpath_value
[XPATH_MAXLEN
];
5438 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
5439 snprintf(xpath_value
, sizeof(xpath_value
),
5440 "%s/rmap-set-action/frr-bgp-route-map:exclude-as-path", xpath
);
5441 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, str
);
5442 ret
= nb_cli_apply_changes(vty
, NULL
);
5443 XFREE(MTYPE_TMP
, str
);
5447 DEFUN_YANG (no_set_aspath_exclude
,
5448 no_set_aspath_exclude_cmd
,
5449 "no set as-path exclude (1-4294967295)...",
5452 "Transform BGP AS_PATH attribute\n"
5453 "Exclude from the as-path\n"
5457 "./set-action[action='frr-bgp-route-map:as-path-exclude']";
5459 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
5460 return nb_cli_apply_changes(vty
, NULL
);
5463 ALIAS_YANG (no_set_aspath_exclude
, no_set_aspath_exclude_all_cmd
,
5464 "no set as-path exclude",
5466 "Transform BGP AS_PATH attribute\n"
5467 "Exclude from the as-path\n")
5469 DEFUN_YANG (set_community
,
5471 "set community AA:NN...",
5473 "BGP community attribute\n"
5481 struct community
*com
= NULL
;
5483 char *argstr
= NULL
;
5487 "./set-action[action='frr-bgp-route-map:set-community']";
5488 char xpath_value
[XPATH_MAXLEN
];
5490 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
5491 snprintf(xpath_value
, sizeof(xpath_value
),
5492 "%s/rmap-set-action/frr-bgp-route-map:community-string",
5495 b
= buffer_new(1024);
5497 for (i
= idx_aa_nn
; i
< argc
; i
++) {
5498 if (strncmp(argv
[i
]->arg
, "additive", strlen(argv
[i
]->arg
))
5505 buffer_putc(b
, ' ');
5509 if (strncmp(argv
[i
]->arg
, "internet", strlen(argv
[i
]->arg
))
5511 buffer_putstr(b
, "internet");
5514 if (strncmp(argv
[i
]->arg
, "local-AS", strlen(argv
[i
]->arg
))
5516 buffer_putstr(b
, "local-AS");
5519 if (strncmp(argv
[i
]->arg
, "no-a", strlen("no-a")) == 0
5520 && strncmp(argv
[i
]->arg
, "no-advertise",
5521 strlen(argv
[i
]->arg
))
5523 buffer_putstr(b
, "no-advertise");
5526 if (strncmp(argv
[i
]->arg
, "no-e", strlen("no-e")) == 0
5527 && strncmp(argv
[i
]->arg
, "no-export", strlen(argv
[i
]->arg
))
5529 buffer_putstr(b
, "no-export");
5532 if (strncmp(argv
[i
]->arg
, "blackhole", strlen(argv
[i
]->arg
))
5534 buffer_putstr(b
, "blackhole");
5537 if (strncmp(argv
[i
]->arg
, "graceful-shutdown",
5538 strlen(argv
[i
]->arg
))
5540 buffer_putstr(b
, "graceful-shutdown");
5543 buffer_putstr(b
, argv
[i
]->arg
);
5545 buffer_putc(b
, '\0');
5547 /* Fetch result string then compile it to communities attribute. */
5548 str
= buffer_getstr(b
);
5552 com
= community_str2com(str
);
5553 XFREE(MTYPE_TMP
, str
);
5556 /* Can't compile user input into communities attribute. */
5558 vty_out(vty
, "%% Malformed communities attribute\n");
5559 return CMD_WARNING_CONFIG_FAILED
;
5562 /* Set communites attribute string. */
5563 str
= community_str(com
, false);
5566 size_t argstr_sz
= strlen(str
) + strlen(" additive") + 1;
5567 argstr
= XCALLOC(MTYPE_TMP
, argstr_sz
);
5568 strlcpy(argstr
, str
, argstr_sz
);
5569 strlcat(argstr
, " additive", argstr_sz
);
5570 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, argstr
);
5572 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, str
);
5574 ret
= nb_cli_apply_changes(vty
, NULL
);
5577 XFREE(MTYPE_TMP
, argstr
);
5578 community_free(&com
);
5583 DEFUN_YANG (set_community_none
,
5584 set_community_none_cmd
,
5585 "set community none",
5587 "BGP community attribute\n"
5588 "No community attribute\n")
5591 "./set-action[action='frr-bgp-route-map:set-community']";
5592 char xpath_value
[XPATH_MAXLEN
];
5594 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
5596 snprintf(xpath_value
, sizeof(xpath_value
),
5597 "%s/rmap-set-action/frr-bgp-route-map:community-none", xpath
);
5598 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, "true");
5599 return nb_cli_apply_changes(vty
, NULL
);
5602 DEFUN_YANG (no_set_community
,
5603 no_set_community_cmd
,
5604 "no set community AA:NN...",
5607 "BGP community attribute\n"
5611 "./set-action[action='frr-bgp-route-map:set-community']";
5613 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
5614 return nb_cli_apply_changes(vty
, NULL
);
5617 ALIAS_YANG (no_set_community
,
5618 no_set_community_short_cmd
,
5622 "BGP community attribute\n")
5624 DEFPY_YANG (set_community_delete
,
5625 set_community_delete_cmd
,
5626 "set comm-list <(1-99)|(100-500)|COMMUNITY_LIST_NAME> delete",
5628 "set BGP community list (for deletion)\n"
5629 "Community-list number (standard)\n"
5630 "Community-list number (expanded)\n"
5631 "Community-list name\n"
5632 "Delete matching communities\n")
5635 "./set-action[action='frr-bgp-route-map:comm-list-delete']";
5636 char xpath_value
[XPATH_MAXLEN
];
5637 int idx_comm_list
= 2;
5639 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
5641 snprintf(xpath_value
, sizeof(xpath_value
),
5642 "%s/rmap-set-action/frr-bgp-route-map:comm-list-name",
5644 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
,
5645 argv
[idx_comm_list
]->arg
);
5647 return nb_cli_apply_changes(vty
, NULL
);
5651 DEFUN_YANG (no_set_community_delete
,
5652 no_set_community_delete_cmd
,
5653 "no set comm-list [<(1-99)|(100-500)|COMMUNITY_LIST_NAME> delete]",
5656 "set BGP community list (for deletion)\n"
5657 "Community-list number (standard)\n"
5658 "Community-list number (expanded)\n"
5659 "Community-list name\n"
5660 "Delete matching communities\n")
5663 "./set-action[action='frr-bgp-route-map:comm-list-delete']";
5665 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
5666 return nb_cli_apply_changes(vty
, NULL
);
5669 DEFUN_YANG (set_lcommunity
,
5671 "set large-community AA:BB:CC...",
5673 "BGP large community attribute\n"
5674 "Large Community number in aa:bb:cc format or additive\n")
5679 "./set-action[action='frr-bgp-route-map:set-large-community']";
5680 char xpath_value
[XPATH_MAXLEN
];
5682 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
5684 snprintf(xpath_value
, sizeof(xpath_value
),
5685 "%s/rmap-set-action/frr-bgp-route-map:large-community-string",
5687 str
= argv_concat(argv
, argc
, 2);
5688 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, str
);
5689 ret
= nb_cli_apply_changes(vty
, NULL
);
5690 XFREE(MTYPE_TMP
, str
);
5694 DEFUN_YANG (set_lcommunity_none
,
5695 set_lcommunity_none_cmd
,
5696 "set large-community none",
5698 "BGP large community attribute\n"
5699 "No large community attribute\n")
5702 "./set-action[action='frr-bgp-route-map:set-large-community']";
5703 char xpath_value
[XPATH_MAXLEN
];
5705 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
5707 snprintf(xpath_value
, sizeof(xpath_value
),
5708 "%s/rmap-set-action/frr-bgp-route-map:large-community-none",
5710 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, "true");
5711 return nb_cli_apply_changes(vty
, NULL
);
5714 DEFUN_YANG (no_set_lcommunity
,
5715 no_set_lcommunity_cmd
,
5716 "no set large-community none",
5719 "BGP large community attribute\n"
5720 "No community attribute\n")
5723 "./set-action[action='frr-bgp-route-map:set-large-community']";
5725 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
5726 return nb_cli_apply_changes(vty
, NULL
);
5729 DEFUN_YANG (no_set_lcommunity1
,
5730 no_set_lcommunity1_cmd
,
5731 "no set large-community AA:BB:CC...",
5734 "BGP large community attribute\n"
5735 "Large community in AA:BB:CC... format or additive\n")
5738 "./set-action[action='frr-bgp-route-map:set-large-community']";
5740 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
5741 return nb_cli_apply_changes(vty
, NULL
);
5744 ALIAS_YANG (no_set_lcommunity1
,
5745 no_set_lcommunity1_short_cmd
,
5746 "no set large-community",
5749 "BGP large community attribute\n")
5751 DEFPY_YANG (set_lcommunity_delete
,
5752 set_lcommunity_delete_cmd
,
5753 "set large-comm-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME> delete",
5755 "set BGP large community list (for deletion)\n"
5756 "Large Community-list number (standard)\n"
5757 "Large Communitly-list number (expanded)\n"
5758 "Large Community-list name\n"
5759 "Delete matching large communities\n")
5762 "./set-action[action='frr-bgp-route-map:large-comm-list-delete']";
5763 char xpath_value
[XPATH_MAXLEN
];
5764 int idx_lcomm_list
= 2;
5766 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
5768 snprintf(xpath_value
, sizeof(xpath_value
),
5769 "%s/rmap-set-action/frr-bgp-route-map:comm-list-name",
5771 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
,
5772 argv
[idx_lcomm_list
]->arg
);
5774 return nb_cli_apply_changes(vty
, NULL
);
5777 DEFUN_YANG (no_set_lcommunity_delete
,
5778 no_set_lcommunity_delete_cmd
,
5779 "no set large-comm-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME> [delete]",
5782 "set BGP large community list (for deletion)\n"
5783 "Large Community-list number (standard)\n"
5784 "Large Communitly-list number (expanded)\n"
5785 "Large Community-list name\n"
5786 "Delete matching large communities\n")
5789 "./set-action[action='frr-bgp-route-map:large-comm-list-delete']";
5791 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
5792 return nb_cli_apply_changes(vty
, NULL
);
5795 ALIAS_YANG (no_set_lcommunity_delete
,
5796 no_set_lcommunity_delete_short_cmd
,
5797 "no set large-comm-list",
5800 "set BGP large community list (for deletion)\n")
5802 DEFUN_YANG (set_ecommunity_rt
,
5803 set_ecommunity_rt_cmd
,
5804 "set extcommunity rt ASN:NN_OR_IP-ADDRESS:NN...",
5806 "BGP extended community attribute\n"
5807 "Route Target extended community\n"
5808 "VPN extended community\n")
5814 "./set-action[action='frr-bgp-route-map:set-extcommunity-rt']";
5815 char xpath_value
[XPATH_MAXLEN
];
5817 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
5819 snprintf(xpath_value
, sizeof(xpath_value
),
5820 "%s/rmap-set-action/frr-bgp-route-map:extcommunity-rt", xpath
);
5821 str
= argv_concat(argv
, argc
, idx_asn_nn
);
5822 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, str
);
5823 ret
= nb_cli_apply_changes(vty
, NULL
);
5824 XFREE(MTYPE_TMP
, str
);
5828 DEFUN_YANG (no_set_ecommunity_rt
,
5829 no_set_ecommunity_rt_cmd
,
5830 "no set extcommunity rt ASN:NN_OR_IP-ADDRESS:NN...",
5833 "BGP extended community attribute\n"
5834 "Route Target extended community\n"
5835 "VPN extended community\n")
5838 "./set-action[action='frr-bgp-route-map:set-extcommunity-rt']";
5839 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
5840 return nb_cli_apply_changes(vty
, NULL
);
5843 ALIAS_YANG (no_set_ecommunity_rt
,
5844 no_set_ecommunity_rt_short_cmd
,
5845 "no set extcommunity rt",
5848 "BGP extended community attribute\n"
5849 "Route Target extended community\n")
5851 DEFUN_YANG (set_ecommunity_soo
,
5852 set_ecommunity_soo_cmd
,
5853 "set extcommunity soo ASN:NN_OR_IP-ADDRESS:NN...",
5855 "BGP extended community attribute\n"
5856 "Site-of-Origin extended community\n"
5857 "VPN extended community\n")
5863 "./set-action[action='frr-bgp-route-map:set-extcommunity-soo']";
5864 char xpath_value
[XPATH_MAXLEN
];
5866 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
5868 snprintf(xpath_value
, sizeof(xpath_value
),
5869 "%s/rmap-set-action/frr-bgp-route-map:extcommunity-soo",
5871 str
= argv_concat(argv
, argc
, idx_asn_nn
);
5872 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, str
);
5873 ret
= nb_cli_apply_changes(vty
, NULL
);
5874 XFREE(MTYPE_TMP
, str
);
5878 DEFUN_YANG (no_set_ecommunity_soo
,
5879 no_set_ecommunity_soo_cmd
,
5880 "no set extcommunity soo ASN:NN_OR_IP-ADDRESS:NN...",
5883 "BGP extended community attribute\n"
5884 "Site-of-Origin extended community\n"
5885 "VPN extended community\n")
5888 "./set-action[action='frr-bgp-route-map:set-extcommunity-soo']";
5889 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
5890 return nb_cli_apply_changes(vty
, NULL
);
5893 ALIAS_YANG (no_set_ecommunity_soo
,
5894 no_set_ecommunity_soo_short_cmd
,
5895 "no set extcommunity soo",
5898 "GP extended community attribute\n"
5899 "Site-of-Origin extended community\n")
5901 DEFUN_YANG(set_ecommunity_none
, set_ecommunity_none_cmd
,
5902 "set extcommunity none",
5904 "BGP extended community attribute\n"
5905 "No extended community attribute\n")
5908 "./set-action[action='frr-bgp-route-map:set-extcommunity-none']";
5909 char xpath_value
[XPATH_MAXLEN
];
5911 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
5913 snprintf(xpath_value
, sizeof(xpath_value
),
5914 "%s/rmap-set-action/frr-bgp-route-map:extcommunity-none",
5916 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, "true");
5917 return nb_cli_apply_changes(vty
, NULL
);
5920 DEFUN_YANG(no_set_ecommunity_none
, no_set_ecommunity_none_cmd
,
5921 "no set extcommunity none",
5923 "BGP extended community attribute\n"
5924 "No extended community attribute\n")
5927 "./set-action[action='frr-bgp-route-map:set-extcommunity-none']";
5928 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
5929 return nb_cli_apply_changes(vty
, NULL
);
5932 DEFUN_YANG (set_ecommunity_lb
,
5933 set_ecommunity_lb_cmd
,
5934 "set extcommunity bandwidth <(1-25600)|cumulative|num-multipaths> [non-transitive]",
5936 "BGP extended community attribute\n"
5937 "Link bandwidth extended community\n"
5938 "Bandwidth value in Mbps\n"
5939 "Cumulative bandwidth of all multipaths (outbound-only)\n"
5940 "Internally computed bandwidth based on number of multipaths (outbound-only)\n"
5941 "Attribute is set as non-transitive\n")
5944 int idx_non_transitive
= 0;
5946 "./set-action[action='frr-bgp-route-map:set-extcommunity-lb']";
5947 char xpath_lb_type
[XPATH_MAXLEN
];
5948 char xpath_bandwidth
[XPATH_MAXLEN
];
5949 char xpath_non_transitive
[XPATH_MAXLEN
];
5951 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
5953 snprintf(xpath_lb_type
, sizeof(xpath_lb_type
),
5954 "%s/rmap-set-action/frr-bgp-route-map:extcommunity-lb/lb-type",
5956 snprintf(xpath_bandwidth
, sizeof(xpath_bandwidth
),
5957 "%s/rmap-set-action/frr-bgp-route-map:extcommunity-lb/bandwidth",
5959 snprintf(xpath_non_transitive
, sizeof(xpath_non_transitive
),
5960 "%s/rmap-set-action/frr-bgp-route-map:extcommunity-lb/two-octet-as-specific",
5963 if ((strcmp(argv
[idx_lb
]->arg
, "cumulative")) == 0)
5964 nb_cli_enqueue_change(vty
, xpath_lb_type
, NB_OP_MODIFY
,
5965 "cumulative-bandwidth");
5966 else if ((strcmp(argv
[idx_lb
]->arg
, "num-multipaths")) == 0)
5967 nb_cli_enqueue_change(vty
, xpath_lb_type
, NB_OP_MODIFY
,
5968 "computed-bandwidth");
5970 nb_cli_enqueue_change(vty
, xpath_lb_type
, NB_OP_MODIFY
,
5971 "explicit-bandwidth");
5972 nb_cli_enqueue_change(vty
, xpath_bandwidth
, NB_OP_MODIFY
,
5976 if (argv_find(argv
, argc
, "non-transitive", &idx_non_transitive
))
5977 nb_cli_enqueue_change(vty
, xpath_non_transitive
, NB_OP_MODIFY
,
5980 nb_cli_enqueue_change(vty
, xpath_non_transitive
, NB_OP_MODIFY
,
5983 return nb_cli_apply_changes(vty
, NULL
);
5986 DEFUN_YANG (no_set_ecommunity_lb
,
5987 no_set_ecommunity_lb_cmd
,
5988 "no set extcommunity bandwidth <(1-25600)|cumulative|num-multipaths> [non-transitive]",
5991 "BGP extended community attribute\n"
5992 "Link bandwidth extended community\n"
5993 "Bandwidth value in Mbps\n"
5994 "Cumulative bandwidth of all multipaths (outbound-only)\n"
5995 "Internally computed bandwidth based on number of multipaths (outbound-only)\n"
5996 "Attribute is set as non-transitive\n")
5999 "./set-action[action='frr-bgp-route-map:set-extcommunity-lb']";
6001 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
6002 return nb_cli_apply_changes(vty
, NULL
);
6005 ALIAS_YANG (no_set_ecommunity_lb
,
6006 no_set_ecommunity_lb_short_cmd
,
6007 "no set extcommunity bandwidth",
6010 "BGP extended community attribute\n"
6011 "Link bandwidth extended community\n")
6013 DEFUN_YANG (set_origin
,
6015 "set origin <egp|igp|incomplete>",
6020 "unknown heritage\n")
6023 const char *origin_type
;
6025 "./set-action[action='frr-bgp-route-map:set-origin']";
6026 char xpath_value
[XPATH_MAXLEN
];
6028 if (strncmp(argv
[idx_origin
]->arg
, "igp", 2) == 0)
6029 origin_type
= "igp";
6030 else if (strncmp(argv
[idx_origin
]->arg
, "egp", 1) == 0)
6031 origin_type
= "egp";
6032 else if (strncmp(argv
[idx_origin
]->arg
, "incomplete", 2) == 0)
6033 origin_type
= "incomplete";
6035 vty_out(vty
, "%% Invalid match origin type\n");
6036 return CMD_WARNING_CONFIG_FAILED
;
6039 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
6040 snprintf(xpath_value
, sizeof(xpath_value
),
6041 "%s/rmap-set-action/frr-bgp-route-map:origin", xpath
);
6042 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, origin_type
);
6044 return nb_cli_apply_changes(vty
, NULL
);
6047 DEFUN_YANG (no_set_origin
,
6049 "no set origin [<egp|igp|incomplete>]",
6055 "unknown heritage\n")
6058 "./set-action[action='frr-bgp-route-map:set-origin']";
6060 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
6061 return nb_cli_apply_changes(vty
, NULL
);
6064 DEFUN_YANG (set_atomic_aggregate
,
6065 set_atomic_aggregate_cmd
,
6066 "set atomic-aggregate",
6068 "BGP atomic aggregate attribute\n" )
6071 "./set-action[action='frr-bgp-route-map:atomic-aggregate']";
6072 char xpath_value
[XPATH_MAXLEN
];
6074 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
6075 snprintf(xpath_value
, sizeof(xpath_value
),
6076 "%s/rmap-set-action/frr-bgp-route-map:atomic-aggregate",
6078 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, NULL
);
6080 return nb_cli_apply_changes(vty
, NULL
);
6083 DEFUN_YANG (no_set_atomic_aggregate
,
6084 no_set_atomic_aggregate_cmd
,
6085 "no set atomic-aggregate",
6088 "BGP atomic aggregate attribute\n" )
6091 "./set-action[action='frr-bgp-route-map:atomic-aggregate']";
6093 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
6094 return nb_cli_apply_changes(vty
, NULL
);
6097 DEFUN_YANG (set_aggregator_as
,
6098 set_aggregator_as_cmd
,
6099 "set aggregator as (1-4294967295) A.B.C.D",
6101 "BGP aggregator attribute\n"
6102 "AS number of aggregator\n"
6104 "IP address of aggregator\n")
6108 char xpath_asn
[XPATH_MAXLEN
];
6109 char xpath_addr
[XPATH_MAXLEN
];
6111 "./set-action[action='frr-bgp-route-map:aggregator']";
6113 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
6116 xpath_asn
, sizeof(xpath_asn
),
6117 "%s/rmap-set-action/frr-bgp-route-map:aggregator/aggregator-asn",
6119 nb_cli_enqueue_change(vty
, xpath_asn
, NB_OP_MODIFY
,
6120 argv
[idx_number
]->arg
);
6123 xpath_addr
, sizeof(xpath_addr
),
6124 "%s/rmap-set-action/frr-bgp-route-map:aggregator/aggregator-address",
6126 nb_cli_enqueue_change(vty
, xpath_addr
, NB_OP_MODIFY
,
6127 argv
[idx_ipv4
]->arg
);
6129 return nb_cli_apply_changes(vty
, NULL
);
6132 DEFUN_YANG (no_set_aggregator_as
,
6133 no_set_aggregator_as_cmd
,
6134 "no set aggregator as [(1-4294967295) A.B.C.D]",
6137 "BGP aggregator attribute\n"
6138 "AS number of aggregator\n"
6140 "IP address of aggregator\n")
6143 "./set-action[action='frr-bgp-route-map:aggregator']";
6145 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
6146 return nb_cli_apply_changes(vty
, NULL
);
6149 DEFUN_YANG (match_ipv6_next_hop
,
6150 match_ipv6_next_hop_cmd
,
6151 "match ipv6 next-hop ACCESSLIST6_NAME",
6154 "Match IPv6 next-hop address of route\n"
6155 "IPv6 access-list name\n")
6158 "./match-condition[condition='frr-route-map:ipv6-next-hop-list']";
6159 char xpath_value
[XPATH_MAXLEN
];
6161 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
6162 snprintf(xpath_value
, sizeof(xpath_value
),
6163 "%s/rmap-match-condition/list-name", xpath
);
6164 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
,
6165 argv
[argc
- 1]->arg
);
6167 return nb_cli_apply_changes(vty
, NULL
);
6170 DEFUN_YANG (no_match_ipv6_next_hop
,
6171 no_match_ipv6_next_hop_cmd
,
6172 "no match ipv6 next-hop [ACCESSLIST6_NAME]",
6176 "Match IPv6 next-hop address of route\n"
6177 "IPv6 access-list name\n")
6180 "./match-condition[condition='frr-route-map:ipv6-next-hop-list']";
6182 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
6183 return nb_cli_apply_changes(vty
, NULL
);
6186 DEFUN_YANG (match_ipv6_next_hop_address
,
6187 match_ipv6_next_hop_address_cmd
,
6188 "match ipv6 next-hop address X:X::X:X",
6191 "Match IPv6 next-hop address of route\n"
6193 "IPv6 address of next hop\n")
6196 "./match-condition[condition='frr-bgp-route-map:ipv6-nexthop']";
6197 char xpath_value
[XPATH_MAXLEN
];
6199 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
6200 snprintf(xpath_value
, sizeof(xpath_value
),
6201 "%s/rmap-match-condition/frr-bgp-route-map:ipv6-address",
6203 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
,
6204 argv
[argc
- 1]->arg
);
6206 return nb_cli_apply_changes(vty
, NULL
);
6209 DEFUN_YANG (no_match_ipv6_next_hop_address
,
6210 no_match_ipv6_next_hop_address_cmd
,
6211 "no match ipv6 next-hop address X:X::X:X",
6215 "Match IPv6 next-hop address of route\n"
6217 "IPv6 address of next hop\n")
6220 "./match-condition[condition='frr-bgp-route-map:ipv6-nexthop']";
6222 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
6223 return nb_cli_apply_changes(vty
, NULL
);
6226 ALIAS_HIDDEN (match_ipv6_next_hop_address
,
6227 match_ipv6_next_hop_old_cmd
,
6228 "match ipv6 next-hop X:X::X:X",
6231 "Match IPv6 next-hop address of route\n"
6232 "IPv6 address of next hop\n")
6234 ALIAS_HIDDEN (no_match_ipv6_next_hop_address
,
6235 no_match_ipv6_next_hop_old_cmd
,
6236 "no match ipv6 next-hop X:X::X:X",
6240 "Match IPv6 next-hop address of route\n"
6241 "IPv6 address of next hop\n")
6243 DEFUN_YANG (match_ipv6_next_hop_prefix_list
,
6244 match_ipv6_next_hop_prefix_list_cmd
,
6245 "match ipv6 next-hop prefix-list PREFIXLIST_NAME",
6248 "Match IPv6 next-hop address of route\n"
6249 "Match entries by prefix-list\n"
6250 "IPv6 prefix-list name\n")
6253 "./match-condition[condition='frr-route-map:ipv6-next-hop-prefix-list']";
6254 char xpath_value
[XPATH_MAXLEN
];
6256 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
6257 snprintf(xpath_value
, sizeof(xpath_value
),
6258 "%s/rmap-match-condition/list-name", xpath
);
6259 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
,
6260 argv
[argc
- 1]->arg
);
6262 return nb_cli_apply_changes(vty
, NULL
);
6265 DEFUN_YANG (no_match_ipv6_next_hop_prefix_list
,
6266 no_match_ipv6_next_hop_prefix_list_cmd
,
6267 "no match ipv6 next-hop prefix-list [PREFIXLIST_NAME]",
6271 "Match IPv6 next-hop address of route\n"
6272 "Match entries by prefix-list\n"
6273 "IPv6 prefix-list name\n")
6276 "./match-condition[condition='frr-route-map:ipv6-next-hop-prefix-list']";
6278 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
6279 return nb_cli_apply_changes(vty
, NULL
);
6282 DEFPY_YANG (match_ipv4_next_hop
,
6283 match_ipv4_next_hop_cmd
,
6284 "match ip next-hop address A.B.C.D",
6287 "Match IP next-hop address of route\n"
6289 "IP address of next-hop\n")
6292 "./match-condition[condition='frr-bgp-route-map:ipv4-nexthop']";
6293 char xpath_value
[XPATH_MAXLEN
];
6295 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
6296 snprintf(xpath_value
, sizeof(xpath_value
),
6297 "%s/rmap-match-condition/frr-bgp-route-map:ipv4-address",
6299 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, argv
[4]->arg
);
6301 return nb_cli_apply_changes(vty
, NULL
);
6304 DEFPY_YANG (no_match_ipv4_next_hop
,
6305 no_match_ipv4_next_hop_cmd
,
6306 "no match ip next-hop address [A.B.C.D]",
6310 "Match IP next-hop address of route\n"
6312 "IP address of next-hop\n")
6315 "./match-condition[condition='frr-bgp-route-map:ipv4-nexthop']";
6317 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
6318 return nb_cli_apply_changes(vty
, NULL
);
6321 DEFUN_YANG (set_ipv6_nexthop_peer
,
6322 set_ipv6_nexthop_peer_cmd
,
6323 "set ipv6 next-hop peer-address",
6326 "Next hop address\n"
6327 "Use peer address (for BGP only)\n")
6330 "./set-action[action='frr-bgp-route-map:ipv6-peer-address']";
6331 char xpath_value
[XPATH_MAXLEN
];
6333 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
6334 snprintf(xpath_value
, sizeof(xpath_value
),
6335 "%s/rmap-set-action/frr-bgp-route-map:preference", xpath
);
6336 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, "true");
6338 return nb_cli_apply_changes(vty
, NULL
);
6341 DEFUN_YANG (no_set_ipv6_nexthop_peer
,
6342 no_set_ipv6_nexthop_peer_cmd
,
6343 "no set ipv6 next-hop peer-address",
6347 "IPv6 next-hop address\n"
6348 "Use peer address (for BGP only)\n")
6351 "./set-action[action='frr-bgp-route-map:ipv6-peer-address']";
6353 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
6354 return nb_cli_apply_changes(vty
, NULL
);
6357 DEFUN_YANG (set_ipv6_nexthop_prefer_global
,
6358 set_ipv6_nexthop_prefer_global_cmd
,
6359 "set ipv6 next-hop prefer-global",
6362 "IPv6 next-hop address\n"
6363 "Prefer global over link-local if both exist\n")
6366 "./set-action[action='frr-bgp-route-map:ipv6-prefer-global']";
6367 char xpath_value
[XPATH_MAXLEN
];
6369 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
6370 snprintf(xpath_value
, sizeof(xpath_value
),
6371 "%s/rmap-set-action/frr-bgp-route-map:preference", xpath
);
6372 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
, "true");
6374 return nb_cli_apply_changes(vty
, NULL
);
6377 DEFUN_YANG (no_set_ipv6_nexthop_prefer_global
,
6378 no_set_ipv6_nexthop_prefer_global_cmd
,
6379 "no set ipv6 next-hop prefer-global",
6383 "IPv6 next-hop address\n"
6384 "Prefer global over link-local if both exist\n")
6387 "./set-action[action='frr-bgp-route-map:ipv6-prefer-global']";
6389 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
6390 return nb_cli_apply_changes(vty
, NULL
);
6393 DEFUN_YANG (set_ipv6_nexthop_global
,
6394 set_ipv6_nexthop_global_cmd
,
6395 "set ipv6 next-hop global X:X::X:X",
6398 "IPv6 next-hop address\n"
6399 "IPv6 global address\n"
6400 "IPv6 address of next hop\n")
6404 "./set-action[action='frr-bgp-route-map:ipv6-nexthop-global']";
6405 char xpath_value
[XPATH_MAXLEN
];
6407 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
6408 snprintf(xpath_value
, sizeof(xpath_value
),
6409 "%s/rmap-set-action/frr-bgp-route-map:ipv6-address", xpath
);
6410 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
,
6411 argv
[idx_ipv6
]->arg
);
6413 return nb_cli_apply_changes(vty
, NULL
);
6416 DEFUN_YANG (no_set_ipv6_nexthop_global
,
6417 no_set_ipv6_nexthop_global_cmd
,
6418 "no set ipv6 next-hop global X:X::X:X",
6422 "IPv6 next-hop address\n"
6423 "IPv6 global address\n"
6424 "IPv6 address of next hop\n")
6427 "./set-action[action='frr-bgp-route-map:ipv6-nexthop-global']";
6429 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
6430 return nb_cli_apply_changes(vty
, NULL
);
6433 #ifdef KEEP_OLD_VPN_COMMANDS
6434 DEFUN_YANG (set_vpn_nexthop
,
6435 set_vpn_nexthop_cmd
,
6436 "set <vpnv4 next-hop A.B.C.D|vpnv6 next-hop X:X::X:X>",
6438 "VPNv4 information\n"
6439 "VPN next-hop address\n"
6440 "IP address of next hop\n"
6441 "VPNv6 information\n"
6442 "VPN next-hop address\n"
6443 "IPv6 address of next hop\n")
6448 char xpath_value
[XPATH_MAXLEN
];
6450 if (argv_find_and_parse_vpnvx(argv
, argc
, &idx
, &afi
)) {
6451 if (afi
== AFI_IP
) {
6453 "./set-action[action='frr-bgp-route-map:ipv4-vpn-address']";
6455 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
6457 xpath_value
, sizeof(xpath_value
),
6458 "%s/rmap-set-action/frr-bgp-route-map:ipv4-address",
6462 "./set-action[action='frr-bgp-route-map:ipv6-vpn-address']";
6464 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
6466 xpath_value
, sizeof(xpath_value
),
6467 "%s/rmap-set-action/frr-bgp-route-map:ipv6-address",
6471 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
,
6474 return nb_cli_apply_changes(vty
, NULL
);
6480 DEFUN_YANG (no_set_vpn_nexthop
,
6481 no_set_vpn_nexthop_cmd
,
6482 "no set <vpnv4 next-hop A.B.C.D|vpnv6 next-hop X:X::X:X>",
6485 "VPNv4 information\n"
6486 "VPN next-hop address\n"
6487 "IP address of next hop\n"
6488 "VPNv6 information\n"
6489 "VPN next-hop address\n"
6490 "IPv6 address of next hop\n")
6495 if (argv_find_and_parse_vpnvx(argv
, argc
, &idx
, &afi
)) {
6496 if (afi
== AFI_IP
) {
6498 "./set-action[action='frr-bgp-route-map:ipv4-vpn-address']";
6499 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
6502 "./set-action[action='frr-bgp-route-map:ipv6-vpn-address']";
6503 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
6505 return nb_cli_apply_changes(vty
, NULL
);
6509 #endif /* KEEP_OLD_VPN_COMMANDS */
6511 DEFUN_YANG (set_ipx_vpn_nexthop
,
6512 set_ipx_vpn_nexthop_cmd
,
6513 "set <ipv4|ipv6> vpn next-hop <A.B.C.D|X:X::X:X>",
6515 "IPv4 information\n"
6516 "IPv6 information\n"
6518 "VPN next-hop address\n"
6519 "IP address of next hop\n"
6520 "IPv6 address of next hop\n")
6525 char xpath_value
[XPATH_MAXLEN
];
6527 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
6528 if (afi
== AFI_IP
) {
6530 "./set-action[action='frr-bgp-route-map:ipv4-vpn-address']";
6532 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
6534 xpath_value
, sizeof(xpath_value
),
6535 "%s/rmap-set-action/frr-bgp-route-map:ipv4-address",
6539 "./set-action[action='frr-bgp-route-map:ipv6-vpn-address']";
6541 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
6543 xpath_value
, sizeof(xpath_value
),
6544 "%s/rmap-set-action/frr-bgp-route-map:ipv6-address",
6547 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
,
6549 return nb_cli_apply_changes(vty
, NULL
);
6554 DEFUN_YANG (no_set_ipx_vpn_nexthop
,
6555 no_set_ipx_vpn_nexthop_cmd
,
6556 "no set <ipv4|ipv6> vpn next-hop [<A.B.C.D|X:X::X:X>]",
6559 "IPv4 information\n"
6560 "IPv6 information\n"
6562 "VPN next-hop address\n"
6563 "IP address of next hop\n"
6564 "IPv6 address of next hop\n")
6569 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
6570 if (afi
== AFI_IP
) {
6572 "./set-action[action='frr-bgp-route-map:ipv4-vpn-address']";
6573 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
6576 "./set-action[action='frr-bgp-route-map:ipv6-vpn-address']";
6577 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
6579 return nb_cli_apply_changes(vty
, NULL
);
6584 DEFUN_YANG (set_originator_id
,
6585 set_originator_id_cmd
,
6586 "set originator-id A.B.C.D",
6588 "BGP originator ID attribute\n"
6589 "IP address of originator\n")
6593 "./set-action[action='frr-bgp-route-map:originator-id']";
6594 char xpath_value
[XPATH_MAXLEN
];
6596 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
6597 snprintf(xpath_value
, sizeof(xpath_value
),
6598 "%s/rmap-set-action/frr-bgp-route-map:originator-id", xpath
);
6599 nb_cli_enqueue_change(vty
, xpath_value
, NB_OP_MODIFY
,
6600 argv
[idx_ipv4
]->arg
);
6602 return nb_cli_apply_changes(vty
, NULL
);
6605 DEFUN_YANG (no_set_originator_id
,
6606 no_set_originator_id_cmd
,
6607 "no set originator-id [A.B.C.D]",
6610 "BGP originator ID attribute\n"
6611 "IP address of originator\n")
6614 "./set-action[action='frr-bgp-route-map:originator-id']";
6616 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
6617 return nb_cli_apply_changes(vty
, NULL
);
6620 /* Initialization of route map. */
6621 void bgp_route_map_init(void)
6625 route_map_add_hook(bgp_route_map_add
);
6626 route_map_delete_hook(bgp_route_map_delete
);
6627 route_map_event_hook(bgp_route_map_event
);
6629 route_map_match_interface_hook(generic_match_add
);
6630 route_map_no_match_interface_hook(generic_match_delete
);
6632 route_map_match_ip_address_hook(generic_match_add
);
6633 route_map_no_match_ip_address_hook(generic_match_delete
);
6635 route_map_match_ip_address_prefix_list_hook(generic_match_add
);
6636 route_map_no_match_ip_address_prefix_list_hook(generic_match_delete
);
6638 route_map_match_ip_next_hop_hook(generic_match_add
);
6639 route_map_no_match_ip_next_hop_hook(generic_match_delete
);
6641 route_map_match_ipv6_next_hop_hook(generic_match_add
);
6642 route_map_no_match_ipv6_next_hop_hook(generic_match_delete
);
6644 route_map_match_ip_next_hop_prefix_list_hook(generic_match_add
);
6645 route_map_no_match_ip_next_hop_prefix_list_hook(generic_match_delete
);
6647 route_map_match_ip_next_hop_type_hook(generic_match_add
);
6648 route_map_no_match_ip_next_hop_type_hook(generic_match_delete
);
6650 route_map_match_ipv6_address_hook(generic_match_add
);
6651 route_map_no_match_ipv6_address_hook(generic_match_delete
);
6653 route_map_match_ipv6_address_prefix_list_hook(generic_match_add
);
6654 route_map_no_match_ipv6_address_prefix_list_hook(generic_match_delete
);
6656 route_map_match_ipv6_next_hop_type_hook(generic_match_add
);
6657 route_map_no_match_ipv6_next_hop_type_hook(generic_match_delete
);
6659 route_map_match_ipv6_next_hop_prefix_list_hook(generic_match_add
);
6660 route_map_no_match_ipv6_next_hop_prefix_list_hook(generic_match_delete
);
6662 route_map_match_metric_hook(generic_match_add
);
6663 route_map_no_match_metric_hook(generic_match_delete
);
6665 route_map_match_tag_hook(generic_match_add
);
6666 route_map_no_match_tag_hook(generic_match_delete
);
6668 route_map_set_srte_color_hook(generic_set_add
);
6669 route_map_no_set_srte_color_hook(generic_set_delete
);
6671 route_map_set_ip_nexthop_hook(generic_set_add
);
6672 route_map_no_set_ip_nexthop_hook(generic_set_delete
);
6674 route_map_set_ipv6_nexthop_local_hook(generic_set_add
);
6675 route_map_no_set_ipv6_nexthop_local_hook(generic_set_delete
);
6677 route_map_set_metric_hook(generic_set_add
);
6678 route_map_no_set_metric_hook(generic_set_delete
);
6680 route_map_set_tag_hook(generic_set_add
);
6681 route_map_no_set_tag_hook(generic_set_delete
);
6683 route_map_install_match(&route_match_peer_cmd
);
6684 route_map_install_match(&route_match_alias_cmd
);
6685 route_map_install_match(&route_match_local_pref_cmd
);
6686 #ifdef HAVE_SCRIPTING
6687 route_map_install_match(&route_match_script_cmd
);
6689 route_map_install_match(&route_match_ip_address_cmd
);
6690 route_map_install_match(&route_match_ip_next_hop_cmd
);
6691 route_map_install_match(&route_match_ip_route_source_cmd
);
6692 route_map_install_match(&route_match_ip_address_prefix_list_cmd
);
6693 route_map_install_match(&route_match_ip_next_hop_prefix_list_cmd
);
6694 route_map_install_match(&route_match_ip_next_hop_type_cmd
);
6695 route_map_install_match(&route_match_ip_route_source_prefix_list_cmd
);
6696 route_map_install_match(&route_match_aspath_cmd
);
6697 route_map_install_match(&route_match_community_cmd
);
6698 route_map_install_match(&route_match_lcommunity_cmd
);
6699 route_map_install_match(&route_match_ecommunity_cmd
);
6700 route_map_install_match(&route_match_local_pref_cmd
);
6701 route_map_install_match(&route_match_metric_cmd
);
6702 route_map_install_match(&route_match_origin_cmd
);
6703 route_map_install_match(&route_match_probability_cmd
);
6704 route_map_install_match(&route_match_interface_cmd
);
6705 route_map_install_match(&route_match_tag_cmd
);
6706 route_map_install_match(&route_match_mac_address_cmd
);
6707 route_map_install_match(&route_match_evpn_vni_cmd
);
6708 route_map_install_match(&route_match_evpn_route_type_cmd
);
6709 route_map_install_match(&route_match_evpn_rd_cmd
);
6710 route_map_install_match(&route_match_evpn_default_route_cmd
);
6711 route_map_install_match(&route_match_vrl_source_vrf_cmd
);
6713 route_map_install_set(&route_set_evpn_gateway_ip_ipv4_cmd
);
6714 route_map_install_set(&route_set_evpn_gateway_ip_ipv6_cmd
);
6715 route_map_install_set(&route_set_table_id_cmd
);
6716 route_map_install_set(&route_set_srte_color_cmd
);
6717 route_map_install_set(&route_set_ip_nexthop_cmd
);
6718 route_map_install_set(&route_set_local_pref_cmd
);
6719 route_map_install_set(&route_set_weight_cmd
);
6720 route_map_install_set(&route_set_label_index_cmd
);
6721 route_map_install_set(&route_set_metric_cmd
);
6722 route_map_install_set(&route_set_distance_cmd
);
6723 route_map_install_set(&route_set_aspath_prepend_cmd
);
6724 route_map_install_set(&route_set_aspath_exclude_cmd
);
6725 route_map_install_set(&route_set_origin_cmd
);
6726 route_map_install_set(&route_set_atomic_aggregate_cmd
);
6727 route_map_install_set(&route_set_aggregator_as_cmd
);
6728 route_map_install_set(&route_set_community_cmd
);
6729 route_map_install_set(&route_set_community_delete_cmd
);
6730 route_map_install_set(&route_set_lcommunity_cmd
);
6731 route_map_install_set(&route_set_lcommunity_delete_cmd
);
6732 route_map_install_set(&route_set_vpnv4_nexthop_cmd
);
6733 route_map_install_set(&route_set_vpnv6_nexthop_cmd
);
6734 route_map_install_set(&route_set_originator_id_cmd
);
6735 route_map_install_set(&route_set_ecommunity_rt_cmd
);
6736 route_map_install_set(&route_set_ecommunity_soo_cmd
);
6737 route_map_install_set(&route_set_ecommunity_lb_cmd
);
6738 route_map_install_set(&route_set_ecommunity_none_cmd
);
6739 route_map_install_set(&route_set_tag_cmd
);
6740 route_map_install_set(&route_set_label_index_cmd
);
6742 install_element(RMAP_NODE
, &match_peer_cmd
);
6743 install_element(RMAP_NODE
, &match_peer_local_cmd
);
6744 install_element(RMAP_NODE
, &no_match_peer_cmd
);
6745 install_element(RMAP_NODE
, &match_ip_route_source_cmd
);
6746 install_element(RMAP_NODE
, &no_match_ip_route_source_cmd
);
6747 install_element(RMAP_NODE
, &match_ip_route_source_prefix_list_cmd
);
6748 install_element(RMAP_NODE
, &no_match_ip_route_source_prefix_list_cmd
);
6749 install_element(RMAP_NODE
, &match_mac_address_cmd
);
6750 install_element(RMAP_NODE
, &no_match_mac_address_cmd
);
6751 install_element(RMAP_NODE
, &match_evpn_vni_cmd
);
6752 install_element(RMAP_NODE
, &no_match_evpn_vni_cmd
);
6753 install_element(RMAP_NODE
, &match_evpn_route_type_cmd
);
6754 install_element(RMAP_NODE
, &no_match_evpn_route_type_cmd
);
6755 install_element(RMAP_NODE
, &match_evpn_rd_cmd
);
6756 install_element(RMAP_NODE
, &no_match_evpn_rd_cmd
);
6757 install_element(RMAP_NODE
, &match_evpn_default_route_cmd
);
6758 install_element(RMAP_NODE
, &no_match_evpn_default_route_cmd
);
6759 install_element(RMAP_NODE
, &set_evpn_gw_ip_ipv4_cmd
);
6760 install_element(RMAP_NODE
, &no_set_evpn_gw_ip_ipv4_cmd
);
6761 install_element(RMAP_NODE
, &set_evpn_gw_ip_ipv6_cmd
);
6762 install_element(RMAP_NODE
, &no_set_evpn_gw_ip_ipv6_cmd
);
6763 install_element(RMAP_NODE
, &match_vrl_source_vrf_cmd
);
6764 install_element(RMAP_NODE
, &no_match_vrl_source_vrf_cmd
);
6766 install_element(RMAP_NODE
, &match_aspath_cmd
);
6767 install_element(RMAP_NODE
, &no_match_aspath_cmd
);
6768 install_element(RMAP_NODE
, &match_local_pref_cmd
);
6769 install_element(RMAP_NODE
, &no_match_local_pref_cmd
);
6770 install_element(RMAP_NODE
, &match_alias_cmd
);
6771 install_element(RMAP_NODE
, &no_match_alias_cmd
);
6772 install_element(RMAP_NODE
, &match_community_cmd
);
6773 install_element(RMAP_NODE
, &no_match_community_cmd
);
6774 install_element(RMAP_NODE
, &match_lcommunity_cmd
);
6775 install_element(RMAP_NODE
, &no_match_lcommunity_cmd
);
6776 install_element(RMAP_NODE
, &match_ecommunity_cmd
);
6777 install_element(RMAP_NODE
, &no_match_ecommunity_cmd
);
6778 install_element(RMAP_NODE
, &match_origin_cmd
);
6779 install_element(RMAP_NODE
, &no_match_origin_cmd
);
6780 install_element(RMAP_NODE
, &match_probability_cmd
);
6781 install_element(RMAP_NODE
, &no_match_probability_cmd
);
6783 install_element(RMAP_NODE
, &no_set_table_id_cmd
);
6784 install_element(RMAP_NODE
, &set_table_id_cmd
);
6785 install_element(RMAP_NODE
, &set_ip_nexthop_peer_cmd
);
6786 install_element(RMAP_NODE
, &set_ip_nexthop_unchanged_cmd
);
6787 install_element(RMAP_NODE
, &set_local_pref_cmd
);
6788 install_element(RMAP_NODE
, &set_distance_cmd
);
6789 install_element(RMAP_NODE
, &no_set_distance_cmd
);
6790 install_element(RMAP_NODE
, &no_set_local_pref_cmd
);
6791 install_element(RMAP_NODE
, &set_weight_cmd
);
6792 install_element(RMAP_NODE
, &set_label_index_cmd
);
6793 install_element(RMAP_NODE
, &no_set_weight_cmd
);
6794 install_element(RMAP_NODE
, &no_set_label_index_cmd
);
6795 install_element(RMAP_NODE
, &set_aspath_prepend_asn_cmd
);
6796 install_element(RMAP_NODE
, &set_aspath_prepend_lastas_cmd
);
6797 install_element(RMAP_NODE
, &set_aspath_exclude_cmd
);
6798 install_element(RMAP_NODE
, &no_set_aspath_prepend_cmd
);
6799 install_element(RMAP_NODE
, &no_set_aspath_prepend_lastas_cmd
);
6800 install_element(RMAP_NODE
, &no_set_aspath_exclude_cmd
);
6801 install_element(RMAP_NODE
, &no_set_aspath_exclude_all_cmd
);
6802 install_element(RMAP_NODE
, &set_origin_cmd
);
6803 install_element(RMAP_NODE
, &no_set_origin_cmd
);
6804 install_element(RMAP_NODE
, &set_atomic_aggregate_cmd
);
6805 install_element(RMAP_NODE
, &no_set_atomic_aggregate_cmd
);
6806 install_element(RMAP_NODE
, &set_aggregator_as_cmd
);
6807 install_element(RMAP_NODE
, &no_set_aggregator_as_cmd
);
6808 install_element(RMAP_NODE
, &set_community_cmd
);
6809 install_element(RMAP_NODE
, &set_community_none_cmd
);
6810 install_element(RMAP_NODE
, &no_set_community_cmd
);
6811 install_element(RMAP_NODE
, &no_set_community_short_cmd
);
6812 install_element(RMAP_NODE
, &set_community_delete_cmd
);
6813 install_element(RMAP_NODE
, &no_set_community_delete_cmd
);
6814 install_element(RMAP_NODE
, &set_lcommunity_cmd
);
6815 install_element(RMAP_NODE
, &set_lcommunity_none_cmd
);
6816 install_element(RMAP_NODE
, &no_set_lcommunity_cmd
);
6817 install_element(RMAP_NODE
, &no_set_lcommunity1_cmd
);
6818 install_element(RMAP_NODE
, &no_set_lcommunity1_short_cmd
);
6819 install_element(RMAP_NODE
, &set_lcommunity_delete_cmd
);
6820 install_element(RMAP_NODE
, &no_set_lcommunity_delete_cmd
);
6821 install_element(RMAP_NODE
, &no_set_lcommunity_delete_short_cmd
);
6822 install_element(RMAP_NODE
, &set_ecommunity_rt_cmd
);
6823 install_element(RMAP_NODE
, &no_set_ecommunity_rt_cmd
);
6824 install_element(RMAP_NODE
, &no_set_ecommunity_rt_short_cmd
);
6825 install_element(RMAP_NODE
, &set_ecommunity_soo_cmd
);
6826 install_element(RMAP_NODE
, &no_set_ecommunity_soo_cmd
);
6827 install_element(RMAP_NODE
, &no_set_ecommunity_soo_short_cmd
);
6828 install_element(RMAP_NODE
, &set_ecommunity_lb_cmd
);
6829 install_element(RMAP_NODE
, &no_set_ecommunity_lb_cmd
);
6830 install_element(RMAP_NODE
, &no_set_ecommunity_lb_short_cmd
);
6831 install_element(RMAP_NODE
, &set_ecommunity_none_cmd
);
6832 install_element(RMAP_NODE
, &no_set_ecommunity_none_cmd
);
6833 #ifdef KEEP_OLD_VPN_COMMANDS
6834 install_element(RMAP_NODE
, &set_vpn_nexthop_cmd
);
6835 install_element(RMAP_NODE
, &no_set_vpn_nexthop_cmd
);
6836 #endif /* KEEP_OLD_VPN_COMMANDS */
6837 install_element(RMAP_NODE
, &set_ipx_vpn_nexthop_cmd
);
6838 install_element(RMAP_NODE
, &no_set_ipx_vpn_nexthop_cmd
);
6839 install_element(RMAP_NODE
, &set_originator_id_cmd
);
6840 install_element(RMAP_NODE
, &no_set_originator_id_cmd
);
6842 route_map_install_match(&route_match_ipv6_address_cmd
);
6843 route_map_install_match(&route_match_ipv6_next_hop_cmd
);
6844 route_map_install_match(&route_match_ipv6_next_hop_address_cmd
);
6845 route_map_install_match(&route_match_ipv6_next_hop_prefix_list_cmd
);
6846 route_map_install_match(&route_match_ipv4_next_hop_cmd
);
6847 route_map_install_match(&route_match_ipv6_address_prefix_list_cmd
);
6848 route_map_install_match(&route_match_ipv6_next_hop_type_cmd
);
6849 route_map_install_set(&route_set_ipv6_nexthop_global_cmd
);
6850 route_map_install_set(&route_set_ipv6_nexthop_prefer_global_cmd
);
6851 route_map_install_set(&route_set_ipv6_nexthop_local_cmd
);
6852 route_map_install_set(&route_set_ipv6_nexthop_peer_cmd
);
6854 install_element(RMAP_NODE
, &match_ipv6_next_hop_cmd
);
6855 install_element(RMAP_NODE
, &match_ipv6_next_hop_address_cmd
);
6856 install_element(RMAP_NODE
, &match_ipv6_next_hop_prefix_list_cmd
);
6857 install_element(RMAP_NODE
, &no_match_ipv6_next_hop_cmd
);
6858 install_element(RMAP_NODE
, &no_match_ipv6_next_hop_address_cmd
);
6859 install_element(RMAP_NODE
, &no_match_ipv6_next_hop_prefix_list_cmd
);
6860 install_element(RMAP_NODE
, &match_ipv6_next_hop_old_cmd
);
6861 install_element(RMAP_NODE
, &no_match_ipv6_next_hop_old_cmd
);
6862 install_element(RMAP_NODE
, &match_ipv4_next_hop_cmd
);
6863 install_element(RMAP_NODE
, &no_match_ipv4_next_hop_cmd
);
6864 install_element(RMAP_NODE
, &set_ipv6_nexthop_global_cmd
);
6865 install_element(RMAP_NODE
, &no_set_ipv6_nexthop_global_cmd
);
6866 install_element(RMAP_NODE
, &set_ipv6_nexthop_prefer_global_cmd
);
6867 install_element(RMAP_NODE
, &no_set_ipv6_nexthop_prefer_global_cmd
);
6868 install_element(RMAP_NODE
, &set_ipv6_nexthop_peer_cmd
);
6869 install_element(RMAP_NODE
, &no_set_ipv6_nexthop_peer_cmd
);
6870 #ifdef HAVE_SCRIPTING
6871 install_element(RMAP_NODE
, &match_script_cmd
);
6875 void bgp_route_map_terminate(void)
6877 /* ToDo: Cleanup all the used memory */