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_vty.h"
56 /* Memo of route-map commands.
65 ip route-source : Done
69 ipv6 route-source: (This will not be implemented by bgpd)
70 ipv6 prefix-list : Done
71 length : (This will not be implemented by bgpd)
73 route-type : (This will not be implemented by bgpd)
74 tag : (This will not be implemented by bgpd)
76 set as-path prepend : Done
78 automatic-tag : (This will not be implemented by bgpd)
82 default : (This will not be implemented by bgpd)
83 interface : (This will not be implemented by bgpd)
84 ip default : (This will not be implemented by bgpd)
86 ip precedence : (This will not be implemented by bgpd)
87 ip tos : (This will not be implemented by bgpd)
88 level : (This will not be implemented by bgpd)
89 local-preference : Done
93 tag : (This will not be implemented by bgpd)
98 set ipv6 next-hop global: Done
99 set ipv6 next-hop local : Done
100 set as-path exclude : Done
104 /* 'match peer (A.B.C.D|X:X::X:X)' */
106 /* Compares the peer specified in the 'match peer' clause with the peer
107 received in bgp_info->peer. If it is the same, or if the peer structure
108 received is a peer_group containing it, returns RMAP_MATCH. */
109 static route_map_result_t
110 route_match_peer (void *rule
, struct prefix
*prefix
, route_map_object_t type
,
114 union sockunion su_def
= { .sa
.sa_family
= AF_INET
,
115 .sin
.sin_addr
.s_addr
= INADDR_ANY
};
116 struct peer_group
*group
;
118 struct listnode
*node
, *nnode
;
120 if (type
== RMAP_BGP
)
123 peer
= ((struct bgp_info
*) object
)->peer
;
125 if ( ! CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IMPORT
) &&
126 ! CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_EXPORT
) )
129 /* If su='0.0.0.0' (command 'match peer local'), and it's a NETWORK,
130 REDISTRIBUTE or DEFAULT_GENERATED route => return RMAP_MATCH */
131 if (sockunion_same (su
, &su_def
))
134 if ( CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_NETWORK
) ||
135 CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
) ||
136 CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_DEFAULT
))
143 if (! CHECK_FLAG (peer
->sflags
, PEER_STATUS_GROUP
))
145 if (sockunion_same (su
, &peer
->su
))
153 for (ALL_LIST_ELEMENTS (group
->peer
, node
, nnode
, peer
))
155 if (sockunion_same (su
, &peer
->su
))
165 route_match_peer_compile (const char *arg
)
170 su
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (union sockunion
));
172 ret
= str2sockunion (strcmp(arg
, "local") ? arg
: "0.0.0.0", su
);
174 XFREE (MTYPE_ROUTE_MAP_COMPILED
, su
);
181 /* Free route map's compiled `ip address' value. */
183 route_match_peer_free (void *rule
)
185 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
188 /* Route map commands for ip address matching. */
189 struct route_map_rule_cmd route_match_peer_cmd
=
193 route_match_peer_compile
,
194 route_match_peer_free
197 /* `match ip address IP_ACCESS_LIST' */
199 /* Match function should return 1 if match is success else return
201 static route_map_result_t
202 route_match_ip_address (void *rule
, struct prefix
*prefix
,
203 route_map_object_t type
, void *object
)
205 struct access_list
*alist
;
206 /* struct prefix_ipv4 match; */
208 if (type
== RMAP_BGP
)
210 alist
= access_list_lookup (AFI_IP
, (char *) rule
);
214 return (access_list_apply (alist
, prefix
) == FILTER_DENY
?
215 RMAP_NOMATCH
: RMAP_MATCH
);
220 /* Route map `ip address' match statement. `arg' should be
223 route_match_ip_address_compile (const char *arg
)
225 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
228 /* Free route map's compiled `ip address' value. */
230 route_match_ip_address_free (void *rule
)
232 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
235 /* Route map commands for ip address matching. */
236 struct route_map_rule_cmd route_match_ip_address_cmd
=
239 route_match_ip_address
,
240 route_match_ip_address_compile
,
241 route_match_ip_address_free
244 /* `match ip next-hop IP_ADDRESS' */
246 /* Match function return 1 if match is success else return zero. */
247 static route_map_result_t
248 route_match_ip_next_hop (void *rule
, struct prefix
*prefix
,
249 route_map_object_t type
, void *object
)
251 struct access_list
*alist
;
252 struct bgp_info
*bgp_info
;
253 struct prefix_ipv4 p
;
255 if (type
== RMAP_BGP
)
259 p
.prefix
= bgp_info
->attr
->nexthop
;
260 p
.prefixlen
= IPV4_MAX_BITLEN
;
262 alist
= access_list_lookup (AFI_IP
, (char *) rule
);
266 return (access_list_apply (alist
, &p
) == FILTER_DENY
?
267 RMAP_NOMATCH
: RMAP_MATCH
);
272 /* Route map `ip next-hop' match statement. `arg' is
275 route_match_ip_next_hop_compile (const char *arg
)
277 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
280 /* Free route map's compiled `ip address' value. */
282 route_match_ip_next_hop_free (void *rule
)
284 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
287 /* Route map commands for ip next-hop matching. */
288 struct route_map_rule_cmd route_match_ip_next_hop_cmd
=
291 route_match_ip_next_hop
,
292 route_match_ip_next_hop_compile
,
293 route_match_ip_next_hop_free
296 /* `match ip route-source ACCESS-LIST' */
298 /* Match function return 1 if match is success else return zero. */
299 static route_map_result_t
300 route_match_ip_route_source (void *rule
, struct prefix
*prefix
,
301 route_map_object_t type
, void *object
)
303 struct access_list
*alist
;
304 struct bgp_info
*bgp_info
;
306 struct prefix_ipv4 p
;
308 if (type
== RMAP_BGP
)
311 peer
= bgp_info
->peer
;
313 if (! peer
|| sockunion_family (&peer
->su
) != AF_INET
)
317 p
.prefix
= peer
->su
.sin
.sin_addr
;
318 p
.prefixlen
= IPV4_MAX_BITLEN
;
320 alist
= access_list_lookup (AFI_IP
, (char *) rule
);
324 return (access_list_apply (alist
, &p
) == FILTER_DENY
?
325 RMAP_NOMATCH
: RMAP_MATCH
);
330 /* Route map `ip route-source' match statement. `arg' is
333 route_match_ip_route_source_compile (const char *arg
)
335 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
338 /* Free route map's compiled `ip address' value. */
340 route_match_ip_route_source_free (void *rule
)
342 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
345 /* Route map commands for ip route-source matching. */
346 struct route_map_rule_cmd route_match_ip_route_source_cmd
=
349 route_match_ip_route_source
,
350 route_match_ip_route_source_compile
,
351 route_match_ip_route_source_free
354 /* `match ip address prefix-list PREFIX_LIST' */
356 static route_map_result_t
357 route_match_ip_address_prefix_list (void *rule
, struct prefix
*prefix
,
358 route_map_object_t type
, void *object
)
360 struct prefix_list
*plist
;
362 if (type
== RMAP_BGP
)
364 plist
= prefix_list_lookup (AFI_IP
, (char *) rule
);
368 return (prefix_list_apply (plist
, prefix
) == PREFIX_DENY
?
369 RMAP_NOMATCH
: RMAP_MATCH
);
375 route_match_ip_address_prefix_list_compile (const char *arg
)
377 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
381 route_match_ip_address_prefix_list_free (void *rule
)
383 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
386 struct route_map_rule_cmd route_match_ip_address_prefix_list_cmd
=
388 "ip address prefix-list",
389 route_match_ip_address_prefix_list
,
390 route_match_ip_address_prefix_list_compile
,
391 route_match_ip_address_prefix_list_free
394 /* `match ip next-hop prefix-list PREFIX_LIST' */
396 static route_map_result_t
397 route_match_ip_next_hop_prefix_list (void *rule
, struct prefix
*prefix
,
398 route_map_object_t type
, void *object
)
400 struct prefix_list
*plist
;
401 struct bgp_info
*bgp_info
;
402 struct prefix_ipv4 p
;
404 if (type
== RMAP_BGP
)
408 p
.prefix
= bgp_info
->attr
->nexthop
;
409 p
.prefixlen
= IPV4_MAX_BITLEN
;
411 plist
= prefix_list_lookup (AFI_IP
, (char *) rule
);
415 return (prefix_list_apply (plist
, &p
) == PREFIX_DENY
?
416 RMAP_NOMATCH
: RMAP_MATCH
);
422 route_match_ip_next_hop_prefix_list_compile (const char *arg
)
424 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
428 route_match_ip_next_hop_prefix_list_free (void *rule
)
430 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
433 struct route_map_rule_cmd route_match_ip_next_hop_prefix_list_cmd
=
435 "ip next-hop prefix-list",
436 route_match_ip_next_hop_prefix_list
,
437 route_match_ip_next_hop_prefix_list_compile
,
438 route_match_ip_next_hop_prefix_list_free
441 /* `match ip route-source prefix-list PREFIX_LIST' */
443 static route_map_result_t
444 route_match_ip_route_source_prefix_list (void *rule
, struct prefix
*prefix
,
445 route_map_object_t type
, void *object
)
447 struct prefix_list
*plist
;
448 struct bgp_info
*bgp_info
;
450 struct prefix_ipv4 p
;
452 if (type
== RMAP_BGP
)
455 peer
= bgp_info
->peer
;
457 if (! peer
|| sockunion_family (&peer
->su
) != AF_INET
)
461 p
.prefix
= peer
->su
.sin
.sin_addr
;
462 p
.prefixlen
= IPV4_MAX_BITLEN
;
464 plist
= prefix_list_lookup (AFI_IP
, (char *) rule
);
468 return (prefix_list_apply (plist
, &p
) == PREFIX_DENY
?
469 RMAP_NOMATCH
: RMAP_MATCH
);
475 route_match_ip_route_source_prefix_list_compile (const char *arg
)
477 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
481 route_match_ip_route_source_prefix_list_free (void *rule
)
483 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
486 struct route_map_rule_cmd route_match_ip_route_source_prefix_list_cmd
=
488 "ip route-source prefix-list",
489 route_match_ip_route_source_prefix_list
,
490 route_match_ip_route_source_prefix_list_compile
,
491 route_match_ip_route_source_prefix_list_free
494 /* `match metric METRIC' */
496 /* Match function return 1 if match is success else return zero. */
497 static route_map_result_t
498 route_match_metric (void *rule
, struct prefix
*prefix
,
499 route_map_object_t type
, void *object
)
502 struct bgp_info
*bgp_info
;
504 if (type
== RMAP_BGP
)
509 if (bgp_info
->attr
->med
== *med
)
517 /* Route map `match metric' match statement. `arg' is MED value */
519 route_match_metric_compile (const char *arg
)
523 unsigned long tmpval
;
525 /* Metric value shoud be integer. */
526 if (! all_digit (arg
))
530 tmpval
= strtoul (arg
, &endptr
, 10);
531 if (*endptr
!= '\0' || errno
|| tmpval
> UINT32_MAX
)
534 med
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_int32_t
));
543 /* Free route map's compiled `match metric' value. */
545 route_match_metric_free (void *rule
)
547 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
550 /* Route map commands for metric matching. */
551 struct route_map_rule_cmd route_match_metric_cmd
=
555 route_match_metric_compile
,
556 route_match_metric_free
559 /* `match as-path ASPATH' */
561 /* Match function for as-path match. I assume given object is */
562 static route_map_result_t
563 route_match_aspath (void *rule
, struct prefix
*prefix
,
564 route_map_object_t type
, void *object
)
567 struct as_list
*as_list
;
568 struct bgp_info
*bgp_info
;
570 if (type
== RMAP_BGP
)
572 as_list
= as_list_lookup ((char *) rule
);
579 return ((as_list_apply (as_list
, bgp_info
->attr
->aspath
) == AS_FILTER_DENY
) ? RMAP_NOMATCH
: RMAP_MATCH
);
584 /* Compile function for as-path match. */
586 route_match_aspath_compile (const char *arg
)
588 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
591 /* Compile function for as-path match. */
593 route_match_aspath_free (void *rule
)
595 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
598 /* Route map commands for aspath matching. */
599 struct route_map_rule_cmd route_match_aspath_cmd
=
603 route_match_aspath_compile
,
604 route_match_aspath_free
607 /* `match community COMMUNIY' */
608 struct rmap_community
614 /* Match function for community match. */
615 static route_map_result_t
616 route_match_community (void *rule
, struct prefix
*prefix
,
617 route_map_object_t type
, void *object
)
619 struct community_list
*list
;
620 struct bgp_info
*bgp_info
;
621 struct rmap_community
*rcom
;
623 if (type
== RMAP_BGP
)
628 list
= community_list_lookup (bgp_clist
, rcom
->name
, COMMUNITY_LIST_MASTER
);
634 if (community_list_exact_match (bgp_info
->attr
->community
, list
))
639 if (community_list_match (bgp_info
->attr
->community
, list
))
646 /* Compile function for community match. */
648 route_match_community_compile (const char *arg
)
650 struct rmap_community
*rcom
;
654 rcom
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct rmap_community
));
656 p
= strchr (arg
, ' ');
660 rcom
->name
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, len
+ 1);
661 memcpy (rcom
->name
, arg
, len
);
666 rcom
->name
= XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
672 /* Compile function for community match. */
674 route_match_community_free (void *rule
)
676 struct rmap_community
*rcom
= rule
;
678 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rcom
->name
);
679 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rcom
);
682 /* Route map commands for community matching. */
683 struct route_map_rule_cmd route_match_community_cmd
=
686 route_match_community
,
687 route_match_community_compile
,
688 route_match_community_free
691 /* Match function for extcommunity match. */
692 static route_map_result_t
693 route_match_ecommunity (void *rule
, struct prefix
*prefix
,
694 route_map_object_t type
, void *object
)
696 struct community_list
*list
;
697 struct bgp_info
*bgp_info
;
699 if (type
== RMAP_BGP
)
703 if (!bgp_info
->attr
->extra
)
706 list
= community_list_lookup (bgp_clist
, (char *) rule
,
707 EXTCOMMUNITY_LIST_MASTER
);
711 if (ecommunity_list_match (bgp_info
->attr
->extra
->ecommunity
, list
))
717 /* Compile function for extcommunity match. */
719 route_match_ecommunity_compile (const char *arg
)
721 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
724 /* Compile function for extcommunity match. */
726 route_match_ecommunity_free (void *rule
)
728 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
731 /* Route map commands for community matching. */
732 struct route_map_rule_cmd route_match_ecommunity_cmd
=
735 route_match_ecommunity
,
736 route_match_ecommunity_compile
,
737 route_match_ecommunity_free
740 /* `match nlri` and `set nlri` are replaced by `address-family ipv4`
741 and `address-family vpnv4'. */
744 static route_map_result_t
745 route_match_origin (void *rule
, struct prefix
*prefix
,
746 route_map_object_t type
, void *object
)
749 struct bgp_info
*bgp_info
;
751 if (type
== RMAP_BGP
)
756 if (bgp_info
->attr
->origin
== *origin
)
764 route_match_origin_compile (const char *arg
)
768 origin
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_char
));
770 if (strcmp (arg
, "igp") == 0)
772 else if (strcmp (arg
, "egp") == 0)
780 /* Free route map's compiled `ip address' value. */
782 route_match_origin_free (void *rule
)
784 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
787 /* Route map commands for origin matching. */
788 struct route_map_rule_cmd route_match_origin_cmd
=
792 route_match_origin_compile
,
793 route_match_origin_free
796 /* match probability { */
798 static route_map_result_t
799 route_match_probability (void *rule
, struct prefix
*prefix
,
800 route_map_object_t type
, void *object
)
803 #if _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE >= 500
809 switch (*(unsigned *) rule
)
812 case RAND_MAX
: return RMAP_MATCH
;
814 if (r
< *(unsigned *) rule
)
824 route_match_probability_compile (const char *arg
)
829 #if _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE >= 500
830 srandom (time (NULL
));
836 lobule
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (unsigned));
840 case 0: *lobule
= 0; break;
841 case 100: *lobule
= RAND_MAX
; break;
842 default: *lobule
= RAND_MAX
/ 100 * perc
;
849 route_match_probability_free (void *rule
)
851 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
854 struct route_map_rule_cmd route_match_probability_cmd
=
857 route_match_probability
,
858 route_match_probability_compile
,
859 route_match_probability_free
864 /* `set ip next-hop IP_ADDRESS' */
866 /* Set nexthop to object. ojbect must be pointer to struct attr. */
867 struct rmap_ip_nexthop_set
869 struct in_addr
*address
;
873 static route_map_result_t
874 route_set_ip_nexthop (void *rule
, struct prefix
*prefix
,
875 route_map_object_t type
, void *object
)
877 struct rmap_ip_nexthop_set
*rins
= rule
;
878 struct bgp_info
*bgp_info
;
881 if (type
== RMAP_BGP
)
884 peer
= bgp_info
->peer
;
886 if (rins
->peer_address
)
888 if ((CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IN
) ||
889 CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IMPORT
))
891 && sockunion_family (peer
->su_remote
) == AF_INET
)
893 bgp_info
->attr
->nexthop
.s_addr
= sockunion2ip (peer
->su_remote
);
894 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
);
896 else if (CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
)
898 && sockunion_family (peer
->su_local
) == AF_INET
)
900 bgp_info
->attr
->nexthop
.s_addr
= sockunion2ip (peer
->su_local
);
901 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
);
906 /* Set next hop value. */
907 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
);
908 bgp_info
->attr
->nexthop
= *rins
->address
;
915 /* Route map `ip nexthop' compile function. Given string is converted
916 to struct in_addr structure. */
918 route_set_ip_nexthop_compile (const char *arg
)
920 struct rmap_ip_nexthop_set
*rins
;
921 struct in_addr
*address
= NULL
;
922 int peer_address
= 0;
925 if (strcmp (arg
, "peer-address") == 0)
929 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in_addr
));
930 ret
= inet_aton (arg
, address
);
934 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
939 rins
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct rmap_ip_nexthop_set
));
941 rins
->address
= address
;
942 rins
->peer_address
= peer_address
;
947 /* Free route map's compiled `ip nexthop' value. */
949 route_set_ip_nexthop_free (void *rule
)
951 struct rmap_ip_nexthop_set
*rins
= rule
;
954 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rins
->address
);
956 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rins
);
959 /* Route map commands for ip nexthop set. */
960 struct route_map_rule_cmd route_set_ip_nexthop_cmd
=
963 route_set_ip_nexthop
,
964 route_set_ip_nexthop_compile
,
965 route_set_ip_nexthop_free
968 /* `set local-preference LOCAL_PREF' */
970 /* Set local preference. */
971 static route_map_result_t
972 route_set_local_pref (void *rule
, struct prefix
*prefix
,
973 route_map_object_t type
, void *object
)
975 u_int32_t
*local_pref
;
976 struct bgp_info
*bgp_info
;
978 if (type
== RMAP_BGP
)
980 /* Fetch routemap's rule information. */
984 /* Set local preference value. */
985 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
);
986 bgp_info
->attr
->local_pref
= *local_pref
;
992 /* set local preference compilation. */
994 route_set_local_pref_compile (const char *arg
)
997 u_int32_t
*local_pref
;
1000 /* Local preference value shoud be integer. */
1001 if (! all_digit (arg
))
1005 tmp
= strtoul (arg
, &endptr
, 10);
1006 if (*endptr
!= '\0' || errno
|| tmp
> UINT32_MAX
)
1009 local_pref
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_int32_t
));
1019 /* Free route map's local preference value. */
1021 route_set_local_pref_free (void *rule
)
1023 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1026 /* Set local preference rule structure. */
1027 struct route_map_rule_cmd route_set_local_pref_cmd
=
1030 route_set_local_pref
,
1031 route_set_local_pref_compile
,
1032 route_set_local_pref_free
,
1035 /* `set weight WEIGHT' */
1038 static route_map_result_t
1039 route_set_weight (void *rule
, struct prefix
*prefix
, route_map_object_t type
,
1043 struct bgp_info
*bgp_info
;
1045 if (type
== RMAP_BGP
)
1047 /* Fetch routemap's rule information. */
1051 /* Set weight value. */
1053 (bgp_attr_extra_get (bgp_info
->attr
))->weight
= *weight
;
1054 else if (bgp_info
->attr
->extra
)
1055 bgp_info
->attr
->extra
->weight
= 0;
1061 /* set local preference compilation. */
1063 route_set_weight_compile (const char *arg
)
1067 char *endptr
= NULL
;
1069 /* Local preference value shoud be integer. */
1070 if (! all_digit (arg
))
1074 tmp
= strtoul (arg
, &endptr
, 10);
1075 if (*endptr
!= '\0' || errno
|| tmp
> UINT32_MAX
)
1078 weight
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_int32_t
));
1088 /* Free route map's local preference value. */
1090 route_set_weight_free (void *rule
)
1092 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1095 /* Set local preference rule structure. */
1096 struct route_map_rule_cmd route_set_weight_cmd
=
1100 route_set_weight_compile
,
1101 route_set_weight_free
,
1104 /* `set metric METRIC' */
1106 /* Set metric to attribute. */
1107 static route_map_result_t
1108 route_set_metric (void *rule
, struct prefix
*prefix
,
1109 route_map_object_t type
, void *object
)
1112 u_int32_t metric_val
;
1113 struct bgp_info
*bgp_info
;
1115 if (type
== RMAP_BGP
)
1117 /* Fetch routemap's rule information. */
1121 if (! (bgp_info
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
)))
1122 bgp_info
->attr
->med
= 0;
1123 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
1125 if (all_digit (metric
))
1127 metric_val
= strtoul (metric
, (char **)NULL
, 10);
1128 bgp_info
->attr
->med
= metric_val
;
1132 metric_val
= strtoul (metric
+1, (char **)NULL
, 10);
1134 if (strncmp (metric
, "+", 1) == 0)
1136 if (bgp_info
->attr
->med
/2 + metric_val
/2 > BGP_MED_MAX
/2)
1137 bgp_info
->attr
->med
= BGP_MED_MAX
- 1;
1139 bgp_info
->attr
->med
+= metric_val
;
1141 else if (strncmp (metric
, "-", 1) == 0)
1143 if (bgp_info
->attr
->med
<= metric_val
)
1144 bgp_info
->attr
->med
= 0;
1146 bgp_info
->attr
->med
-= metric_val
;
1153 /* set metric compilation. */
1155 route_set_metric_compile (const char *arg
)
1159 char *endptr
= NULL
;
1161 if (all_digit (arg
))
1163 /* set metric value check*/
1165 larg
= strtoul (arg
, &endptr
, 10);
1166 if (*endptr
!= '\0' || errno
|| larg
> UINT32_MAX
)
1172 /* set metric +/-value check */
1173 if ((strncmp (arg
, "+", 1) != 0
1174 && strncmp (arg
, "-", 1) != 0)
1175 || (! all_digit (arg
+1)))
1179 larg
= strtoul (arg
+1, &endptr
, 10);
1180 if (*endptr
!= '\0' || errno
|| larg
> UINT32_MAX
)
1185 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
1188 /* Free route map's compiled `set metric' value. */
1190 route_set_metric_free (void *rule
)
1192 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1195 /* Set metric rule structure. */
1196 struct route_map_rule_cmd route_set_metric_cmd
=
1200 route_set_metric_compile
,
1201 route_set_metric_free
,
1204 /* `set as-path prepend ASPATH' */
1206 /* For AS path prepend mechanism. */
1207 static route_map_result_t
1208 route_set_aspath_prepend (void *rule
, struct prefix
*prefix
, route_map_object_t type
, void *object
)
1210 struct aspath
*aspath
;
1212 struct bgp_info
*binfo
;
1214 if (type
== RMAP_BGP
)
1219 if (binfo
->attr
->aspath
->refcnt
)
1220 new = aspath_dup (binfo
->attr
->aspath
);
1222 new = binfo
->attr
->aspath
;
1224 aspath_prepend (aspath
, new);
1225 binfo
->attr
->aspath
= new;
1231 /* Compile function for as-path prepend. */
1233 route_set_aspath_prepend_compile (const char *arg
)
1235 struct aspath
*aspath
;
1237 aspath
= aspath_str2aspath (arg
);
1243 /* Compile function for as-path prepend. */
1245 route_set_aspath_prepend_free (void *rule
)
1247 struct aspath
*aspath
= rule
;
1248 aspath_free (aspath
);
1251 /* Set metric rule structure. */
1252 struct route_map_rule_cmd route_set_aspath_prepend_cmd
=
1255 route_set_aspath_prepend
,
1256 route_set_aspath_prepend_compile
,
1257 route_set_aspath_prepend_free
,
1260 /* `set as-path exclude ASn' */
1262 /* For ASN exclude mechanism.
1263 * Iterate over ASns requested and filter them from the given AS_PATH one by one.
1264 * Make a deep copy of existing AS_PATH, but for the first ASn only.
1266 static route_map_result_t
1267 route_set_aspath_exclude (void *rule
, struct prefix
*dummy
, route_map_object_t type
, void *object
)
1269 struct aspath
* new_path
, * exclude_path
;
1270 struct bgp_info
*binfo
;
1272 if (type
== RMAP_BGP
)
1274 exclude_path
= rule
;
1276 if (binfo
->attr
->aspath
->refcnt
)
1277 new_path
= aspath_dup (binfo
->attr
->aspath
);
1279 new_path
= binfo
->attr
->aspath
;
1280 binfo
->attr
->aspath
= aspath_filter_exclude (new_path
, exclude_path
);
1285 /* FIXME: consider using route_set_aspath_prepend_compile() and
1286 * route_set_aspath_prepend_free(), which two below function are
1290 /* Compile function for as-path exclude. */
1292 route_set_aspath_exclude_compile (const char *arg
)
1294 struct aspath
*aspath
;
1296 aspath
= aspath_str2aspath (arg
);
1303 route_set_aspath_exclude_free (void *rule
)
1305 struct aspath
*aspath
= rule
;
1306 aspath_free (aspath
);
1309 /* Set ASn exlude rule structure. */
1310 struct route_map_rule_cmd route_set_aspath_exclude_cmd
=
1313 route_set_aspath_exclude
,
1314 route_set_aspath_exclude_compile
,
1315 route_set_aspath_exclude_free
,
1318 /* `set community COMMUNITY' */
1321 struct community
*com
;
1326 /* For community set mechanism. */
1327 static route_map_result_t
1328 route_set_community (void *rule
, struct prefix
*prefix
,
1329 route_map_object_t type
, void *object
)
1331 struct rmap_com_set
*rcs
;
1332 struct bgp_info
*binfo
;
1334 struct community
*new = NULL
;
1335 struct community
*old
;
1336 struct community
*merge
;
1338 if (type
== RMAP_BGP
)
1343 old
= attr
->community
;
1348 attr
->flag
&= ~(ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
));
1349 attr
->community
= NULL
;
1350 /* See the longer comment down below. */
1351 if (old
&& old
->refcnt
== 0)
1352 community_free(old
);
1356 /* "additive" case. */
1357 if (rcs
->additive
&& old
)
1359 merge
= community_merge (community_dup (old
), rcs
->com
);
1361 /* HACK: if the old community is not intern'd,
1362 * we should free it here, or all reference to it may be lost.
1363 * Really need to cleanup attribute caching sometime.
1365 if (old
->refcnt
== 0)
1366 community_free (old
);
1367 new = community_uniq_sort (merge
);
1368 community_free (merge
);
1371 new = community_dup (rcs
->com
);
1373 /* will be interned by caller if required */
1374 attr
->community
= new;
1376 attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
);
1382 /* Compile function for set community. */
1384 route_set_community_compile (const char *arg
)
1386 struct rmap_com_set
*rcs
;
1387 struct community
*com
= NULL
;
1392 if (strcmp (arg
, "none") == 0)
1396 sp
= strstr (arg
, "additive");
1400 /* "additive" keyworkd is included. */
1405 com
= community_str2com (arg
);
1414 rcs
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct rmap_com_set
));
1416 rcs
->additive
= additive
;
1422 /* Free function for set community. */
1424 route_set_community_free (void *rule
)
1426 struct rmap_com_set
*rcs
= rule
;
1429 community_free (rcs
->com
);
1430 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rcs
);
1433 /* Set community rule structure. */
1434 struct route_map_rule_cmd route_set_community_cmd
=
1437 route_set_community
,
1438 route_set_community_compile
,
1439 route_set_community_free
,
1442 /* `set comm-list (<1-99>|<100-500>|WORD) delete' */
1444 /* For community set mechanism. */
1445 static route_map_result_t
1446 route_set_community_delete (void *rule
, struct prefix
*prefix
,
1447 route_map_object_t type
, void *object
)
1449 struct community_list
*list
;
1450 struct community
*merge
;
1451 struct community
*new;
1452 struct community
*old
;
1453 struct bgp_info
*binfo
;
1455 if (type
== RMAP_BGP
)
1461 list
= community_list_lookup (bgp_clist
, rule
, COMMUNITY_LIST_MASTER
);
1462 old
= binfo
->attr
->community
;
1466 merge
= community_list_match_delete (community_dup (old
), list
);
1467 new = community_uniq_sort (merge
);
1468 community_free (merge
);
1470 /* HACK: if the old community is not intern'd,
1471 * we should free it here, or all reference to it may be lost.
1472 * Really need to cleanup attribute caching sometime.
1474 if (old
->refcnt
== 0)
1475 community_free (old
);
1479 binfo
->attr
->community
= NULL
;
1480 binfo
->attr
->flag
&= ~ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
);
1481 community_free (new);
1485 binfo
->attr
->community
= new;
1486 binfo
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
);
1494 /* Compile function for set community. */
1496 route_set_community_delete_compile (const char *arg
)
1502 p
= strchr (arg
, ' ');
1506 str
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, len
+ 1);
1507 memcpy (str
, arg
, len
);
1515 /* Free function for set community. */
1517 route_set_community_delete_free (void *rule
)
1519 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1522 /* Set community rule structure. */
1523 struct route_map_rule_cmd route_set_community_delete_cmd
=
1526 route_set_community_delete
,
1527 route_set_community_delete_compile
,
1528 route_set_community_delete_free
,
1531 /* `set extcommunity rt COMMUNITY' */
1533 /* For community set mechanism. */
1534 static route_map_result_t
1535 route_set_ecommunity_rt (void *rule
, struct prefix
*prefix
,
1536 route_map_object_t type
, void *object
)
1538 struct ecommunity
*ecom
;
1539 struct ecommunity
*new_ecom
;
1540 struct ecommunity
*old_ecom
;
1541 struct bgp_info
*bgp_info
;
1543 if (type
== RMAP_BGP
)
1551 /* We assume additive for Extended Community. */
1552 old_ecom
= (bgp_attr_extra_get (bgp_info
->attr
))->ecommunity
;
1555 new_ecom
= ecommunity_merge (ecommunity_dup (old_ecom
), ecom
);
1557 new_ecom
= ecommunity_dup (ecom
);
1559 bgp_info
->attr
->extra
->ecommunity
= ecommunity_intern (new_ecom
);
1562 ecommunity_unintern (&old_ecom
);
1564 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES
);
1569 /* Compile function for set community. */
1571 route_set_ecommunity_rt_compile (const char *arg
)
1573 struct ecommunity
*ecom
;
1575 ecom
= ecommunity_str2com (arg
, ECOMMUNITY_ROUTE_TARGET
, 0);
1578 return ecommunity_intern (ecom
);
1581 /* Free function for set community. */
1583 route_set_ecommunity_rt_free (void *rule
)
1585 struct ecommunity
*ecom
= rule
;
1586 ecommunity_unintern (&ecom
);
1589 /* Set community rule structure. */
1590 struct route_map_rule_cmd route_set_ecommunity_rt_cmd
=
1593 route_set_ecommunity_rt
,
1594 route_set_ecommunity_rt_compile
,
1595 route_set_ecommunity_rt_free
,
1598 /* `set extcommunity soo COMMUNITY' */
1600 /* For community set mechanism. */
1601 static route_map_result_t
1602 route_set_ecommunity_soo (void *rule
, struct prefix
*prefix
,
1603 route_map_object_t type
, void *object
)
1605 struct ecommunity
*ecom
, *old_ecom
, *new_ecom
;
1606 struct bgp_info
*bgp_info
;
1608 if (type
== RMAP_BGP
)
1616 old_ecom
= (bgp_attr_extra_get (bgp_info
->attr
))->ecommunity
;
1619 new_ecom
= ecommunity_merge (ecommunity_dup (old_ecom
), ecom
);
1621 new_ecom
= ecommunity_dup (ecom
);
1623 bgp_info
->attr
->extra
->ecommunity
= ecommunity_intern (new_ecom
);
1626 ecommunity_unintern (&old_ecom
);
1628 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES
);
1633 /* Compile function for set community. */
1635 route_set_ecommunity_soo_compile (const char *arg
)
1637 struct ecommunity
*ecom
;
1639 ecom
= ecommunity_str2com (arg
, ECOMMUNITY_SITE_ORIGIN
, 0);
1643 return ecommunity_intern (ecom
);
1646 /* Free function for set community. */
1648 route_set_ecommunity_soo_free (void *rule
)
1650 struct ecommunity
*ecom
= rule
;
1651 ecommunity_unintern (&ecom
);
1654 /* Set community rule structure. */
1655 struct route_map_rule_cmd route_set_ecommunity_soo_cmd
=
1658 route_set_ecommunity_soo
,
1659 route_set_ecommunity_soo_compile
,
1660 route_set_ecommunity_soo_free
,
1663 /* `set origin ORIGIN' */
1665 /* For origin set. */
1666 static route_map_result_t
1667 route_set_origin (void *rule
, struct prefix
*prefix
, route_map_object_t type
, void *object
)
1670 struct bgp_info
*bgp_info
;
1672 if (type
== RMAP_BGP
)
1677 bgp_info
->attr
->origin
= *origin
;
1683 /* Compile function for origin set. */
1685 route_set_origin_compile (const char *arg
)
1689 origin
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_char
));
1691 if (strcmp (arg
, "igp") == 0)
1693 else if (strcmp (arg
, "egp") == 0)
1701 /* Compile function for origin set. */
1703 route_set_origin_free (void *rule
)
1705 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1708 /* Set metric rule structure. */
1709 struct route_map_rule_cmd route_set_origin_cmd
=
1713 route_set_origin_compile
,
1714 route_set_origin_free
,
1717 /* `set atomic-aggregate' */
1719 /* For atomic aggregate set. */
1720 static route_map_result_t
1721 route_set_atomic_aggregate (void *rule
, struct prefix
*prefix
,
1722 route_map_object_t type
, void *object
)
1724 struct bgp_info
*bgp_info
;
1726 if (type
== RMAP_BGP
)
1729 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
1735 /* Compile function for atomic aggregate. */
1737 route_set_atomic_aggregate_compile (const char *arg
)
1742 /* Compile function for atomic aggregate. */
1744 route_set_atomic_aggregate_free (void *rule
)
1749 /* Set atomic aggregate rule structure. */
1750 struct route_map_rule_cmd route_set_atomic_aggregate_cmd
=
1753 route_set_atomic_aggregate
,
1754 route_set_atomic_aggregate_compile
,
1755 route_set_atomic_aggregate_free
,
1758 /* `set aggregator as AS A.B.C.D' */
1762 struct in_addr address
;
1765 static route_map_result_t
1766 route_set_aggregator_as (void *rule
, struct prefix
*prefix
,
1767 route_map_object_t type
, void *object
)
1769 struct bgp_info
*bgp_info
;
1770 struct aggregator
*aggregator
;
1771 struct attr_extra
*ae
;
1773 if (type
== RMAP_BGP
)
1777 ae
= bgp_attr_extra_get (bgp_info
->attr
);
1779 ae
->aggregator_as
= aggregator
->as
;
1780 ae
->aggregator_addr
= aggregator
->address
;
1781 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
);
1788 route_set_aggregator_as_compile (const char *arg
)
1790 struct aggregator
*aggregator
;
1794 aggregator
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct aggregator
));
1795 sscanf (arg
, "%s %s", as
, address
);
1797 aggregator
->as
= strtoul (as
, NULL
, 10);
1798 inet_aton (address
, &aggregator
->address
);
1804 route_set_aggregator_as_free (void *rule
)
1806 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1809 struct route_map_rule_cmd route_set_aggregator_as_cmd
=
1812 route_set_aggregator_as
,
1813 route_set_aggregator_as_compile
,
1814 route_set_aggregator_as_free
,
1818 /* `match ipv6 address IP_ACCESS_LIST' */
1820 static route_map_result_t
1821 route_match_ipv6_address (void *rule
, struct prefix
*prefix
,
1822 route_map_object_t type
, void *object
)
1824 struct access_list
*alist
;
1826 if (type
== RMAP_BGP
)
1828 alist
= access_list_lookup (AFI_IP6
, (char *) rule
);
1830 return RMAP_NOMATCH
;
1832 return (access_list_apply (alist
, prefix
) == FILTER_DENY
?
1833 RMAP_NOMATCH
: RMAP_MATCH
);
1835 return RMAP_NOMATCH
;
1839 route_match_ipv6_address_compile (const char *arg
)
1841 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
1845 route_match_ipv6_address_free (void *rule
)
1847 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1850 /* Route map commands for ip address matching. */
1851 struct route_map_rule_cmd route_match_ipv6_address_cmd
=
1854 route_match_ipv6_address
,
1855 route_match_ipv6_address_compile
,
1856 route_match_ipv6_address_free
1859 /* `match ipv6 next-hop IP_ADDRESS' */
1861 static route_map_result_t
1862 route_match_ipv6_next_hop (void *rule
, struct prefix
*prefix
,
1863 route_map_object_t type
, void *object
)
1865 struct in6_addr
*addr
;
1866 struct bgp_info
*bgp_info
;
1868 if (type
== RMAP_BGP
)
1873 if (!bgp_info
->attr
->extra
)
1874 return RMAP_NOMATCH
;
1876 if (IPV6_ADDR_SAME (&bgp_info
->attr
->extra
->mp_nexthop_global
, rule
))
1879 if (bgp_info
->attr
->extra
->mp_nexthop_len
== 32 &&
1880 IPV6_ADDR_SAME (&bgp_info
->attr
->extra
->mp_nexthop_local
, rule
))
1883 return RMAP_NOMATCH
;
1886 return RMAP_NOMATCH
;
1890 route_match_ipv6_next_hop_compile (const char *arg
)
1892 struct in6_addr
*address
;
1895 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in6_addr
));
1897 ret
= inet_pton (AF_INET6
, arg
, address
);
1900 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
1908 route_match_ipv6_next_hop_free (void *rule
)
1910 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1913 struct route_map_rule_cmd route_match_ipv6_next_hop_cmd
=
1916 route_match_ipv6_next_hop
,
1917 route_match_ipv6_next_hop_compile
,
1918 route_match_ipv6_next_hop_free
1921 /* `match ipv6 address prefix-list PREFIX_LIST' */
1923 static route_map_result_t
1924 route_match_ipv6_address_prefix_list (void *rule
, struct prefix
*prefix
,
1925 route_map_object_t type
, void *object
)
1927 struct prefix_list
*plist
;
1929 if (type
== RMAP_BGP
)
1931 plist
= prefix_list_lookup (AFI_IP6
, (char *) rule
);
1933 return RMAP_NOMATCH
;
1935 return (prefix_list_apply (plist
, prefix
) == PREFIX_DENY
?
1936 RMAP_NOMATCH
: RMAP_MATCH
);
1938 return RMAP_NOMATCH
;
1942 route_match_ipv6_address_prefix_list_compile (const char *arg
)
1944 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
1948 route_match_ipv6_address_prefix_list_free (void *rule
)
1950 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1953 struct route_map_rule_cmd route_match_ipv6_address_prefix_list_cmd
=
1955 "ipv6 address prefix-list",
1956 route_match_ipv6_address_prefix_list
,
1957 route_match_ipv6_address_prefix_list_compile
,
1958 route_match_ipv6_address_prefix_list_free
1961 /* `set ipv6 nexthop global IP_ADDRESS' */
1963 /* Set nexthop to object. ojbect must be pointer to struct attr. */
1964 static route_map_result_t
1965 route_set_ipv6_nexthop_global (void *rule
, struct prefix
*prefix
,
1966 route_map_object_t type
, void *object
)
1968 struct in6_addr
*address
;
1969 struct bgp_info
*bgp_info
;
1971 if (type
== RMAP_BGP
)
1973 /* Fetch routemap's rule information. */
1977 /* Set next hop value. */
1978 (bgp_attr_extra_get (bgp_info
->attr
))->mp_nexthop_global
= *address
;
1980 /* Set nexthop length. */
1981 if (bgp_info
->attr
->extra
->mp_nexthop_len
== 0)
1982 bgp_info
->attr
->extra
->mp_nexthop_len
= 16;
1988 /* Route map `ip next-hop' compile function. Given string is converted
1989 to struct in_addr structure. */
1991 route_set_ipv6_nexthop_global_compile (const char *arg
)
1994 struct in6_addr
*address
;
1996 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in6_addr
));
1998 ret
= inet_pton (AF_INET6
, arg
, address
);
2002 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
2009 /* Free route map's compiled `ip next-hop' value. */
2011 route_set_ipv6_nexthop_global_free (void *rule
)
2013 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2016 /* Route map commands for ip nexthop set. */
2017 struct route_map_rule_cmd route_set_ipv6_nexthop_global_cmd
=
2019 "ipv6 next-hop global",
2020 route_set_ipv6_nexthop_global
,
2021 route_set_ipv6_nexthop_global_compile
,
2022 route_set_ipv6_nexthop_global_free
2025 /* `set ipv6 nexthop local IP_ADDRESS' */
2027 /* Set nexthop to object. ojbect must be pointer to struct attr. */
2028 static route_map_result_t
2029 route_set_ipv6_nexthop_local (void *rule
, struct prefix
*prefix
,
2030 route_map_object_t type
, void *object
)
2032 struct in6_addr
*address
;
2033 struct bgp_info
*bgp_info
;
2035 if (type
== RMAP_BGP
)
2037 /* Fetch routemap's rule information. */
2041 /* Set next hop value. */
2042 (bgp_attr_extra_get (bgp_info
->attr
))->mp_nexthop_local
= *address
;
2044 /* Set nexthop length. */
2045 if (bgp_info
->attr
->extra
->mp_nexthop_len
!= 32)
2046 bgp_info
->attr
->extra
->mp_nexthop_len
= 32;
2052 /* Route map `ip nexthop' compile function. Given string is converted
2053 to struct in_addr structure. */
2055 route_set_ipv6_nexthop_local_compile (const char *arg
)
2058 struct in6_addr
*address
;
2060 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in6_addr
));
2062 ret
= inet_pton (AF_INET6
, arg
, address
);
2066 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
2073 /* Free route map's compiled `ip nexthop' value. */
2075 route_set_ipv6_nexthop_local_free (void *rule
)
2077 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2080 /* Route map commands for ip nexthop set. */
2081 struct route_map_rule_cmd route_set_ipv6_nexthop_local_cmd
=
2083 "ipv6 next-hop local",
2084 route_set_ipv6_nexthop_local
,
2085 route_set_ipv6_nexthop_local_compile
,
2086 route_set_ipv6_nexthop_local_free
2088 #endif /* HAVE_IPV6 */
2090 /* `set vpnv4 nexthop A.B.C.D' */
2092 static route_map_result_t
2093 route_set_vpnv4_nexthop (void *rule
, struct prefix
*prefix
,
2094 route_map_object_t type
, void *object
)
2096 struct in_addr
*address
;
2097 struct bgp_info
*bgp_info
;
2099 if (type
== RMAP_BGP
)
2101 /* Fetch routemap's rule information. */
2105 /* Set next hop value. */
2106 (bgp_attr_extra_get (bgp_info
->attr
))->mp_nexthop_global_in
= *address
;
2113 route_set_vpnv4_nexthop_compile (const char *arg
)
2116 struct in_addr
*address
;
2118 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in_addr
));
2120 ret
= inet_aton (arg
, address
);
2124 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
2132 route_set_vpnv4_nexthop_free (void *rule
)
2134 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2137 /* Route map commands for ip nexthop set. */
2138 struct route_map_rule_cmd route_set_vpnv4_nexthop_cmd
=
2141 route_set_vpnv4_nexthop
,
2142 route_set_vpnv4_nexthop_compile
,
2143 route_set_vpnv4_nexthop_free
2146 /* `set originator-id' */
2148 /* For origin set. */
2149 static route_map_result_t
2150 route_set_originator_id (void *rule
, struct prefix
*prefix
, route_map_object_t type
, void *object
)
2152 struct in_addr
*address
;
2153 struct bgp_info
*bgp_info
;
2155 if (type
== RMAP_BGP
)
2160 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
);
2161 (bgp_attr_extra_get (bgp_info
->attr
))->originator_id
= *address
;
2167 /* Compile function for originator-id set. */
2169 route_set_originator_id_compile (const char *arg
)
2172 struct in_addr
*address
;
2174 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in_addr
));
2176 ret
= inet_aton (arg
, address
);
2180 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
2187 /* Compile function for originator_id set. */
2189 route_set_originator_id_free (void *rule
)
2191 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2194 /* Set metric rule structure. */
2195 struct route_map_rule_cmd route_set_originator_id_cmd
=
2198 route_set_originator_id
,
2199 route_set_originator_id_compile
,
2200 route_set_originator_id_free
,
2203 /* Add bgp route map rule. */
2205 bgp_route_match_add (struct vty
*vty
, struct route_map_index
*index
,
2206 const char *command
, const char *arg
)
2210 ret
= route_map_add_match (index
, command
, arg
);
2215 case RMAP_RULE_MISSING
:
2216 vty_out (vty
, "%% Can't find rule.%s", VTY_NEWLINE
);
2218 case RMAP_COMPILE_ERROR
:
2219 vty_out (vty
, "%% Argument is malformed.%s", VTY_NEWLINE
);
2226 /* Delete bgp route map rule. */
2228 bgp_route_match_delete (struct vty
*vty
, struct route_map_index
*index
,
2229 const char *command
, const char *arg
)
2233 ret
= route_map_delete_match (index
, command
, arg
);
2238 case RMAP_RULE_MISSING
:
2239 vty_out (vty
, "%% Can't find rule.%s", VTY_NEWLINE
);
2241 case RMAP_COMPILE_ERROR
:
2242 vty_out (vty
, "%% Argument is malformed.%s", VTY_NEWLINE
);
2249 /* Add bgp route map rule. */
2251 bgp_route_set_add (struct vty
*vty
, struct route_map_index
*index
,
2252 const char *command
, const char *arg
)
2256 ret
= route_map_add_set (index
, command
, arg
);
2261 case RMAP_RULE_MISSING
:
2262 vty_out (vty
, "%% Can't find rule.%s", VTY_NEWLINE
);
2264 case RMAP_COMPILE_ERROR
:
2265 vty_out (vty
, "%% Argument is malformed.%s", VTY_NEWLINE
);
2272 /* Delete bgp route map rule. */
2274 bgp_route_set_delete (struct vty
*vty
, struct route_map_index
*index
,
2275 const char *command
, const char *arg
)
2279 ret
= route_map_delete_set (index
, command
, arg
);
2284 case RMAP_RULE_MISSING
:
2285 vty_out (vty
, "%% Can't find rule.%s", VTY_NEWLINE
);
2287 case RMAP_COMPILE_ERROR
:
2288 vty_out (vty
, "%% Argument is malformed.%s", VTY_NEWLINE
);
2295 /* Hook function for updating route_map assignment. */
2297 bgp_route_map_update (const char *unused
)
2303 struct listnode
*node
, *nnode
;
2304 struct listnode
*mnode
, *mnnode
;
2307 struct peer_group
*group
;
2308 struct bgp_filter
*filter
;
2309 struct bgp_node
*bn
;
2310 struct bgp_static
*bgp_static
;
2312 /* For neighbor route-map updates. */
2313 for (ALL_LIST_ELEMENTS (bm
->bgp
, mnode
, mnnode
, bgp
))
2315 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
2317 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2318 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2320 filter
= &peer
->filter
[afi
][safi
];
2322 for (direct
= RMAP_IN
; direct
< RMAP_MAX
; direct
++)
2324 if (filter
->map
[direct
].name
)
2325 filter
->map
[direct
].map
=
2326 route_map_lookup_by_name (filter
->map
[direct
].name
);
2328 filter
->map
[direct
].map
= NULL
;
2331 if (filter
->usmap
.name
)
2332 filter
->usmap
.map
= route_map_lookup_by_name (filter
->usmap
.name
);
2334 filter
->usmap
.map
= NULL
;
2337 for (ALL_LIST_ELEMENTS (bgp
->group
, node
, nnode
, group
))
2339 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2340 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2342 filter
= &group
->conf
->filter
[afi
][safi
];
2344 for (direct
= RMAP_IN
; direct
< RMAP_MAX
; direct
++)
2346 if (filter
->map
[direct
].name
)
2347 filter
->map
[direct
].map
=
2348 route_map_lookup_by_name (filter
->map
[direct
].name
);
2350 filter
->map
[direct
].map
= NULL
;
2353 if (filter
->usmap
.name
)
2354 filter
->usmap
.map
= route_map_lookup_by_name (filter
->usmap
.name
);
2356 filter
->usmap
.map
= NULL
;
2361 /* For default-originate route-map updates. */
2362 for (ALL_LIST_ELEMENTS (bm
->bgp
, mnode
, mnnode
, bgp
))
2364 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
2366 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2367 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2369 if (peer
->default_rmap
[afi
][safi
].name
)
2370 peer
->default_rmap
[afi
][safi
].map
=
2371 route_map_lookup_by_name (peer
->default_rmap
[afi
][safi
].name
);
2373 peer
->default_rmap
[afi
][safi
].map
= NULL
;
2378 /* For network route-map updates. */
2379 for (ALL_LIST_ELEMENTS (bm
->bgp
, mnode
, mnnode
, bgp
))
2381 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2382 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2383 for (bn
= bgp_table_top (bgp
->route
[afi
][safi
]); bn
;
2384 bn
= bgp_route_next (bn
))
2385 if ((bgp_static
= bn
->info
) != NULL
)
2387 if (bgp_static
->rmap
.name
)
2388 bgp_static
->rmap
.map
=
2389 route_map_lookup_by_name (bgp_static
->rmap
.name
);
2391 bgp_static
->rmap
.map
= NULL
;
2395 /* For redistribute route-map updates. */
2396 for (ALL_LIST_ELEMENTS (bm
->bgp
, mnode
, mnnode
, bgp
))
2398 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++)
2400 if (bgp
->rmap
[ZEBRA_FAMILY_IPV4
][i
].name
)
2401 bgp
->rmap
[ZEBRA_FAMILY_IPV4
][i
].map
=
2402 route_map_lookup_by_name (bgp
->rmap
[ZEBRA_FAMILY_IPV4
][i
].name
);
2404 if (bgp
->rmap
[ZEBRA_FAMILY_IPV6
][i
].name
)
2405 bgp
->rmap
[ZEBRA_FAMILY_IPV6
][i
].map
=
2406 route_map_lookup_by_name (bgp
->rmap
[ZEBRA_FAMILY_IPV6
][i
].name
);
2407 #endif /* HAVE_IPV6 */
2414 "match peer (A.B.C.D|X:X::X:X)",
2416 "Match peer address\n"
2417 "IPv6 address of peer\n"
2418 "IP address of peer\n")
2420 return bgp_route_match_add (vty
, vty
->index
, "peer", argv
[0]);
2423 DEFUN (match_peer_local
,
2424 match_peer_local_cmd
,
2427 "Match peer address\n"
2428 "Static or Redistributed routes\n")
2430 return bgp_route_match_add (vty
, vty
->index
, "peer", "local");
2433 DEFUN (no_match_peer
,
2438 "Match peer address\n")
2441 return bgp_route_match_delete (vty
, vty
->index
, "peer", NULL
);
2443 return bgp_route_match_delete (vty
, vty
->index
, "peer", argv
[0]);
2446 ALIAS (no_match_peer
,
2447 no_match_peer_val_cmd
,
2448 "no match peer (A.B.C.D|X:X::X:X)",
2451 "Match peer address\n"
2452 "IPv6 address of peer\n"
2453 "IP address of peer\n")
2455 ALIAS (no_match_peer
,
2456 no_match_peer_local_cmd
,
2457 "no match peer local",
2460 "Match peer address\n"
2461 "Static or Redistributed routes\n")
2463 DEFUN (match_ip_address
,
2464 match_ip_address_cmd
,
2465 "match ip address (<1-199>|<1300-2699>|WORD)",
2468 "Match address of route\n"
2469 "IP access-list number\n"
2470 "IP access-list number (expanded range)\n"
2471 "IP Access-list name\n")
2473 return bgp_route_match_add (vty
, vty
->index
, "ip address", argv
[0]);
2476 DEFUN (no_match_ip_address
,
2477 no_match_ip_address_cmd
,
2478 "no match ip address",
2482 "Match address of route\n")
2485 return bgp_route_match_delete (vty
, vty
->index
, "ip address", NULL
);
2487 return bgp_route_match_delete (vty
, vty
->index
, "ip address", argv
[0]);
2490 ALIAS (no_match_ip_address
,
2491 no_match_ip_address_val_cmd
,
2492 "no match ip address (<1-199>|<1300-2699>|WORD)",
2496 "Match address of route\n"
2497 "IP access-list number\n"
2498 "IP access-list number (expanded range)\n"
2499 "IP Access-list name\n")
2501 DEFUN (match_ip_next_hop
,
2502 match_ip_next_hop_cmd
,
2503 "match ip next-hop (<1-199>|<1300-2699>|WORD)",
2506 "Match next-hop address of route\n"
2507 "IP access-list number\n"
2508 "IP access-list number (expanded range)\n"
2509 "IP Access-list name\n")
2511 return bgp_route_match_add (vty
, vty
->index
, "ip next-hop", argv
[0]);
2514 DEFUN (no_match_ip_next_hop
,
2515 no_match_ip_next_hop_cmd
,
2516 "no match ip next-hop",
2520 "Match next-hop address of route\n")
2523 return bgp_route_match_delete (vty
, vty
->index
, "ip next-hop", NULL
);
2525 return bgp_route_match_delete (vty
, vty
->index
, "ip next-hop", argv
[0]);
2528 ALIAS (no_match_ip_next_hop
,
2529 no_match_ip_next_hop_val_cmd
,
2530 "no match ip next-hop (<1-199>|<1300-2699>|WORD)",
2534 "Match next-hop address of route\n"
2535 "IP access-list number\n"
2536 "IP access-list number (expanded range)\n"
2537 "IP Access-list name\n")
2539 /* match probability { */
2541 DEFUN (match_probability
,
2542 match_probability_cmd
,
2543 "match probability <0-100>",
2545 "Match portion of routes defined by percentage value\n"
2546 "Percentage of routes\n")
2548 return bgp_route_match_add (vty
, vty
->index
, "probability", argv
[0]);
2551 DEFUN (no_match_probability
,
2552 no_match_probability_cmd
,
2553 "no match probability",
2556 "Match portion of routes defined by percentage value\n")
2558 return bgp_route_match_delete (vty
, vty
->index
, "probability", argc
? argv
[0] : NULL
);
2561 ALIAS (no_match_probability
,
2562 no_match_probability_val_cmd
,
2563 "no match probability <1-99>",
2566 "Match portion of routes defined by percentage value\n"
2567 "Percentage of routes\n")
2571 DEFUN (match_ip_route_source
,
2572 match_ip_route_source_cmd
,
2573 "match ip route-source (<1-199>|<1300-2699>|WORD)",
2576 "Match advertising source address of route\n"
2577 "IP access-list number\n"
2578 "IP access-list number (expanded range)\n"
2579 "IP standard access-list name\n")
2581 return bgp_route_match_add (vty
, vty
->index
, "ip route-source", argv
[0]);
2584 DEFUN (no_match_ip_route_source
,
2585 no_match_ip_route_source_cmd
,
2586 "no match ip route-source",
2590 "Match advertising source address of route\n")
2593 return bgp_route_match_delete (vty
, vty
->index
, "ip route-source", NULL
);
2595 return bgp_route_match_delete (vty
, vty
->index
, "ip route-source", argv
[0]);
2598 ALIAS (no_match_ip_route_source
,
2599 no_match_ip_route_source_val_cmd
,
2600 "no match ip route-source (<1-199>|<1300-2699>|WORD)",
2604 "Match advertising source address of route\n"
2605 "IP access-list number\n"
2606 "IP access-list number (expanded range)\n"
2607 "IP standard access-list name\n")
2609 DEFUN (match_ip_address_prefix_list
,
2610 match_ip_address_prefix_list_cmd
,
2611 "match ip address prefix-list WORD",
2614 "Match address of route\n"
2615 "Match entries of prefix-lists\n"
2616 "IP prefix-list name\n")
2618 return bgp_route_match_add (vty
, vty
->index
, "ip address prefix-list", argv
[0]);
2621 DEFUN (no_match_ip_address_prefix_list
,
2622 no_match_ip_address_prefix_list_cmd
,
2623 "no match ip address prefix-list",
2627 "Match address of route\n"
2628 "Match entries of prefix-lists\n")
2631 return bgp_route_match_delete (vty
, vty
->index
, "ip address prefix-list", NULL
);
2633 return bgp_route_match_delete (vty
, vty
->index
, "ip address prefix-list", argv
[0]);
2636 ALIAS (no_match_ip_address_prefix_list
,
2637 no_match_ip_address_prefix_list_val_cmd
,
2638 "no match ip address prefix-list WORD",
2642 "Match address of route\n"
2643 "Match entries of prefix-lists\n"
2644 "IP prefix-list name\n")
2646 DEFUN (match_ip_next_hop_prefix_list
,
2647 match_ip_next_hop_prefix_list_cmd
,
2648 "match ip next-hop prefix-list WORD",
2651 "Match next-hop address of route\n"
2652 "Match entries of prefix-lists\n"
2653 "IP prefix-list name\n")
2655 return bgp_route_match_add (vty
, vty
->index
, "ip next-hop prefix-list", argv
[0]);
2658 DEFUN (no_match_ip_next_hop_prefix_list
,
2659 no_match_ip_next_hop_prefix_list_cmd
,
2660 "no match ip next-hop prefix-list",
2664 "Match next-hop address of route\n"
2665 "Match entries of prefix-lists\n")
2668 return bgp_route_match_delete (vty
, vty
->index
, "ip next-hop prefix-list", NULL
);
2670 return bgp_route_match_delete (vty
, vty
->index
, "ip next-hop prefix-list", argv
[0]);
2673 ALIAS (no_match_ip_next_hop_prefix_list
,
2674 no_match_ip_next_hop_prefix_list_val_cmd
,
2675 "no match ip next-hop prefix-list WORD",
2679 "Match next-hop address of route\n"
2680 "Match entries of prefix-lists\n"
2681 "IP prefix-list name\n")
2683 DEFUN (match_ip_route_source_prefix_list
,
2684 match_ip_route_source_prefix_list_cmd
,
2685 "match ip route-source prefix-list WORD",
2688 "Match advertising source address of route\n"
2689 "Match entries of prefix-lists\n"
2690 "IP prefix-list name\n")
2692 return bgp_route_match_add (vty
, vty
->index
, "ip route-source prefix-list", argv
[0]);
2695 DEFUN (no_match_ip_route_source_prefix_list
,
2696 no_match_ip_route_source_prefix_list_cmd
,
2697 "no match ip route-source prefix-list",
2701 "Match advertising source address of route\n"
2702 "Match entries of prefix-lists\n")
2705 return bgp_route_match_delete (vty
, vty
->index
, "ip route-source prefix-list", NULL
);
2707 return bgp_route_match_delete (vty
, vty
->index
, "ip route-source prefix-list", argv
[0]);
2710 ALIAS (no_match_ip_route_source_prefix_list
,
2711 no_match_ip_route_source_prefix_list_val_cmd
,
2712 "no match ip route-source prefix-list WORD",
2716 "Match advertising source address of route\n"
2717 "Match entries of prefix-lists\n"
2718 "IP prefix-list name\n")
2720 DEFUN (match_metric
,
2722 "match metric <0-4294967295>",
2724 "Match metric of route\n"
2727 return bgp_route_match_add (vty
, vty
->index
, "metric", argv
[0]);
2730 DEFUN (no_match_metric
,
2731 no_match_metric_cmd
,
2735 "Match metric of route\n")
2738 return bgp_route_match_delete (vty
, vty
->index
, "metric", NULL
);
2740 return bgp_route_match_delete (vty
, vty
->index
, "metric", argv
[0]);
2743 ALIAS (no_match_metric
,
2744 no_match_metric_val_cmd
,
2745 "no match metric <0-4294967295>",
2748 "Match metric of route\n"
2751 DEFUN (match_community
,
2752 match_community_cmd
,
2753 "match community (<1-99>|<100-500>|WORD)",
2755 "Match BGP community list\n"
2756 "Community-list number (standard)\n"
2757 "Community-list number (expanded)\n"
2758 "Community-list name\n")
2760 return bgp_route_match_add (vty
, vty
->index
, "community", argv
[0]);
2763 DEFUN (match_community_exact
,
2764 match_community_exact_cmd
,
2765 "match community (<1-99>|<100-500>|WORD) exact-match",
2767 "Match BGP community list\n"
2768 "Community-list number (standard)\n"
2769 "Community-list number (expanded)\n"
2770 "Community-list name\n"
2771 "Do exact matching of communities\n")
2776 argstr
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
,
2777 strlen (argv
[0]) + strlen ("exact-match") + 2);
2779 sprintf (argstr
, "%s exact-match", argv
[0]);
2781 ret
= bgp_route_match_add (vty
, vty
->index
, "community", argstr
);
2783 XFREE (MTYPE_ROUTE_MAP_COMPILED
, argstr
);
2788 DEFUN (no_match_community
,
2789 no_match_community_cmd
,
2790 "no match community",
2793 "Match BGP community list\n")
2795 return bgp_route_match_delete (vty
, vty
->index
, "community", NULL
);
2798 ALIAS (no_match_community
,
2799 no_match_community_val_cmd
,
2800 "no match community (<1-99>|<100-500>|WORD)",
2803 "Match BGP community list\n"
2804 "Community-list number (standard)\n"
2805 "Community-list number (expanded)\n"
2806 "Community-list name\n")
2808 ALIAS (no_match_community
,
2809 no_match_community_exact_cmd
,
2810 "no match community (<1-99>|<100-500>|WORD) exact-match",
2813 "Match BGP community list\n"
2814 "Community-list number (standard)\n"
2815 "Community-list number (expanded)\n"
2816 "Community-list name\n"
2817 "Do exact matching of communities\n")
2819 DEFUN (match_ecommunity
,
2820 match_ecommunity_cmd
,
2821 "match extcommunity (<1-99>|<100-500>|WORD)",
2823 "Match BGP/VPN extended community list\n"
2824 "Extended community-list number (standard)\n"
2825 "Extended community-list number (expanded)\n"
2826 "Extended community-list name\n")
2828 return bgp_route_match_add (vty
, vty
->index
, "extcommunity", argv
[0]);
2831 DEFUN (no_match_ecommunity
,
2832 no_match_ecommunity_cmd
,
2833 "no match extcommunity",
2836 "Match BGP/VPN extended community list\n")
2838 return bgp_route_match_delete (vty
, vty
->index
, "extcommunity", NULL
);
2841 ALIAS (no_match_ecommunity
,
2842 no_match_ecommunity_val_cmd
,
2843 "no match extcommunity (<1-99>|<100-500>|WORD)",
2846 "Match BGP/VPN extended community list\n"
2847 "Extended community-list number (standard)\n"
2848 "Extended community-list number (expanded)\n"
2849 "Extended community-list name\n")
2851 DEFUN (match_aspath
,
2853 "match as-path WORD",
2855 "Match BGP AS path list\n"
2856 "AS path access-list name\n")
2858 return bgp_route_match_add (vty
, vty
->index
, "as-path", argv
[0]);
2861 DEFUN (no_match_aspath
,
2862 no_match_aspath_cmd
,
2866 "Match BGP AS path list\n")
2868 return bgp_route_match_delete (vty
, vty
->index
, "as-path", NULL
);
2871 ALIAS (no_match_aspath
,
2872 no_match_aspath_val_cmd
,
2873 "no match as-path WORD",
2876 "Match BGP AS path list\n"
2877 "AS path access-list name\n")
2879 DEFUN (match_origin
,
2881 "match origin (egp|igp|incomplete)",
2886 "unknown heritage\n")
2888 if (strncmp (argv
[0], "igp", 2) == 0)
2889 return bgp_route_match_add (vty
, vty
->index
, "origin", "igp");
2890 if (strncmp (argv
[0], "egp", 1) == 0)
2891 return bgp_route_match_add (vty
, vty
->index
, "origin", "egp");
2892 if (strncmp (argv
[0], "incomplete", 2) == 0)
2893 return bgp_route_match_add (vty
, vty
->index
, "origin", "incomplete");
2898 DEFUN (no_match_origin
,
2899 no_match_origin_cmd
,
2903 "BGP origin code\n")
2905 return bgp_route_match_delete (vty
, vty
->index
, "origin", NULL
);
2908 ALIAS (no_match_origin
,
2909 no_match_origin_val_cmd
,
2910 "no match origin (egp|igp|incomplete)",
2916 "unknown heritage\n")
2918 DEFUN (set_ip_nexthop
,
2920 "set ip next-hop A.B.C.D",
2923 "Next hop address\n"
2924 "IP address of next hop\n")
2929 ret
= str2sockunion (argv
[0], &su
);
2932 vty_out (vty
, "%% Malformed Next-hop address%s", VTY_NEWLINE
);
2936 return bgp_route_set_add (vty
, vty
->index
, "ip next-hop", argv
[0]);
2939 DEFUN (set_ip_nexthop_peer
,
2940 set_ip_nexthop_peer_cmd
,
2941 "set ip next-hop peer-address",
2944 "Next hop address\n"
2945 "Use peer address (for BGP only)\n")
2947 return bgp_route_set_add (vty
, vty
->index
, "ip next-hop", "peer-address");
2950 DEFUN_DEPRECATED (no_set_ip_nexthop_peer
,
2951 no_set_ip_nexthop_peer_cmd
,
2952 "no set ip next-hop peer-address",
2956 "Next hop address\n"
2957 "Use peer address (for BGP only)\n")
2959 return bgp_route_set_delete (vty
, vty
->index
, "ip next-hop", NULL
);
2963 DEFUN (no_set_ip_nexthop
,
2964 no_set_ip_nexthop_cmd
,
2965 "no set ip next-hop",
2968 "Next hop address\n")
2971 return bgp_route_set_delete (vty
, vty
->index
, "ip next-hop", NULL
);
2973 return bgp_route_set_delete (vty
, vty
->index
, "ip next-hop", argv
[0]);
2976 ALIAS (no_set_ip_nexthop
,
2977 no_set_ip_nexthop_val_cmd
,
2978 "no set ip next-hop A.B.C.D",
2982 "Next hop address\n"
2983 "IP address of next hop\n")
2987 "set metric <0-4294967295>",
2989 "Metric value for destination routing protocol\n"
2992 return bgp_route_set_add (vty
, vty
->index
, "metric", argv
[0]);
2996 set_metric_addsub_cmd
,
2997 "set metric <+/-metric>",
2999 "Metric value for destination routing protocol\n"
3000 "Add or subtract metric\n")
3002 DEFUN (no_set_metric
,
3007 "Metric value for destination routing protocol\n")
3010 return bgp_route_set_delete (vty
, vty
->index
, "metric", NULL
);
3012 return bgp_route_set_delete (vty
, vty
->index
, "metric", argv
[0]);
3015 ALIAS (no_set_metric
,
3016 no_set_metric_val_cmd
,
3017 "no set metric <0-4294967295>",
3020 "Metric value for destination routing protocol\n"
3023 DEFUN (set_local_pref
,
3025 "set local-preference <0-4294967295>",
3027 "BGP local preference path attribute\n"
3028 "Preference value\n")
3030 return bgp_route_set_add (vty
, vty
->index
, "local-preference", argv
[0]);
3033 DEFUN (no_set_local_pref
,
3034 no_set_local_pref_cmd
,
3035 "no set local-preference",
3038 "BGP local preference path attribute\n")
3041 return bgp_route_set_delete (vty
, vty
->index
, "local-preference", NULL
);
3043 return bgp_route_set_delete (vty
, vty
->index
, "local-preference", argv
[0]);
3046 ALIAS (no_set_local_pref
,
3047 no_set_local_pref_val_cmd
,
3048 "no set local-preference <0-4294967295>",
3051 "BGP local preference path attribute\n"
3052 "Preference value\n")
3056 "set weight <0-4294967295>",
3058 "BGP weight for routing table\n"
3061 return bgp_route_set_add (vty
, vty
->index
, "weight", argv
[0]);
3064 DEFUN (no_set_weight
,
3069 "BGP weight for routing table\n")
3072 return bgp_route_set_delete (vty
, vty
->index
, "weight", NULL
);
3074 return bgp_route_set_delete (vty
, vty
->index
, "weight", argv
[0]);
3077 ALIAS (no_set_weight
,
3078 no_set_weight_val_cmd
,
3079 "no set weight <0-4294967295>",
3082 "BGP weight for routing table\n"
3085 DEFUN (set_aspath_prepend
,
3086 set_aspath_prepend_cmd
,
3087 "set as-path prepend ." CMD_AS_RANGE
,
3089 "Transform BGP AS_PATH attribute\n"
3090 "Prepend to the as-path\n"
3096 str
= argv_concat (argv
, argc
, 0);
3097 ret
= bgp_route_set_add (vty
, vty
->index
, "as-path prepend", str
);
3098 XFREE (MTYPE_TMP
, str
);
3103 DEFUN (no_set_aspath_prepend
,
3104 no_set_aspath_prepend_cmd
,
3105 "no set as-path prepend",
3108 "Transform BGP AS_PATH attribute\n"
3109 "Prepend to the as-path\n")
3115 return bgp_route_set_delete (vty
, vty
->index
, "as-path prepend", NULL
);
3117 str
= argv_concat (argv
, argc
, 0);
3118 ret
= bgp_route_set_delete (vty
, vty
->index
, "as-path prepend", str
);
3119 XFREE (MTYPE_TMP
, str
);
3123 ALIAS (no_set_aspath_prepend
,
3124 no_set_aspath_prepend_val_cmd
,
3125 "no set as-path prepend ." CMD_AS_RANGE
,
3128 "Transform BGP AS_PATH attribute\n"
3129 "Prepend to the as-path\n"
3132 DEFUN (set_aspath_exclude
,
3133 set_aspath_exclude_cmd
,
3134 "set as-path exclude ." CMD_AS_RANGE
,
3136 "Transform BGP AS-path attribute\n"
3137 "Exclude from the as-path\n"
3143 str
= argv_concat (argv
, argc
, 0);
3144 ret
= bgp_route_set_add (vty
, vty
->index
, "as-path exclude", str
);
3145 XFREE (MTYPE_TMP
, str
);
3149 DEFUN (no_set_aspath_exclude
,
3150 no_set_aspath_exclude_cmd
,
3151 "no set as-path exclude",
3154 "Transform BGP AS_PATH attribute\n"
3155 "Exclude from the as-path\n")
3161 return bgp_route_set_delete (vty
, vty
->index
, "as-path exclude", NULL
);
3163 str
= argv_concat (argv
, argc
, 0);
3164 ret
= bgp_route_set_delete (vty
, vty
->index
, "as-path exclude", str
);
3165 XFREE (MTYPE_TMP
, str
);
3169 ALIAS (no_set_aspath_exclude
,
3170 no_set_aspath_exclude_val_cmd
,
3171 "no set as-path exclude ." CMD_AS_RANGE
,
3174 "Transform BGP AS_PATH attribute\n"
3175 "Exclude from the as-path\n"
3178 DEFUN (set_community
,
3180 "set community .AA:NN",
3182 "BGP community attribute\n"
3183 "Community number in aa:nn format or local-AS|no-advertise|no-export|internet or additive\n")
3189 struct community
*com
= NULL
;
3194 b
= buffer_new (1024);
3196 for (i
= 0; i
< argc
; i
++)
3198 if (strncmp (argv
[i
], "additive", strlen (argv
[i
])) == 0)
3205 buffer_putc (b
, ' ');
3209 if (strncmp (argv
[i
], "internet", strlen (argv
[i
])) == 0)
3211 buffer_putstr (b
, "internet");
3214 if (strncmp (argv
[i
], "local-AS", strlen (argv
[i
])) == 0)
3216 buffer_putstr (b
, "local-AS");
3219 if (strncmp (argv
[i
], "no-a", strlen ("no-a")) == 0
3220 && strncmp (argv
[i
], "no-advertise", strlen (argv
[i
])) == 0)
3222 buffer_putstr (b
, "no-advertise");
3225 if (strncmp (argv
[i
], "no-e", strlen ("no-e"))== 0
3226 && strncmp (argv
[i
], "no-export", strlen (argv
[i
])) == 0)
3228 buffer_putstr (b
, "no-export");
3231 buffer_putstr (b
, argv
[i
]);
3233 buffer_putc (b
, '\0');
3235 /* Fetch result string then compile it to communities attribute. */
3236 str
= buffer_getstr (b
);
3241 com
= community_str2com (str
);
3242 XFREE (MTYPE_TMP
, str
);
3245 /* Can't compile user input into communities attribute. */
3248 vty_out (vty
, "%% Malformed communities attribute%s", VTY_NEWLINE
);
3252 /* Set communites attribute string. */
3253 str
= community_str (com
);
3257 argstr
= XCALLOC (MTYPE_TMP
, strlen (str
) + strlen (" additive") + 1);
3258 strcpy (argstr
, str
);
3259 strcpy (argstr
+ strlen (str
), " additive");
3260 ret
= bgp_route_set_add (vty
, vty
->index
, "community", argstr
);
3261 XFREE (MTYPE_TMP
, argstr
);
3264 ret
= bgp_route_set_add (vty
, vty
->index
, "community", str
);
3266 community_free (com
);
3271 DEFUN (set_community_none
,
3272 set_community_none_cmd
,
3273 "set community none",
3275 "BGP community attribute\n"
3276 "No community attribute\n")
3278 return bgp_route_set_add (vty
, vty
->index
, "community", "none");
3281 DEFUN (no_set_community
,
3282 no_set_community_cmd
,
3286 "BGP community attribute\n")
3288 return bgp_route_set_delete (vty
, vty
->index
, "community", NULL
);
3291 ALIAS (no_set_community
,
3292 no_set_community_val_cmd
,
3293 "no set community .AA:NN",
3296 "BGP community attribute\n"
3297 "Community number in aa:nn format or local-AS|no-advertise|no-export|internet or additive\n")
3299 ALIAS (no_set_community
,
3300 no_set_community_none_cmd
,
3301 "no set community none",
3304 "BGP community attribute\n"
3305 "No community attribute\n")
3307 DEFUN (set_community_delete
,
3308 set_community_delete_cmd
,
3309 "set comm-list (<1-99>|<100-500>|WORD) delete",
3311 "set BGP community list (for deletion)\n"
3312 "Community-list number (standard)\n"
3313 "Communitly-list number (expanded)\n"
3314 "Community-list name\n"
3315 "Delete matching communities\n")
3319 str
= XCALLOC (MTYPE_TMP
, strlen (argv
[0]) + strlen (" delete") + 1);
3320 strcpy (str
, argv
[0]);
3321 strcpy (str
+ strlen (argv
[0]), " delete");
3323 bgp_route_set_add (vty
, vty
->index
, "comm-list", str
);
3325 XFREE (MTYPE_TMP
, str
);
3329 DEFUN (no_set_community_delete
,
3330 no_set_community_delete_cmd
,
3334 "set BGP community list (for deletion)\n")
3336 return bgp_route_set_delete (vty
, vty
->index
, "comm-list", NULL
);
3339 ALIAS (no_set_community_delete
,
3340 no_set_community_delete_val_cmd
,
3341 "no set comm-list (<1-99>|<100-500>|WORD) delete",
3344 "set BGP community list (for deletion)\n"
3345 "Community-list number (standard)\n"
3346 "Communitly-list number (expanded)\n"
3347 "Community-list name\n"
3348 "Delete matching communities\n")
3350 DEFUN (set_ecommunity_rt
,
3351 set_ecommunity_rt_cmd
,
3352 "set extcommunity rt .ASN:nn_or_IP-address:nn",
3354 "BGP extended community attribute\n"
3355 "Route Target extended community\n"
3356 "VPN extended community\n")
3361 str
= argv_concat (argv
, argc
, 0);
3362 ret
= bgp_route_set_add (vty
, vty
->index
, "extcommunity rt", str
);
3363 XFREE (MTYPE_TMP
, str
);
3368 DEFUN (no_set_ecommunity_rt
,
3369 no_set_ecommunity_rt_cmd
,
3370 "no set extcommunity rt",
3373 "BGP extended community attribute\n"
3374 "Route Target extended community\n")
3376 return bgp_route_set_delete (vty
, vty
->index
, "extcommunity rt", NULL
);
3379 ALIAS (no_set_ecommunity_rt
,
3380 no_set_ecommunity_rt_val_cmd
,
3381 "no set extcommunity rt .ASN:nn_or_IP-address:nn",
3384 "BGP extended community attribute\n"
3385 "Route Target extended community\n"
3386 "VPN extended community\n")
3388 DEFUN (set_ecommunity_soo
,
3389 set_ecommunity_soo_cmd
,
3390 "set extcommunity soo .ASN:nn_or_IP-address:nn",
3392 "BGP extended community attribute\n"
3393 "Site-of-Origin extended community\n"
3394 "VPN extended community\n")
3399 str
= argv_concat (argv
, argc
, 0);
3400 ret
= bgp_route_set_add (vty
, vty
->index
, "extcommunity soo", str
);
3401 XFREE (MTYPE_TMP
, str
);
3405 DEFUN (no_set_ecommunity_soo
,
3406 no_set_ecommunity_soo_cmd
,
3407 "no set extcommunity soo",
3410 "BGP extended community attribute\n"
3411 "Site-of-Origin extended community\n")
3413 return bgp_route_set_delete (vty
, vty
->index
, "extcommunity soo", NULL
);
3416 ALIAS (no_set_ecommunity_soo
,
3417 no_set_ecommunity_soo_val_cmd
,
3418 "no set extcommunity soo .ASN:nn_or_IP-address:nn",
3421 "BGP extended community attribute\n"
3422 "Site-of-Origin extended community\n"
3423 "VPN extended community\n")
3427 "set origin (egp|igp|incomplete)",
3432 "unknown heritage\n")
3434 if (strncmp (argv
[0], "igp", 2) == 0)
3435 return bgp_route_set_add (vty
, vty
->index
, "origin", "igp");
3436 if (strncmp (argv
[0], "egp", 1) == 0)
3437 return bgp_route_set_add (vty
, vty
->index
, "origin", "egp");
3438 if (strncmp (argv
[0], "incomplete", 2) == 0)
3439 return bgp_route_set_add (vty
, vty
->index
, "origin", "incomplete");
3444 DEFUN (no_set_origin
,
3449 "BGP origin code\n")
3451 return bgp_route_set_delete (vty
, vty
->index
, "origin", NULL
);
3454 ALIAS (no_set_origin
,
3455 no_set_origin_val_cmd
,
3456 "no set origin (egp|igp|incomplete)",
3462 "unknown heritage\n")
3464 DEFUN (set_atomic_aggregate
,
3465 set_atomic_aggregate_cmd
,
3466 "set atomic-aggregate",
3468 "BGP atomic aggregate attribute\n" )
3470 return bgp_route_set_add (vty
, vty
->index
, "atomic-aggregate", NULL
);
3473 DEFUN (no_set_atomic_aggregate
,
3474 no_set_atomic_aggregate_cmd
,
3475 "no set atomic-aggregate",
3478 "BGP atomic aggregate attribute\n" )
3480 return bgp_route_set_delete (vty
, vty
->index
, "atomic-aggregate", NULL
);
3483 DEFUN (set_aggregator_as
,
3484 set_aggregator_as_cmd
,
3485 "set aggregator as " CMD_AS_RANGE
" A.B.C.D",
3487 "BGP aggregator attribute\n"
3488 "AS number of aggregator\n"
3490 "IP address of aggregator\n")
3494 struct in_addr address
;
3497 VTY_GET_INTEGER_RANGE ("AS", as
, argv
[0], 1, BGP_AS4_MAX
);
3499 ret
= inet_aton (argv
[1], &address
);
3502 vty_out (vty
, "Aggregator IP address is invalid%s", VTY_NEWLINE
);
3506 argstr
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
,
3507 strlen (argv
[0]) + strlen (argv
[1]) + 2);
3509 sprintf (argstr
, "%s %s", argv
[0], argv
[1]);
3511 ret
= bgp_route_set_add (vty
, vty
->index
, "aggregator as", argstr
);
3513 XFREE (MTYPE_ROUTE_MAP_COMPILED
, argstr
);
3518 DEFUN (no_set_aggregator_as
,
3519 no_set_aggregator_as_cmd
,
3520 "no set aggregator as",
3523 "BGP aggregator attribute\n"
3524 "AS number of aggregator\n")
3528 struct in_addr address
;
3532 return bgp_route_set_delete (vty
, vty
->index
, "aggregator as", NULL
);
3534 VTY_GET_INTEGER_RANGE ("AS", as
, argv
[0], 1, BGP_AS4_MAX
);
3536 ret
= inet_aton (argv
[1], &address
);
3539 vty_out (vty
, "Aggregator IP address is invalid%s", VTY_NEWLINE
);
3543 argstr
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
,
3544 strlen (argv
[0]) + strlen (argv
[1]) + 2);
3546 sprintf (argstr
, "%s %s", argv
[0], argv
[1]);
3548 ret
= bgp_route_set_delete (vty
, vty
->index
, "aggregator as", argstr
);
3550 XFREE (MTYPE_ROUTE_MAP_COMPILED
, argstr
);
3555 ALIAS (no_set_aggregator_as
,
3556 no_set_aggregator_as_val_cmd
,
3557 "no set aggregator as " CMD_AS_RANGE
" A.B.C.D",
3560 "BGP aggregator attribute\n"
3561 "AS number of aggregator\n"
3563 "IP address of aggregator\n")
3567 DEFUN (match_ipv6_address
,
3568 match_ipv6_address_cmd
,
3569 "match ipv6 address WORD",
3572 "Match IPv6 address of route\n"
3573 "IPv6 access-list name\n")
3575 return bgp_route_match_add (vty
, vty
->index
, "ipv6 address", argv
[0]);
3578 DEFUN (no_match_ipv6_address
,
3579 no_match_ipv6_address_cmd
,
3580 "no match ipv6 address WORD",
3584 "Match IPv6 address of route\n"
3585 "IPv6 access-list name\n")
3587 return bgp_route_match_delete (vty
, vty
->index
, "ipv6 address", argv
[0]);
3590 DEFUN (match_ipv6_next_hop
,
3591 match_ipv6_next_hop_cmd
,
3592 "match ipv6 next-hop X:X::X:X",
3595 "Match IPv6 next-hop address of route\n"
3596 "IPv6 address of next hop\n")
3598 return bgp_route_match_add (vty
, vty
->index
, "ipv6 next-hop", argv
[0]);
3601 DEFUN (no_match_ipv6_next_hop
,
3602 no_match_ipv6_next_hop_cmd
,
3603 "no match ipv6 next-hop X:X::X:X",
3607 "Match IPv6 next-hop address of route\n"
3608 "IPv6 address of next hop\n")
3610 return bgp_route_match_delete (vty
, vty
->index
, "ipv6 next-hop", argv
[0]);
3613 DEFUN (match_ipv6_address_prefix_list
,
3614 match_ipv6_address_prefix_list_cmd
,
3615 "match ipv6 address prefix-list WORD",
3618 "Match address of route\n"
3619 "Match entries of prefix-lists\n"
3620 "IP prefix-list name\n")
3622 return bgp_route_match_add (vty
, vty
->index
, "ipv6 address prefix-list", argv
[0]);
3625 DEFUN (no_match_ipv6_address_prefix_list
,
3626 no_match_ipv6_address_prefix_list_cmd
,
3627 "no match ipv6 address prefix-list WORD",
3631 "Match address of route\n"
3632 "Match entries of prefix-lists\n"
3633 "IP prefix-list name\n")
3635 return bgp_route_match_delete (vty
, vty
->index
, "ipv6 address prefix-list", argv
[0]);
3638 DEFUN (set_ipv6_nexthop_global
,
3639 set_ipv6_nexthop_global_cmd
,
3640 "set ipv6 next-hop global X:X::X:X",
3643 "IPv6 next-hop address\n"
3644 "IPv6 global address\n"
3645 "IPv6 address of next hop\n")
3647 return bgp_route_set_add (vty
, vty
->index
, "ipv6 next-hop global", argv
[0]);
3650 DEFUN (no_set_ipv6_nexthop_global
,
3651 no_set_ipv6_nexthop_global_cmd
,
3652 "no set ipv6 next-hop global",
3656 "IPv6 next-hop address\n"
3657 "IPv6 global address\n")
3660 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop global", NULL
);
3662 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop global", argv
[0]);
3665 ALIAS (no_set_ipv6_nexthop_global
,
3666 no_set_ipv6_nexthop_global_val_cmd
,
3667 "no set ipv6 next-hop global X:X::X:X",
3671 "IPv6 next-hop address\n"
3672 "IPv6 global address\n"
3673 "IPv6 address of next hop\n")
3675 DEFUN (set_ipv6_nexthop_local
,
3676 set_ipv6_nexthop_local_cmd
,
3677 "set ipv6 next-hop local X:X::X:X",
3680 "IPv6 next-hop address\n"
3681 "IPv6 local address\n"
3682 "IPv6 address of next hop\n")
3684 return bgp_route_set_add (vty
, vty
->index
, "ipv6 next-hop local", argv
[0]);
3687 DEFUN (no_set_ipv6_nexthop_local
,
3688 no_set_ipv6_nexthop_local_cmd
,
3689 "no set ipv6 next-hop local",
3693 "IPv6 next-hop address\n"
3694 "IPv6 local address\n")
3697 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop local", NULL
);
3699 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop local", argv
[0]);
3702 ALIAS (no_set_ipv6_nexthop_local
,
3703 no_set_ipv6_nexthop_local_val_cmd
,
3704 "no set ipv6 next-hop local X:X::X:X",
3708 "IPv6 next-hop address\n"
3709 "IPv6 local address\n"
3710 "IPv6 address of next hop\n")
3711 #endif /* HAVE_IPV6 */
3713 DEFUN (set_vpnv4_nexthop
,
3714 set_vpnv4_nexthop_cmd
,
3715 "set vpnv4 next-hop A.B.C.D",
3717 "VPNv4 information\n"
3718 "VPNv4 next-hop address\n"
3719 "IP address of next hop\n")
3721 return bgp_route_set_add (vty
, vty
->index
, "vpnv4 next-hop", argv
[0]);
3724 DEFUN (no_set_vpnv4_nexthop
,
3725 no_set_vpnv4_nexthop_cmd
,
3726 "no set vpnv4 next-hop",
3729 "VPNv4 information\n"
3730 "VPNv4 next-hop address\n")
3733 return bgp_route_set_delete (vty
, vty
->index
, "vpnv4 next-hop", NULL
);
3735 return bgp_route_set_delete (vty
, vty
->index
, "vpnv4 next-hop", argv
[0]);
3738 ALIAS (no_set_vpnv4_nexthop
,
3739 no_set_vpnv4_nexthop_val_cmd
,
3740 "no set vpnv4 next-hop A.B.C.D",
3743 "VPNv4 information\n"
3744 "VPNv4 next-hop address\n"
3745 "IP address of next hop\n")
3747 DEFUN (set_originator_id
,
3748 set_originator_id_cmd
,
3749 "set originator-id A.B.C.D",
3751 "BGP originator ID attribute\n"
3752 "IP address of originator\n")
3754 return bgp_route_set_add (vty
, vty
->index
, "originator-id", argv
[0]);
3757 DEFUN (no_set_originator_id
,
3758 no_set_originator_id_cmd
,
3759 "no set originator-id",
3762 "BGP originator ID attribute\n")
3765 return bgp_route_set_delete (vty
, vty
->index
, "originator-id", NULL
);
3767 return bgp_route_set_delete (vty
, vty
->index
, "originator-id", argv
[0]);
3770 ALIAS (no_set_originator_id
,
3771 no_set_originator_id_val_cmd
,
3772 "no set originator-id A.B.C.D",
3775 "BGP originator ID attribute\n"
3776 "IP address of originator\n")
3778 DEFUN_DEPRECATED (set_pathlimit_ttl
,
3779 set_pathlimit_ttl_cmd
,
3780 "set pathlimit ttl <1-255>",
3782 "BGP AS-Pathlimit attribute\n"
3783 "Set AS-Path Hop-count TTL\n")
3788 DEFUN_DEPRECATED (no_set_pathlimit_ttl
,
3789 no_set_pathlimit_ttl_cmd
,
3790 "no set pathlimit ttl",
3793 "BGP AS-Pathlimit attribute\n"
3794 "Set AS-Path Hop-count TTL\n")
3799 ALIAS (no_set_pathlimit_ttl
,
3800 no_set_pathlimit_ttl_val_cmd
,
3801 "no set pathlimit ttl <1-255>",
3804 "BGP AS-Pathlimit attribute\n"
3805 "Set AS-Path Hop-count TTL\n")
3807 DEFUN_DEPRECATED (match_pathlimit_as
,
3808 match_pathlimit_as_cmd
,
3809 "match pathlimit as <1-65535>",
3811 "BGP AS-Pathlimit attribute\n"
3812 "Match Pathlimit AS number\n")
3817 DEFUN_DEPRECATED (no_match_pathlimit_as
,
3818 no_match_pathlimit_as_cmd
,
3819 "no match pathlimit as",
3822 "BGP AS-Pathlimit attribute\n"
3823 "Match Pathlimit AS number\n")
3828 ALIAS (no_match_pathlimit_as
,
3829 no_match_pathlimit_as_val_cmd
,
3830 "no match pathlimit as <1-65535>",
3833 "BGP AS-Pathlimit attribute\n"
3834 "Match Pathlimit ASN\n")
3837 /* Initialization of route map. */
3839 bgp_route_map_init (void)
3842 route_map_init_vty ();
3843 route_map_add_hook (bgp_route_map_update
);
3844 route_map_delete_hook (bgp_route_map_update
);
3846 route_map_install_match (&route_match_peer_cmd
);
3847 route_map_install_match (&route_match_ip_address_cmd
);
3848 route_map_install_match (&route_match_ip_next_hop_cmd
);
3849 route_map_install_match (&route_match_ip_route_source_cmd
);
3850 route_map_install_match (&route_match_ip_address_prefix_list_cmd
);
3851 route_map_install_match (&route_match_ip_next_hop_prefix_list_cmd
);
3852 route_map_install_match (&route_match_ip_route_source_prefix_list_cmd
);
3853 route_map_install_match (&route_match_aspath_cmd
);
3854 route_map_install_match (&route_match_community_cmd
);
3855 route_map_install_match (&route_match_ecommunity_cmd
);
3856 route_map_install_match (&route_match_metric_cmd
);
3857 route_map_install_match (&route_match_origin_cmd
);
3858 route_map_install_match (&route_match_probability_cmd
);
3860 route_map_install_set (&route_set_ip_nexthop_cmd
);
3861 route_map_install_set (&route_set_local_pref_cmd
);
3862 route_map_install_set (&route_set_weight_cmd
);
3863 route_map_install_set (&route_set_metric_cmd
);
3864 route_map_install_set (&route_set_aspath_prepend_cmd
);
3865 route_map_install_set (&route_set_aspath_exclude_cmd
);
3866 route_map_install_set (&route_set_origin_cmd
);
3867 route_map_install_set (&route_set_atomic_aggregate_cmd
);
3868 route_map_install_set (&route_set_aggregator_as_cmd
);
3869 route_map_install_set (&route_set_community_cmd
);
3870 route_map_install_set (&route_set_community_delete_cmd
);
3871 route_map_install_set (&route_set_vpnv4_nexthop_cmd
);
3872 route_map_install_set (&route_set_originator_id_cmd
);
3873 route_map_install_set (&route_set_ecommunity_rt_cmd
);
3874 route_map_install_set (&route_set_ecommunity_soo_cmd
);
3876 install_element (RMAP_NODE
, &match_peer_cmd
);
3877 install_element (RMAP_NODE
, &match_peer_local_cmd
);
3878 install_element (RMAP_NODE
, &no_match_peer_cmd
);
3879 install_element (RMAP_NODE
, &no_match_peer_val_cmd
);
3880 install_element (RMAP_NODE
, &no_match_peer_local_cmd
);
3881 install_element (RMAP_NODE
, &match_ip_address_cmd
);
3882 install_element (RMAP_NODE
, &no_match_ip_address_cmd
);
3883 install_element (RMAP_NODE
, &no_match_ip_address_val_cmd
);
3884 install_element (RMAP_NODE
, &match_ip_next_hop_cmd
);
3885 install_element (RMAP_NODE
, &no_match_ip_next_hop_cmd
);
3886 install_element (RMAP_NODE
, &no_match_ip_next_hop_val_cmd
);
3887 install_element (RMAP_NODE
, &match_ip_route_source_cmd
);
3888 install_element (RMAP_NODE
, &no_match_ip_route_source_cmd
);
3889 install_element (RMAP_NODE
, &no_match_ip_route_source_val_cmd
);
3890 install_element (RMAP_NODE
, &match_ip_address_prefix_list_cmd
);
3891 install_element (RMAP_NODE
, &no_match_ip_address_prefix_list_cmd
);
3892 install_element (RMAP_NODE
, &no_match_ip_address_prefix_list_val_cmd
);
3893 install_element (RMAP_NODE
, &match_ip_next_hop_prefix_list_cmd
);
3894 install_element (RMAP_NODE
, &no_match_ip_next_hop_prefix_list_cmd
);
3895 install_element (RMAP_NODE
, &no_match_ip_next_hop_prefix_list_val_cmd
);
3896 install_element (RMAP_NODE
, &match_ip_route_source_prefix_list_cmd
);
3897 install_element (RMAP_NODE
, &no_match_ip_route_source_prefix_list_cmd
);
3898 install_element (RMAP_NODE
, &no_match_ip_route_source_prefix_list_val_cmd
);
3900 install_element (RMAP_NODE
, &match_aspath_cmd
);
3901 install_element (RMAP_NODE
, &no_match_aspath_cmd
);
3902 install_element (RMAP_NODE
, &no_match_aspath_val_cmd
);
3903 install_element (RMAP_NODE
, &match_metric_cmd
);
3904 install_element (RMAP_NODE
, &no_match_metric_cmd
);
3905 install_element (RMAP_NODE
, &no_match_metric_val_cmd
);
3906 install_element (RMAP_NODE
, &match_community_cmd
);
3907 install_element (RMAP_NODE
, &match_community_exact_cmd
);
3908 install_element (RMAP_NODE
, &no_match_community_cmd
);
3909 install_element (RMAP_NODE
, &no_match_community_val_cmd
);
3910 install_element (RMAP_NODE
, &no_match_community_exact_cmd
);
3911 install_element (RMAP_NODE
, &match_ecommunity_cmd
);
3912 install_element (RMAP_NODE
, &no_match_ecommunity_cmd
);
3913 install_element (RMAP_NODE
, &no_match_ecommunity_val_cmd
);
3914 install_element (RMAP_NODE
, &match_origin_cmd
);
3915 install_element (RMAP_NODE
, &no_match_origin_cmd
);
3916 install_element (RMAP_NODE
, &no_match_origin_val_cmd
);
3917 install_element (RMAP_NODE
, &match_probability_cmd
);
3918 install_element (RMAP_NODE
, &no_match_probability_cmd
);
3919 install_element (RMAP_NODE
, &no_match_probability_val_cmd
);
3921 install_element (RMAP_NODE
, &set_ip_nexthop_cmd
);
3922 install_element (RMAP_NODE
, &set_ip_nexthop_peer_cmd
);
3923 install_element (RMAP_NODE
, &no_set_ip_nexthop_cmd
);
3924 install_element (RMAP_NODE
, &no_set_ip_nexthop_val_cmd
);
3925 install_element (RMAP_NODE
, &set_local_pref_cmd
);
3926 install_element (RMAP_NODE
, &no_set_local_pref_cmd
);
3927 install_element (RMAP_NODE
, &no_set_local_pref_val_cmd
);
3928 install_element (RMAP_NODE
, &set_weight_cmd
);
3929 install_element (RMAP_NODE
, &no_set_weight_cmd
);
3930 install_element (RMAP_NODE
, &no_set_weight_val_cmd
);
3931 install_element (RMAP_NODE
, &set_metric_cmd
);
3932 install_element (RMAP_NODE
, &set_metric_addsub_cmd
);
3933 install_element (RMAP_NODE
, &no_set_metric_cmd
);
3934 install_element (RMAP_NODE
, &no_set_metric_val_cmd
);
3935 install_element (RMAP_NODE
, &set_aspath_prepend_cmd
);
3936 install_element (RMAP_NODE
, &set_aspath_exclude_cmd
);
3937 install_element (RMAP_NODE
, &no_set_aspath_prepend_cmd
);
3938 install_element (RMAP_NODE
, &no_set_aspath_prepend_val_cmd
);
3939 install_element (RMAP_NODE
, &no_set_aspath_exclude_cmd
);
3940 install_element (RMAP_NODE
, &no_set_aspath_exclude_val_cmd
);
3941 install_element (RMAP_NODE
, &set_origin_cmd
);
3942 install_element (RMAP_NODE
, &no_set_origin_cmd
);
3943 install_element (RMAP_NODE
, &no_set_origin_val_cmd
);
3944 install_element (RMAP_NODE
, &set_atomic_aggregate_cmd
);
3945 install_element (RMAP_NODE
, &no_set_atomic_aggregate_cmd
);
3946 install_element (RMAP_NODE
, &set_aggregator_as_cmd
);
3947 install_element (RMAP_NODE
, &no_set_aggregator_as_cmd
);
3948 install_element (RMAP_NODE
, &no_set_aggregator_as_val_cmd
);
3949 install_element (RMAP_NODE
, &set_community_cmd
);
3950 install_element (RMAP_NODE
, &set_community_none_cmd
);
3951 install_element (RMAP_NODE
, &no_set_community_cmd
);
3952 install_element (RMAP_NODE
, &no_set_community_val_cmd
);
3953 install_element (RMAP_NODE
, &no_set_community_none_cmd
);
3954 install_element (RMAP_NODE
, &set_community_delete_cmd
);
3955 install_element (RMAP_NODE
, &no_set_community_delete_cmd
);
3956 install_element (RMAP_NODE
, &no_set_community_delete_val_cmd
);
3957 install_element (RMAP_NODE
, &set_ecommunity_rt_cmd
);
3958 install_element (RMAP_NODE
, &no_set_ecommunity_rt_cmd
);
3959 install_element (RMAP_NODE
, &no_set_ecommunity_rt_val_cmd
);
3960 install_element (RMAP_NODE
, &set_ecommunity_soo_cmd
);
3961 install_element (RMAP_NODE
, &no_set_ecommunity_soo_cmd
);
3962 install_element (RMAP_NODE
, &no_set_ecommunity_soo_val_cmd
);
3963 install_element (RMAP_NODE
, &set_vpnv4_nexthop_cmd
);
3964 install_element (RMAP_NODE
, &no_set_vpnv4_nexthop_cmd
);
3965 install_element (RMAP_NODE
, &no_set_vpnv4_nexthop_val_cmd
);
3966 install_element (RMAP_NODE
, &set_originator_id_cmd
);
3967 install_element (RMAP_NODE
, &no_set_originator_id_cmd
);
3968 install_element (RMAP_NODE
, &no_set_originator_id_val_cmd
);
3971 route_map_install_match (&route_match_ipv6_address_cmd
);
3972 route_map_install_match (&route_match_ipv6_next_hop_cmd
);
3973 route_map_install_match (&route_match_ipv6_address_prefix_list_cmd
);
3974 route_map_install_set (&route_set_ipv6_nexthop_global_cmd
);
3975 route_map_install_set (&route_set_ipv6_nexthop_local_cmd
);
3977 install_element (RMAP_NODE
, &match_ipv6_address_cmd
);
3978 install_element (RMAP_NODE
, &no_match_ipv6_address_cmd
);
3979 install_element (RMAP_NODE
, &match_ipv6_next_hop_cmd
);
3980 install_element (RMAP_NODE
, &no_match_ipv6_next_hop_cmd
);
3981 install_element (RMAP_NODE
, &match_ipv6_address_prefix_list_cmd
);
3982 install_element (RMAP_NODE
, &no_match_ipv6_address_prefix_list_cmd
);
3983 install_element (RMAP_NODE
, &set_ipv6_nexthop_global_cmd
);
3984 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_global_cmd
);
3985 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_global_val_cmd
);
3986 install_element (RMAP_NODE
, &set_ipv6_nexthop_local_cmd
);
3987 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_local_cmd
);
3988 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_local_val_cmd
);
3989 #endif /* HAVE_IPV6 */
3991 /* AS-Pathlimit: functionality removed, commands kept for
3994 install_element (RMAP_NODE
, &set_pathlimit_ttl_cmd
);
3995 install_element (RMAP_NODE
, &no_set_pathlimit_ttl_cmd
);
3996 install_element (RMAP_NODE
, &no_set_pathlimit_ttl_val_cmd
);
3997 install_element (RMAP_NODE
, &match_pathlimit_as_cmd
);
3998 install_element (RMAP_NODE
, &no_match_pathlimit_as_cmd
);
3999 install_element (RMAP_NODE
, &no_match_pathlimit_as_val_cmd
);