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
17 along with GNU Zebra; see the file COPYING. If not, write to the Free
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
31 #ifdef HAVE_LIBPCREPOSIX
32 # include <pcreposix.h>
34 # ifdef HAVE_GNU_REGEX
37 # include "regex-gnu.h"
38 # endif /* HAVE_GNU_REGEX */
39 #endif /* HAVE_LIBPCREPOSIX */
41 #include "sockunion.h"
43 #include "bgpd/bgpd.h"
44 #include "bgpd/bgp_table.h"
45 #include "bgpd/bgp_attr.h"
46 #include "bgpd/bgp_aspath.h"
47 #include "bgpd/bgp_route.h"
48 #include "bgpd/bgp_regex.h"
49 #include "bgpd/bgp_community.h"
50 #include "bgpd/bgp_clist.h"
51 #include "bgpd/bgp_filter.h"
52 #include "bgpd/bgp_mplsvpn.h"
53 #include "bgpd/bgp_ecommunity.h"
54 #include "bgpd/bgp_lcommunity.h"
55 #include "bgpd/bgp_vty.h"
57 /* Memo of route-map commands.
67 ip route-source : Done
71 ipv6 route-source: (This will not be implemented by bgpd)
72 ipv6 prefix-list : Done
73 length : (This will not be implemented by bgpd)
75 route-type : (This will not be implemented by bgpd)
77 local-preference : Done
79 set as-path prepend : Done
81 automatic-tag : (This will not be implemented by bgpd)
83 large-community : Done
84 large-comm-list : Done
87 default : (This will not be implemented by bgpd)
88 interface : (This will not be implemented by bgpd)
89 ip default : (This will not be implemented by bgpd)
91 ip precedence : (This will not be implemented by bgpd)
92 ip tos : (This will not be implemented by bgpd)
93 level : (This will not be implemented by bgpd)
94 local-preference : Done
103 set ipv6 next-hop global: Done
104 set ipv6 next-hop local : Done
105 set as-path exclude : Done
109 /* generic value manipulation to be shared in multiple rules */
111 #define RMAP_VALUE_SET 0
112 #define RMAP_VALUE_ADD 1
113 #define RMAP_VALUE_SUB 2
123 route_value_match (struct rmap_value *rv, u_int32_t value)
125 if (rv->variable == 0 && value == rv->value)
132 route_value_adjust (struct rmap_value *rv, u_int32_t current, struct peer *peer)
136 switch (rv->variable)
149 if (current > UINT32_MAX-value)
151 return current + value;
153 if (current <= value)
155 return current - value;
162 route_value_compile (const char *arg)
164 u_int8_t action = RMAP_VALUE_SET, var = 0;
165 unsigned long larg = 0;
167 struct rmap_value *rv;
171 action = RMAP_VALUE_ADD;
174 else if (arg[0] == '-')
176 action = RMAP_VALUE_SUB;
183 larg = strtoul (arg, &endptr, 10);
184 if (*arg == 0 || *endptr != 0 || errno || larg > UINT32_MAX)
189 if (strcmp(arg, "rtt") == 0)
195 rv = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof(struct rmap_value));
206 route_value_free (void *rule)
208 XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
211 /* generic as path object to be shared in multiple rules */
214 route_aspath_compile (const char *arg)
216 struct aspath *aspath;
218 aspath = aspath_str2aspath (arg);
225 route_aspath_free (void *rule)
227 struct aspath *aspath = rule;
228 aspath_free (aspath);
231 /* 'match peer (A.B.C.D|X:X::X:X)' */
233 /* Compares the peer specified in the 'match peer' clause with the peer
234 received in bgp_info->peer. If it is the same, or if the peer structure
235 received is a peer_group containing it, returns RMAP_MATCH. */
236 static route_map_result_t
237 route_match_peer (void *rule, struct prefix *prefix, route_map_object_t type,
241 union sockunion su_def = { .sin = { .sin_family = AF_INET,
242 .sin_addr.s_addr = INADDR_ANY } };
243 struct peer_group *group;
245 struct listnode *node, *nnode;
247 if (type == RMAP_BGP)
250 peer = ((struct bgp_info *) object)->peer;
252 if ( ! CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT) &&
253 ! CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_EXPORT) )
256 /* If su='0.0.0.0' (command 'match peer local'), and it's a NETWORK,
257 REDISTRIBUTE or DEFAULT_GENERATED route => return RMAP_MATCH */
258 if (sockunion_same (su, &su_def))
261 if ( CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_NETWORK) ||
262 CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE) ||
263 CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_DEFAULT))
270 if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
272 if (sockunion_same (su, &peer->su))
280 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
282 if (sockunion_same (su, &peer->su))
292 route_match_peer_compile (const char *arg)
297 su = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (union sockunion));
299 ret = str2sockunion (strcmp(arg, "local") ? arg : "0.0.0.0", su);
301 XFREE (MTYPE_ROUTE_MAP_COMPILED, su);
308 /* Free route map's compiled `ip address' value. */
310 route_match_peer_free (void *rule)
312 XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
315 /* Route map commands for ip address matching. */
316 struct route_map_rule_cmd route_match_peer_cmd =
320 route_match_peer_compile,
321 route_match_peer_free
324 /* `match ip address IP_ACCESS_LIST' */
326 /* Match function should return 1 if match is success else return
328 static route_map_result_t
329 route_match_ip_address (void *rule, struct prefix *prefix,
330 route_map_object_t type, void *object)
332 struct access_list *alist;
333 /* struct prefix_ipv4 match; */
335 if (type == RMAP_BGP)
337 alist = access_list_lookup (AFI_IP, (char *) rule);
341 return (access_list_apply (alist, prefix) == FILTER_DENY ?
342 RMAP_NOMATCH : RMAP_MATCH);
347 /* Route map `ip address' match statement. `arg' should be
350 route_match_ip_address_compile (const char *arg)
352 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
355 /* Free route map's compiled `ip address' value. */
357 route_match_ip_address_free (void *rule)
359 XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
362 /* Route map commands for ip address matching. */
363 struct route_map_rule_cmd route_match_ip_address_cmd =
366 route_match_ip_address,
367 route_match_ip_address_compile,
368 route_match_ip_address_free
371 /* `match ip next-hop IP_ADDRESS' */
373 /* Match function return 1 if match is success else return zero. */
374 static route_map_result_t
375 route_match_ip_next_hop (void *rule, struct prefix *prefix,
376 route_map_object_t type, void *object)
378 struct access_list *alist;
379 struct bgp_info *bgp_info;
380 struct prefix_ipv4 p;
382 if (type == RMAP_BGP)
386 p.prefix = bgp_info->attr->nexthop;
387 p.prefixlen = IPV4_MAX_BITLEN;
389 alist = access_list_lookup (AFI_IP, (char *) rule);
393 return (access_list_apply (alist, &p) == FILTER_DENY ?
394 RMAP_NOMATCH : RMAP_MATCH);
399 /* Route map `ip next-hop' match statement. `arg' is
402 route_match_ip_next_hop_compile (const char *arg)
404 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
407 /* Free route map's compiled `ip address' value. */
409 route_match_ip_next_hop_free (void *rule)
411 XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
414 /* Route map commands for ip next-hop matching. */
415 struct route_map_rule_cmd route_match_ip_next_hop_cmd =
418 route_match_ip_next_hop,
419 route_match_ip_next_hop_compile,
420 route_match_ip_next_hop_free
423 /* `match ip route-source ACCESS-LIST' */
425 /* Match function return 1 if match is success else return zero. */
426 static route_map_result_t
427 route_match_ip_route_source (void *rule, struct prefix *prefix,
428 route_map_object_t type, void *object)
430 struct access_list *alist;
431 struct bgp_info *bgp_info;
433 struct prefix_ipv4 p;
435 if (type == RMAP_BGP)
438 peer = bgp_info->peer;
440 if (! peer || sockunion_family (&peer->su) != AF_INET)
444 p.prefix = peer->su.sin.sin_addr;
445 p.prefixlen = IPV4_MAX_BITLEN;
447 alist = access_list_lookup (AFI_IP, (char *) rule);
451 return (access_list_apply (alist, &p) == FILTER_DENY ?
452 RMAP_NOMATCH : RMAP_MATCH);
457 /* Route map `ip route-source' match statement. `arg' is
460 route_match_ip_route_source_compile (const char *arg)
462 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
465 /* Free route map's compiled `ip address' value. */
467 route_match_ip_route_source_free (void *rule)
469 XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
472 /* Route map commands for ip route-source matching. */
473 struct route_map_rule_cmd route_match_ip_route_source_cmd =
476 route_match_ip_route_source,
477 route_match_ip_route_source_compile,
478 route_match_ip_route_source_free
481 /* `match ip address prefix-list PREFIX_LIST' */
483 static route_map_result_t
484 route_match_ip_address_prefix_list (void *rule, struct prefix *prefix,
485 route_map_object_t type, void *object)
487 struct prefix_list *plist;
489 if (type == RMAP_BGP)
491 plist = prefix_list_lookup (AFI_IP, (char *) rule);
495 return (prefix_list_apply (plist, prefix) == PREFIX_DENY ?
496 RMAP_NOMATCH : RMAP_MATCH);
502 route_match_ip_address_prefix_list_compile (const char *arg)
504 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
508 route_match_ip_address_prefix_list_free (void *rule)
510 XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
513 struct route_map_rule_cmd route_match_ip_address_prefix_list_cmd =
515 "ip address prefix-list",
516 route_match_ip_address_prefix_list,
517 route_match_ip_address_prefix_list_compile,
518 route_match_ip_address_prefix_list_free
521 /* `match ip next-hop prefix-list PREFIX_LIST' */
523 static route_map_result_t
524 route_match_ip_next_hop_prefix_list (void *rule, struct prefix *prefix,
525 route_map_object_t type, void *object)
527 struct prefix_list *plist;
528 struct bgp_info *bgp_info;
529 struct prefix_ipv4 p;
531 if (type == RMAP_BGP)
535 p.prefix = bgp_info->attr->nexthop;
536 p.prefixlen = IPV4_MAX_BITLEN;
538 plist = prefix_list_lookup (AFI_IP, (char *) rule);
542 return (prefix_list_apply (plist, &p) == PREFIX_DENY ?
543 RMAP_NOMATCH : RMAP_MATCH);
549 route_match_ip_next_hop_prefix_list_compile (const char *arg)
551 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
555 route_match_ip_next_hop_prefix_list_free (void *rule)
557 XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
560 struct route_map_rule_cmd route_match_ip_next_hop_prefix_list_cmd =
562 "ip next-hop prefix-list",
563 route_match_ip_next_hop_prefix_list,
564 route_match_ip_next_hop_prefix_list_compile,
565 route_match_ip_next_hop_prefix_list_free
568 /* `match ip route-source prefix-list PREFIX_LIST' */
570 static route_map_result_t
571 route_match_ip_route_source_prefix_list (void *rule, struct prefix *prefix,
572 route_map_object_t type, void *object)
574 struct prefix_list *plist;
575 struct bgp_info *bgp_info;
577 struct prefix_ipv4 p;
579 if (type == RMAP_BGP)
582 peer = bgp_info->peer;
584 if (! peer || sockunion_family (&peer->su) != AF_INET)
588 p.prefix = peer->su.sin.sin_addr;
589 p.prefixlen = IPV4_MAX_BITLEN;
591 plist = prefix_list_lookup (AFI_IP, (char *) rule);
595 return (prefix_list_apply (plist, &p) == PREFIX_DENY ?
596 RMAP_NOMATCH : RMAP_MATCH);
602 route_match_ip_route_source_prefix_list_compile (const char *arg)
604 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
608 route_match_ip_route_source_prefix_list_free (void *rule)
610 XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
613 struct route_map_rule_cmd route_match_ip_route_source_prefix_list_cmd =
615 "ip route-source prefix-list",
616 route_match_ip_route_source_prefix_list,
617 route_match_ip_route_source_prefix_list_compile,
618 route_match_ip_route_source_prefix_list_free
621 /* `match local-preference LOCAL-PREF' */
623 /* Match function return 1 if match is success else return zero. */
624 static route_map_result_t
625 route_match_local_pref (void *rule, struct prefix *prefix,
626 route_map_object_t type, void *object)
628 u_int32_t *local_pref;
629 struct bgp_info *bgp_info;
631 if (type == RMAP_BGP)
636 if (bgp_info->attr->local_pref == *local_pref)
644 /* Route map `match local-preference' match statement.
645 `arg' is local-pref value */
647 route_match_local_pref_compile (const char *arg)
649 u_int32_t *local_pref;
651 unsigned long tmpval;
653 /* Locpref value shoud be integer. */
654 if (! all_digit (arg))
658 tmpval = strtoul (arg, &endptr, 10);
659 if (*endptr != '\0' || errno || tmpval > UINT32_MAX)
662 local_pref = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_int32_t));
667 *local_pref = tmpval;
671 /* Free route map's compiled `match local-preference' value. */
673 route_match_local_pref_free (void *rule)
675 XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
678 /* Route map commands for metric matching. */
679 struct route_map_rule_cmd route_match_local_pref_cmd =
682 route_match_local_pref,
683 route_match_local_pref_compile,
684 route_match_local_pref_free
687 /* `match metric METRIC' */
689 /* Match function return 1 if match is success else return zero. */
690 static route_map_result_t
691 route_match_metric (void *rule, struct prefix *prefix,
692 route_map_object_t type, void *object)
694 struct rmap_value *rv;
695 struct bgp_info *bgp_info;
697 if (type == RMAP_BGP)
701 return route_value_match(rv, bgp_info->attr->med);
706 /* Route map commands for metric matching. */
707 struct route_map_rule_cmd route_match_metric_cmd =
715 /* `match as-path ASPATH' */
717 /* Match function for as-path match. I assume given object is */
718 static route_map_result_t
719 route_match_aspath (void *rule, struct prefix *prefix,
720 route_map_object_t type, void *object)
723 struct as_list *as_list;
724 struct bgp_info *bgp_info;
726 if (type == RMAP_BGP)
728 as_list = as_list_lookup ((char *) rule);
735 return ((as_list_apply (as_list, bgp_info->attr->aspath) == AS_FILTER_DENY) ? RMAP_NOMATCH : RMAP_MATCH);
740 /* Compile function for as-path match. */
742 route_match_aspath_compile (const char *arg)
744 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
747 /* Compile function for as-path match. */
749 route_match_aspath_free (void *rule)
751 XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
754 /* Route map commands for aspath matching. */
755 struct route_map_rule_cmd route_match_aspath_cmd =
759 route_match_aspath_compile,
760 route_match_aspath_free
763 /* `match community COMMUNIY' */
764 struct rmap_community
770 /* Match function for community match. */
771 static route_map_result_t
772 route_match_community (void *rule, struct prefix *prefix,
773 route_map_object_t type, void *object)
775 struct community_list *list;
776 struct bgp_info *bgp_info;
777 struct rmap_community *rcom;
779 if (type == RMAP_BGP)
784 list = community_list_lookup (bgp_clist, rcom->name, COMMUNITY_LIST_MASTER);
790 if (community_list_exact_match (bgp_info->attr->community, list))
795 if (community_list_match (bgp_info->attr->community, list))
802 /* Compile function for community match. */
804 route_match_community_compile (const char *arg)
806 struct rmap_community *rcom;
810 rcom = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct rmap_community));
812 p = strchr (arg, ' ');
816 rcom->name = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, len + 1);
817 memcpy (rcom->name, arg, len);
822 rcom->name = XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
828 /* Compile function for community match. */
830 route_match_community_free (void *rule)
832 struct rmap_community *rcom = rule;
834 XFREE (MTYPE_ROUTE_MAP_COMPILED, rcom->name);
835 XFREE (MTYPE_ROUTE_MAP_COMPILED, rcom);
838 /* Route map commands for community matching. */
839 struct route_map_rule_cmd route_match_community_cmd =
842 route_match_community,
843 route_match_community_compile,
844 route_match_community_free
847 /* Match function for lcommunity match. */
848 static route_map_result_t
849 route_match_lcommunity (void *rule, struct prefix *prefix,
850 route_map_object_t type, void *object)
852 struct community_list *list;
853 struct bgp_info *bgp_info;
854 struct rmap_community *rcom;
856 if (type == RMAP_BGP)
861 list = community_list_lookup (bgp_clist, rcom->name,
862 LARGE_COMMUNITY_LIST_MASTER);
866 if (bgp_info->attr->extra &&
867 lcommunity_list_match (bgp_info->attr->extra->lcommunity, list))
874 /* Compile function for community match. */
876 route_match_lcommunity_compile (const char *arg)
878 struct rmap_community *rcom;
882 rcom = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct rmap_community));
884 p = strchr (arg, ' ');
888 rcom->name = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, len + 1);
889 memcpy (rcom->name, arg, len);
893 rcom->name = XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
899 /* Compile function for community match. */
901 route_match_lcommunity_free (void *rule)
903 struct rmap_community *rcom = rule;
905 XFREE (MTYPE_ROUTE_MAP_COMPILED, rcom->name);
906 XFREE (MTYPE_ROUTE_MAP_COMPILED, rcom);
909 /* Route map commands for community matching. */
910 struct route_map_rule_cmd route_match_lcommunity_cmd =
913 route_match_lcommunity,
914 route_match_lcommunity_compile,
915 route_match_lcommunity_free
919 /* Match function for extcommunity match. */
920 static route_map_result_t
921 route_match_ecommunity (void *rule, struct prefix *prefix,
922 route_map_object_t type, void *object)
924 struct community_list *list;
925 struct bgp_info *bgp_info;
927 if (type == RMAP_BGP)
931 if (!bgp_info->attr->extra)
934 list = community_list_lookup (bgp_clist, (char *) rule,
935 EXTCOMMUNITY_LIST_MASTER);
939 if (ecommunity_list_match (bgp_info->attr->extra->ecommunity, list))
945 /* Compile function for extcommunity match. */
947 route_match_ecommunity_compile (const char *arg)
949 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
952 /* Compile function for extcommunity match. */
954 route_match_ecommunity_free (void *rule)
956 XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
959 /* Route map commands for community matching. */
960 struct route_map_rule_cmd route_match_ecommunity_cmd =
963 route_match_ecommunity,
964 route_match_ecommunity_compile,
965 route_match_ecommunity_free
968 /* `match nlri` and `set nlri` are replaced by `address-family ipv4`
969 and `address-family vpnv4'. */
972 static route_map_result_t
973 route_match_origin (void *rule, struct prefix *prefix,
974 route_map_object_t type, void *object)
977 struct bgp_info *bgp_info;
979 if (type == RMAP_BGP)
984 if (bgp_info->attr->origin == *origin)
992 route_match_origin_compile (const char *arg)
996 origin = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_char));
998 if (strcmp (arg, "igp") == 0)
1000 else if (strcmp (arg, "egp") == 0)
1008 /* Free route map's compiled `ip address' value. */
1010 route_match_origin_free (void *rule)
1012 XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
1015 /* Route map commands for origin matching. */
1016 struct route_map_rule_cmd route_match_origin_cmd =
1020 route_match_origin_compile,
1021 route_match_origin_free
1024 /* match probability { */
1026 static route_map_result_t
1027 route_match_probability (void *rule, struct prefix *prefix,
1028 route_map_object_t type, void *object)
1032 switch (*(long *) rule)
1035 case RAND_MAX: return RMAP_MATCH;
1037 if (r < *(long *) rule)
1043 return RMAP_NOMATCH;
1047 route_match_probability_compile (const char *arg)
1053 lobule = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (long));
1057 case 0: *lobule = 0; break;
1058 case 100: *lobule = RAND_MAX; break;
1059 default: *lobule = RAND_MAX / 100 * perc;
1066 route_match_probability_free (void *rule)
1068 XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
1071 struct route_map_rule_cmd route_match_probability_cmd =
1074 route_match_probability,
1075 route_match_probability_compile,
1076 route_match_probability_free
1081 /* `set ip next-hop IP_ADDRESS' */
1083 /* Match function return 1 if match is success else return zero. */
1084 static route_map_result_t
1085 route_match_tag (void *rule, struct prefix *prefix,
1086 route_map_object_t type, void *object)
1089 struct bgp_info *bgp_info;
1091 if (type == RMAP_BGP)
1096 if (!bgp_info->attr->extra)
1097 return RMAP_NOMATCH;
1099 return ((bgp_info->attr->extra->tag == *tag)? RMAP_MATCH : RMAP_NOMATCH);
1102 return RMAP_NOMATCH;
1105 /* Route map commands for tag matching. */
1106 static struct route_map_rule_cmd route_match_tag_cmd =
1110 route_map_rule_tag_compile,
1111 route_map_rule_tag_free,
1115 /* Set nexthop to object. ojbect must be pointer to struct attr. */
1116 struct rmap_ip_nexthop_set
1118 struct in_addr *address;
1122 static route_map_result_t
1123 route_set_ip_nexthop (void *rule, struct prefix *prefix,
1124 route_map_object_t type, void *object)
1126 struct rmap_ip_nexthop_set *rins = rule;
1127 struct bgp_info *bgp_info;
1130 if (type == RMAP_BGP)
1133 peer = bgp_info->peer;
1135 if (rins->peer_address)
1137 if ((CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN) ||
1138 CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT))
1140 && sockunion_family (peer->su_remote) == AF_INET)
1142 bgp_info->attr->nexthop.s_addr = sockunion2ip (peer->su_remote);
1143 bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP);
1145 else if (CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT)
1147 && sockunion_family (peer->su_local) == AF_INET)
1149 bgp_info->attr->nexthop.s_addr = sockunion2ip (peer->su_local);
1150 bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP);
1155 /* Set next hop value. */
1156 bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP);
1157 bgp_info->attr->nexthop = *rins->address;
1164 /* Route map `ip nexthop' compile function. Given string is converted
1165 to struct in_addr structure. */
1167 route_set_ip_nexthop_compile (const char *arg)
1169 struct rmap_ip_nexthop_set *rins;
1170 struct in_addr *address = NULL;
1171 int peer_address = 0;
1174 if (strcmp (arg, "peer-address") == 0)
1178 address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct in_addr));
1179 ret = inet_aton (arg, address);
1183 XFREE (MTYPE_ROUTE_MAP_COMPILED, address);
1188 rins = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct rmap_ip_nexthop_set));
1190 rins->address = address;
1191 rins->peer_address = peer_address;
1196 /* Free route map's compiled `ip nexthop' value. */
1198 route_set_ip_nexthop_free (void *rule)
1200 struct rmap_ip_nexthop_set *rins = rule;
1203 XFREE (MTYPE_ROUTE_MAP_COMPILED, rins->address);
1205 XFREE (MTYPE_ROUTE_MAP_COMPILED, rins);
1208 /* Route map commands for ip nexthop set. */
1209 struct route_map_rule_cmd route_set_ip_nexthop_cmd =
1212 route_set_ip_nexthop,
1213 route_set_ip_nexthop_compile,
1214 route_set_ip_nexthop_free
1217 /* `set local-preference LOCAL_PREF' */
1219 /* Set local preference. */
1220 static route_map_result_t
1221 route_set_local_pref (void *rule, struct prefix *prefix,
1222 route_map_object_t type, void *object)
1224 struct rmap_value *rv;
1225 struct bgp_info *bgp_info;
1226 u_int32_t locpref = 0;
1228 if (type == RMAP_BGP)
1230 /* Fetch routemap's rule information. */
1234 /* Set local preference value. */
1235 if (bgp_info->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
1236 locpref = bgp_info->attr->local_pref;
1238 bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF);
1239 bgp_info->attr->local_pref = route_value_adjust(rv, locpref, bgp_info->peer);
1245 /* Set local preference rule structure. */
1246 struct route_map_rule_cmd route_set_local_pref_cmd =
1249 route_set_local_pref,
1250 route_value_compile,
1254 /* `set weight WEIGHT' */
1257 static route_map_result_t
1258 route_set_weight (void *rule, struct prefix *prefix, route_map_object_t type,
1261 struct rmap_value *rv;
1262 struct bgp_info *bgp_info;
1265 if (type == RMAP_BGP)
1267 /* Fetch routemap's rule information. */
1271 /* Set weight value. */
1272 weight = route_value_adjust(rv, 0, bgp_info->peer);
1274 (bgp_attr_extra_get (bgp_info->attr))->weight = weight;
1275 else if (bgp_info->attr->extra)
1276 bgp_info->attr->extra->weight = 0;
1282 /* Set local preference rule structure. */
1283 struct route_map_rule_cmd route_set_weight_cmd =
1287 route_value_compile,
1291 /* `set metric METRIC' */
1293 /* Set metric to attribute. */
1294 static route_map_result_t
1295 route_set_metric (void *rule, struct prefix *prefix,
1296 route_map_object_t type, void *object)
1298 struct rmap_value *rv;
1299 struct bgp_info *bgp_info;
1302 if (type == RMAP_BGP)
1304 /* Fetch routemap's rule information. */
1308 if (bgp_info->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
1309 med = bgp_info->attr->med;
1311 bgp_info->attr->med = route_value_adjust(rv, med, bgp_info->peer);
1312 bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
1317 /* Set metric rule structure. */
1318 struct route_map_rule_cmd route_set_metric_cmd =
1322 route_value_compile,
1326 /* `set as-path prepend ASPATH' */
1328 /* For AS path prepend mechanism. */
1329 static route_map_result_t
1330 route_set_aspath_prepend (void *rule, struct prefix *prefix, route_map_object_t type, void *object)
1332 struct aspath *aspath;
1334 struct bgp_info *binfo;
1336 if (type == RMAP_BGP)
1340 if (binfo->attr->aspath->refcnt)
1341 new = aspath_dup (binfo->attr->aspath);
1343 new = binfo->attr->aspath;
1345 if ((uintptr_t)rule > 10)
1348 aspath_prepend (aspath, new);
1352 as_t as = aspath_leftmost(new);
1353 if (!as) as = binfo->peer->as;
1354 new = aspath_add_seq_n (new, as, (uintptr_t) rule);
1357 binfo->attr->aspath = new;
1364 route_set_aspath_prepend_compile (const char *arg)
1368 if (sscanf(arg, "last-as %u", &num) == 1 && num > 0 && num < 10)
1369 return (void*)(uintptr_t)num;
1371 return route_aspath_compile(arg);
1375 route_set_aspath_prepend_free (void *rule)
1377 if ((uintptr_t)rule > 10)
1378 route_aspath_free(rule);
1382 /* Set as-path prepend rule structure. */
1383 struct route_map_rule_cmd route_set_aspath_prepend_cmd =
1386 route_set_aspath_prepend,
1387 route_set_aspath_prepend_compile,
1388 route_set_aspath_prepend_free,
1391 /* `set as-path exclude ASn' */
1393 /* For ASN exclude mechanism.
1394 * Iterate over ASns requested and filter them from the given AS_PATH one by one.
1395 * Make a deep copy of existing AS_PATH, but for the first ASn only.
1397 static route_map_result_t
1398 route_set_aspath_exclude (void *rule, struct prefix *dummy, route_map_object_t type, void *object)
1400 struct aspath * new_path, * exclude_path;
1401 struct bgp_info *binfo;
1403 if (type == RMAP_BGP)
1405 exclude_path = rule;
1407 if (binfo->attr->aspath->refcnt)
1408 new_path = aspath_dup (binfo->attr->aspath);
1410 new_path = binfo->attr->aspath;
1411 binfo->attr->aspath = aspath_filter_exclude (new_path, exclude_path);
1416 /* Set ASn exlude rule structure. */
1417 struct route_map_rule_cmd route_set_aspath_exclude_cmd =
1420 route_set_aspath_exclude,
1421 route_aspath_compile,
1425 /* `set community COMMUNITY' */
1428 struct community *com;
1433 /* For community set mechanism. */
1434 static route_map_result_t
1435 route_set_community (void *rule, struct prefix *prefix,
1436 route_map_object_t type, void *object)
1438 struct rmap_com_set *rcs;
1439 struct bgp_info *binfo;
1441 struct community *new = NULL;
1442 struct community *old;
1443 struct community *merge;
1445 if (type == RMAP_BGP)
1450 old = attr->community;
1455 attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES));
1456 attr->community = NULL;
1457 /* See the longer comment down below. */
1458 if (old && old->refcnt == 0)
1459 community_free(old);
1463 /* "additive" case. */
1464 if (rcs->additive && old)
1466 merge = community_merge (community_dup (old), rcs->com);
1468 /* HACK: if the old community is not intern'd,
1469 * we should free it here, or all reference to it may be lost.
1470 * Really need to cleanup attribute caching sometime.
1472 if (old->refcnt == 0)
1473 community_free (old);
1474 new = community_uniq_sort (merge);
1475 community_free (merge);
1478 new = community_dup (rcs->com);
1480 /* will be interned by caller if required */
1481 attr->community = new;
1483 attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES);
1489 /* Compile function for set community. */
1491 route_set_community_compile (const char *arg)
1493 struct rmap_com_set *rcs;
1494 struct community *com = NULL;
1499 if (strcmp (arg, "none") == 0)
1503 sp = strstr (arg, "additive");
1507 /* "additive" keyworkd is included. */
1512 com = community_str2com (arg);
1521 rcs = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct rmap_com_set));
1523 rcs->additive = additive;
1529 /* Free function for set community. */
1531 route_set_community_free (void *rule)
1533 struct rmap_com_set *rcs = rule;
1536 community_free (rcs->com);
1537 XFREE (MTYPE_ROUTE_MAP_COMPILED, rcs);
1540 /* Set community rule structure. */
1541 struct route_map_rule_cmd route_set_community_cmd =
1544 route_set_community,
1545 route_set_community_compile,
1546 route_set_community_free,
1549 /* `set community COMMUNITY' */
1550 struct rmap_lcom_set
1552 struct lcommunity *lcom;
1558 /* For lcommunity set mechanism. */
1559 static route_map_result_t
1560 route_set_lcommunity (void *rule, struct prefix *prefix,
1561 route_map_object_t type, void *object)
1563 struct rmap_lcom_set *rcs;
1564 struct bgp_info *binfo;
1566 struct lcommunity *new = NULL;
1567 struct lcommunity *old;
1568 struct lcommunity *merge;
1570 if (type == RMAP_BGP)
1575 old = (attr->extra) ? attr->extra->lcommunity : NULL;
1580 attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES));
1582 attr->extra->lcommunity = NULL;
1584 /* See the longer comment down below. */
1585 if (old && old->refcnt == 0)
1586 lcommunity_free(&old);
1590 if (rcs->additive && old)
1592 merge = lcommunity_merge (lcommunity_dup (old), rcs->lcom);
1594 /* HACK: if the old large-community is not intern'd,
1595 * we should free it here, or all reference to it may be lost.
1596 * Really need to cleanup attribute caching sometime.
1598 if (old->refcnt == 0)
1599 lcommunity_free (&old);
1600 new = lcommunity_uniq_sort (merge);
1601 lcommunity_free (&merge);
1605 new = lcommunity_dup (rcs->lcom);
1608 /* will be interned by caller if required */
1609 bgp_attr_extra_get (attr)->lcommunity = new;
1610 attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES);
1616 /* Compile function for set community. */
1618 route_set_lcommunity_compile (const char *arg)
1620 struct rmap_lcom_set *rcs;
1621 struct lcommunity *lcom = NULL;
1626 if (strcmp (arg, "none") == 0)
1630 sp = strstr (arg, "additive");
1634 /* "additive" keyworkd is included. */
1639 lcom = lcommunity_str2com (arg);
1648 rcs = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct rmap_com_set));
1650 rcs->additive = additive;
1656 /* Free function for set lcommunity. */
1658 route_set_lcommunity_free (void *rule)
1660 struct rmap_lcom_set *rcs = rule;
1663 lcommunity_free (&rcs->lcom);
1665 XFREE (MTYPE_ROUTE_MAP_COMPILED, rcs);
1668 /* Set community rule structure. */
1669 struct route_map_rule_cmd route_set_lcommunity_cmd =
1672 route_set_lcommunity,
1673 route_set_lcommunity_compile,
1674 route_set_lcommunity_free,
1677 /* `set large-comm-list (<1-99>|<100-500>|WORD) delete' */
1679 /* For large community set mechanism. */
1680 static route_map_result_t
1681 route_set_lcommunity_delete (void *rule, struct prefix *prefix,
1682 route_map_object_t type, void *object)
1684 struct community_list *list;
1685 struct lcommunity *merge;
1686 struct lcommunity *new;
1687 struct lcommunity *old;
1688 struct bgp_info *binfo;
1690 if (type == RMAP_BGP)
1696 list = community_list_lookup (bgp_clist, rule,
1697 LARGE_COMMUNITY_LIST_MASTER);
1698 old = ((binfo->attr->extra) ? binfo->attr->extra->lcommunity : NULL);
1702 merge = lcommunity_list_match_delete (lcommunity_dup (old), list);
1703 new = lcommunity_uniq_sort (merge);
1704 lcommunity_free (&merge);
1706 /* HACK: if the old community is not intern'd,
1707 * we should free it here, or all reference to it may be lost.
1708 * Really need to cleanup attribute caching sometime.
1710 if (old->refcnt == 0)
1711 lcommunity_free (&old);
1715 binfo->attr->extra->lcommunity = NULL;
1716 binfo->attr->flag &= ~ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES);
1717 lcommunity_free (&new);
1721 binfo->attr->extra->lcommunity = new;
1722 binfo->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES);
1730 /* Compile function for set lcommunity. */
1732 route_set_lcommunity_delete_compile (const char *arg)
1738 p = strchr (arg, ' ');
1742 str = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, len + 1);
1743 memcpy (str, arg, len);
1751 /* Free function for set lcommunity. */
1753 route_set_lcommunity_delete_free (void *rule)
1755 XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
1758 /* Set lcommunity rule structure. */
1759 struct route_map_rule_cmd route_set_lcommunity_delete_cmd =
1762 route_set_lcommunity_delete,
1763 route_set_lcommunity_delete_compile,
1764 route_set_lcommunity_delete_free,
1768 /* `set comm-list (<1-99>|<100-500>|WORD) delete' */
1770 /* For community set mechanism. */
1771 static route_map_result_t
1772 route_set_community_delete (void *rule, struct prefix *prefix,
1773 route_map_object_t type, void *object)
1775 struct community_list *list;
1776 struct community *merge;
1777 struct community *new;
1778 struct community *old;
1779 struct bgp_info *binfo;
1781 if (type == RMAP_BGP)
1787 list = community_list_lookup (bgp_clist, rule, COMMUNITY_LIST_MASTER);
1788 old = binfo->attr->community;
1792 merge = community_list_match_delete (community_dup (old), list);
1793 new = community_uniq_sort (merge);
1794 community_free (merge);
1796 /* HACK: if the old community is not intern'd,
1797 * we should free it here, or all reference to it may be lost.
1798 * Really need to cleanup attribute caching sometime.
1800 if (old->refcnt == 0)
1801 community_free (old);
1805 binfo->attr->community = NULL;
1806 binfo->attr->flag &= ~ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES);
1807 community_free (new);
1811 binfo->attr->community = new;
1812 binfo->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES);
1820 /* Compile function for set community. */
1822 route_set_community_delete_compile (const char *arg)
1828 p = strchr (arg, ' ');
1832 str = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, len + 1);
1833 memcpy (str, arg, len);
1841 /* Free function for set community. */
1843 route_set_community_delete_free (void *rule)
1845 XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
1848 /* Set community rule structure. */
1849 struct route_map_rule_cmd route_set_community_delete_cmd =
1852 route_set_community_delete,
1853 route_set_community_delete_compile,
1854 route_set_community_delete_free,
1857 /* `set extcommunity rt COMMUNITY' */
1859 /* For community set mechanism. Used by _rt and _soo. */
1860 static route_map_result_t
1861 route_set_ecommunity (void *rule, struct prefix *prefix,
1862 route_map_object_t type, void *object)
1864 struct ecommunity *ecom;
1865 struct ecommunity *new_ecom;
1866 struct ecommunity *old_ecom;
1867 struct bgp_info *bgp_info;
1869 if (type == RMAP_BGP)
1877 /* We assume additive for Extended Community. */
1878 old_ecom = (bgp_attr_extra_get (bgp_info->attr))->ecommunity;
1882 new_ecom = ecommunity_merge (ecommunity_dup (old_ecom), ecom);
1884 /* old_ecom->refcnt = 1 => owned elsewhere, e.g. bgp_update_receive()
1885 * ->refcnt = 0 => set by a previous route-map statement */
1886 if (!old_ecom->refcnt)
1887 ecommunity_free (&old_ecom);
1890 new_ecom = ecommunity_dup (ecom);
1892 /* will be intern()'d or attr_flush()'d by bgp_update_main() */
1893 bgp_info->attr->extra->ecommunity = new_ecom;
1895 bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES);
1900 /* Compile function for set community. */
1902 route_set_ecommunity_rt_compile (const char *arg)
1904 struct ecommunity *ecom;
1906 ecom = ecommunity_str2com (arg, ECOMMUNITY_ROUTE_TARGET, 0);
1909 return ecommunity_intern (ecom);
1912 /* Free function for set community. Used by _rt and _soo */
1914 route_set_ecommunity_free (void *rule)
1916 struct ecommunity *ecom = rule;
1917 ecommunity_unintern (&ecom);
1920 /* Set community rule structure. */
1921 struct route_map_rule_cmd route_set_ecommunity_rt_cmd =
1924 route_set_ecommunity,
1925 route_set_ecommunity_rt_compile,
1926 route_set_ecommunity_free,
1929 /* `set extcommunity soo COMMUNITY' */
1931 /* Compile function for set community. */
1933 route_set_ecommunity_soo_compile (const char *arg)
1935 struct ecommunity *ecom;
1937 ecom = ecommunity_str2com (arg, ECOMMUNITY_SITE_ORIGIN, 0);
1941 return ecommunity_intern (ecom);
1944 /* Set community rule structure. */
1945 struct route_map_rule_cmd route_set_ecommunity_soo_cmd =
1948 route_set_ecommunity,
1949 route_set_ecommunity_soo_compile,
1950 route_set_ecommunity_free,
1953 /* `set origin ORIGIN' */
1955 /* For origin set. */
1956 static route_map_result_t
1957 route_set_origin (void *rule, struct prefix *prefix, route_map_object_t type, void *object)
1960 struct bgp_info *bgp_info;
1962 if (type == RMAP_BGP)
1967 bgp_info->attr->origin = *origin;
1973 /* Compile function for origin set. */
1975 route_set_origin_compile (const char *arg)
1979 origin = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_char));
1981 if (strcmp (arg, "igp") == 0)
1983 else if (strcmp (arg, "egp") == 0)
1991 /* Compile function for origin set. */
1993 route_set_origin_free (void *rule)
1995 XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
1998 /* Set origin rule structure. */
1999 struct route_map_rule_cmd route_set_origin_cmd =
2003 route_set_origin_compile,
2004 route_set_origin_free,
2007 /* `set atomic-aggregate' */
2009 /* For atomic aggregate set. */
2010 static route_map_result_t
2011 route_set_atomic_aggregate (void *rule, struct prefix *prefix,
2012 route_map_object_t type, void *object)
2014 struct bgp_info *bgp_info;
2016 if (type == RMAP_BGP)
2019 bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE);
2025 /* Compile function for atomic aggregate. */
2027 route_set_atomic_aggregate_compile (const char *arg)
2032 /* Compile function for atomic aggregate. */
2034 route_set_atomic_aggregate_free (void *rule)
2039 /* Set atomic aggregate rule structure. */
2040 struct route_map_rule_cmd route_set_atomic_aggregate_cmd =
2043 route_set_atomic_aggregate,
2044 route_set_atomic_aggregate_compile,
2045 route_set_atomic_aggregate_free,
2048 /* `set aggregator as AS A.B.C.D' */
2052 struct in_addr address;
2055 static route_map_result_t
2056 route_set_aggregator_as (void *rule, struct prefix *prefix,
2057 route_map_object_t type, void *object)
2059 struct bgp_info *bgp_info;
2060 struct aggregator *aggregator;
2061 struct attr_extra *ae;
2063 if (type == RMAP_BGP)
2067 ae = bgp_attr_extra_get (bgp_info->attr);
2069 ae->aggregator_as = aggregator->as;
2070 ae->aggregator_addr = aggregator->address;
2071 bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR);
2078 route_set_aggregator_as_compile (const char *arg)
2080 struct aggregator *aggregator;
2084 aggregator = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct aggregator));
2085 sscanf (arg, "%s %s", as, address);
2087 aggregator->as = strtoul (as, NULL, 10);
2088 inet_aton (address, &aggregator->address);
2094 route_set_aggregator_as_free (void *rule)
2096 XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
2099 struct route_map_rule_cmd route_set_aggregator_as_cmd =
2102 route_set_aggregator_as,
2103 route_set_aggregator_as_compile,
2104 route_set_aggregator_as_free,
2107 /* Set tag to object. object must be pointer to struct bgp_info */
2108 static route_map_result_t
2109 route_set_tag (void *rule, struct prefix *prefix,
2110 route_map_object_t type, void *object)
2113 struct bgp_info *bgp_info;
2114 struct attr_extra *ae;
2116 if (type == RMAP_BGP)
2120 ae = bgp_attr_extra_get (bgp_info->attr);
2130 /* Route map commands for tag set. */
2131 static struct route_map_rule_cmd route_set_tag_cmd =
2135 route_map_rule_tag_compile,
2136 route_map_rule_tag_free,
2140 /* `match ipv6 address IP_ACCESS_LIST' */
2142 static route_map_result_t
2143 route_match_ipv6_address (void *rule, struct prefix *prefix,
2144 route_map_object_t type, void *object)
2146 struct access_list *alist;
2148 if (type == RMAP_BGP)
2150 alist = access_list_lookup (AFI_IP6, (char *) rule);
2152 return RMAP_NOMATCH;
2154 return (access_list_apply (alist, prefix) == FILTER_DENY ?
2155 RMAP_NOMATCH : RMAP_MATCH);
2157 return RMAP_NOMATCH;
2161 route_match_ipv6_address_compile (const char *arg)
2163 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
2167 route_match_ipv6_address_free (void *rule)
2169 XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
2172 /* Route map commands for ip address matching. */
2173 struct route_map_rule_cmd route_match_ipv6_address_cmd =
2176 route_match_ipv6_address,
2177 route_match_ipv6_address_compile,
2178 route_match_ipv6_address_free
2181 /* `match ipv6 next-hop IP_ADDRESS' */
2183 static route_map_result_t
2184 route_match_ipv6_next_hop (void *rule, struct prefix *prefix,
2185 route_map_object_t type, void *object)
2187 struct in6_addr *addr = rule;
2188 struct bgp_info *bgp_info;
2190 if (type == RMAP_BGP)
2194 if (!bgp_info->attr->extra)
2195 return RMAP_NOMATCH;
2197 if (IPV6_ADDR_SAME (&bgp_info->attr->extra->mp_nexthop_global, addr))
2200 if (bgp_info->attr->extra->mp_nexthop_len == 32 &&
2201 IPV6_ADDR_SAME (&bgp_info->attr->extra->mp_nexthop_local, addr))
2204 return RMAP_NOMATCH;
2207 return RMAP_NOMATCH;
2211 route_match_ipv6_next_hop_compile (const char *arg)
2213 struct in6_addr *address;
2216 address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct in6_addr));
2218 ret = inet_pton (AF_INET6, arg, address);
2221 XFREE (MTYPE_ROUTE_MAP_COMPILED, address);
2229 route_match_ipv6_next_hop_free (void *rule)
2231 XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
2234 struct route_map_rule_cmd route_match_ipv6_next_hop_cmd =
2237 route_match_ipv6_next_hop,
2238 route_match_ipv6_next_hop_compile,
2239 route_match_ipv6_next_hop_free
2242 /* `match ipv6 address prefix-list PREFIX_LIST' */
2244 static route_map_result_t
2245 route_match_ipv6_address_prefix_list (void *rule, struct prefix *prefix,
2246 route_map_object_t type, void *object)
2248 struct prefix_list *plist;
2250 if (type == RMAP_BGP)
2252 plist = prefix_list_lookup (AFI_IP6, (char *) rule);
2254 return RMAP_NOMATCH;
2256 return (prefix_list_apply (plist, prefix) == PREFIX_DENY ?
2257 RMAP_NOMATCH : RMAP_MATCH);
2259 return RMAP_NOMATCH;
2263 route_match_ipv6_address_prefix_list_compile (const char *arg)
2265 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
2269 route_match_ipv6_address_prefix_list_free (void *rule)
2271 XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
2274 struct route_map_rule_cmd route_match_ipv6_address_prefix_list_cmd =
2276 "ipv6 address prefix-list",
2277 route_match_ipv6_address_prefix_list,
2278 route_match_ipv6_address_prefix_list_compile,
2279 route_match_ipv6_address_prefix_list_free
2282 /* `set ipv6 nexthop global IP_ADDRESS' */
2284 /* Set nexthop to object. ojbect must be pointer to struct attr. */
2285 static route_map_result_t
2286 route_set_ipv6_nexthop_global (void *rule, struct prefix *prefix,
2287 route_map_object_t type, void *object)
2289 struct in6_addr *address;
2290 struct bgp_info *bgp_info;
2292 if (type == RMAP_BGP)
2294 /* Fetch routemap's rule information. */
2298 /* Set next hop value. */
2299 (bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_global = *address;
2301 /* Set nexthop length. */
2302 if (bgp_info->attr->extra->mp_nexthop_len == 0)
2303 bgp_info->attr->extra->mp_nexthop_len = 16;
2309 /* Route map `ip next-hop' compile function. Given string is converted
2310 to struct in_addr structure. */
2312 route_set_ipv6_nexthop_global_compile (const char *arg)
2315 struct in6_addr *address;
2317 address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct in6_addr));
2319 ret = inet_pton (AF_INET6, arg, address);
2323 XFREE (MTYPE_ROUTE_MAP_COMPILED, address);
2330 /* Free route map's compiled `ip next-hop' value. */
2332 route_set_ipv6_nexthop_global_free (void *rule)
2334 XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
2337 /* Route map commands for ip nexthop set. */
2338 struct route_map_rule_cmd route_set_ipv6_nexthop_global_cmd =
2340 "ipv6 next-hop global",
2341 route_set_ipv6_nexthop_global,
2342 route_set_ipv6_nexthop_global_compile,
2343 route_set_ipv6_nexthop_global_free
2346 /* `set ipv6 nexthop local IP_ADDRESS' */
2348 /* Set nexthop to object. ojbect must be pointer to struct attr. */
2349 static route_map_result_t
2350 route_set_ipv6_nexthop_local (void *rule, struct prefix *prefix,
2351 route_map_object_t type, void *object)
2353 struct in6_addr *address;
2354 struct bgp_info *bgp_info;
2356 if (type == RMAP_BGP)
2358 /* Fetch routemap's rule information. */
2362 /* Set next hop value. */
2363 (bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_local = *address;
2365 /* Set nexthop length. */
2366 if (bgp_info->attr->extra->mp_nexthop_len != 32)
2367 bgp_info->attr->extra->mp_nexthop_len = 32;
2373 /* Route map `ip nexthop' compile function. Given string is converted
2374 to struct in_addr structure. */
2376 route_set_ipv6_nexthop_local_compile (const char *arg)
2379 struct in6_addr *address;
2381 address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct in6_addr));
2383 ret = inet_pton (AF_INET6, arg, address);
2387 XFREE (MTYPE_ROUTE_MAP_COMPILED, address);
2394 /* Free route map's compiled `ip nexthop' value. */
2396 route_set_ipv6_nexthop_local_free (void *rule)
2398 XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
2401 /* Route map commands for ip nexthop set. */
2402 struct route_map_rule_cmd route_set_ipv6_nexthop_local_cmd =
2404 "ipv6 next-hop local",
2405 route_set_ipv6_nexthop_local,
2406 route_set_ipv6_nexthop_local_compile,
2407 route_set_ipv6_nexthop_local_free
2410 /* `set ipv6 nexthop peer-address' */
2412 /* Set nexthop to object. ojbect must be pointer to struct attr. */
2413 static route_map_result_t
2414 route_set_ipv6_nexthop_peer (void *rule, struct prefix *prefix,
2415 route_map_object_t type, void *object)
2417 struct in6_addr peer_address;
2418 struct bgp_info *bgp_info;
2421 if (type == RMAP_BGP)
2423 /* Fetch routemap's rule information. */
2425 peer = bgp_info->peer;
2427 if ((CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN) ||
2428 CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT))
2430 && sockunion_family (peer->su_remote) == AF_INET6)
2432 peer_address = peer->su_remote->sin6.sin6_addr;
2434 else if (CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT)
2436 && sockunion_family (peer->su_local) == AF_INET6)
2438 peer_address = peer->su_local->sin6.sin6_addr;
2441 if (IN6_IS_ADDR_LINKLOCAL(&peer_address))
2443 /* Set next hop value. */
2444 (bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_local = peer_address;
2446 /* Set nexthop length. */
2447 if (bgp_info->attr->extra->mp_nexthop_len != 32)
2448 bgp_info->attr->extra->mp_nexthop_len = 32;
2452 /* Set next hop value. */
2453 (bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_global = peer_address;
2455 /* Set nexthop length. */
2456 if (bgp_info->attr->extra->mp_nexthop_len == 0)
2457 bgp_info->attr->extra->mp_nexthop_len = 16;
2464 /* Route map `ip next-hop' compile function. Given string is converted
2465 to struct in_addr structure. */
2467 route_set_ipv6_nexthop_peer_compile (const char *arg)
2471 rins = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (int));
2477 /* Free route map's compiled `ip next-hop' value. */
2479 route_set_ipv6_nexthop_peer_free (void *rule)
2481 XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
2484 /* Route map commands for ip nexthop set. */
2485 struct route_map_rule_cmd route_set_ipv6_nexthop_peer_cmd =
2487 "ipv6 next-hop peer-address",
2488 route_set_ipv6_nexthop_peer,
2489 route_set_ipv6_nexthop_peer_compile,
2490 route_set_ipv6_nexthop_peer_free
2493 /* `set vpnv4 nexthop A.B.C.D' */
2495 static route_map_result_t
2496 route_set_vpnv4_nexthop (void *rule, struct prefix *prefix,
2497 route_map_object_t type, void *object)
2499 struct in_addr *address;
2500 struct bgp_info *bgp_info;
2502 if (type == RMAP_BGP)
2504 /* Fetch routemap's rule information. */
2508 /* Set next hop value. */
2509 (bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_global_in = *address;
2510 (bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_len = 4;
2517 route_set_vpnv4_nexthop_compile (const char *arg)
2520 struct in_addr *address;
2522 address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct in_addr));
2524 ret = inet_aton (arg, address);
2528 XFREE (MTYPE_ROUTE_MAP_COMPILED, address);
2536 route_set_vpnv4_nexthop_free (void *rule)
2538 XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
2541 /* Route map commands for ip nexthop set. */
2542 struct route_map_rule_cmd route_set_vpnv4_nexthop_cmd =
2545 route_set_vpnv4_nexthop,
2546 route_set_vpnv4_nexthop_compile,
2547 route_set_vpnv4_nexthop_free
2550 /* `set originator-id' */
2552 /* For origin set. */
2553 static route_map_result_t
2554 route_set_originator_id (void *rule, struct prefix *prefix, route_map_object_t type, void *object)
2556 struct in_addr *address;
2557 struct bgp_info *bgp_info;
2559 if (type == RMAP_BGP)
2564 bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID);
2565 (bgp_attr_extra_get (bgp_info->attr))->originator_id = *address;
2571 /* Compile function for originator-id set. */
2573 route_set_originator_id_compile (const char *arg)
2576 struct in_addr *address;
2578 address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct in_addr));
2580 ret = inet_aton (arg, address);
2584 XFREE (MTYPE_ROUTE_MAP_COMPILED, address);
2591 /* Compile function for originator_id set. */
2593 route_set_originator_id_free (void *rule)
2595 XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
2598 /* Set originator-id rule structure. */
2599 struct route_map_rule_cmd route_set_originator_id_cmd =
2602 route_set_originator_id,
2603 route_set_originator_id_compile,
2604 route_set_originator_id_free,
2607 /* Add bgp route map rule. */
2609 bgp_route_match_add (struct vty *vty, struct route_map_index *index,
2610 const char *command, const char *arg)
2614 ret = route_map_add_match (index, command, arg);
2619 case RMAP_RULE_MISSING:
2620 vty_out (vty, "%% BGP Can't find rule.%s", VTY_NEWLINE);
2622 case RMAP_COMPILE_ERROR:
2623 vty_out (vty, "%% BGP Argument is malformed.%s", VTY_NEWLINE);
2630 /* Delete bgp route map rule. */
2632 bgp_route_match_delete (struct vty *vty, struct route_map_index *index,
2633 const char *command, const char *arg)
2637 ret = route_map_delete_match (index, command, arg);
2642 case RMAP_RULE_MISSING:
2643 vty_out (vty, "%% BGP Can't find rule.%s", VTY_NEWLINE);
2645 case RMAP_COMPILE_ERROR:
2646 vty_out (vty, "%% BGP Argument is malformed.%s", VTY_NEWLINE);
2653 /* Add bgp route map rule. */
2655 bgp_route_set_add (struct vty *vty, struct route_map_index *index,
2656 const char *command, const char *arg)
2660 ret = route_map_add_set (index, command, arg);
2665 case RMAP_RULE_MISSING:
2666 vty_out (vty, "%% BGP Can't find rule.%s", VTY_NEWLINE);
2668 case RMAP_COMPILE_ERROR:
2669 vty_out (vty, "%% BGP Argument is malformed.%s", VTY_NEWLINE);
2676 /* Delete bgp route map rule. */
2678 bgp_route_set_delete (struct vty *vty, struct route_map_index *index,
2679 const char *command, const char *arg)
2683 ret = route_map_delete_set (index, command, arg);
2688 case RMAP_RULE_MISSING:
2689 vty_out (vty, "%% BGP Can't find rule.%s", VTY_NEWLINE);
2691 case RMAP_COMPILE_ERROR:
2692 vty_out (vty, "%% BGP Argument is malformed.%s", VTY_NEWLINE);
2699 /* Hook function for updating route_map assignment. */
2701 bgp_route_map_update (const char *unused)
2707 struct listnode *node, *nnode;
2708 struct listnode *mnode, *mnnode;
2711 struct peer_group *group;
2712 struct bgp_filter *filter;
2713 struct bgp_node *bn;
2714 struct bgp_static *bgp_static;
2716 if (bm->bgp == NULL) /* may be called during cleanup */
2719 /* For neighbor route-map updates. */
2720 for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
2722 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
2724 for (afi = AFI_IP; afi < AFI_MAX; afi++)
2725 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
2727 filter = &peer->filter[afi][safi];
2729 for (direct = RMAP_IN; direct < RMAP_MAX; direct++)
2731 if (filter->map[direct].name)
2732 filter->map[direct].map =
2733 route_map_lookup_by_name (filter->map[direct].name);
2735 filter->map[direct].map = NULL;
2738 if (filter->usmap.name)
2739 filter->usmap.map = route_map_lookup_by_name (filter->usmap.name);
2741 filter->usmap.map = NULL;
2744 for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
2746 for (afi = AFI_IP; afi < AFI_MAX; afi++)
2747 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
2749 filter = &group->conf->filter[afi][safi];
2751 for (direct = RMAP_IN; direct < RMAP_MAX; direct++)
2753 if (filter->map[direct].name)
2754 filter->map[direct].map =
2755 route_map_lookup_by_name (filter->map[direct].name);
2757 filter->map[direct].map = NULL;
2760 if (filter->usmap.name)
2761 filter->usmap.map = route_map_lookup_by_name (filter->usmap.name);
2763 filter->usmap.map = NULL;
2768 /* For default-originate route-map updates. */
2769 for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
2771 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
2773 for (afi = AFI_IP; afi < AFI_MAX; afi++)
2774 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
2776 if (peer->default_rmap[afi][safi].name)
2777 peer->default_rmap[afi][safi].map =
2778 route_map_lookup_by_name (peer->default_rmap[afi][safi].name);
2780 peer->default_rmap[afi][safi].map = NULL;
2785 /* For network route-map updates. */
2786 for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
2788 for (afi = AFI_IP; afi < AFI_MAX; afi++)
2789 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
2790 for (bn = bgp_table_top (bgp->route[afi][safi]); bn;
2791 bn = bgp_route_next (bn))
2792 if ((bgp_static = bn->info) != NULL)
2794 if (bgp_static->rmap.name)
2795 bgp_static->rmap.map =
2796 route_map_lookup_by_name (bgp_static->rmap.name);
2798 bgp_static->rmap.map = NULL;
2802 /* For redistribute route-map updates. */
2803 for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
2805 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
2807 if (bgp->rmap[AFI_IP][i].name)
2808 bgp->rmap[AFI_IP][i].map =
2809 route_map_lookup_by_name (bgp->rmap[AFI_IP][i].name);
2810 if (bgp->rmap[AFI_IP6][i].name)
2811 bgp->rmap[AFI_IP6][i].map =
2812 route_map_lookup_by_name (bgp->rmap[AFI_IP6][i].name);
2819 "match peer (A.B.C.D|X:X::X:X)",
2821 "Match peer address\n"
2822 "IP address of peer\n"
2823 "IPv6 address of peer\n")
2825 return bgp_route_match_add (vty, vty->index, "peer", argv[0]);
2828 DEFUN (match_peer_local,
2829 match_peer_local_cmd,
2832 "Match peer address\n"
2833 "Static or Redistributed routes\n")
2835 return bgp_route_match_add (vty, vty->index, "peer", "local");
2838 DEFUN (no_match_peer,
2843 "Match peer address\n")
2846 return bgp_route_match_delete (vty, vty->index, "peer", NULL);
2848 return bgp_route_match_delete (vty, vty->index, "peer", argv[0]);
2851 ALIAS (no_match_peer,
2852 no_match_peer_val_cmd,
2853 "no match peer (A.B.C.D|X:X::X:X)",
2856 "Match peer address\n"
2857 "IP address of peer\n"
2858 "IPv6 address of peer\n")
2860 ALIAS (no_match_peer,
2861 no_match_peer_local_cmd,
2862 "no match peer local",
2865 "Match peer address\n"
2866 "Static or Redistributed routes\n")
2868 DEFUN (match_ip_address,
2869 match_ip_address_cmd,
2870 "match ip address (<1-199>|<1300-2699>|WORD)",
2873 "Match address of route\n"
2874 "IP access-list number\n"
2875 "IP access-list number (expanded range)\n"
2876 "IP Access-list name\n")
2878 return bgp_route_match_add (vty, vty->index, "ip address", argv[0]);
2881 DEFUN (no_match_ip_address,
2882 no_match_ip_address_cmd,
2883 "no match ip address",
2887 "Match address of route\n")
2890 return bgp_route_match_delete (vty, vty->index, "ip address", NULL);
2892 return bgp_route_match_delete (vty, vty->index, "ip address", argv[0]);
2895 ALIAS (no_match_ip_address,
2896 no_match_ip_address_val_cmd,
2897 "no match ip address (<1-199>|<1300-2699>|WORD)",
2901 "Match address of route\n"
2902 "IP access-list number\n"
2903 "IP access-list number (expanded range)\n"
2904 "IP Access-list name\n")
2906 DEFUN (match_ip_next_hop,
2907 match_ip_next_hop_cmd,
2908 "match ip next-hop (<1-199>|<1300-2699>|WORD)",
2911 "Match next-hop address of route\n"
2912 "IP access-list number\n"
2913 "IP access-list number (expanded range)\n"
2914 "IP Access-list name\n")
2916 return bgp_route_match_add (vty, vty->index, "ip next-hop", argv[0]);
2919 DEFUN (no_match_ip_next_hop,
2920 no_match_ip_next_hop_cmd,
2921 "no match ip next-hop",
2925 "Match next-hop address of route\n")
2928 return bgp_route_match_delete (vty, vty->index, "ip next-hop", NULL);
2930 return bgp_route_match_delete (vty, vty->index, "ip next-hop", argv[0]);
2933 ALIAS (no_match_ip_next_hop,
2934 no_match_ip_next_hop_val_cmd,
2935 "no match ip next-hop (<1-199>|<1300-2699>|WORD)",
2939 "Match next-hop address of route\n"
2940 "IP access-list number\n"
2941 "IP access-list number (expanded range)\n"
2942 "IP Access-list name\n")
2944 /* match probability { */
2946 DEFUN (match_probability,
2947 match_probability_cmd,
2948 "match probability <0-100>",
2950 "Match portion of routes defined by percentage value\n"
2951 "Percentage of routes\n")
2953 return bgp_route_match_add (vty, vty->index, "probability", argv[0]);
2956 DEFUN (no_match_probability,
2957 no_match_probability_cmd,
2958 "no match probability",
2961 "Match portion of routes defined by percentage value\n")
2963 return bgp_route_match_delete (vty, vty->index, "probability", argc ? argv[0] : NULL);
2966 ALIAS (no_match_probability,
2967 no_match_probability_val_cmd,
2968 "no match probability <1-99>",
2971 "Match portion of routes defined by percentage value\n"
2972 "Percentage of routes\n")
2976 DEFUN (match_ip_route_source,
2977 match_ip_route_source_cmd,
2978 "match ip route-source (<1-199>|<1300-2699>|WORD)",
2981 "Match advertising source address of route\n"
2982 "IP access-list number\n"
2983 "IP access-list number (expanded range)\n"
2984 "IP standard access-list name\n")
2986 return bgp_route_match_add (vty, vty->index, "ip route-source", argv[0]);
2989 DEFUN (no_match_ip_route_source,
2990 no_match_ip_route_source_cmd,
2991 "no match ip route-source",
2995 "Match advertising source address of route\n")
2998 return bgp_route_match_delete (vty, vty->index, "ip route-source", NULL);
3000 return bgp_route_match_delete (vty, vty->index, "ip route-source", argv[0]);
3003 ALIAS (no_match_ip_route_source,
3004 no_match_ip_route_source_val_cmd,
3005 "no match ip route-source (<1-199>|<1300-2699>|WORD)",
3009 "Match advertising source address of route\n"
3010 "IP access-list number\n"
3011 "IP access-list number (expanded range)\n"
3012 "IP standard access-list name\n")
3014 DEFUN (match_ip_address_prefix_list,
3015 match_ip_address_prefix_list_cmd,
3016 "match ip address prefix-list WORD",
3019 "Match address of route\n"
3020 "Match entries of prefix-lists\n"
3021 "IP prefix-list name\n")
3023 return bgp_route_match_add (vty, vty->index, "ip address prefix-list", argv[0]);
3026 DEFUN (no_match_ip_address_prefix_list,
3027 no_match_ip_address_prefix_list_cmd,
3028 "no match ip address prefix-list",
3032 "Match address of route\n"
3033 "Match entries of prefix-lists\n")
3036 return bgp_route_match_delete (vty, vty->index, "ip address prefix-list", NULL);
3038 return bgp_route_match_delete (vty, vty->index, "ip address prefix-list", argv[0]);
3041 ALIAS (no_match_ip_address_prefix_list,
3042 no_match_ip_address_prefix_list_val_cmd,
3043 "no match ip address prefix-list WORD",
3047 "Match address of route\n"
3048 "Match entries of prefix-lists\n"
3049 "IP prefix-list name\n")
3051 DEFUN (match_ip_next_hop_prefix_list,
3052 match_ip_next_hop_prefix_list_cmd,
3053 "match ip next-hop prefix-list WORD",
3056 "Match next-hop address of route\n"
3057 "Match entries of prefix-lists\n"
3058 "IP prefix-list name\n")
3060 return bgp_route_match_add (vty, vty->index, "ip next-hop prefix-list", argv[0]);
3063 DEFUN (no_match_ip_next_hop_prefix_list,
3064 no_match_ip_next_hop_prefix_list_cmd,
3065 "no match ip next-hop prefix-list",
3069 "Match next-hop address of route\n"
3070 "Match entries of prefix-lists\n")
3073 return bgp_route_match_delete (vty, vty->index, "ip next-hop prefix-list", NULL);
3075 return bgp_route_match_delete (vty, vty->index, "ip next-hop prefix-list", argv[0]);
3078 ALIAS (no_match_ip_next_hop_prefix_list,
3079 no_match_ip_next_hop_prefix_list_val_cmd,
3080 "no match ip next-hop prefix-list WORD",
3084 "Match next-hop address of route\n"
3085 "Match entries of prefix-lists\n"
3086 "IP prefix-list name\n")
3088 DEFUN (match_ip_route_source_prefix_list,
3089 match_ip_route_source_prefix_list_cmd,
3090 "match ip route-source prefix-list WORD",
3093 "Match advertising source address of route\n"
3094 "Match entries of prefix-lists\n"
3095 "IP prefix-list name\n")
3097 return bgp_route_match_add (vty, vty->index, "ip route-source prefix-list", argv[0]);
3100 DEFUN (no_match_ip_route_source_prefix_list,
3101 no_match_ip_route_source_prefix_list_cmd,
3102 "no match ip route-source prefix-list",
3106 "Match advertising source address of route\n"
3107 "Match entries of prefix-lists\n")
3110 return bgp_route_match_delete (vty, vty->index, "ip route-source prefix-list", NULL);
3112 return bgp_route_match_delete (vty, vty->index, "ip route-source prefix-list", argv[0]);
3115 ALIAS (no_match_ip_route_source_prefix_list,
3116 no_match_ip_route_source_prefix_list_val_cmd,
3117 "no match ip route-source prefix-list WORD",
3121 "Match advertising source address of route\n"
3122 "Match entries of prefix-lists\n"
3123 "IP prefix-list name\n")
3125 DEFUN (match_metric,
3127 "match metric <0-4294967295>",
3129 "Match metric of route\n"
3132 return bgp_route_match_add (vty, vty->index, "metric", argv[0]);
3135 DEFUN (no_match_metric,
3136 no_match_metric_cmd,
3140 "Match metric of route\n")
3143 return bgp_route_match_delete (vty, vty->index, "metric", NULL);
3145 return bgp_route_match_delete (vty, vty->index, "metric", argv[0]);
3148 ALIAS (no_match_metric,
3149 no_match_metric_val_cmd,
3150 "no match metric <0-4294967295>",
3153 "Match metric of route\n"
3156 DEFUN (match_local_pref,
3157 match_local_pref_cmd,
3158 "match local-preference <0-4294967295>",
3160 "Match local-preference of route\n"
3163 return bgp_route_match_add (vty, vty->index, "local-preference", argv[0]);
3166 DEFUN (no_match_local_pref,
3167 no_match_local_pref_cmd,
3168 "no match local-preference",
3171 "Match local preference of route\n")
3174 return bgp_route_match_delete (vty, vty->index, "local-preference", NULL);
3176 return bgp_route_match_delete (vty, vty->index, "local-preference", argv[0]);
3179 ALIAS (no_match_local_pref,
3180 no_match_local_pref_val_cmd,
3181 "no match local-preference <0-4294967295>",
3184 "Match local preference of route\n"
3185 "Local preference value\n")
3187 DEFUN (match_community,
3188 match_community_cmd,
3189 "match community (<1-99>|<100-500>|WORD)",
3191 "Match BGP community list\n"
3192 "Community-list number (standard)\n"
3193 "Community-list number (expanded)\n"
3194 "Community-list name\n")
3196 return bgp_route_match_add (vty, vty->index, "community", argv[0]);
3199 DEFUN (match_community_exact,
3200 match_community_exact_cmd,
3201 "match community (<1-99>|<100-500>|WORD) exact-match",
3203 "Match BGP community list\n"
3204 "Community-list number (standard)\n"
3205 "Community-list number (expanded)\n"
3206 "Community-list name\n"
3207 "Do exact matching of communities\n")
3212 argstr = XMALLOC (MTYPE_ROUTE_MAP_COMPILED,
3213 strlen (argv[0]) + strlen ("exact-match") + 2);
3215 sprintf (argstr, "%s exact-match", argv[0]);
3217 ret = bgp_route_match_add (vty, vty->index, "community", argstr);
3219 XFREE (MTYPE_ROUTE_MAP_COMPILED, argstr);
3224 DEFUN (no_match_community,
3225 no_match_community_cmd,
3226 "no match community",
3229 "Match BGP community list\n")
3231 return bgp_route_match_delete (vty, vty->index, "community", NULL);
3234 ALIAS (no_match_community,
3235 no_match_community_val_cmd,
3236 "no match community (<1-99>|<100-500>|WORD)",
3239 "Match BGP community list\n"
3240 "Community-list number (standard)\n"
3241 "Community-list number (expanded)\n"
3242 "Community-list name\n")
3244 ALIAS (no_match_community,
3245 no_match_community_exact_cmd,
3246 "no match community (<1-99>|<100-500>|WORD) exact-match",
3249 "Match BGP community list\n"
3250 "Community-list number (standard)\n"
3251 "Community-list number (expanded)\n"
3252 "Community-list name\n"
3253 "Do exact matching of communities\n")
3255 DEFUN (match_lcommunity,
3256 match_lcommunity_cmd,
3257 "match large-community (<1-99>|<100-500>|WORD)",
3259 "Match BGP large community list\n"
3260 "Large Community-list number (standard)\n"
3261 "Large Community-list number (expanded)\n"
3262 "Large Community-list name\n")
3264 return bgp_route_match_add (vty, vty->index, "large-community", argv[0]);
3267 DEFUN (no_match_lcommunity,
3268 no_match_lcommunity_cmd,
3269 "no match large-community (<1-99>|<100-500>|WORD)",
3272 "Match BGP large community list\n"
3273 "Large Community-list number (standard)\n"
3274 "Large Community-list number (expanded)\n"
3275 "Large Community-list name\n")
3277 return bgp_route_match_delete (vty, vty->index, "large-community", NULL);
3281 DEFUN (match_ecommunity,
3282 match_ecommunity_cmd,
3283 "match extcommunity (<1-99>|<100-500>|WORD)",
3285 "Match BGP/VPN extended community list\n"
3286 "Extended community-list number (standard)\n"
3287 "Extended community-list number (expanded)\n"
3288 "Extended community-list name\n")
3290 return bgp_route_match_add (vty, vty->index, "extcommunity", argv[0]);
3293 DEFUN (no_match_ecommunity,
3294 no_match_ecommunity_cmd,
3295 "no match extcommunity",
3298 "Match BGP/VPN extended community list\n")
3300 return bgp_route_match_delete (vty, vty->index, "extcommunity", NULL);
3303 ALIAS (no_match_ecommunity,
3304 no_match_ecommunity_val_cmd,
3305 "no match extcommunity (<1-99>|<100-500>|WORD)",
3308 "Match BGP/VPN extended community list\n"
3309 "Extended community-list number (standard)\n"
3310 "Extended community-list number (expanded)\n"
3311 "Extended community-list name\n")
3313 DEFUN (match_aspath,
3315 "match as-path WORD",
3317 "Match BGP AS path list\n"
3318 "AS path access-list name\n")
3320 return bgp_route_match_add (vty, vty->index, "as-path", argv[0]);
3323 DEFUN (no_match_aspath,
3324 no_match_aspath_cmd,
3328 "Match BGP AS path list\n")
3330 return bgp_route_match_delete (vty, vty->index, "as-path", NULL);
3333 ALIAS (no_match_aspath,
3334 no_match_aspath_val_cmd,
3335 "no match as-path WORD",
3338 "Match BGP AS path list\n"
3339 "AS path access-list name\n")
3341 DEFUN (match_origin,
3343 "match origin (egp|igp|incomplete)",
3348 "unknown heritage\n")
3350 if (strncmp (argv[0], "igp", 2) == 0)
3351 return bgp_route_match_add (vty, vty->index, "origin", "igp");
3352 if (strncmp (argv[0], "egp", 1) == 0)
3353 return bgp_route_match_add (vty, vty->index, "origin", "egp");
3354 if (strncmp (argv[0], "incomplete", 2) == 0)
3355 return bgp_route_match_add (vty, vty->index, "origin", "incomplete");
3360 DEFUN (no_match_origin,
3361 no_match_origin_cmd,
3365 "BGP origin code\n")
3367 return bgp_route_match_delete (vty, vty->index, "origin", NULL);
3370 ALIAS (no_match_origin,
3371 no_match_origin_val_cmd,
3372 "no match origin (egp|igp|incomplete)",
3378 "unknown heritage\n")
3382 "match tag <1-4294967295>",
3384 "Match tag of route\n"
3387 return bgp_route_match_add (vty, vty->index, "tag", argv[0]);
3390 DEFUN (no_match_tag,
3395 "Match tag of route\n")
3398 return bgp_route_match_delete (vty, vty->index, "tag", NULL);
3400 return bgp_route_match_delete (vty, vty->index, "tag", argv[0]);
3403 ALIAS (no_match_tag,
3404 no_match_tag_val_cmd,
3405 "no match tag <1-4294967295>",
3408 "Match tag of route\n"
3411 DEFUN (set_ip_nexthop,
3413 "set ip next-hop A.B.C.D",
3416 "Next hop address\n"
3417 "IP address of next hop\n")
3422 ret = str2sockunion (argv[0], &su);
3425 vty_out (vty, "%% Malformed Next-hop address%s", VTY_NEWLINE);
3429 return bgp_route_set_add (vty, vty->index, "ip next-hop", argv[0]);
3432 DEFUN (set_ip_nexthop_peer,
3433 set_ip_nexthop_peer_cmd,
3434 "set ip next-hop peer-address",
3437 "Next hop address\n"
3438 "Use peer address (for BGP only)\n")
3440 return bgp_route_set_add (vty, vty->index, "ip next-hop", "peer-address");
3443 DEFUN_DEPRECATED (no_set_ip_nexthop_peer,
3444 no_set_ip_nexthop_peer_cmd,
3445 "no set ip next-hop peer-address",
3449 "Next hop address\n"
3450 "Use peer address (for BGP only)\n")
3452 return bgp_route_set_delete (vty, vty->index, "ip next-hop", NULL);
3456 DEFUN (no_set_ip_nexthop,
3457 no_set_ip_nexthop_cmd,
3458 "no set ip next-hop",
3461 "Next hop address\n")
3464 return bgp_route_set_delete (vty, vty->index, "ip next-hop", NULL);
3466 return bgp_route_set_delete (vty, vty->index, "ip next-hop", argv[0]);
3469 ALIAS (no_set_ip_nexthop,
3470 no_set_ip_nexthop_val_cmd,
3471 "no set ip next-hop A.B.C.D",
3475 "Next hop address\n"
3476 "IP address of next hop\n")
3480 "set metric <0-4294967295>",
3482 "Metric value for destination routing protocol\n"
3485 return bgp_route_set_add (vty, vty->index, "metric", argv[0]);
3489 set_metric_addsub_cmd,
3490 "set metric <+/-metric>",
3492 "Metric value for destination routing protocol\n"
3493 "Add or subtract metric\n")
3497 "set metric (rtt|+rtt|-rtt)",
3499 "Metric value for destination routing protocol\n"
3500 "Assign round trip time\n"
3501 "Add round trip time\n"
3502 "Subtract round trip time\n")
3504 DEFUN (no_set_metric,
3509 "Metric value for destination routing protocol\n")
3512 return bgp_route_set_delete (vty, vty->index, "metric", NULL);
3514 return bgp_route_set_delete (vty, vty->index, "metric", argv[0]);
3517 ALIAS (no_set_metric,
3518 no_set_metric_val_cmd,
3519 "no set metric <0-4294967295>",
3522 "Metric value for destination routing protocol\n"
3525 DEFUN (set_local_pref,
3527 "set local-preference <0-4294967295>",
3529 "BGP local preference path attribute\n"
3530 "Preference value\n")
3532 return bgp_route_set_add (vty, vty->index, "local-preference", argv[0]);
3535 DEFUN (no_set_local_pref,
3536 no_set_local_pref_cmd,
3537 "no set local-preference",
3540 "BGP local preference path attribute\n")
3543 return bgp_route_set_delete (vty, vty->index, "local-preference", NULL);
3545 return bgp_route_set_delete (vty, vty->index, "local-preference", argv[0]);
3548 ALIAS (no_set_local_pref,
3549 no_set_local_pref_val_cmd,
3550 "no set local-preference <0-4294967295>",
3553 "BGP local preference path attribute\n"
3554 "Preference value\n")
3558 "set weight <0-4294967295>",
3560 "BGP weight for routing table\n"
3563 return bgp_route_set_add (vty, vty->index, "weight", argv[0]);
3566 DEFUN (no_set_weight,
3571 "BGP weight for routing table\n")
3574 return bgp_route_set_delete (vty, vty->index, "weight", NULL);
3576 return bgp_route_set_delete (vty, vty->index, "weight", argv[0]);
3579 ALIAS (no_set_weight,
3580 no_set_weight_val_cmd,
3581 "no set weight <0-4294967295>",
3584 "BGP weight for routing table\n"
3587 DEFUN (set_aspath_prepend,
3588 set_aspath_prepend_cmd,
3589 "set as-path prepend ." CMD_AS_RANGE,
3591 "Transform BGP AS_PATH attribute\n"
3592 "Prepend to the as-path\n"
3598 str = argv_concat (argv, argc, 0);
3599 ret = bgp_route_set_add (vty, vty->index, "as-path prepend", str);
3600 XFREE (MTYPE_TMP, str);
3605 ALIAS (set_aspath_prepend,
3606 set_aspath_prepend_lastas_cmd,
3607 "set as-path prepend (last-as) <1-10>",
3609 "Transform BGP AS_PATH attribute\n"
3610 "Prepend to the as-path\n"
3611 "Use the peer's AS-number\n"
3612 "Number of times to insert")
3614 DEFUN (no_set_aspath_prepend,
3615 no_set_aspath_prepend_cmd,
3616 "no set as-path prepend",
3619 "Transform BGP AS_PATH attribute\n"
3620 "Prepend to the as-path\n")
3626 return bgp_route_set_delete (vty, vty->index, "as-path prepend", NULL);
3628 str = argv_concat (argv, argc, 0);
3629 ret = bgp_route_set_delete (vty, vty->index, "as-path prepend", str);
3630 XFREE (MTYPE_TMP, str);
3634 ALIAS (no_set_aspath_prepend,
3635 no_set_aspath_prepend_val_cmd,
3636 "no set as-path prepend ." CMD_AS_RANGE,
3639 "Transform BGP AS_PATH attribute\n"
3640 "Prepend to the as-path\n"
3643 DEFUN (set_aspath_exclude,
3644 set_aspath_exclude_cmd,
3645 "set as-path exclude ." CMD_AS_RANGE,
3647 "Transform BGP AS-path attribute\n"
3648 "Exclude from the as-path\n"
3654 str = argv_concat (argv, argc, 0);
3655 ret = bgp_route_set_add (vty, vty->index, "as-path exclude", str);
3656 XFREE (MTYPE_TMP, str);
3660 DEFUN (no_set_aspath_exclude,
3661 no_set_aspath_exclude_cmd,
3662 "no set as-path exclude",
3665 "Transform BGP AS_PATH attribute\n"
3666 "Exclude from the as-path\n")
3672 return bgp_route_set_delete (vty, vty->index, "as-path exclude", NULL);
3674 str = argv_concat (argv, argc, 0);
3675 ret = bgp_route_set_delete (vty, vty->index, "as-path exclude", str);
3676 XFREE (MTYPE_TMP, str);
3680 ALIAS (no_set_aspath_exclude,
3681 no_set_aspath_exclude_val_cmd,
3682 "no set as-path exclude ." CMD_AS_RANGE,
3685 "Transform BGP AS_PATH attribute\n"
3686 "Exclude from the as-path\n"
3689 DEFUN (set_community,
3691 "set community .AA:NN",
3693 "BGP community attribute\n"
3694 "Community number in aa:nn format or local-AS|no-advertise|no-export|internet or additive\n")
3700 struct community *com = NULL;
3705 b = buffer_new (1024);
3707 for (i = 0; i < argc; i++)
3709 if (strncmp (argv[i], "additive", strlen (argv[i])) == 0)
3716 buffer_putc (b, ' ');
3720 if (strncmp (argv[i], "internet", strlen (argv[i])) == 0)
3722 buffer_putstr (b, "internet");
3725 if (strncmp (argv[i], "local-AS", strlen (argv[i])) == 0)
3727 buffer_putstr (b, "local-AS");
3730 if (strncmp (argv[i], "no-a", strlen ("no-a")) == 0
3731 && strncmp (argv[i], "no-advertise", strlen (argv[i])) == 0)
3733 buffer_putstr (b, "no-advertise");
3736 if (strncmp (argv[i], "no-e", strlen ("no-e"))== 0
3737 && strncmp (argv[i], "no-export", strlen (argv[i])) == 0)
3739 buffer_putstr (b, "no-export");
3742 buffer_putstr (b, argv[i]);
3744 buffer_putc (b, '\0');
3746 /* Fetch result string then compile it to communities attribute. */
3747 str = buffer_getstr (b);
3752 com = community_str2com (str);
3753 XFREE (MTYPE_TMP, str);
3756 /* Can't compile user input into communities attribute. */
3759 vty_out (vty, "%% Malformed communities attribute%s", VTY_NEWLINE);
3763 /* Set communites attribute string. */
3764 str = community_str (com);
3768 argstr = XCALLOC (MTYPE_TMP, strlen (str) + strlen (" additive") + 1);
3769 strcpy (argstr, str);
3770 strcpy (argstr + strlen (str), " additive");
3771 ret = bgp_route_set_add (vty, vty->index, "community", argstr);
3772 XFREE (MTYPE_TMP, argstr);
3775 ret = bgp_route_set_add (vty, vty->index, "community", str);
3777 community_free (com);
3782 DEFUN (set_community_none,
3783 set_community_none_cmd,
3784 "set community none",
3786 "BGP community attribute\n"
3787 "No community attribute\n")
3789 return bgp_route_set_add (vty, vty->index, "community", "none");
3792 DEFUN (no_set_community,
3793 no_set_community_cmd,
3797 "BGP community attribute\n")
3799 return bgp_route_set_delete (vty, vty->index, "community", NULL);
3802 ALIAS (no_set_community,
3803 no_set_community_val_cmd,
3804 "no set community .AA:NN",
3807 "BGP community attribute\n"
3808 "Community number in aa:nn format or local-AS|no-advertise|no-export|internet or additive\n")
3810 ALIAS (no_set_community,
3811 no_set_community_none_cmd,
3812 "no set community none",
3815 "BGP community attribute\n"
3816 "No community attribute\n")
3818 DEFUN (set_community_delete,
3819 set_community_delete_cmd,
3820 "set comm-list (<1-99>|<100-500>|WORD) delete",
3822 "set BGP community list (for deletion)\n"
3823 "Community-list number (standard)\n"
3824 "Community-list number (expanded)\n"
3825 "Community-list name\n"
3826 "Delete matching communities\n")
3830 str = XCALLOC (MTYPE_TMP, strlen (argv[0]) + strlen (" delete") + 1);
3831 strcpy (str, argv[0]);
3832 strcpy (str + strlen (argv[0]), " delete");
3834 bgp_route_set_add (vty, vty->index, "comm-list", str);
3836 XFREE (MTYPE_TMP, str);
3840 DEFUN (no_set_community_delete,
3841 no_set_community_delete_cmd,
3845 "set BGP community list (for deletion)\n")
3847 return bgp_route_set_delete (vty, vty->index, "comm-list", NULL);
3850 ALIAS (no_set_community_delete,
3851 no_set_community_delete_val_cmd,
3852 "no set comm-list (<1-99>|<100-500>|WORD) delete",
3855 "set BGP community list (for deletion)\n"
3856 "Community-list number (standard)\n"
3857 "Community-list number (expanded)\n"
3858 "Community-list name\n"
3859 "Delete matching communities\n")
3862 DEFUN (set_lcommunity,
3864 "set large-community .AA:BB:CC",
3866 "BGP large community attribute\n"
3867 "Large Community number in aa:bb:cc format or additive\n")
3872 str = argv_concat (argv, argc, 0);
3873 ret = bgp_route_set_add (vty, vty->index, "large-community", str);
3874 XFREE (MTYPE_TMP, str);
3879 DEFUN (set_lcommunity_none,
3880 set_lcommunity_none_cmd,
3881 "set large-community none",
3883 "BGP large community attribute\n"
3884 "No large community attribute\n")
3886 return bgp_route_set_add (vty, vty->index, "large-community", "none");
3889 DEFUN (no_set_lcommunity,
3890 no_set_lcommunity_cmd,
3891 "no set large-community",
3894 "BGP large community attribute\n"
3895 "Large community\n")
3897 return bgp_route_set_delete (vty, vty->index, "large-community", NULL);
3900 ALIAS (no_set_lcommunity,
3901 no_set_lcommunity_val_cmd,
3902 "no set large-community .AA:BB:CC",
3905 "BGP large community attribute\n"
3906 "Large community in .AA:BB:CC format or additive\n")
3908 ALIAS (no_set_lcommunity,
3909 no_set_lcommunity_none_cmd,
3910 "no set large-community none",
3913 "BGP community attribute\n"
3914 "No community attribute\n")
3916 DEFUN (set_lcommunity_delete,
3917 set_lcommunity_delete_cmd,
3918 "set large-comm-list (<1-99>|<100-500>|WORD) delete",
3920 "set BGP large community list (for deletion)\n"
3921 "Large Community-list number (standard)\n"
3922 "Large Communitly-list number (expanded)\n"
3923 "Large Community-list name\n"
3924 "Delete matching large communities\n")
3928 str = XCALLOC (MTYPE_TMP, strlen (argv[0]) + strlen (" delete") + 1);
3929 strcpy (str, argv[0]);
3930 strcpy (str + strlen (argv[0]), " delete");
3932 bgp_route_set_add (vty, vty->index, "large-comm-list", str);
3934 XFREE (MTYPE_TMP, str);
3938 DEFUN (no_set_lcommunity_delete,
3939 no_set_lcommunity_delete_cmd,
3940 "no set large-comm-list",
3943 "set BGP large community list (for deletion)\n")
3945 return bgp_route_set_delete (vty, vty->index, "large-comm-list", NULL);
3948 ALIAS (no_set_lcommunity_delete,
3949 no_set_lcommunity_delete_val_cmd,
3950 "no set large-comm-list (<1-99>|<100-500>|WORD) delete",
3953 "set BGP large community list (for deletion)\n"
3954 "Large Community-list number (standard)\n"
3955 "Large Communitly-list number (expanded)\n"
3956 "Large Community-list name\n"
3957 "Delete matching large communities\n")
3959 DEFUN (set_ecommunity_rt,
3960 set_ecommunity_rt_cmd,
3961 "set extcommunity rt .ASN:nn_or_IP-address:nn",
3963 "BGP extended community attribute\n"
3964 "Route Target extended community\n"
3965 "VPN extended community\n")
3970 str = argv_concat (argv, argc, 0);
3971 ret = bgp_route_set_add (vty, vty->index, "extcommunity rt", str);
3972 XFREE (MTYPE_TMP, str);
3977 DEFUN (no_set_ecommunity_rt,
3978 no_set_ecommunity_rt_cmd,
3979 "no set extcommunity rt",
3982 "BGP extended community attribute\n"
3983 "Route Target extended community\n")
3985 return bgp_route_set_delete (vty, vty->index, "extcommunity rt", NULL);
3988 ALIAS (no_set_ecommunity_rt,
3989 no_set_ecommunity_rt_val_cmd,
3990 "no set extcommunity rt .ASN:nn_or_IP-address:nn",
3993 "BGP extended community attribute\n"
3994 "Route Target extended community\n"
3995 "VPN extended community\n")
3997 DEFUN (set_ecommunity_soo,
3998 set_ecommunity_soo_cmd,
3999 "set extcommunity soo .ASN:nn_or_IP-address:nn",
4001 "BGP extended community attribute\n"
4002 "Site-of-Origin extended community\n"
4003 "VPN extended community\n")
4008 str = argv_concat (argv, argc, 0);
4009 ret = bgp_route_set_add (vty, vty->index, "extcommunity soo", str);
4010 XFREE (MTYPE_TMP, str);
4014 DEFUN (no_set_ecommunity_soo,
4015 no_set_ecommunity_soo_cmd,
4016 "no set extcommunity soo",
4019 "BGP extended community attribute\n"
4020 "Site-of-Origin extended community\n")
4022 return bgp_route_set_delete (vty, vty->index, "extcommunity soo", NULL);
4025 ALIAS (no_set_ecommunity_soo,
4026 no_set_ecommunity_soo_val_cmd,
4027 "no set extcommunity soo .ASN:nn_or_IP-address:nn",
4030 "BGP extended community attribute\n"
4031 "Site-of-Origin extended community\n"
4032 "VPN extended community\n")
4036 "set origin (egp|igp|incomplete)",
4041 "unknown heritage\n")
4043 if (strncmp (argv[0], "igp", 2) == 0)
4044 return bgp_route_set_add (vty, vty->index, "origin", "igp");
4045 if (strncmp (argv[0], "egp", 1) == 0)
4046 return bgp_route_set_add (vty, vty->index, "origin", "egp");
4047 if (strncmp (argv[0], "incomplete", 2) == 0)
4048 return bgp_route_set_add (vty, vty->index, "origin", "incomplete");
4053 DEFUN (no_set_origin,
4058 "BGP origin code\n")
4060 return bgp_route_set_delete (vty, vty->index, "origin", NULL);
4063 ALIAS (no_set_origin,
4064 no_set_origin_val_cmd,
4065 "no set origin (egp|igp|incomplete)",
4071 "unknown heritage\n")
4073 DEFUN (set_atomic_aggregate,
4074 set_atomic_aggregate_cmd,
4075 "set atomic-aggregate",
4077 "BGP atomic aggregate attribute\n" )
4079 return bgp_route_set_add (vty, vty->index, "atomic-aggregate", NULL);
4082 DEFUN (no_set_atomic_aggregate,
4083 no_set_atomic_aggregate_cmd,
4084 "no set atomic-aggregate",
4087 "BGP atomic aggregate attribute\n" )
4089 return bgp_route_set_delete (vty, vty->index, "atomic-aggregate", NULL);
4092 DEFUN (set_aggregator_as,
4093 set_aggregator_as_cmd,
4094 "set aggregator as " CMD_AS_RANGE " A.B.C.D",
4096 "BGP aggregator attribute\n"
4097 "AS number of aggregator\n"
4099 "IP address of aggregator\n")
4102 as_t as __attribute__((unused)); /* dummy for VTY_GET_INTEGER_RANGE */
4103 struct in_addr address;
4106 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
4108 ret = inet_aton (argv[1], &address);
4111 vty_out (vty, "Aggregator IP address is invalid%s", VTY_NEWLINE);
4115 argstr = XMALLOC (MTYPE_ROUTE_MAP_COMPILED,
4116 strlen (argv[0]) + strlen (argv[1]) + 2);
4118 sprintf (argstr, "%s %s", argv[0], argv[1]);
4120 ret = bgp_route_set_add (vty, vty->index, "aggregator as", argstr);
4122 XFREE (MTYPE_ROUTE_MAP_COMPILED, argstr);
4127 DEFUN (no_set_aggregator_as,
4128 no_set_aggregator_as_cmd,
4129 "no set aggregator as",
4132 "BGP aggregator attribute\n"
4133 "AS number of aggregator\n")
4136 as_t as __attribute__((unused)); /* dummy for VTY_GET_INTEGER_RANGE */
4137 struct in_addr address;
4141 return bgp_route_set_delete (vty, vty->index, "aggregator as", NULL);
4143 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
4145 ret = inet_aton (argv[1], &address);
4148 vty_out (vty, "Aggregator IP address is invalid%s", VTY_NEWLINE);
4152 argstr = XMALLOC (MTYPE_ROUTE_MAP_COMPILED,
4153 strlen (argv[0]) + strlen (argv[1]) + 2);
4155 sprintf (argstr, "%s %s", argv[0], argv[1]);
4157 ret = bgp_route_set_delete (vty, vty->index, "aggregator as", argstr);
4159 XFREE (MTYPE_ROUTE_MAP_COMPILED, argstr);
4164 ALIAS (no_set_aggregator_as,
4165 no_set_aggregator_as_val_cmd,
4166 "no set aggregator as " CMD_AS_RANGE " A.B.C.D",
4169 "BGP aggregator attribute\n"
4170 "AS number of aggregator\n"
4172 "IP address of aggregator\n")
4176 "set tag <1-4294967295>",
4178 "Tag value for routing protocol\n"
4181 return bgp_route_set_add (vty, vty->index, "tag", argv[0]);
4189 "Tag value for routing protocol\n")
4192 bgp_route_set_delete(vty, vty->index, "tag", NULL);
4194 return bgp_route_set_delete (vty, vty->index, "tag", argv[0]);
4199 "no set tag <1-4294967295>",
4202 "Tag value for routing protocol\n"
4206 DEFUN (match_ipv6_address,
4207 match_ipv6_address_cmd,
4208 "match ipv6 address WORD",
4211 "Match IPv6 address of route\n"
4212 "IPv6 access-list name\n")
4214 return bgp_route_match_add (vty, vty->index, "ipv6 address", argv[0]);
4217 DEFUN (no_match_ipv6_address,
4218 no_match_ipv6_address_cmd,
4219 "no match ipv6 address WORD",
4223 "Match IPv6 address of route\n"
4224 "IPv6 access-list name\n")
4226 return bgp_route_match_delete (vty, vty->index, "ipv6 address", argv[0]);
4229 DEFUN (match_ipv6_next_hop,
4230 match_ipv6_next_hop_cmd,
4231 "match ipv6 next-hop X:X::X:X",
4234 "Match IPv6 next-hop address of route\n"
4235 "IPv6 address of next hop\n")
4237 return bgp_route_match_add (vty, vty->index, "ipv6 next-hop", argv[0]);
4240 DEFUN (no_match_ipv6_next_hop,
4241 no_match_ipv6_next_hop_cmd,
4242 "no match ipv6 next-hop X:X::X:X",
4246 "Match IPv6 next-hop address of route\n"
4247 "IPv6 address of next hop\n")
4249 return bgp_route_match_delete (vty, vty->index, "ipv6 next-hop", argv[0]);
4252 DEFUN (match_ipv6_address_prefix_list,
4253 match_ipv6_address_prefix_list_cmd,
4254 "match ipv6 address prefix-list WORD",
4257 "Match address of route\n"
4258 "Match entries of prefix-lists\n"
4259 "IP prefix-list name\n")
4261 return bgp_route_match_add (vty, vty->index, "ipv6 address prefix-list", argv[0]);
4264 DEFUN (no_match_ipv6_address_prefix_list,
4265 no_match_ipv6_address_prefix_list_cmd,
4266 "no match ipv6 address prefix-list WORD",
4270 "Match address of route\n"
4271 "Match entries of prefix-lists\n"
4272 "IP prefix-list name\n")
4274 return bgp_route_match_delete (vty, vty->index, "ipv6 address prefix-list", argv[0]);
4277 DEFUN (set_ipv6_nexthop_peer,
4278 set_ipv6_nexthop_peer_cmd,
4279 "set ipv6 next-hop peer-address",
4282 "Next hop address\n"
4283 "Use peer address (for BGP only)\n")
4285 return bgp_route_set_add (vty, vty->index, "ipv6 next-hop peer-address", NULL);
4288 DEFUN (no_set_ipv6_nexthop_peer,
4289 no_set_ipv6_nexthop_peer_cmd,
4290 "no set ipv6 next-hop peer-address",
4294 "IPv6 next-hop address\n"
4297 return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop", argv[0]);
4300 DEFUN (set_ipv6_nexthop_global,
4301 set_ipv6_nexthop_global_cmd,
4302 "set ipv6 next-hop global X:X::X:X",
4305 "IPv6 next-hop address\n"
4306 "IPv6 global address\n"
4307 "IPv6 address of next hop\n")
4309 return bgp_route_set_add (vty, vty->index, "ipv6 next-hop global", argv[0]);
4312 DEFUN (no_set_ipv6_nexthop_global,
4313 no_set_ipv6_nexthop_global_cmd,
4314 "no set ipv6 next-hop global",
4318 "IPv6 next-hop address\n"
4319 "IPv6 global address\n")
4322 return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop global", NULL);
4324 return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop global", argv[0]);
4327 ALIAS (no_set_ipv6_nexthop_global,
4328 no_set_ipv6_nexthop_global_val_cmd,
4329 "no set ipv6 next-hop global X:X::X:X",
4333 "IPv6 next-hop address\n"
4334 "IPv6 global address\n"
4335 "IPv6 address of next hop\n")
4337 DEFUN (set_ipv6_nexthop_local,
4338 set_ipv6_nexthop_local_cmd,
4339 "set ipv6 next-hop local X:X::X:X",
4342 "IPv6 next-hop address\n"
4343 "IPv6 local address\n"
4344 "IPv6 address of next hop\n")
4346 return bgp_route_set_add (vty, vty->index, "ipv6 next-hop local", argv[0]);
4349 DEFUN (no_set_ipv6_nexthop_local,
4350 no_set_ipv6_nexthop_local_cmd,
4351 "no set ipv6 next-hop local",
4355 "IPv6 next-hop address\n"
4356 "IPv6 local address\n")
4359 return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop local", NULL);
4361 return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop local", argv[0]);
4364 ALIAS (no_set_ipv6_nexthop_local,
4365 no_set_ipv6_nexthop_local_val_cmd,
4366 "no set ipv6 next-hop local X:X::X:X",
4370 "IPv6 next-hop address\n"
4371 "IPv6 local address\n"
4372 "IPv6 address of next hop\n")
4374 DEFUN (set_vpnv4_nexthop,
4375 set_vpnv4_nexthop_cmd,
4376 "set vpnv4 next-hop A.B.C.D",
4378 "VPNv4 information\n"
4379 "VPNv4 next-hop address\n"
4380 "IP address of next hop\n")
4382 return bgp_route_set_add (vty, vty->index, "vpnv4 next-hop", argv[0]);
4385 DEFUN (no_set_vpnv4_nexthop,
4386 no_set_vpnv4_nexthop_cmd,
4387 "no set vpnv4 next-hop",
4390 "VPNv4 information\n"
4391 "VPNv4 next-hop address\n")
4394 return bgp_route_set_delete (vty, vty->index, "vpnv4 next-hop", NULL);
4396 return bgp_route_set_delete (vty, vty->index, "vpnv4 next-hop", argv[0]);
4399 ALIAS (no_set_vpnv4_nexthop,
4400 no_set_vpnv4_nexthop_val_cmd,
4401 "no set vpnv4 next-hop A.B.C.D",
4404 "VPNv4 information\n"
4405 "VPNv4 next-hop address\n"
4406 "IP address of next hop\n")
4408 DEFUN (set_originator_id,
4409 set_originator_id_cmd,
4410 "set originator-id A.B.C.D",
4412 "BGP originator ID attribute\n"
4413 "IP address of originator\n")
4415 return bgp_route_set_add (vty, vty->index, "originator-id", argv[0]);
4418 DEFUN (no_set_originator_id,
4419 no_set_originator_id_cmd,
4420 "no set originator-id",
4423 "BGP originator ID attribute\n")
4426 return bgp_route_set_delete (vty, vty->index, "originator-id", NULL);
4428 return bgp_route_set_delete (vty, vty->index, "originator-id", argv[0]);
4431 ALIAS (no_set_originator_id,
4432 no_set_originator_id_val_cmd,
4433 "no set originator-id A.B.C.D",
4436 "BGP originator ID attribute\n"
4437 "IP address of originator\n")
4439 DEFUN_DEPRECATED (set_pathlimit_ttl,
4440 set_pathlimit_ttl_cmd,
4441 "set pathlimit ttl <1-255>",
4443 "BGP AS-Pathlimit attribute\n"
4444 "Set AS-Path Hop-count TTL\n")
4449 DEFUN_DEPRECATED (no_set_pathlimit_ttl,
4450 no_set_pathlimit_ttl_cmd,
4451 "no set pathlimit ttl",
4454 "BGP AS-Pathlimit attribute\n"
4455 "Set AS-Path Hop-count TTL\n")
4460 ALIAS (no_set_pathlimit_ttl,
4461 no_set_pathlimit_ttl_val_cmd,
4462 "no set pathlimit ttl <1-255>",
4465 "BGP AS-Pathlimit attribute\n"
4466 "Set AS-Path Hop-count TTL\n")
4468 DEFUN_DEPRECATED (match_pathlimit_as,
4469 match_pathlimit_as_cmd,
4470 "match pathlimit as <1-65535>",
4472 "BGP AS-Pathlimit attribute\n"
4473 "Match Pathlimit AS number\n")
4478 DEFUN_DEPRECATED (no_match_pathlimit_as,
4479 no_match_pathlimit_as_cmd,
4480 "no match pathlimit as",
4483 "BGP AS-Pathlimit attribute\n"
4484 "Match Pathlimit AS number\n")
4489 ALIAS (no_match_pathlimit_as,
4490 no_match_pathlimit_as_val_cmd,
4491 "no match pathlimit as <1-65535>",
4494 "BGP AS-Pathlimit attribute\n"
4495 "Match Pathlimit ASN\n")
4498 /* Initialization of route map. */
4500 bgp_route_map_init (void)
4503 route_map_init_vty ();
4504 route_map_add_hook (bgp_route_map_update);
4505 route_map_delete_hook (bgp_route_map_update);
4507 route_map_install_match (&route_match_peer_cmd);
4508 route_map_install_match (&route_match_local_pref_cmd);
4509 route_map_install_match (&route_match_ip_address_cmd);
4510 route_map_install_match (&route_match_ip_next_hop_cmd);
4511 route_map_install_match (&route_match_ip_route_source_cmd);
4512 route_map_install_match (&route_match_ip_address_prefix_list_cmd);
4513 route_map_install_match (&route_match_ip_next_hop_prefix_list_cmd);
4514 route_map_install_match (&route_match_ip_route_source_prefix_list_cmd);
4515 route_map_install_match (&route_match_aspath_cmd);
4516 route_map_install_match (&route_match_community_cmd);
4517 route_map_install_match (&route_match_lcommunity_cmd);
4518 route_map_install_match (&route_match_ecommunity_cmd);
4519 route_map_install_match (&route_match_local_pref_cmd);
4520 route_map_install_match (&route_match_metric_cmd);
4521 route_map_install_match (&route_match_origin_cmd);
4522 route_map_install_match (&route_match_probability_cmd);
4523 route_map_install_match (&route_match_tag_cmd);
4525 route_map_install_set (&route_set_ip_nexthop_cmd);
4526 route_map_install_set (&route_set_local_pref_cmd);
4527 route_map_install_set (&route_set_weight_cmd);
4528 route_map_install_set (&route_set_metric_cmd);
4529 route_map_install_set (&route_set_aspath_prepend_cmd);
4530 route_map_install_set (&route_set_aspath_exclude_cmd);
4531 route_map_install_set (&route_set_origin_cmd);
4532 route_map_install_set (&route_set_atomic_aggregate_cmd);
4533 route_map_install_set (&route_set_aggregator_as_cmd);
4534 route_map_install_set (&route_set_community_cmd);
4535 route_map_install_set (&route_set_community_delete_cmd);
4536 route_map_install_set (&route_set_lcommunity_cmd);
4537 route_map_install_set (&route_set_lcommunity_delete_cmd);
4538 route_map_install_set (&route_set_vpnv4_nexthop_cmd);
4539 route_map_install_set (&route_set_originator_id_cmd);
4540 route_map_install_set (&route_set_ecommunity_rt_cmd);
4541 route_map_install_set (&route_set_ecommunity_soo_cmd);
4542 route_map_install_set (&route_set_tag_cmd);
4544 install_element (RMAP_NODE, &match_peer_cmd);
4545 install_element (RMAP_NODE, &match_peer_local_cmd);
4546 install_element (RMAP_NODE, &no_match_peer_cmd);
4547 install_element (RMAP_NODE, &no_match_peer_val_cmd);
4548 install_element (RMAP_NODE, &no_match_peer_local_cmd);
4549 install_element (RMAP_NODE, &match_ip_address_cmd);
4550 install_element (RMAP_NODE, &no_match_ip_address_cmd);
4551 install_element (RMAP_NODE, &no_match_ip_address_val_cmd);
4552 install_element (RMAP_NODE, &match_ip_next_hop_cmd);
4553 install_element (RMAP_NODE, &no_match_ip_next_hop_cmd);
4554 install_element (RMAP_NODE, &no_match_ip_next_hop_val_cmd);
4555 install_element (RMAP_NODE, &match_ip_route_source_cmd);
4556 install_element (RMAP_NODE, &no_match_ip_route_source_cmd);
4557 install_element (RMAP_NODE, &no_match_ip_route_source_val_cmd);
4558 install_element (RMAP_NODE, &match_ip_address_prefix_list_cmd);
4559 install_element (RMAP_NODE, &no_match_ip_address_prefix_list_cmd);
4560 install_element (RMAP_NODE, &no_match_ip_address_prefix_list_val_cmd);
4561 install_element (RMAP_NODE, &match_ip_next_hop_prefix_list_cmd);
4562 install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_cmd);
4563 install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_val_cmd);
4564 install_element (RMAP_NODE, &match_ip_route_source_prefix_list_cmd);
4565 install_element (RMAP_NODE, &no_match_ip_route_source_prefix_list_cmd);
4566 install_element (RMAP_NODE, &no_match_ip_route_source_prefix_list_val_cmd);
4568 install_element (RMAP_NODE, &match_aspath_cmd);
4569 install_element (RMAP_NODE, &no_match_aspath_cmd);
4570 install_element (RMAP_NODE, &no_match_aspath_val_cmd);
4571 install_element (RMAP_NODE, &match_metric_cmd);
4572 install_element (RMAP_NODE, &no_match_metric_cmd);
4573 install_element (RMAP_NODE, &no_match_metric_val_cmd);
4574 install_element (RMAP_NODE, &match_local_pref_cmd);
4575 install_element (RMAP_NODE, &no_match_local_pref_cmd);
4576 install_element (RMAP_NODE, &no_match_local_pref_val_cmd);
4577 install_element (RMAP_NODE, &match_community_cmd);
4578 install_element (RMAP_NODE, &match_community_exact_cmd);
4579 install_element (RMAP_NODE, &no_match_community_cmd);
4580 install_element (RMAP_NODE, &no_match_community_val_cmd);
4581 install_element (RMAP_NODE, &no_match_community_exact_cmd);
4582 install_element (RMAP_NODE, &match_lcommunity_cmd);
4583 install_element (RMAP_NODE, &no_match_lcommunity_cmd);
4584 install_element (RMAP_NODE, &match_ecommunity_cmd);
4585 install_element (RMAP_NODE, &no_match_ecommunity_cmd);
4586 install_element (RMAP_NODE, &no_match_ecommunity_val_cmd);
4587 install_element (RMAP_NODE, &match_origin_cmd);
4588 install_element (RMAP_NODE, &no_match_origin_cmd);
4589 install_element (RMAP_NODE, &no_match_origin_val_cmd);
4590 install_element (RMAP_NODE, &match_probability_cmd);
4591 install_element (RMAP_NODE, &no_match_probability_cmd);
4592 install_element (RMAP_NODE, &no_match_probability_val_cmd);
4593 install_element (RMAP_NODE, &match_tag_cmd);
4594 install_element (RMAP_NODE, &no_match_tag_cmd);
4595 install_element (RMAP_NODE, &no_match_tag_val_cmd);
4597 install_element (RMAP_NODE, &set_ip_nexthop_cmd);
4598 install_element (RMAP_NODE, &set_ip_nexthop_peer_cmd);
4599 install_element (RMAP_NODE, &no_set_ip_nexthop_cmd);
4600 install_element (RMAP_NODE, &no_set_ip_nexthop_val_cmd);
4601 install_element (RMAP_NODE, &set_local_pref_cmd);
4602 install_element (RMAP_NODE, &no_set_local_pref_cmd);
4603 install_element (RMAP_NODE, &no_set_local_pref_val_cmd);
4604 install_element (RMAP_NODE, &set_weight_cmd);
4605 install_element (RMAP_NODE, &no_set_weight_cmd);
4606 install_element (RMAP_NODE, &no_set_weight_val_cmd);
4607 install_element (RMAP_NODE, &set_metric_cmd);
4608 install_element (RMAP_NODE, &set_metric_addsub_cmd);
4609 install_element (RMAP_NODE, &set_metric_rtt_cmd);
4610 install_element (RMAP_NODE, &no_set_metric_cmd);
4611 install_element (RMAP_NODE, &no_set_metric_val_cmd);
4612 install_element (RMAP_NODE, &set_aspath_prepend_cmd);
4613 install_element (RMAP_NODE, &set_aspath_prepend_lastas_cmd);
4614 install_element (RMAP_NODE, &set_aspath_exclude_cmd);
4615 install_element (RMAP_NODE, &no_set_aspath_prepend_cmd);
4616 install_element (RMAP_NODE, &no_set_aspath_prepend_val_cmd);
4617 install_element (RMAP_NODE, &no_set_aspath_exclude_cmd);
4618 install_element (RMAP_NODE, &no_set_aspath_exclude_val_cmd);
4619 install_element (RMAP_NODE, &set_origin_cmd);
4620 install_element (RMAP_NODE, &no_set_origin_cmd);
4621 install_element (RMAP_NODE, &no_set_origin_val_cmd);
4622 install_element (RMAP_NODE, &set_atomic_aggregate_cmd);
4623 install_element (RMAP_NODE, &no_set_atomic_aggregate_cmd);
4624 install_element (RMAP_NODE, &set_aggregator_as_cmd);
4625 install_element (RMAP_NODE, &no_set_aggregator_as_cmd);
4626 install_element (RMAP_NODE, &no_set_aggregator_as_val_cmd);
4627 install_element (RMAP_NODE, &set_community_cmd);
4628 install_element (RMAP_NODE, &set_community_none_cmd);
4629 install_element (RMAP_NODE, &no_set_community_cmd);
4630 install_element (RMAP_NODE, &no_set_community_val_cmd);
4631 install_element (RMAP_NODE, &no_set_community_none_cmd);
4632 install_element (RMAP_NODE, &set_community_delete_cmd);
4633 install_element (RMAP_NODE, &no_set_community_delete_cmd);
4634 install_element (RMAP_NODE, &no_set_community_delete_val_cmd);
4635 install_element (RMAP_NODE, &set_lcommunity_cmd);
4636 install_element (RMAP_NODE, &set_lcommunity_none_cmd);
4637 install_element (RMAP_NODE, &no_set_lcommunity_cmd);
4638 install_element (RMAP_NODE, &no_set_lcommunity_val_cmd);
4639 install_element (RMAP_NODE, &no_set_lcommunity_none_cmd);
4640 install_element (RMAP_NODE, &set_lcommunity_delete_cmd);
4641 install_element (RMAP_NODE, &no_set_lcommunity_delete_cmd);
4642 install_element (RMAP_NODE, &no_set_lcommunity_delete_val_cmd);
4643 install_element (RMAP_NODE, &set_ecommunity_rt_cmd);
4644 install_element (RMAP_NODE, &no_set_ecommunity_rt_cmd);
4645 install_element (RMAP_NODE, &no_set_ecommunity_rt_val_cmd);
4646 install_element (RMAP_NODE, &set_ecommunity_soo_cmd);
4647 install_element (RMAP_NODE, &no_set_ecommunity_soo_cmd);
4648 install_element (RMAP_NODE, &no_set_ecommunity_soo_val_cmd);
4649 install_element (RMAP_NODE, &set_vpnv4_nexthop_cmd);
4650 install_element (RMAP_NODE, &no_set_vpnv4_nexthop_cmd);
4651 install_element (RMAP_NODE, &no_set_vpnv4_nexthop_val_cmd);
4652 install_element (RMAP_NODE, &set_originator_id_cmd);
4653 install_element (RMAP_NODE, &no_set_originator_id_cmd);
4654 install_element (RMAP_NODE, &no_set_originator_id_val_cmd);
4655 install_element (RMAP_NODE, &set_tag_cmd);
4656 install_element (RMAP_NODE, &no_set_tag_cmd);
4657 install_element (RMAP_NODE, &no_set_tag_val_cmd);
4659 route_map_install_match (&route_match_ipv6_address_cmd);
4660 route_map_install_match (&route_match_ipv6_next_hop_cmd);
4661 route_map_install_match (&route_match_ipv6_address_prefix_list_cmd);
4662 route_map_install_set (&route_set_ipv6_nexthop_global_cmd);
4663 route_map_install_set (&route_set_ipv6_nexthop_local_cmd);
4664 route_map_install_set (&route_set_ipv6_nexthop_peer_cmd);
4666 install_element (RMAP_NODE, &match_ipv6_address_cmd);
4667 install_element (RMAP_NODE, &no_match_ipv6_address_cmd);
4668 install_element (RMAP_NODE, &match_ipv6_next_hop_cmd);
4669 install_element (RMAP_NODE, &no_match_ipv6_next_hop_cmd);
4670 install_element (RMAP_NODE, &match_ipv6_address_prefix_list_cmd);
4671 install_element (RMAP_NODE, &no_match_ipv6_address_prefix_list_cmd);
4672 install_element (RMAP_NODE, &set_ipv6_nexthop_global_cmd);
4673 install_element (RMAP_NODE, &no_set_ipv6_nexthop_global_cmd);
4674 install_element (RMAP_NODE, &no_set_ipv6_nexthop_global_val_cmd);
4675 install_element (RMAP_NODE, &set_ipv6_nexthop_local_cmd);
4676 install_element (RMAP_NODE, &no_set_ipv6_nexthop_local_cmd);
4677 install_element (RMAP_NODE, &no_set_ipv6_nexthop_local_val_cmd);
4678 install_element (RMAP_NODE, &set_ipv6_nexthop_peer_cmd);
4679 install_element (RMAP_NODE, &no_set_ipv6_nexthop_peer_cmd);
4681 /* AS-Pathlimit: functionality removed, commands kept for
4684 install_element (RMAP_NODE, &set_pathlimit_ttl_cmd);
4685 install_element (RMAP_NODE, &no_set_pathlimit_ttl_cmd);
4686 install_element (RMAP_NODE, &no_set_pathlimit_ttl_val_cmd);
4687 install_element (RMAP_NODE, &match_pathlimit_as_cmd);
4688 install_element (RMAP_NODE, &no_match_pathlimit_as_cmd);
4689 install_element (RMAP_NODE, &no_match_pathlimit_as_val_cmd);