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
*su2
;
115 struct peer_group
*group
;
117 struct listnode
*node
, *nnode
;
119 if (type
== RMAP_BGP
)
122 peer
= ((struct bgp_info
*) object
)->peer
;
124 if ( ! CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IMPORT
) &&
125 ! CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_EXPORT
) )
128 /* If su='0.0.0.0' (command 'match peer local'), and it's a NETWORK,
129 REDISTRIBUTE or DEFAULT_GENERATED route => return RMAP_MATCH */
130 su2
= sockunion_str2su ("0.0.0.0");
131 if ( sockunion_same (su
, su2
) )
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
))
141 sockunion_free (su2
);
144 sockunion_free (su2
);
146 if (! CHECK_FLAG (peer
->sflags
, PEER_STATUS_GROUP
))
148 if (sockunion_same (su
, &peer
->su
))
156 for (ALL_LIST_ELEMENTS (group
->peer
, node
, nnode
, peer
))
158 if (sockunion_same (su
, &peer
->su
))
168 route_match_peer_compile (const char *arg
)
173 su
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (union sockunion
));
175 ret
= str2sockunion ( (arg
)? arg
: "0.0.0.0", su
);
177 XFREE (MTYPE_ROUTE_MAP_COMPILED
, su
);
184 /* Free route map's compiled `ip address' value. */
186 route_match_peer_free (void *rule
)
188 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
191 /* Route map commands for ip address matching. */
192 struct route_map_rule_cmd route_match_peer_cmd
=
196 route_match_peer_compile
,
197 route_match_peer_free
200 /* `match ip address IP_ACCESS_LIST' */
202 /* Match function should return 1 if match is success else return
204 static route_map_result_t
205 route_match_ip_address (void *rule
, struct prefix
*prefix
,
206 route_map_object_t type
, void *object
)
208 struct access_list
*alist
;
209 /* struct prefix_ipv4 match; */
211 if (type
== RMAP_BGP
)
213 alist
= access_list_lookup (AFI_IP
, (char *) rule
);
217 return (access_list_apply (alist
, prefix
) == FILTER_DENY
?
218 RMAP_NOMATCH
: RMAP_MATCH
);
223 /* Route map `ip address' match statement. `arg' should be
226 route_match_ip_address_compile (const char *arg
)
228 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
231 /* Free route map's compiled `ip address' value. */
233 route_match_ip_address_free (void *rule
)
235 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
238 /* Route map commands for ip address matching. */
239 struct route_map_rule_cmd route_match_ip_address_cmd
=
242 route_match_ip_address
,
243 route_match_ip_address_compile
,
244 route_match_ip_address_free
247 /* `match ip next-hop IP_ADDRESS' */
249 /* Match function return 1 if match is success else return zero. */
250 static route_map_result_t
251 route_match_ip_next_hop (void *rule
, struct prefix
*prefix
,
252 route_map_object_t type
, void *object
)
254 struct access_list
*alist
;
255 struct bgp_info
*bgp_info
;
256 struct prefix_ipv4 p
;
258 if (type
== RMAP_BGP
)
262 p
.prefix
= bgp_info
->attr
->nexthop
;
263 p
.prefixlen
= IPV4_MAX_BITLEN
;
265 alist
= access_list_lookup (AFI_IP
, (char *) rule
);
269 return (access_list_apply (alist
, &p
) == FILTER_DENY
?
270 RMAP_NOMATCH
: RMAP_MATCH
);
275 /* Route map `ip next-hop' match statement. `arg' is
278 route_match_ip_next_hop_compile (const char *arg
)
280 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
283 /* Free route map's compiled `ip address' value. */
285 route_match_ip_next_hop_free (void *rule
)
287 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
290 /* Route map commands for ip next-hop matching. */
291 struct route_map_rule_cmd route_match_ip_next_hop_cmd
=
294 route_match_ip_next_hop
,
295 route_match_ip_next_hop_compile
,
296 route_match_ip_next_hop_free
299 /* `match ip route-source ACCESS-LIST' */
301 /* Match function return 1 if match is success else return zero. */
302 static route_map_result_t
303 route_match_ip_route_source (void *rule
, struct prefix
*prefix
,
304 route_map_object_t type
, void *object
)
306 struct access_list
*alist
;
307 struct bgp_info
*bgp_info
;
309 struct prefix_ipv4 p
;
311 if (type
== RMAP_BGP
)
314 peer
= bgp_info
->peer
;
316 if (! peer
|| sockunion_family (&peer
->su
) != AF_INET
)
320 p
.prefix
= peer
->su
.sin
.sin_addr
;
321 p
.prefixlen
= IPV4_MAX_BITLEN
;
323 alist
= access_list_lookup (AFI_IP
, (char *) rule
);
327 return (access_list_apply (alist
, &p
) == FILTER_DENY
?
328 RMAP_NOMATCH
: RMAP_MATCH
);
333 /* Route map `ip route-source' match statement. `arg' is
336 route_match_ip_route_source_compile (const char *arg
)
338 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
341 /* Free route map's compiled `ip address' value. */
343 route_match_ip_route_source_free (void *rule
)
345 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
348 /* Route map commands for ip route-source matching. */
349 struct route_map_rule_cmd route_match_ip_route_source_cmd
=
352 route_match_ip_route_source
,
353 route_match_ip_route_source_compile
,
354 route_match_ip_route_source_free
357 /* `match ip address prefix-list PREFIX_LIST' */
359 static route_map_result_t
360 route_match_ip_address_prefix_list (void *rule
, struct prefix
*prefix
,
361 route_map_object_t type
, void *object
)
363 struct prefix_list
*plist
;
365 if (type
== RMAP_BGP
)
367 plist
= prefix_list_lookup (AFI_IP
, (char *) rule
);
371 return (prefix_list_apply (plist
, prefix
) == PREFIX_DENY
?
372 RMAP_NOMATCH
: RMAP_MATCH
);
378 route_match_ip_address_prefix_list_compile (const char *arg
)
380 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
384 route_match_ip_address_prefix_list_free (void *rule
)
386 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
389 struct route_map_rule_cmd route_match_ip_address_prefix_list_cmd
=
391 "ip address prefix-list",
392 route_match_ip_address_prefix_list
,
393 route_match_ip_address_prefix_list_compile
,
394 route_match_ip_address_prefix_list_free
397 /* `match ip next-hop prefix-list PREFIX_LIST' */
399 static route_map_result_t
400 route_match_ip_next_hop_prefix_list (void *rule
, struct prefix
*prefix
,
401 route_map_object_t type
, void *object
)
403 struct prefix_list
*plist
;
404 struct bgp_info
*bgp_info
;
405 struct prefix_ipv4 p
;
407 if (type
== RMAP_BGP
)
411 p
.prefix
= bgp_info
->attr
->nexthop
;
412 p
.prefixlen
= IPV4_MAX_BITLEN
;
414 plist
= prefix_list_lookup (AFI_IP
, (char *) rule
);
418 return (prefix_list_apply (plist
, &p
) == PREFIX_DENY
?
419 RMAP_NOMATCH
: RMAP_MATCH
);
425 route_match_ip_next_hop_prefix_list_compile (const char *arg
)
427 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
431 route_match_ip_next_hop_prefix_list_free (void *rule
)
433 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
436 struct route_map_rule_cmd route_match_ip_next_hop_prefix_list_cmd
=
438 "ip next-hop prefix-list",
439 route_match_ip_next_hop_prefix_list
,
440 route_match_ip_next_hop_prefix_list_compile
,
441 route_match_ip_next_hop_prefix_list_free
444 /* `match ip route-source prefix-list PREFIX_LIST' */
446 static route_map_result_t
447 route_match_ip_route_source_prefix_list (void *rule
, struct prefix
*prefix
,
448 route_map_object_t type
, void *object
)
450 struct prefix_list
*plist
;
451 struct bgp_info
*bgp_info
;
453 struct prefix_ipv4 p
;
455 if (type
== RMAP_BGP
)
458 peer
= bgp_info
->peer
;
460 if (! peer
|| sockunion_family (&peer
->su
) != AF_INET
)
464 p
.prefix
= peer
->su
.sin
.sin_addr
;
465 p
.prefixlen
= IPV4_MAX_BITLEN
;
467 plist
= prefix_list_lookup (AFI_IP
, (char *) rule
);
471 return (prefix_list_apply (plist
, &p
) == PREFIX_DENY
?
472 RMAP_NOMATCH
: RMAP_MATCH
);
478 route_match_ip_route_source_prefix_list_compile (const char *arg
)
480 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
484 route_match_ip_route_source_prefix_list_free (void *rule
)
486 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
489 struct route_map_rule_cmd route_match_ip_route_source_prefix_list_cmd
=
491 "ip route-source prefix-list",
492 route_match_ip_route_source_prefix_list
,
493 route_match_ip_route_source_prefix_list_compile
,
494 route_match_ip_route_source_prefix_list_free
497 /* `match metric METRIC' */
499 /* Match function return 1 if match is success else return zero. */
500 static route_map_result_t
501 route_match_metric (void *rule
, struct prefix
*prefix
,
502 route_map_object_t type
, void *object
)
505 struct bgp_info
*bgp_info
;
507 if (type
== RMAP_BGP
)
512 if (bgp_info
->attr
->med
== *med
)
520 /* Route map `match metric' match statement. `arg' is MED value */
522 route_match_metric_compile (const char *arg
)
526 unsigned long tmpval
;
528 tmpval
= strtoul (arg
, &endptr
, 10);
529 if (*endptr
!= '\0' || tmpval
== ULONG_MAX
|| tmpval
> UINT32_MAX
)
532 med
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_int32_t
));
541 /* Free route map's compiled `match metric' value. */
543 route_match_metric_free (void *rule
)
545 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
548 /* Route map commands for metric matching. */
549 struct route_map_rule_cmd route_match_metric_cmd
=
553 route_match_metric_compile
,
554 route_match_metric_free
557 /* `match as-path ASPATH' */
559 /* Match function for as-path match. I assume given object is */
560 static route_map_result_t
561 route_match_aspath (void *rule
, struct prefix
*prefix
,
562 route_map_object_t type
, void *object
)
565 struct as_list
*as_list
;
566 struct bgp_info
*bgp_info
;
568 if (type
== RMAP_BGP
)
570 as_list
= as_list_lookup ((char *) rule
);
577 return ((as_list_apply (as_list
, bgp_info
->attr
->aspath
) == AS_FILTER_DENY
) ? RMAP_NOMATCH
: RMAP_MATCH
);
582 /* Compile function for as-path match. */
584 route_match_aspath_compile (const char *arg
)
586 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
589 /* Compile function for as-path match. */
591 route_match_aspath_free (void *rule
)
593 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
596 /* Route map commands for aspath matching. */
597 struct route_map_rule_cmd route_match_aspath_cmd
=
601 route_match_aspath_compile
,
602 route_match_aspath_free
605 /* `match community COMMUNIY' */
606 struct rmap_community
612 /* Match function for community match. */
613 static route_map_result_t
614 route_match_community (void *rule
, struct prefix
*prefix
,
615 route_map_object_t type
, void *object
)
617 struct community_list
*list
;
618 struct bgp_info
*bgp_info
;
619 struct rmap_community
*rcom
;
621 if (type
== RMAP_BGP
)
626 list
= community_list_lookup (bgp_clist
, rcom
->name
, COMMUNITY_LIST_MASTER
);
632 if (community_list_exact_match (bgp_info
->attr
->community
, list
))
637 if (community_list_match (bgp_info
->attr
->community
, list
))
644 /* Compile function for community match. */
646 route_match_community_compile (const char *arg
)
648 struct rmap_community
*rcom
;
652 rcom
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct rmap_community
));
654 p
= strchr (arg
, ' ');
658 rcom
->name
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, len
+ 1);
659 memcpy (rcom
->name
, arg
, len
);
664 rcom
->name
= XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
670 /* Compile function for community match. */
672 route_match_community_free (void *rule
)
674 struct rmap_community
*rcom
= rule
;
676 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rcom
->name
);
677 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rcom
);
680 /* Route map commands for community matching. */
681 struct route_map_rule_cmd route_match_community_cmd
=
684 route_match_community
,
685 route_match_community_compile
,
686 route_match_community_free
689 /* Match function for extcommunity match. */
690 static route_map_result_t
691 route_match_ecommunity (void *rule
, struct prefix
*prefix
,
692 route_map_object_t type
, void *object
)
694 struct community_list
*list
;
695 struct bgp_info
*bgp_info
;
697 if (type
== RMAP_BGP
)
701 if (!bgp_info
->attr
->extra
)
704 list
= community_list_lookup (bgp_clist
, (char *) rule
,
705 EXTCOMMUNITY_LIST_MASTER
);
709 if (ecommunity_list_match (bgp_info
->attr
->extra
->ecommunity
, list
))
715 /* Compile function for extcommunity match. */
717 route_match_ecommunity_compile (const char *arg
)
719 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
722 /* Compile function for extcommunity match. */
724 route_match_ecommunity_free (void *rule
)
726 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
729 /* Route map commands for community matching. */
730 struct route_map_rule_cmd route_match_ecommunity_cmd
=
733 route_match_ecommunity
,
734 route_match_ecommunity_compile
,
735 route_match_ecommunity_free
738 /* `match nlri` and `set nlri` are replaced by `address-family ipv4`
739 and `address-family vpnv4'. */
742 static route_map_result_t
743 route_match_origin (void *rule
, struct prefix
*prefix
,
744 route_map_object_t type
, void *object
)
747 struct bgp_info
*bgp_info
;
749 if (type
== RMAP_BGP
)
754 if (bgp_info
->attr
->origin
== *origin
)
762 route_match_origin_compile (const char *arg
)
766 origin
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_char
));
768 if (strcmp (arg
, "igp") == 0)
770 else if (strcmp (arg
, "egp") == 0)
778 /* Free route map's compiled `ip address' value. */
780 route_match_origin_free (void *rule
)
782 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
785 /* Route map commands for origin matching. */
786 struct route_map_rule_cmd route_match_origin_cmd
=
790 route_match_origin_compile
,
791 route_match_origin_free
793 /* `set ip next-hop IP_ADDRESS' */
795 /* Set nexthop to object. ojbect must be pointer to struct attr. */
796 struct rmap_ip_nexthop_set
798 struct in_addr
*address
;
802 static route_map_result_t
803 route_set_ip_nexthop (void *rule
, struct prefix
*prefix
,
804 route_map_object_t type
, void *object
)
806 struct rmap_ip_nexthop_set
*rins
= rule
;
807 struct in_addr peer_address
;
808 struct bgp_info
*bgp_info
;
811 if (type
== RMAP_BGP
)
814 peer
= bgp_info
->peer
;
816 if (rins
->peer_address
)
818 if ((CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IN
) ||
819 CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IMPORT
))
821 && sockunion_family (peer
->su_remote
) == AF_INET
)
823 inet_aton (sockunion_su2str (peer
->su_remote
), &peer_address
);
824 bgp_info
->attr
->nexthop
= peer_address
;
825 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
);
827 else if (CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
)
829 && sockunion_family (peer
->su_local
) == AF_INET
)
831 inet_aton (sockunion_su2str (peer
->su_local
), &peer_address
);
832 bgp_info
->attr
->nexthop
= peer_address
;
833 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
);
838 /* Set next hop value. */
839 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
);
840 bgp_info
->attr
->nexthop
= *rins
->address
;
847 /* Route map `ip nexthop' compile function. Given string is converted
848 to struct in_addr structure. */
850 route_set_ip_nexthop_compile (const char *arg
)
852 struct rmap_ip_nexthop_set
*rins
;
853 struct in_addr
*address
= NULL
;
854 int peer_address
= 0;
857 if (strcmp (arg
, "peer-address") == 0)
861 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in_addr
));
862 ret
= inet_aton (arg
, address
);
866 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
871 rins
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct rmap_ip_nexthop_set
));
873 rins
->address
= address
;
874 rins
->peer_address
= peer_address
;
879 /* Free route map's compiled `ip nexthop' value. */
881 route_set_ip_nexthop_free (void *rule
)
883 struct rmap_ip_nexthop_set
*rins
= rule
;
886 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rins
->address
);
888 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rins
);
891 /* Route map commands for ip nexthop set. */
892 struct route_map_rule_cmd route_set_ip_nexthop_cmd
=
895 route_set_ip_nexthop
,
896 route_set_ip_nexthop_compile
,
897 route_set_ip_nexthop_free
900 /* `set local-preference LOCAL_PREF' */
902 /* Set local preference. */
903 static route_map_result_t
904 route_set_local_pref (void *rule
, struct prefix
*prefix
,
905 route_map_object_t type
, void *object
)
907 u_int32_t
*local_pref
;
908 struct bgp_info
*bgp_info
;
910 if (type
== RMAP_BGP
)
912 /* Fetch routemap's rule information. */
916 /* Set local preference value. */
917 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
);
918 bgp_info
->attr
->local_pref
= *local_pref
;
924 /* set local preference compilation. */
926 route_set_local_pref_compile (const char *arg
)
929 u_int32_t
*local_pref
;
932 /* Local preference value shoud be integer. */
933 if (! all_digit (arg
))
936 tmp
= strtoul (arg
, &endptr
, 10);
937 if (*endptr
!= '\0' || tmp
== ULONG_MAX
|| tmp
> UINT32_MAX
)
940 local_pref
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_int32_t
));
950 /* Free route map's local preference value. */
952 route_set_local_pref_free (void *rule
)
954 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
957 /* Set local preference rule structure. */
958 struct route_map_rule_cmd route_set_local_pref_cmd
=
961 route_set_local_pref
,
962 route_set_local_pref_compile
,
963 route_set_local_pref_free
,
966 /* `set weight WEIGHT' */
969 static route_map_result_t
970 route_set_weight (void *rule
, struct prefix
*prefix
, route_map_object_t type
,
974 struct bgp_info
*bgp_info
;
976 if (type
== RMAP_BGP
)
978 /* Fetch routemap's rule information. */
982 /* Set weight value. */
984 (bgp_attr_extra_get (bgp_info
->attr
))->weight
= *weight
;
985 else if (bgp_info
->attr
->extra
)
986 bgp_info
->attr
->extra
->weight
= 0;
992 /* set local preference compilation. */
994 route_set_weight_compile (const char *arg
)
1000 /* Local preference value shoud be integer. */
1001 if (! all_digit (arg
))
1005 tmp
= strtoul (arg
, &endptr
, 10);
1006 if (*endptr
!= '\0' || tmp
== ULONG_MAX
|| tmp
> UINT32_MAX
)
1009 weight
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_int32_t
));
1019 /* Free route map's local preference value. */
1021 route_set_weight_free (void *rule
)
1023 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1026 /* Set local preference rule structure. */
1027 struct route_map_rule_cmd route_set_weight_cmd
=
1031 route_set_weight_compile
,
1032 route_set_weight_free
,
1035 /* `set metric METRIC' */
1037 /* Set metric to attribute. */
1038 static route_map_result_t
1039 route_set_metric (void *rule
, struct prefix
*prefix
,
1040 route_map_object_t type
, void *object
)
1043 u_int32_t metric_val
;
1044 struct bgp_info
*bgp_info
;
1046 if (type
== RMAP_BGP
)
1048 /* Fetch routemap's rule information. */
1052 if (! (bgp_info
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
)))
1053 bgp_info
->attr
->med
= 0;
1054 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
1056 if (all_digit (metric
))
1058 metric_val
= strtoul (metric
, (char **)NULL
, 10);
1059 bgp_info
->attr
->med
= metric_val
;
1063 metric_val
= strtoul (metric
+1, (char **)NULL
, 10);
1065 if (strncmp (metric
, "+", 1) == 0)
1067 if (bgp_info
->attr
->med
/2 + metric_val
/2 > BGP_MED_MAX
/2)
1068 bgp_info
->attr
->med
= BGP_MED_MAX
- 1;
1070 bgp_info
->attr
->med
+= metric_val
;
1072 else if (strncmp (metric
, "-", 1) == 0)
1074 if (bgp_info
->attr
->med
<= metric_val
)
1075 bgp_info
->attr
->med
= 0;
1077 bgp_info
->attr
->med
-= metric_val
;
1084 /* set metric compilation. */
1086 route_set_metric_compile (const char *arg
)
1090 char *endptr
= NULL
;
1092 if (all_digit (arg
))
1094 /* set metric value check*/
1095 larg
= strtoul (arg
, &endptr
, 10);
1096 if (*endptr
!= '\0' || larg
== ULONG_MAX
|| larg
> UINT32_MAX
)
1102 /* set metric +/-value check */
1103 if ((strncmp (arg
, "+", 1) != 0
1104 && strncmp (arg
, "-", 1) != 0)
1105 || (! all_digit (arg
+1)))
1108 larg
= strtoul (arg
+1, &endptr
, 10);
1109 if (*endptr
!= '\0' || larg
== ULONG_MAX
|| larg
> UINT32_MAX
)
1114 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
1117 /* Free route map's compiled `set metric' value. */
1119 route_set_metric_free (void *rule
)
1121 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1124 /* Set metric rule structure. */
1125 struct route_map_rule_cmd route_set_metric_cmd
=
1129 route_set_metric_compile
,
1130 route_set_metric_free
,
1133 /* `set as-path prepend ASPATH' */
1135 /* For AS path prepend mechanism. */
1136 static route_map_result_t
1137 route_set_aspath_prepend (void *rule
, struct prefix
*prefix
, route_map_object_t type
, void *object
)
1139 struct aspath
*aspath
;
1141 struct bgp_info
*binfo
;
1143 if (type
== RMAP_BGP
)
1148 if (binfo
->attr
->aspath
->refcnt
)
1149 new = aspath_dup (binfo
->attr
->aspath
);
1151 new = binfo
->attr
->aspath
;
1153 aspath_prepend (aspath
, new);
1154 binfo
->attr
->aspath
= new;
1160 /* Compile function for as-path prepend. */
1162 route_set_aspath_prepend_compile (const char *arg
)
1164 struct aspath
*aspath
;
1166 aspath
= aspath_str2aspath (arg
);
1172 /* Compile function for as-path prepend. */
1174 route_set_aspath_prepend_free (void *rule
)
1176 struct aspath
*aspath
= rule
;
1177 aspath_free (aspath
);
1180 /* Set metric rule structure. */
1181 struct route_map_rule_cmd route_set_aspath_prepend_cmd
=
1184 route_set_aspath_prepend
,
1185 route_set_aspath_prepend_compile
,
1186 route_set_aspath_prepend_free
,
1189 /* `set as-path exclude ASn' */
1191 /* For ASN exclude mechanism.
1192 * Iterate over ASns requested and filter them from the given AS_PATH one by one.
1193 * Make a deep copy of existing AS_PATH, but for the first ASn only.
1195 static route_map_result_t
1196 route_set_aspath_exclude (void *rule
, struct prefix
*dummy
, route_map_object_t type
, void *object
)
1198 struct aspath
* new_path
, * exclude_path
;
1199 struct bgp_info
*binfo
;
1201 if (type
== RMAP_BGP
)
1203 exclude_path
= rule
;
1205 if (binfo
->attr
->aspath
->refcnt
)
1206 new_path
= aspath_dup (binfo
->attr
->aspath
);
1208 new_path
= binfo
->attr
->aspath
;
1209 binfo
->attr
->aspath
= aspath_filter_exclude (new_path
, exclude_path
);
1214 /* FIXME: consider using route_set_aspath_prepend_compile() and
1215 * route_set_aspath_prepend_free(), which two below function are
1219 /* Compile function for as-path exclude. */
1221 route_set_aspath_exclude_compile (const char *arg
)
1223 struct aspath
*aspath
;
1225 aspath
= aspath_str2aspath (arg
);
1232 route_set_aspath_exclude_free (void *rule
)
1234 struct aspath
*aspath
= rule
;
1235 aspath_free (aspath
);
1238 /* Set ASn exlude rule structure. */
1239 struct route_map_rule_cmd route_set_aspath_exclude_cmd
=
1242 route_set_aspath_exclude
,
1243 route_set_aspath_exclude_compile
,
1244 route_set_aspath_exclude_free
,
1247 /* `set community COMMUNITY' */
1250 struct community
*com
;
1255 /* For community set mechanism. */
1256 static route_map_result_t
1257 route_set_community (void *rule
, struct prefix
*prefix
,
1258 route_map_object_t type
, void *object
)
1260 struct rmap_com_set
*rcs
;
1261 struct bgp_info
*binfo
;
1263 struct community
*new = NULL
;
1264 struct community
*old
;
1265 struct community
*merge
;
1267 if (type
== RMAP_BGP
)
1272 old
= attr
->community
;
1277 attr
->flag
&= ~(ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
));
1278 attr
->community
= NULL
;
1282 /* "additive" case. */
1283 if (rcs
->additive
&& old
)
1285 merge
= community_merge (community_dup (old
), rcs
->com
);
1287 /* HACK: if the old community is not intern'd,
1288 * we should free it here, or all reference to it may be lost.
1289 * Really need to cleanup attribute caching sometime.
1291 if (old
->refcnt
== 0)
1292 community_free (old
);
1293 new = community_uniq_sort (merge
);
1294 community_free (merge
);
1297 new = community_dup (rcs
->com
);
1299 /* will be interned by caller if required */
1300 attr
->community
= new;
1302 attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
);
1308 /* Compile function for set community. */
1310 route_set_community_compile (const char *arg
)
1312 struct rmap_com_set
*rcs
;
1313 struct community
*com
= NULL
;
1318 if (strcmp (arg
, "none") == 0)
1322 sp
= strstr (arg
, "additive");
1326 /* "additive" keyworkd is included. */
1331 com
= community_str2com (arg
);
1340 rcs
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct rmap_com_set
));
1342 rcs
->additive
= additive
;
1348 /* Free function for set community. */
1350 route_set_community_free (void *rule
)
1352 struct rmap_com_set
*rcs
= rule
;
1355 community_free (rcs
->com
);
1356 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rcs
);
1359 /* Set community rule structure. */
1360 struct route_map_rule_cmd route_set_community_cmd
=
1363 route_set_community
,
1364 route_set_community_compile
,
1365 route_set_community_free
,
1368 /* `set comm-list (<1-99>|<100-500>|WORD) delete' */
1370 /* For community set mechanism. */
1371 static route_map_result_t
1372 route_set_community_delete (void *rule
, struct prefix
*prefix
,
1373 route_map_object_t type
, void *object
)
1375 struct community_list
*list
;
1376 struct community
*merge
;
1377 struct community
*new;
1378 struct community
*old
;
1379 struct bgp_info
*binfo
;
1381 if (type
== RMAP_BGP
)
1387 list
= community_list_lookup (bgp_clist
, rule
, COMMUNITY_LIST_MASTER
);
1388 old
= binfo
->attr
->community
;
1392 merge
= community_list_match_delete (community_dup (old
), list
);
1393 new = community_uniq_sort (merge
);
1394 community_free (merge
);
1398 binfo
->attr
->community
= NULL
;
1399 binfo
->attr
->flag
&= ~ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
);
1400 community_free (new);
1404 binfo
->attr
->community
= new;
1405 binfo
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
);
1413 /* Compile function for set community. */
1415 route_set_community_delete_compile (const char *arg
)
1421 p
= strchr (arg
, ' ');
1425 str
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, len
+ 1);
1426 memcpy (str
, arg
, len
);
1434 /* Free function for set community. */
1436 route_set_community_delete_free (void *rule
)
1438 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1441 /* Set community rule structure. */
1442 struct route_map_rule_cmd route_set_community_delete_cmd
=
1445 route_set_community_delete
,
1446 route_set_community_delete_compile
,
1447 route_set_community_delete_free
,
1450 /* `set extcommunity rt COMMUNITY' */
1452 /* For community set mechanism. */
1453 static route_map_result_t
1454 route_set_ecommunity_rt (void *rule
, struct prefix
*prefix
,
1455 route_map_object_t type
, void *object
)
1457 struct ecommunity
*ecom
;
1458 struct ecommunity
*new_ecom
;
1459 struct ecommunity
*old_ecom
;
1460 struct bgp_info
*bgp_info
;
1462 if (type
== RMAP_BGP
)
1470 /* We assume additive for Extended Community. */
1471 old_ecom
= (bgp_attr_extra_get (bgp_info
->attr
))->ecommunity
;
1474 new_ecom
= ecommunity_merge (ecommunity_dup (old_ecom
), ecom
);
1476 new_ecom
= ecommunity_dup (ecom
);
1478 bgp_info
->attr
->extra
->ecommunity
= new_ecom
;
1481 ecommunity_free (old_ecom
);
1483 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES
);
1488 /* Compile function for set community. */
1490 route_set_ecommunity_rt_compile (const char *arg
)
1492 struct ecommunity
*ecom
;
1494 ecom
= ecommunity_str2com (arg
, ECOMMUNITY_ROUTE_TARGET
, 0);
1500 /* Free function for set community. */
1502 route_set_ecommunity_rt_free (void *rule
)
1504 struct ecommunity
*ecom
= rule
;
1505 ecommunity_free (ecom
);
1508 /* Set community rule structure. */
1509 struct route_map_rule_cmd route_set_ecommunity_rt_cmd
=
1512 route_set_ecommunity_rt
,
1513 route_set_ecommunity_rt_compile
,
1514 route_set_ecommunity_rt_free
,
1517 /* `set extcommunity soo COMMUNITY' */
1519 /* For community set mechanism. */
1520 static route_map_result_t
1521 route_set_ecommunity_soo (void *rule
, struct prefix
*prefix
,
1522 route_map_object_t type
, void *object
)
1524 struct ecommunity
*ecom
;
1525 struct bgp_info
*bgp_info
;
1527 if (type
== RMAP_BGP
)
1535 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES
);
1536 (bgp_attr_extra_get (bgp_info
->attr
))->ecommunity
= ecommunity_dup (ecom
);
1541 /* Compile function for set community. */
1543 route_set_ecommunity_soo_compile (const char *arg
)
1545 struct ecommunity
*ecom
;
1547 ecom
= ecommunity_str2com (arg
, ECOMMUNITY_SITE_ORIGIN
, 0);
1554 /* Free function for set community. */
1556 route_set_ecommunity_soo_free (void *rule
)
1558 struct ecommunity
*ecom
= rule
;
1559 ecommunity_free (ecom
);
1562 /* Set community rule structure. */
1563 struct route_map_rule_cmd route_set_ecommunity_soo_cmd
=
1566 route_set_ecommunity_soo
,
1567 route_set_ecommunity_soo_compile
,
1568 route_set_ecommunity_soo_free
,
1571 /* `set origin ORIGIN' */
1573 /* For origin set. */
1574 static route_map_result_t
1575 route_set_origin (void *rule
, struct prefix
*prefix
, route_map_object_t type
, void *object
)
1578 struct bgp_info
*bgp_info
;
1580 if (type
== RMAP_BGP
)
1585 bgp_info
->attr
->origin
= *origin
;
1591 /* Compile function for origin set. */
1593 route_set_origin_compile (const char *arg
)
1597 origin
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_char
));
1599 if (strcmp (arg
, "igp") == 0)
1601 else if (strcmp (arg
, "egp") == 0)
1609 /* Compile function for origin set. */
1611 route_set_origin_free (void *rule
)
1613 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1616 /* Set metric rule structure. */
1617 struct route_map_rule_cmd route_set_origin_cmd
=
1621 route_set_origin_compile
,
1622 route_set_origin_free
,
1625 /* `set atomic-aggregate' */
1627 /* For atomic aggregate set. */
1628 static route_map_result_t
1629 route_set_atomic_aggregate (void *rule
, struct prefix
*prefix
,
1630 route_map_object_t type
, void *object
)
1632 struct bgp_info
*bgp_info
;
1634 if (type
== RMAP_BGP
)
1637 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
1643 /* Compile function for atomic aggregate. */
1645 route_set_atomic_aggregate_compile (const char *arg
)
1650 /* Compile function for atomic aggregate. */
1652 route_set_atomic_aggregate_free (void *rule
)
1657 /* Set atomic aggregate rule structure. */
1658 struct route_map_rule_cmd route_set_atomic_aggregate_cmd
=
1661 route_set_atomic_aggregate
,
1662 route_set_atomic_aggregate_compile
,
1663 route_set_atomic_aggregate_free
,
1666 /* `set aggregator as AS A.B.C.D' */
1670 struct in_addr address
;
1673 static route_map_result_t
1674 route_set_aggregator_as (void *rule
, struct prefix
*prefix
,
1675 route_map_object_t type
, void *object
)
1677 struct bgp_info
*bgp_info
;
1678 struct aggregator
*aggregator
;
1679 struct attr_extra
*ae
;
1681 if (type
== RMAP_BGP
)
1685 ae
= bgp_attr_extra_get (bgp_info
->attr
);
1687 ae
->aggregator_as
= aggregator
->as
;
1688 ae
->aggregator_addr
= aggregator
->address
;
1689 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
);
1696 route_set_aggregator_as_compile (const char *arg
)
1698 struct aggregator
*aggregator
;
1702 aggregator
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct aggregator
));
1703 sscanf (arg
, "%s %s", as
, address
);
1705 aggregator
->as
= strtoul (as
, NULL
, 10);
1706 inet_aton (address
, &aggregator
->address
);
1712 route_set_aggregator_as_free (void *rule
)
1714 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1717 struct route_map_rule_cmd route_set_aggregator_as_cmd
=
1720 route_set_aggregator_as
,
1721 route_set_aggregator_as_compile
,
1722 route_set_aggregator_as_free
,
1726 /* `match ipv6 address IP_ACCESS_LIST' */
1728 static route_map_result_t
1729 route_match_ipv6_address (void *rule
, struct prefix
*prefix
,
1730 route_map_object_t type
, void *object
)
1732 struct access_list
*alist
;
1734 if (type
== RMAP_BGP
)
1736 alist
= access_list_lookup (AFI_IP6
, (char *) rule
);
1738 return RMAP_NOMATCH
;
1740 return (access_list_apply (alist
, prefix
) == FILTER_DENY
?
1741 RMAP_NOMATCH
: RMAP_MATCH
);
1743 return RMAP_NOMATCH
;
1747 route_match_ipv6_address_compile (const char *arg
)
1749 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
1753 route_match_ipv6_address_free (void *rule
)
1755 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1758 /* Route map commands for ip address matching. */
1759 struct route_map_rule_cmd route_match_ipv6_address_cmd
=
1762 route_match_ipv6_address
,
1763 route_match_ipv6_address_compile
,
1764 route_match_ipv6_address_free
1767 /* `match ipv6 next-hop IP_ADDRESS' */
1769 static route_map_result_t
1770 route_match_ipv6_next_hop (void *rule
, struct prefix
*prefix
,
1771 route_map_object_t type
, void *object
)
1773 struct in6_addr
*addr
;
1774 struct bgp_info
*bgp_info
;
1776 if (type
== RMAP_BGP
)
1781 if (!bgp_info
->attr
->extra
)
1782 return RMAP_NOMATCH
;
1784 if (IPV6_ADDR_SAME (&bgp_info
->attr
->extra
->mp_nexthop_global
, rule
))
1787 if (bgp_info
->attr
->extra
->mp_nexthop_len
== 32 &&
1788 IPV6_ADDR_SAME (&bgp_info
->attr
->extra
->mp_nexthop_local
, rule
))
1791 return RMAP_NOMATCH
;
1794 return RMAP_NOMATCH
;
1798 route_match_ipv6_next_hop_compile (const char *arg
)
1800 struct in6_addr
*address
;
1803 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in6_addr
));
1805 ret
= inet_pton (AF_INET6
, arg
, address
);
1808 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
1816 route_match_ipv6_next_hop_free (void *rule
)
1818 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1821 struct route_map_rule_cmd route_match_ipv6_next_hop_cmd
=
1824 route_match_ipv6_next_hop
,
1825 route_match_ipv6_next_hop_compile
,
1826 route_match_ipv6_next_hop_free
1829 /* `match ipv6 address prefix-list PREFIX_LIST' */
1831 static route_map_result_t
1832 route_match_ipv6_address_prefix_list (void *rule
, struct prefix
*prefix
,
1833 route_map_object_t type
, void *object
)
1835 struct prefix_list
*plist
;
1837 if (type
== RMAP_BGP
)
1839 plist
= prefix_list_lookup (AFI_IP6
, (char *) rule
);
1841 return RMAP_NOMATCH
;
1843 return (prefix_list_apply (plist
, prefix
) == PREFIX_DENY
?
1844 RMAP_NOMATCH
: RMAP_MATCH
);
1846 return RMAP_NOMATCH
;
1850 route_match_ipv6_address_prefix_list_compile (const char *arg
)
1852 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
1856 route_match_ipv6_address_prefix_list_free (void *rule
)
1858 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1861 struct route_map_rule_cmd route_match_ipv6_address_prefix_list_cmd
=
1863 "ipv6 address prefix-list",
1864 route_match_ipv6_address_prefix_list
,
1865 route_match_ipv6_address_prefix_list_compile
,
1866 route_match_ipv6_address_prefix_list_free
1869 /* `set ipv6 nexthop global IP_ADDRESS' */
1871 /* Set nexthop to object. ojbect must be pointer to struct attr. */
1872 static route_map_result_t
1873 route_set_ipv6_nexthop_global (void *rule
, struct prefix
*prefix
,
1874 route_map_object_t type
, void *object
)
1876 struct in6_addr
*address
;
1877 struct bgp_info
*bgp_info
;
1879 if (type
== RMAP_BGP
)
1881 /* Fetch routemap's rule information. */
1885 /* Set next hop value. */
1886 (bgp_attr_extra_get (bgp_info
->attr
))->mp_nexthop_global
= *address
;
1888 /* Set nexthop length. */
1889 if (bgp_info
->attr
->extra
->mp_nexthop_len
== 0)
1890 bgp_info
->attr
->extra
->mp_nexthop_len
= 16;
1896 /* Route map `ip next-hop' compile function. Given string is converted
1897 to struct in_addr structure. */
1899 route_set_ipv6_nexthop_global_compile (const char *arg
)
1902 struct in6_addr
*address
;
1904 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in6_addr
));
1906 ret
= inet_pton (AF_INET6
, arg
, address
);
1910 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
1917 /* Free route map's compiled `ip next-hop' value. */
1919 route_set_ipv6_nexthop_global_free (void *rule
)
1921 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1924 /* Route map commands for ip nexthop set. */
1925 struct route_map_rule_cmd route_set_ipv6_nexthop_global_cmd
=
1927 "ipv6 next-hop global",
1928 route_set_ipv6_nexthop_global
,
1929 route_set_ipv6_nexthop_global_compile
,
1930 route_set_ipv6_nexthop_global_free
1933 /* `set ipv6 nexthop local IP_ADDRESS' */
1935 /* Set nexthop to object. ojbect must be pointer to struct attr. */
1936 static route_map_result_t
1937 route_set_ipv6_nexthop_local (void *rule
, struct prefix
*prefix
,
1938 route_map_object_t type
, void *object
)
1940 struct in6_addr
*address
;
1941 struct bgp_info
*bgp_info
;
1943 if (type
== RMAP_BGP
)
1945 /* Fetch routemap's rule information. */
1949 /* Set next hop value. */
1950 (bgp_attr_extra_get (bgp_info
->attr
))->mp_nexthop_local
= *address
;
1952 /* Set nexthop length. */
1953 if (bgp_info
->attr
->extra
->mp_nexthop_len
!= 32)
1954 bgp_info
->attr
->extra
->mp_nexthop_len
= 32;
1960 /* Route map `ip nexthop' compile function. Given string is converted
1961 to struct in_addr structure. */
1963 route_set_ipv6_nexthop_local_compile (const char *arg
)
1966 struct in6_addr
*address
;
1968 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in6_addr
));
1970 ret
= inet_pton (AF_INET6
, arg
, address
);
1974 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
1981 /* Free route map's compiled `ip nexthop' value. */
1983 route_set_ipv6_nexthop_local_free (void *rule
)
1985 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1988 /* Route map commands for ip nexthop set. */
1989 struct route_map_rule_cmd route_set_ipv6_nexthop_local_cmd
=
1991 "ipv6 next-hop local",
1992 route_set_ipv6_nexthop_local
,
1993 route_set_ipv6_nexthop_local_compile
,
1994 route_set_ipv6_nexthop_local_free
1996 #endif /* HAVE_IPV6 */
1998 /* `set vpnv4 nexthop A.B.C.D' */
2000 static route_map_result_t
2001 route_set_vpnv4_nexthop (void *rule
, struct prefix
*prefix
,
2002 route_map_object_t type
, void *object
)
2004 struct in_addr
*address
;
2005 struct bgp_info
*bgp_info
;
2007 if (type
== RMAP_BGP
)
2009 /* Fetch routemap's rule information. */
2013 /* Set next hop value. */
2014 (bgp_attr_extra_get (bgp_info
->attr
))->mp_nexthop_global_in
= *address
;
2021 route_set_vpnv4_nexthop_compile (const char *arg
)
2024 struct in_addr
*address
;
2026 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in_addr
));
2028 ret
= inet_aton (arg
, address
);
2032 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
2040 route_set_vpnv4_nexthop_free (void *rule
)
2042 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2045 /* Route map commands for ip nexthop set. */
2046 struct route_map_rule_cmd route_set_vpnv4_nexthop_cmd
=
2049 route_set_vpnv4_nexthop
,
2050 route_set_vpnv4_nexthop_compile
,
2051 route_set_vpnv4_nexthop_free
2054 /* `set originator-id' */
2056 /* For origin set. */
2057 static route_map_result_t
2058 route_set_originator_id (void *rule
, struct prefix
*prefix
, route_map_object_t type
, void *object
)
2060 struct in_addr
*address
;
2061 struct bgp_info
*bgp_info
;
2063 if (type
== RMAP_BGP
)
2068 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
);
2069 (bgp_attr_extra_get (bgp_info
->attr
))->originator_id
= *address
;
2075 /* Compile function for originator-id set. */
2077 route_set_originator_id_compile (const char *arg
)
2080 struct in_addr
*address
;
2082 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in_addr
));
2084 ret
= inet_aton (arg
, address
);
2088 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
2095 /* Compile function for originator_id set. */
2097 route_set_originator_id_free (void *rule
)
2099 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2102 /* Set metric rule structure. */
2103 struct route_map_rule_cmd route_set_originator_id_cmd
=
2106 route_set_originator_id
,
2107 route_set_originator_id_compile
,
2108 route_set_originator_id_free
,
2111 /* Add bgp route map rule. */
2113 bgp_route_match_add (struct vty
*vty
, struct route_map_index
*index
,
2114 const char *command
, const char *arg
)
2118 ret
= route_map_add_match (index
, command
, arg
);
2123 case RMAP_RULE_MISSING
:
2124 vty_out (vty
, "%% Can't find rule.%s", VTY_NEWLINE
);
2126 case RMAP_COMPILE_ERROR
:
2127 vty_out (vty
, "%% Argument is malformed.%s", VTY_NEWLINE
);
2134 /* Delete bgp route map rule. */
2136 bgp_route_match_delete (struct vty
*vty
, struct route_map_index
*index
,
2137 const char *command
, const char *arg
)
2141 ret
= route_map_delete_match (index
, command
, arg
);
2146 case RMAP_RULE_MISSING
:
2147 vty_out (vty
, "%% Can't find rule.%s", VTY_NEWLINE
);
2149 case RMAP_COMPILE_ERROR
:
2150 vty_out (vty
, "%% Argument is malformed.%s", VTY_NEWLINE
);
2157 /* Add bgp route map rule. */
2159 bgp_route_set_add (struct vty
*vty
, struct route_map_index
*index
,
2160 const char *command
, const char *arg
)
2164 ret
= route_map_add_set (index
, command
, arg
);
2169 case RMAP_RULE_MISSING
:
2170 vty_out (vty
, "%% Can't find rule.%s", VTY_NEWLINE
);
2172 case RMAP_COMPILE_ERROR
:
2173 vty_out (vty
, "%% Argument is malformed.%s", VTY_NEWLINE
);
2180 /* Delete bgp route map rule. */
2182 bgp_route_set_delete (struct vty
*vty
, struct route_map_index
*index
,
2183 const char *command
, const char *arg
)
2187 ret
= route_map_delete_set (index
, command
, arg
);
2192 case RMAP_RULE_MISSING
:
2193 vty_out (vty
, "%% Can't find rule.%s", VTY_NEWLINE
);
2195 case RMAP_COMPILE_ERROR
:
2196 vty_out (vty
, "%% Argument is malformed.%s", VTY_NEWLINE
);
2203 /* Hook function for updating route_map assignment. */
2205 bgp_route_map_update (const char *unused
)
2211 struct listnode
*node
, *nnode
;
2212 struct listnode
*mnode
, *mnnode
;
2215 struct peer_group
*group
;
2216 struct bgp_filter
*filter
;
2217 struct bgp_node
*bn
;
2218 struct bgp_static
*bgp_static
;
2220 /* For neighbor route-map updates. */
2221 for (ALL_LIST_ELEMENTS (bm
->bgp
, mnode
, mnnode
, bgp
))
2223 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
2225 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2226 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2228 filter
= &peer
->filter
[afi
][safi
];
2230 for (direct
= RMAP_IN
; direct
< RMAP_MAX
; direct
++)
2232 if (filter
->map
[direct
].name
)
2233 filter
->map
[direct
].map
=
2234 route_map_lookup_by_name (filter
->map
[direct
].name
);
2236 filter
->map
[direct
].map
= NULL
;
2239 if (filter
->usmap
.name
)
2240 filter
->usmap
.map
= route_map_lookup_by_name (filter
->usmap
.name
);
2242 filter
->usmap
.map
= NULL
;
2245 for (ALL_LIST_ELEMENTS (bgp
->group
, node
, nnode
, group
))
2247 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2248 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2250 filter
= &group
->conf
->filter
[afi
][safi
];
2252 for (direct
= RMAP_IN
; direct
< RMAP_MAX
; direct
++)
2254 if (filter
->map
[direct
].name
)
2255 filter
->map
[direct
].map
=
2256 route_map_lookup_by_name (filter
->map
[direct
].name
);
2258 filter
->map
[direct
].map
= NULL
;
2261 if (filter
->usmap
.name
)
2262 filter
->usmap
.map
= route_map_lookup_by_name (filter
->usmap
.name
);
2264 filter
->usmap
.map
= NULL
;
2269 /* For default-originate route-map updates. */
2270 for (ALL_LIST_ELEMENTS (bm
->bgp
, mnode
, mnnode
, bgp
))
2272 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
2274 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2275 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2277 if (peer
->default_rmap
[afi
][safi
].name
)
2278 peer
->default_rmap
[afi
][safi
].map
=
2279 route_map_lookup_by_name (peer
->default_rmap
[afi
][safi
].name
);
2281 peer
->default_rmap
[afi
][safi
].map
= NULL
;
2286 /* For network route-map updates. */
2287 for (ALL_LIST_ELEMENTS (bm
->bgp
, mnode
, mnnode
, bgp
))
2289 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2290 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2291 for (bn
= bgp_table_top (bgp
->route
[afi
][safi
]); bn
;
2292 bn
= bgp_route_next (bn
))
2293 if ((bgp_static
= bn
->info
) != NULL
)
2295 if (bgp_static
->rmap
.name
)
2296 bgp_static
->rmap
.map
=
2297 route_map_lookup_by_name (bgp_static
->rmap
.name
);
2299 bgp_static
->rmap
.map
= NULL
;
2303 /* For redistribute route-map updates. */
2304 for (ALL_LIST_ELEMENTS (bm
->bgp
, mnode
, mnnode
, bgp
))
2306 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++)
2308 if (bgp
->rmap
[ZEBRA_FAMILY_IPV4
][i
].name
)
2309 bgp
->rmap
[ZEBRA_FAMILY_IPV4
][i
].map
=
2310 route_map_lookup_by_name (bgp
->rmap
[ZEBRA_FAMILY_IPV4
][i
].name
);
2312 if (bgp
->rmap
[ZEBRA_FAMILY_IPV6
][i
].name
)
2313 bgp
->rmap
[ZEBRA_FAMILY_IPV6
][i
].map
=
2314 route_map_lookup_by_name (bgp
->rmap
[ZEBRA_FAMILY_IPV6
][i
].name
);
2315 #endif /* HAVE_IPV6 */
2322 "match peer (A.B.C.D|X:X::X:X)",
2324 "Match peer address\n"
2325 "IPv6 address of peer\n"
2326 "IP address of peer\n")
2328 return bgp_route_match_add (vty
, vty
->index
, "peer", argv
[0]);
2331 DEFUN (match_peer_local
,
2332 match_peer_local_cmd
,
2335 "Match peer address\n"
2336 "Static or Redistributed routes\n")
2338 return bgp_route_match_add (vty
, vty
->index
, "peer", NULL
);
2341 DEFUN (no_match_peer
,
2346 "Match peer address\n")
2349 return bgp_route_match_delete (vty
, vty
->index
, "peer", NULL
);
2351 return bgp_route_match_delete (vty
, vty
->index
, "peer", argv
[0]);
2354 ALIAS (no_match_peer
,
2355 no_match_peer_val_cmd
,
2356 "no match peer (A.B.C.D|X:X::X:X)",
2359 "Match peer address\n"
2360 "IPv6 address of peer\n"
2361 "IP address of peer\n")
2363 ALIAS (no_match_peer
,
2364 no_match_peer_local_cmd
,
2365 "no match peer local",
2368 "Match peer address\n"
2369 "Static or Redistributed routes\n")
2371 DEFUN (match_ip_address
,
2372 match_ip_address_cmd
,
2373 "match ip address (<1-199>|<1300-2699>|WORD)",
2376 "Match address of route\n"
2377 "IP access-list number\n"
2378 "IP access-list number (expanded range)\n"
2379 "IP Access-list name\n")
2381 return bgp_route_match_add (vty
, vty
->index
, "ip address", argv
[0]);
2384 DEFUN (no_match_ip_address
,
2385 no_match_ip_address_cmd
,
2386 "no match ip address",
2390 "Match address of route\n")
2393 return bgp_route_match_delete (vty
, vty
->index
, "ip address", NULL
);
2395 return bgp_route_match_delete (vty
, vty
->index
, "ip address", argv
[0]);
2398 ALIAS (no_match_ip_address
,
2399 no_match_ip_address_val_cmd
,
2400 "no match ip address (<1-199>|<1300-2699>|WORD)",
2404 "Match address of route\n"
2405 "IP access-list number\n"
2406 "IP access-list number (expanded range)\n"
2407 "IP Access-list name\n")
2409 DEFUN (match_ip_next_hop
,
2410 match_ip_next_hop_cmd
,
2411 "match ip next-hop (<1-199>|<1300-2699>|WORD)",
2414 "Match next-hop address of route\n"
2415 "IP access-list number\n"
2416 "IP access-list number (expanded range)\n"
2417 "IP Access-list name\n")
2419 return bgp_route_match_add (vty
, vty
->index
, "ip next-hop", argv
[0]);
2422 DEFUN (no_match_ip_next_hop
,
2423 no_match_ip_next_hop_cmd
,
2424 "no match ip next-hop",
2428 "Match next-hop address of route\n")
2431 return bgp_route_match_delete (vty
, vty
->index
, "ip next-hop", NULL
);
2433 return bgp_route_match_delete (vty
, vty
->index
, "ip next-hop", argv
[0]);
2436 ALIAS (no_match_ip_next_hop
,
2437 no_match_ip_next_hop_val_cmd
,
2438 "no match ip next-hop (<1-199>|<1300-2699>|WORD)",
2442 "Match next-hop address of route\n"
2443 "IP access-list number\n"
2444 "IP access-list number (expanded range)\n"
2445 "IP Access-list name\n")
2447 DEFUN (match_ip_route_source
,
2448 match_ip_route_source_cmd
,
2449 "match ip route-source (<1-199>|<1300-2699>|WORD)",
2452 "Match advertising source address of route\n"
2453 "IP access-list number\n"
2454 "IP access-list number (expanded range)\n"
2455 "IP standard access-list name\n")
2457 return bgp_route_match_add (vty
, vty
->index
, "ip route-source", argv
[0]);
2460 DEFUN (no_match_ip_route_source
,
2461 no_match_ip_route_source_cmd
,
2462 "no match ip route-source",
2466 "Match advertising source address of route\n")
2469 return bgp_route_match_delete (vty
, vty
->index
, "ip route-source", NULL
);
2471 return bgp_route_match_delete (vty
, vty
->index
, "ip route-source", argv
[0]);
2474 ALIAS (no_match_ip_route_source
,
2475 no_match_ip_route_source_val_cmd
,
2476 "no match ip route-source (<1-199>|<1300-2699>|WORD)",
2480 "Match advertising source address of route\n"
2481 "IP access-list number\n"
2482 "IP access-list number (expanded range)\n"
2483 "IP standard access-list name\n")
2485 DEFUN (match_ip_address_prefix_list
,
2486 match_ip_address_prefix_list_cmd
,
2487 "match ip address prefix-list WORD",
2490 "Match address of route\n"
2491 "Match entries of prefix-lists\n"
2492 "IP prefix-list name\n")
2494 return bgp_route_match_add (vty
, vty
->index
, "ip address prefix-list", argv
[0]);
2497 DEFUN (no_match_ip_address_prefix_list
,
2498 no_match_ip_address_prefix_list_cmd
,
2499 "no match ip address prefix-list",
2503 "Match address of route\n"
2504 "Match entries of prefix-lists\n")
2507 return bgp_route_match_delete (vty
, vty
->index
, "ip address prefix-list", NULL
);
2509 return bgp_route_match_delete (vty
, vty
->index
, "ip address prefix-list", argv
[0]);
2512 ALIAS (no_match_ip_address_prefix_list
,
2513 no_match_ip_address_prefix_list_val_cmd
,
2514 "no match ip address prefix-list WORD",
2518 "Match address of route\n"
2519 "Match entries of prefix-lists\n"
2520 "IP prefix-list name\n")
2522 DEFUN (match_ip_next_hop_prefix_list
,
2523 match_ip_next_hop_prefix_list_cmd
,
2524 "match ip next-hop prefix-list WORD",
2527 "Match next-hop address of route\n"
2528 "Match entries of prefix-lists\n"
2529 "IP prefix-list name\n")
2531 return bgp_route_match_add (vty
, vty
->index
, "ip next-hop prefix-list", argv
[0]);
2534 DEFUN (no_match_ip_next_hop_prefix_list
,
2535 no_match_ip_next_hop_prefix_list_cmd
,
2536 "no match ip next-hop prefix-list",
2540 "Match next-hop address of route\n"
2541 "Match entries of prefix-lists\n")
2544 return bgp_route_match_delete (vty
, vty
->index
, "ip next-hop prefix-list", NULL
);
2546 return bgp_route_match_delete (vty
, vty
->index
, "ip next-hop prefix-list", argv
[0]);
2549 ALIAS (no_match_ip_next_hop_prefix_list
,
2550 no_match_ip_next_hop_prefix_list_val_cmd
,
2551 "no match ip next-hop prefix-list WORD",
2555 "Match next-hop address of route\n"
2556 "Match entries of prefix-lists\n"
2557 "IP prefix-list name\n")
2559 DEFUN (match_ip_route_source_prefix_list
,
2560 match_ip_route_source_prefix_list_cmd
,
2561 "match ip route-source prefix-list WORD",
2564 "Match advertising source address of route\n"
2565 "Match entries of prefix-lists\n"
2566 "IP prefix-list name\n")
2568 return bgp_route_match_add (vty
, vty
->index
, "ip route-source prefix-list", argv
[0]);
2571 DEFUN (no_match_ip_route_source_prefix_list
,
2572 no_match_ip_route_source_prefix_list_cmd
,
2573 "no match ip route-source prefix-list",
2577 "Match advertising source address of route\n"
2578 "Match entries of prefix-lists\n")
2581 return bgp_route_match_delete (vty
, vty
->index
, "ip route-source prefix-list", NULL
);
2583 return bgp_route_match_delete (vty
, vty
->index
, "ip route-source prefix-list", argv
[0]);
2586 ALIAS (no_match_ip_route_source_prefix_list
,
2587 no_match_ip_route_source_prefix_list_val_cmd
,
2588 "no match ip route-source prefix-list WORD",
2592 "Match advertising source address of route\n"
2593 "Match entries of prefix-lists\n"
2594 "IP prefix-list name\n")
2596 DEFUN (match_metric
,
2598 "match metric <0-4294967295>",
2600 "Match metric of route\n"
2603 return bgp_route_match_add (vty
, vty
->index
, "metric", argv
[0]);
2606 DEFUN (no_match_metric
,
2607 no_match_metric_cmd
,
2611 "Match metric of route\n")
2614 return bgp_route_match_delete (vty
, vty
->index
, "metric", NULL
);
2616 return bgp_route_match_delete (vty
, vty
->index
, "metric", argv
[0]);
2619 ALIAS (no_match_metric
,
2620 no_match_metric_val_cmd
,
2621 "no match metric <0-4294967295>",
2624 "Match metric of route\n"
2627 DEFUN (match_community
,
2628 match_community_cmd
,
2629 "match community (<1-99>|<100-500>|WORD)",
2631 "Match BGP community list\n"
2632 "Community-list number (standard)\n"
2633 "Community-list number (expanded)\n"
2634 "Community-list name\n")
2636 return bgp_route_match_add (vty
, vty
->index
, "community", argv
[0]);
2639 DEFUN (match_community_exact
,
2640 match_community_exact_cmd
,
2641 "match community (<1-99>|<100-500>|WORD) exact-match",
2643 "Match BGP community list\n"
2644 "Community-list number (standard)\n"
2645 "Community-list number (expanded)\n"
2646 "Community-list name\n"
2647 "Do exact matching of communities\n")
2652 argstr
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
,
2653 strlen (argv
[0]) + strlen ("exact-match") + 2);
2655 sprintf (argstr
, "%s exact-match", argv
[0]);
2657 ret
= bgp_route_match_add (vty
, vty
->index
, "community", argstr
);
2659 XFREE (MTYPE_ROUTE_MAP_COMPILED
, argstr
);
2664 DEFUN (no_match_community
,
2665 no_match_community_cmd
,
2666 "no match community",
2669 "Match BGP community list\n")
2671 return bgp_route_match_delete (vty
, vty
->index
, "community", NULL
);
2674 ALIAS (no_match_community
,
2675 no_match_community_val_cmd
,
2676 "no match community (<1-99>|<100-500>|WORD)",
2679 "Match BGP community list\n"
2680 "Community-list number (standard)\n"
2681 "Community-list number (expanded)\n"
2682 "Community-list name\n")
2684 ALIAS (no_match_community
,
2685 no_match_community_exact_cmd
,
2686 "no match community (<1-99>|<100-500>|WORD) exact-match",
2689 "Match BGP community list\n"
2690 "Community-list number (standard)\n"
2691 "Community-list number (expanded)\n"
2692 "Community-list name\n"
2693 "Do exact matching of communities\n")
2695 DEFUN (match_ecommunity
,
2696 match_ecommunity_cmd
,
2697 "match extcommunity (<1-99>|<100-500>|WORD)",
2699 "Match BGP/VPN extended community list\n"
2700 "Extended community-list number (standard)\n"
2701 "Extended community-list number (expanded)\n"
2702 "Extended community-list name\n")
2704 return bgp_route_match_add (vty
, vty
->index
, "extcommunity", argv
[0]);
2707 DEFUN (no_match_ecommunity
,
2708 no_match_ecommunity_cmd
,
2709 "no match extcommunity",
2712 "Match BGP/VPN extended community list\n")
2714 return bgp_route_match_delete (vty
, vty
->index
, "extcommunity", NULL
);
2717 ALIAS (no_match_ecommunity
,
2718 no_match_ecommunity_val_cmd
,
2719 "no match extcommunity (<1-99>|<100-500>|WORD)",
2722 "Match BGP/VPN extended community list\n"
2723 "Extended community-list number (standard)\n"
2724 "Extended community-list number (expanded)\n"
2725 "Extended community-list name\n")
2727 DEFUN (match_aspath
,
2729 "match as-path WORD",
2731 "Match BGP AS path list\n"
2732 "AS path access-list name\n")
2734 return bgp_route_match_add (vty
, vty
->index
, "as-path", argv
[0]);
2737 DEFUN (no_match_aspath
,
2738 no_match_aspath_cmd
,
2742 "Match BGP AS path list\n")
2744 return bgp_route_match_delete (vty
, vty
->index
, "as-path", NULL
);
2747 ALIAS (no_match_aspath
,
2748 no_match_aspath_val_cmd
,
2749 "no match as-path WORD",
2752 "Match BGP AS path list\n"
2753 "AS path access-list name\n")
2755 DEFUN (match_origin
,
2757 "match origin (egp|igp|incomplete)",
2762 "unknown heritage\n")
2764 if (strncmp (argv
[0], "igp", 2) == 0)
2765 return bgp_route_match_add (vty
, vty
->index
, "origin", "igp");
2766 if (strncmp (argv
[0], "egp", 1) == 0)
2767 return bgp_route_match_add (vty
, vty
->index
, "origin", "egp");
2768 if (strncmp (argv
[0], "incomplete", 2) == 0)
2769 return bgp_route_match_add (vty
, vty
->index
, "origin", "incomplete");
2774 DEFUN (no_match_origin
,
2775 no_match_origin_cmd
,
2779 "BGP origin code\n")
2781 return bgp_route_match_delete (vty
, vty
->index
, "origin", NULL
);
2784 ALIAS (no_match_origin
,
2785 no_match_origin_val_cmd
,
2786 "no match origin (egp|igp|incomplete)",
2792 "unknown heritage\n")
2794 DEFUN (set_ip_nexthop
,
2796 "set ip next-hop A.B.C.D",
2799 "Next hop address\n"
2800 "IP address of next hop\n")
2805 ret
= str2sockunion (argv
[0], &su
);
2808 vty_out (vty
, "%% Malformed Next-hop address%s", VTY_NEWLINE
);
2812 return bgp_route_set_add (vty
, vty
->index
, "ip next-hop", argv
[0]);
2815 DEFUN (set_ip_nexthop_peer
,
2816 set_ip_nexthop_peer_cmd
,
2817 "set ip next-hop peer-address",
2820 "Next hop address\n"
2821 "Use peer address (for BGP only)\n")
2823 return bgp_route_set_add (vty
, vty
->index
, "ip next-hop", "peer-address");
2826 DEFUN_DEPRECATED (no_set_ip_nexthop_peer
,
2827 no_set_ip_nexthop_peer_cmd
,
2828 "no set ip next-hop peer-address",
2832 "Next hop address\n"
2833 "Use peer address (for BGP only)\n")
2835 return bgp_route_set_delete (vty
, vty
->index
, "ip next-hop", NULL
);
2839 DEFUN (no_set_ip_nexthop
,
2840 no_set_ip_nexthop_cmd
,
2841 "no set ip next-hop",
2844 "Next hop address\n")
2847 return bgp_route_set_delete (vty
, vty
->index
, "ip next-hop", NULL
);
2849 return bgp_route_set_delete (vty
, vty
->index
, "ip next-hop", argv
[0]);
2852 ALIAS (no_set_ip_nexthop
,
2853 no_set_ip_nexthop_val_cmd
,
2854 "no set ip next-hop A.B.C.D",
2858 "Next hop address\n"
2859 "IP address of next hop\n")
2863 "set metric <0-4294967295>",
2865 "Metric value for destination routing protocol\n"
2868 return bgp_route_set_add (vty
, vty
->index
, "metric", argv
[0]);
2872 set_metric_addsub_cmd
,
2873 "set metric <+/-metric>",
2875 "Metric value for destination routing protocol\n"
2876 "Add or subtract metric\n")
2878 DEFUN (no_set_metric
,
2883 "Metric value for destination routing protocol\n")
2886 return bgp_route_set_delete (vty
, vty
->index
, "metric", NULL
);
2888 return bgp_route_set_delete (vty
, vty
->index
, "metric", argv
[0]);
2891 ALIAS (no_set_metric
,
2892 no_set_metric_val_cmd
,
2893 "no set metric <0-4294967295>",
2896 "Metric value for destination routing protocol\n"
2899 DEFUN (set_local_pref
,
2901 "set local-preference <0-4294967295>",
2903 "BGP local preference path attribute\n"
2904 "Preference value\n")
2906 return bgp_route_set_add (vty
, vty
->index
, "local-preference", argv
[0]);
2909 DEFUN (no_set_local_pref
,
2910 no_set_local_pref_cmd
,
2911 "no set local-preference",
2914 "BGP local preference path attribute\n")
2917 return bgp_route_set_delete (vty
, vty
->index
, "local-preference", NULL
);
2919 return bgp_route_set_delete (vty
, vty
->index
, "local-preference", argv
[0]);
2922 ALIAS (no_set_local_pref
,
2923 no_set_local_pref_val_cmd
,
2924 "no set local-preference <0-4294967295>",
2927 "BGP local preference path attribute\n"
2928 "Preference value\n")
2932 "set weight <0-4294967295>",
2934 "BGP weight for routing table\n"
2937 return bgp_route_set_add (vty
, vty
->index
, "weight", argv
[0]);
2940 DEFUN (no_set_weight
,
2945 "BGP weight for routing table\n")
2948 return bgp_route_set_delete (vty
, vty
->index
, "weight", NULL
);
2950 return bgp_route_set_delete (vty
, vty
->index
, "weight", argv
[0]);
2953 ALIAS (no_set_weight
,
2954 no_set_weight_val_cmd
,
2955 "no set weight <0-4294967295>",
2958 "BGP weight for routing table\n"
2961 DEFUN (set_aspath_prepend
,
2962 set_aspath_prepend_cmd
,
2963 "set as-path prepend ." CMD_AS_RANGE
,
2965 "Transform BGP AS_PATH attribute\n"
2966 "Prepend to the as-path\n"
2972 str
= argv_concat (argv
, argc
, 0);
2973 ret
= bgp_route_set_add (vty
, vty
->index
, "as-path prepend", str
);
2974 XFREE (MTYPE_TMP
, str
);
2979 DEFUN (no_set_aspath_prepend
,
2980 no_set_aspath_prepend_cmd
,
2981 "no set as-path prepend",
2984 "Transform BGP AS_PATH attribute\n"
2985 "Prepend to the as-path\n")
2991 return bgp_route_set_delete (vty
, vty
->index
, "as-path prepend", NULL
);
2993 str
= argv_concat (argv
, argc
, 0);
2994 ret
= bgp_route_set_delete (vty
, vty
->index
, "as-path prepend", str
);
2995 XFREE (MTYPE_TMP
, str
);
2999 ALIAS (no_set_aspath_prepend
,
3000 no_set_aspath_prepend_val_cmd
,
3001 "no set as-path prepend ." CMD_AS_RANGE
,
3004 "Transform BGP AS_PATH attribute\n"
3005 "Prepend to the as-path\n"
3008 DEFUN (set_aspath_exclude
,
3009 set_aspath_exclude_cmd
,
3010 "set as-path exclude ." CMD_AS_RANGE
,
3012 "Transform BGP AS-path attribute\n"
3013 "Exclude from the as-path\n"
3019 str
= argv_concat (argv
, argc
, 0);
3020 ret
= bgp_route_set_add (vty
, vty
->index
, "as-path exclude", str
);
3021 XFREE (MTYPE_TMP
, str
);
3025 DEFUN (no_set_aspath_exclude
,
3026 no_set_aspath_exclude_cmd
,
3027 "no set as-path exclude",
3030 "Transform BGP AS_PATH attribute\n"
3031 "Exclude from the as-path\n")
3037 return bgp_route_set_delete (vty
, vty
->index
, "as-path exclude", NULL
);
3039 str
= argv_concat (argv
, argc
, 0);
3040 ret
= bgp_route_set_delete (vty
, vty
->index
, "as-path exclude", str
);
3041 XFREE (MTYPE_TMP
, str
);
3045 ALIAS (no_set_aspath_exclude
,
3046 no_set_aspath_exclude_val_cmd
,
3047 "no set as-path exclude ." CMD_AS_RANGE
,
3050 "Transform BGP AS_PATH attribute\n"
3051 "Exclude from the as-path\n"
3054 DEFUN (set_community
,
3056 "set community .AA:NN",
3058 "BGP community attribute\n"
3059 "Community number in aa:nn format or local-AS|no-advertise|no-export|internet or additive\n")
3065 struct community
*com
= NULL
;
3070 b
= buffer_new (1024);
3072 for (i
= 0; i
< argc
; i
++)
3074 if (strncmp (argv
[i
], "additive", strlen (argv
[i
])) == 0)
3081 buffer_putc (b
, ' ');
3085 if (strncmp (argv
[i
], "internet", strlen (argv
[i
])) == 0)
3087 buffer_putstr (b
, "internet");
3090 if (strncmp (argv
[i
], "local-AS", strlen (argv
[i
])) == 0)
3092 buffer_putstr (b
, "local-AS");
3095 if (strncmp (argv
[i
], "no-a", strlen ("no-a")) == 0
3096 && strncmp (argv
[i
], "no-advertise", strlen (argv
[i
])) == 0)
3098 buffer_putstr (b
, "no-advertise");
3101 if (strncmp (argv
[i
], "no-e", strlen ("no-e"))== 0
3102 && strncmp (argv
[i
], "no-export", strlen (argv
[i
])) == 0)
3104 buffer_putstr (b
, "no-export");
3107 buffer_putstr (b
, argv
[i
]);
3109 buffer_putc (b
, '\0');
3111 /* Fetch result string then compile it to communities attribute. */
3112 str
= buffer_getstr (b
);
3117 com
= community_str2com (str
);
3118 XFREE (MTYPE_TMP
, str
);
3121 /* Can't compile user input into communities attribute. */
3124 vty_out (vty
, "%% Malformed communities attribute%s", VTY_NEWLINE
);
3128 /* Set communites attribute string. */
3129 str
= community_str (com
);
3133 argstr
= XCALLOC (MTYPE_TMP
, strlen (str
) + strlen (" additive") + 1);
3134 strcpy (argstr
, str
);
3135 strcpy (argstr
+ strlen (str
), " additive");
3136 ret
= bgp_route_set_add (vty
, vty
->index
, "community", argstr
);
3137 XFREE (MTYPE_TMP
, argstr
);
3140 ret
= bgp_route_set_add (vty
, vty
->index
, "community", str
);
3142 community_free (com
);
3147 DEFUN (set_community_none
,
3148 set_community_none_cmd
,
3149 "set community none",
3151 "BGP community attribute\n"
3152 "No community attribute\n")
3154 return bgp_route_set_add (vty
, vty
->index
, "community", "none");
3157 DEFUN (no_set_community
,
3158 no_set_community_cmd
,
3162 "BGP community attribute\n")
3164 return bgp_route_set_delete (vty
, vty
->index
, "community", NULL
);
3167 ALIAS (no_set_community
,
3168 no_set_community_val_cmd
,
3169 "no set community .AA:NN",
3172 "BGP community attribute\n"
3173 "Community number in aa:nn format or local-AS|no-advertise|no-export|internet or additive\n")
3175 ALIAS (no_set_community
,
3176 no_set_community_none_cmd
,
3177 "no set community none",
3180 "BGP community attribute\n"
3181 "No community attribute\n")
3183 DEFUN (set_community_delete
,
3184 set_community_delete_cmd
,
3185 "set comm-list (<1-99>|<100-500>|WORD) delete",
3187 "set BGP community list (for deletion)\n"
3188 "Community-list number (standard)\n"
3189 "Communitly-list number (expanded)\n"
3190 "Community-list name\n"
3191 "Delete matching communities\n")
3195 str
= XCALLOC (MTYPE_TMP
, strlen (argv
[0]) + strlen (" delete") + 1);
3196 strcpy (str
, argv
[0]);
3197 strcpy (str
+ strlen (argv
[0]), " delete");
3199 bgp_route_set_add (vty
, vty
->index
, "comm-list", str
);
3201 XFREE (MTYPE_TMP
, str
);
3205 DEFUN (no_set_community_delete
,
3206 no_set_community_delete_cmd
,
3210 "set BGP community list (for deletion)\n")
3212 return bgp_route_set_delete (vty
, vty
->index
, "comm-list", NULL
);
3215 ALIAS (no_set_community_delete
,
3216 no_set_community_delete_val_cmd
,
3217 "no set comm-list (<1-99>|<100-500>|WORD) delete",
3220 "set BGP community list (for deletion)\n"
3221 "Community-list number (standard)\n"
3222 "Communitly-list number (expanded)\n"
3223 "Community-list name\n"
3224 "Delete matching communities\n")
3226 DEFUN (set_ecommunity_rt
,
3227 set_ecommunity_rt_cmd
,
3228 "set extcommunity rt .ASN:nn_or_IP-address:nn",
3230 "BGP extended community attribute\n"
3231 "Route Target extended community\n"
3232 "VPN extended community\n")
3237 str
= argv_concat (argv
, argc
, 0);
3238 ret
= bgp_route_set_add (vty
, vty
->index
, "extcommunity rt", str
);
3239 XFREE (MTYPE_TMP
, str
);
3244 DEFUN (no_set_ecommunity_rt
,
3245 no_set_ecommunity_rt_cmd
,
3246 "no set extcommunity rt",
3249 "BGP extended community attribute\n"
3250 "Route Target extended community\n")
3252 return bgp_route_set_delete (vty
, vty
->index
, "extcommunity rt", NULL
);
3255 ALIAS (no_set_ecommunity_rt
,
3256 no_set_ecommunity_rt_val_cmd
,
3257 "no set extcommunity rt .ASN:nn_or_IP-address:nn",
3260 "BGP extended community attribute\n"
3261 "Route Target extended community\n"
3262 "VPN extended community\n")
3264 DEFUN (set_ecommunity_soo
,
3265 set_ecommunity_soo_cmd
,
3266 "set extcommunity soo .ASN:nn_or_IP-address:nn",
3268 "BGP extended community attribute\n"
3269 "Site-of-Origin extended community\n"
3270 "VPN extended community\n")
3275 str
= argv_concat (argv
, argc
, 0);
3276 ret
= bgp_route_set_add (vty
, vty
->index
, "extcommunity soo", str
);
3277 XFREE (MTYPE_TMP
, str
);
3281 DEFUN (no_set_ecommunity_soo
,
3282 no_set_ecommunity_soo_cmd
,
3283 "no set extcommunity soo",
3286 "BGP extended community attribute\n"
3287 "Site-of-Origin extended community\n")
3289 return bgp_route_set_delete (vty
, vty
->index
, "extcommunity soo", NULL
);
3292 ALIAS (no_set_ecommunity_soo
,
3293 no_set_ecommunity_soo_val_cmd
,
3294 "no set extcommunity soo .ASN:nn_or_IP-address:nn",
3297 "BGP extended community attribute\n"
3298 "Site-of-Origin extended community\n"
3299 "VPN extended community\n")
3303 "set origin (egp|igp|incomplete)",
3308 "unknown heritage\n")
3310 if (strncmp (argv
[0], "igp", 2) == 0)
3311 return bgp_route_set_add (vty
, vty
->index
, "origin", "igp");
3312 if (strncmp (argv
[0], "egp", 1) == 0)
3313 return bgp_route_set_add (vty
, vty
->index
, "origin", "egp");
3314 if (strncmp (argv
[0], "incomplete", 2) == 0)
3315 return bgp_route_set_add (vty
, vty
->index
, "origin", "incomplete");
3320 DEFUN (no_set_origin
,
3325 "BGP origin code\n")
3327 return bgp_route_set_delete (vty
, vty
->index
, "origin", NULL
);
3330 ALIAS (no_set_origin
,
3331 no_set_origin_val_cmd
,
3332 "no set origin (egp|igp|incomplete)",
3338 "unknown heritage\n")
3340 DEFUN (set_atomic_aggregate
,
3341 set_atomic_aggregate_cmd
,
3342 "set atomic-aggregate",
3344 "BGP atomic aggregate attribute\n" )
3346 return bgp_route_set_add (vty
, vty
->index
, "atomic-aggregate", NULL
);
3349 DEFUN (no_set_atomic_aggregate
,
3350 no_set_atomic_aggregate_cmd
,
3351 "no set atomic-aggregate",
3354 "BGP atomic aggregate attribute\n" )
3356 return bgp_route_set_delete (vty
, vty
->index
, "atomic-aggregate", NULL
);
3359 DEFUN (set_aggregator_as
,
3360 set_aggregator_as_cmd
,
3361 "set aggregator as " CMD_AS_RANGE
" A.B.C.D",
3363 "BGP aggregator attribute\n"
3364 "AS number of aggregator\n"
3366 "IP address of aggregator\n")
3370 struct in_addr address
;
3373 VTY_GET_INTEGER_RANGE ("AS", as
, argv
[0], 1, BGP_AS4_MAX
);
3375 ret
= inet_aton (argv
[1], &address
);
3378 vty_out (vty
, "Aggregator IP address is invalid%s", VTY_NEWLINE
);
3382 argstr
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
,
3383 strlen (argv
[0]) + strlen (argv
[1]) + 2);
3385 sprintf (argstr
, "%s %s", argv
[0], argv
[1]);
3387 ret
= bgp_route_set_add (vty
, vty
->index
, "aggregator as", argstr
);
3389 XFREE (MTYPE_ROUTE_MAP_COMPILED
, argstr
);
3394 DEFUN (no_set_aggregator_as
,
3395 no_set_aggregator_as_cmd
,
3396 "no set aggregator as",
3399 "BGP aggregator attribute\n"
3400 "AS number of aggregator\n")
3404 struct in_addr address
;
3408 return bgp_route_set_delete (vty
, vty
->index
, "aggregator as", NULL
);
3410 VTY_GET_INTEGER_RANGE ("AS", as
, argv
[0], 1, BGP_AS4_MAX
);
3412 ret
= inet_aton (argv
[1], &address
);
3415 vty_out (vty
, "Aggregator IP address is invalid%s", VTY_NEWLINE
);
3419 argstr
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
,
3420 strlen (argv
[0]) + strlen (argv
[1]) + 2);
3422 sprintf (argstr
, "%s %s", argv
[0], argv
[1]);
3424 ret
= bgp_route_set_delete (vty
, vty
->index
, "aggregator as", argstr
);
3426 XFREE (MTYPE_ROUTE_MAP_COMPILED
, argstr
);
3431 ALIAS (no_set_aggregator_as
,
3432 no_set_aggregator_as_val_cmd
,
3433 "no set aggregator as " CMD_AS_RANGE
" A.B.C.D",
3436 "BGP aggregator attribute\n"
3437 "AS number of aggregator\n"
3439 "IP address of aggregator\n")
3443 DEFUN (match_ipv6_address
,
3444 match_ipv6_address_cmd
,
3445 "match ipv6 address WORD",
3448 "Match IPv6 address of route\n"
3449 "IPv6 access-list name\n")
3451 return bgp_route_match_add (vty
, vty
->index
, "ipv6 address", argv
[0]);
3454 DEFUN (no_match_ipv6_address
,
3455 no_match_ipv6_address_cmd
,
3456 "no match ipv6 address WORD",
3460 "Match IPv6 address of route\n"
3461 "IPv6 access-list name\n")
3463 return bgp_route_match_delete (vty
, vty
->index
, "ipv6 address", argv
[0]);
3466 DEFUN (match_ipv6_next_hop
,
3467 match_ipv6_next_hop_cmd
,
3468 "match ipv6 next-hop X:X::X:X",
3471 "Match IPv6 next-hop address of route\n"
3472 "IPv6 address of next hop\n")
3474 return bgp_route_match_add (vty
, vty
->index
, "ipv6 next-hop", argv
[0]);
3477 DEFUN (no_match_ipv6_next_hop
,
3478 no_match_ipv6_next_hop_cmd
,
3479 "no match ipv6 next-hop X:X::X:X",
3483 "Match IPv6 next-hop address of route\n"
3484 "IPv6 address of next hop\n")
3486 return bgp_route_match_delete (vty
, vty
->index
, "ipv6 next-hop", argv
[0]);
3489 DEFUN (match_ipv6_address_prefix_list
,
3490 match_ipv6_address_prefix_list_cmd
,
3491 "match ipv6 address prefix-list WORD",
3494 "Match address of route\n"
3495 "Match entries of prefix-lists\n"
3496 "IP prefix-list name\n")
3498 return bgp_route_match_add (vty
, vty
->index
, "ipv6 address prefix-list", argv
[0]);
3501 DEFUN (no_match_ipv6_address_prefix_list
,
3502 no_match_ipv6_address_prefix_list_cmd
,
3503 "no match ipv6 address prefix-list WORD",
3507 "Match address of route\n"
3508 "Match entries of prefix-lists\n"
3509 "IP prefix-list name\n")
3511 return bgp_route_match_delete (vty
, vty
->index
, "ipv6 address prefix-list", argv
[0]);
3514 DEFUN (set_ipv6_nexthop_global
,
3515 set_ipv6_nexthop_global_cmd
,
3516 "set ipv6 next-hop global X:X::X:X",
3519 "IPv6 next-hop address\n"
3520 "IPv6 global address\n"
3521 "IPv6 address of next hop\n")
3523 return bgp_route_set_add (vty
, vty
->index
, "ipv6 next-hop global", argv
[0]);
3526 DEFUN (no_set_ipv6_nexthop_global
,
3527 no_set_ipv6_nexthop_global_cmd
,
3528 "no set ipv6 next-hop global",
3532 "IPv6 next-hop address\n"
3533 "IPv6 global address\n")
3536 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop global", NULL
);
3538 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop global", argv
[0]);
3541 ALIAS (no_set_ipv6_nexthop_global
,
3542 no_set_ipv6_nexthop_global_val_cmd
,
3543 "no set ipv6 next-hop global X:X::X:X",
3547 "IPv6 next-hop address\n"
3548 "IPv6 global address\n"
3549 "IPv6 address of next hop\n")
3551 DEFUN (set_ipv6_nexthop_local
,
3552 set_ipv6_nexthop_local_cmd
,
3553 "set ipv6 next-hop local X:X::X:X",
3556 "IPv6 next-hop address\n"
3557 "IPv6 local address\n"
3558 "IPv6 address of next hop\n")
3560 return bgp_route_set_add (vty
, vty
->index
, "ipv6 next-hop local", argv
[0]);
3563 DEFUN (no_set_ipv6_nexthop_local
,
3564 no_set_ipv6_nexthop_local_cmd
,
3565 "no set ipv6 next-hop local",
3569 "IPv6 next-hop address\n"
3570 "IPv6 local address\n")
3573 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop local", NULL
);
3575 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop local", argv
[0]);
3578 ALIAS (no_set_ipv6_nexthop_local
,
3579 no_set_ipv6_nexthop_local_val_cmd
,
3580 "no set ipv6 next-hop local X:X::X:X",
3584 "IPv6 next-hop address\n"
3585 "IPv6 local address\n"
3586 "IPv6 address of next hop\n")
3587 #endif /* HAVE_IPV6 */
3589 DEFUN (set_vpnv4_nexthop
,
3590 set_vpnv4_nexthop_cmd
,
3591 "set vpnv4 next-hop A.B.C.D",
3593 "VPNv4 information\n"
3594 "VPNv4 next-hop address\n"
3595 "IP address of next hop\n")
3597 return bgp_route_set_add (vty
, vty
->index
, "vpnv4 next-hop", argv
[0]);
3600 DEFUN (no_set_vpnv4_nexthop
,
3601 no_set_vpnv4_nexthop_cmd
,
3602 "no set vpnv4 next-hop",
3605 "VPNv4 information\n"
3606 "VPNv4 next-hop address\n")
3609 return bgp_route_set_delete (vty
, vty
->index
, "vpnv4 next-hop", NULL
);
3611 return bgp_route_set_delete (vty
, vty
->index
, "vpnv4 next-hop", argv
[0]);
3614 ALIAS (no_set_vpnv4_nexthop
,
3615 no_set_vpnv4_nexthop_val_cmd
,
3616 "no set vpnv4 next-hop A.B.C.D",
3619 "VPNv4 information\n"
3620 "VPNv4 next-hop address\n"
3621 "IP address of next hop\n")
3623 DEFUN (set_originator_id
,
3624 set_originator_id_cmd
,
3625 "set originator-id A.B.C.D",
3627 "BGP originator ID attribute\n"
3628 "IP address of originator\n")
3630 return bgp_route_set_add (vty
, vty
->index
, "originator-id", argv
[0]);
3633 DEFUN (no_set_originator_id
,
3634 no_set_originator_id_cmd
,
3635 "no set originator-id",
3638 "BGP originator ID attribute\n")
3641 return bgp_route_set_delete (vty
, vty
->index
, "originator-id", NULL
);
3643 return bgp_route_set_delete (vty
, vty
->index
, "originator-id", argv
[0]);
3646 ALIAS (no_set_originator_id
,
3647 no_set_originator_id_val_cmd
,
3648 "no set originator-id A.B.C.D",
3651 "BGP originator ID attribute\n"
3652 "IP address of originator\n")
3654 DEFUN_DEPRECATED (set_pathlimit_ttl
,
3655 set_pathlimit_ttl_cmd
,
3656 "set pathlimit ttl <1-255>",
3658 "BGP AS-Pathlimit attribute\n"
3659 "Set AS-Path Hop-count TTL\n")
3664 DEFUN_DEPRECATED (no_set_pathlimit_ttl
,
3665 no_set_pathlimit_ttl_cmd
,
3666 "no set pathlimit ttl",
3669 "BGP AS-Pathlimit attribute\n"
3670 "Set AS-Path Hop-count TTL\n")
3675 ALIAS (no_set_pathlimit_ttl
,
3676 no_set_pathlimit_ttl_val_cmd
,
3677 "no set pathlimit ttl <1-255>",
3680 "BGP AS-Pathlimit attribute\n"
3681 "Set AS-Path Hop-count TTL\n")
3683 DEFUN_DEPRECATED (match_pathlimit_as
,
3684 match_pathlimit_as_cmd
,
3685 "match pathlimit as <1-65535>",
3687 "BGP AS-Pathlimit attribute\n"
3688 "Match Pathlimit AS number\n")
3693 DEFUN_DEPRECATED (no_match_pathlimit_as
,
3694 no_match_pathlimit_as_cmd
,
3695 "no match pathlimit as",
3698 "BGP AS-Pathlimit attribute\n"
3699 "Match Pathlimit AS number\n")
3704 ALIAS (no_match_pathlimit_as
,
3705 no_match_pathlimit_as_val_cmd
,
3706 "no match pathlimit as <1-65535>",
3709 "BGP AS-Pathlimit attribute\n"
3710 "Match Pathlimit ASN\n")
3713 /* Initialization of route map. */
3715 bgp_route_map_init (void)
3718 route_map_init_vty ();
3719 route_map_add_hook (bgp_route_map_update
);
3720 route_map_delete_hook (bgp_route_map_update
);
3722 route_map_install_match (&route_match_peer_cmd
);
3723 route_map_install_match (&route_match_ip_address_cmd
);
3724 route_map_install_match (&route_match_ip_next_hop_cmd
);
3725 route_map_install_match (&route_match_ip_route_source_cmd
);
3726 route_map_install_match (&route_match_ip_address_prefix_list_cmd
);
3727 route_map_install_match (&route_match_ip_next_hop_prefix_list_cmd
);
3728 route_map_install_match (&route_match_ip_route_source_prefix_list_cmd
);
3729 route_map_install_match (&route_match_aspath_cmd
);
3730 route_map_install_match (&route_match_community_cmd
);
3731 route_map_install_match (&route_match_ecommunity_cmd
);
3732 route_map_install_match (&route_match_metric_cmd
);
3733 route_map_install_match (&route_match_origin_cmd
);
3735 route_map_install_set (&route_set_ip_nexthop_cmd
);
3736 route_map_install_set (&route_set_local_pref_cmd
);
3737 route_map_install_set (&route_set_weight_cmd
);
3738 route_map_install_set (&route_set_metric_cmd
);
3739 route_map_install_set (&route_set_aspath_prepend_cmd
);
3740 route_map_install_set (&route_set_aspath_exclude_cmd
);
3741 route_map_install_set (&route_set_origin_cmd
);
3742 route_map_install_set (&route_set_atomic_aggregate_cmd
);
3743 route_map_install_set (&route_set_aggregator_as_cmd
);
3744 route_map_install_set (&route_set_community_cmd
);
3745 route_map_install_set (&route_set_community_delete_cmd
);
3746 route_map_install_set (&route_set_vpnv4_nexthop_cmd
);
3747 route_map_install_set (&route_set_originator_id_cmd
);
3748 route_map_install_set (&route_set_ecommunity_rt_cmd
);
3749 route_map_install_set (&route_set_ecommunity_soo_cmd
);
3751 install_element (RMAP_NODE
, &match_peer_cmd
);
3752 install_element (RMAP_NODE
, &match_peer_local_cmd
);
3753 install_element (RMAP_NODE
, &no_match_peer_cmd
);
3754 install_element (RMAP_NODE
, &no_match_peer_val_cmd
);
3755 install_element (RMAP_NODE
, &no_match_peer_local_cmd
);
3756 install_element (RMAP_NODE
, &match_ip_address_cmd
);
3757 install_element (RMAP_NODE
, &no_match_ip_address_cmd
);
3758 install_element (RMAP_NODE
, &no_match_ip_address_val_cmd
);
3759 install_element (RMAP_NODE
, &match_ip_next_hop_cmd
);
3760 install_element (RMAP_NODE
, &no_match_ip_next_hop_cmd
);
3761 install_element (RMAP_NODE
, &no_match_ip_next_hop_val_cmd
);
3762 install_element (RMAP_NODE
, &match_ip_route_source_cmd
);
3763 install_element (RMAP_NODE
, &no_match_ip_route_source_cmd
);
3764 install_element (RMAP_NODE
, &no_match_ip_route_source_val_cmd
);
3766 install_element (RMAP_NODE
, &match_ip_address_prefix_list_cmd
);
3767 install_element (RMAP_NODE
, &no_match_ip_address_prefix_list_cmd
);
3768 install_element (RMAP_NODE
, &no_match_ip_address_prefix_list_val_cmd
);
3769 install_element (RMAP_NODE
, &match_ip_next_hop_prefix_list_cmd
);
3770 install_element (RMAP_NODE
, &no_match_ip_next_hop_prefix_list_cmd
);
3771 install_element (RMAP_NODE
, &no_match_ip_next_hop_prefix_list_val_cmd
);
3772 install_element (RMAP_NODE
, &match_ip_route_source_prefix_list_cmd
);
3773 install_element (RMAP_NODE
, &no_match_ip_route_source_prefix_list_cmd
);
3774 install_element (RMAP_NODE
, &no_match_ip_route_source_prefix_list_val_cmd
);
3776 install_element (RMAP_NODE
, &match_aspath_cmd
);
3777 install_element (RMAP_NODE
, &no_match_aspath_cmd
);
3778 install_element (RMAP_NODE
, &no_match_aspath_val_cmd
);
3779 install_element (RMAP_NODE
, &match_metric_cmd
);
3780 install_element (RMAP_NODE
, &no_match_metric_cmd
);
3781 install_element (RMAP_NODE
, &no_match_metric_val_cmd
);
3782 install_element (RMAP_NODE
, &match_community_cmd
);
3783 install_element (RMAP_NODE
, &match_community_exact_cmd
);
3784 install_element (RMAP_NODE
, &no_match_community_cmd
);
3785 install_element (RMAP_NODE
, &no_match_community_val_cmd
);
3786 install_element (RMAP_NODE
, &no_match_community_exact_cmd
);
3787 install_element (RMAP_NODE
, &match_ecommunity_cmd
);
3788 install_element (RMAP_NODE
, &no_match_ecommunity_cmd
);
3789 install_element (RMAP_NODE
, &no_match_ecommunity_val_cmd
);
3790 install_element (RMAP_NODE
, &match_origin_cmd
);
3791 install_element (RMAP_NODE
, &no_match_origin_cmd
);
3792 install_element (RMAP_NODE
, &no_match_origin_val_cmd
);
3794 install_element (RMAP_NODE
, &set_ip_nexthop_cmd
);
3795 install_element (RMAP_NODE
, &set_ip_nexthop_peer_cmd
);
3796 install_element (RMAP_NODE
, &no_set_ip_nexthop_cmd
);
3797 install_element (RMAP_NODE
, &no_set_ip_nexthop_val_cmd
);
3798 install_element (RMAP_NODE
, &set_local_pref_cmd
);
3799 install_element (RMAP_NODE
, &no_set_local_pref_cmd
);
3800 install_element (RMAP_NODE
, &no_set_local_pref_val_cmd
);
3801 install_element (RMAP_NODE
, &set_weight_cmd
);
3802 install_element (RMAP_NODE
, &no_set_weight_cmd
);
3803 install_element (RMAP_NODE
, &no_set_weight_val_cmd
);
3804 install_element (RMAP_NODE
, &set_metric_cmd
);
3805 install_element (RMAP_NODE
, &set_metric_addsub_cmd
);
3806 install_element (RMAP_NODE
, &no_set_metric_cmd
);
3807 install_element (RMAP_NODE
, &no_set_metric_val_cmd
);
3808 install_element (RMAP_NODE
, &set_aspath_prepend_cmd
);
3809 install_element (RMAP_NODE
, &set_aspath_exclude_cmd
);
3810 install_element (RMAP_NODE
, &no_set_aspath_prepend_cmd
);
3811 install_element (RMAP_NODE
, &no_set_aspath_prepend_val_cmd
);
3812 install_element (RMAP_NODE
, &no_set_aspath_exclude_cmd
);
3813 install_element (RMAP_NODE
, &no_set_aspath_exclude_val_cmd
);
3814 install_element (RMAP_NODE
, &set_origin_cmd
);
3815 install_element (RMAP_NODE
, &no_set_origin_cmd
);
3816 install_element (RMAP_NODE
, &no_set_origin_val_cmd
);
3817 install_element (RMAP_NODE
, &set_atomic_aggregate_cmd
);
3818 install_element (RMAP_NODE
, &no_set_atomic_aggregate_cmd
);
3819 install_element (RMAP_NODE
, &set_aggregator_as_cmd
);
3820 install_element (RMAP_NODE
, &no_set_aggregator_as_cmd
);
3821 install_element (RMAP_NODE
, &no_set_aggregator_as_val_cmd
);
3822 install_element (RMAP_NODE
, &set_community_cmd
);
3823 install_element (RMAP_NODE
, &set_community_none_cmd
);
3824 install_element (RMAP_NODE
, &no_set_community_cmd
);
3825 install_element (RMAP_NODE
, &no_set_community_val_cmd
);
3826 install_element (RMAP_NODE
, &no_set_community_none_cmd
);
3827 install_element (RMAP_NODE
, &set_community_delete_cmd
);
3828 install_element (RMAP_NODE
, &no_set_community_delete_cmd
);
3829 install_element (RMAP_NODE
, &no_set_community_delete_val_cmd
);
3830 install_element (RMAP_NODE
, &set_ecommunity_rt_cmd
);
3831 install_element (RMAP_NODE
, &no_set_ecommunity_rt_cmd
);
3832 install_element (RMAP_NODE
, &no_set_ecommunity_rt_val_cmd
);
3833 install_element (RMAP_NODE
, &set_ecommunity_soo_cmd
);
3834 install_element (RMAP_NODE
, &no_set_ecommunity_soo_cmd
);
3835 install_element (RMAP_NODE
, &no_set_ecommunity_soo_val_cmd
);
3836 install_element (RMAP_NODE
, &set_vpnv4_nexthop_cmd
);
3837 install_element (RMAP_NODE
, &no_set_vpnv4_nexthop_cmd
);
3838 install_element (RMAP_NODE
, &no_set_vpnv4_nexthop_val_cmd
);
3839 install_element (RMAP_NODE
, &set_originator_id_cmd
);
3840 install_element (RMAP_NODE
, &no_set_originator_id_cmd
);
3841 install_element (RMAP_NODE
, &no_set_originator_id_val_cmd
);
3844 route_map_install_match (&route_match_ipv6_address_cmd
);
3845 route_map_install_match (&route_match_ipv6_next_hop_cmd
);
3846 route_map_install_match (&route_match_ipv6_address_prefix_list_cmd
);
3847 route_map_install_set (&route_set_ipv6_nexthop_global_cmd
);
3848 route_map_install_set (&route_set_ipv6_nexthop_local_cmd
);
3850 install_element (RMAP_NODE
, &match_ipv6_address_cmd
);
3851 install_element (RMAP_NODE
, &no_match_ipv6_address_cmd
);
3852 install_element (RMAP_NODE
, &match_ipv6_next_hop_cmd
);
3853 install_element (RMAP_NODE
, &no_match_ipv6_next_hop_cmd
);
3854 install_element (RMAP_NODE
, &match_ipv6_address_prefix_list_cmd
);
3855 install_element (RMAP_NODE
, &no_match_ipv6_address_prefix_list_cmd
);
3856 install_element (RMAP_NODE
, &set_ipv6_nexthop_global_cmd
);
3857 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_global_cmd
);
3858 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_global_val_cmd
);
3859 install_element (RMAP_NODE
, &set_ipv6_nexthop_local_cmd
);
3860 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_local_cmd
);
3861 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_local_val_cmd
);
3862 #endif /* HAVE_IPV6 */
3864 /* AS-Pathlimit: functionality removed, commands kept for
3867 install_element (RMAP_NODE
, &set_pathlimit_ttl_cmd
);
3868 install_element (RMAP_NODE
, &no_set_pathlimit_ttl_cmd
);
3869 install_element (RMAP_NODE
, &no_set_pathlimit_ttl_val_cmd
);
3870 install_element (RMAP_NODE
, &match_pathlimit_as_cmd
);
3871 install_element (RMAP_NODE
, &no_match_pathlimit_as_cmd
);
3872 install_element (RMAP_NODE
, &no_match_pathlimit_as_val_cmd
);