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
34 #include "regex-gnu.h"
35 #endif /* HAVE_GNU_REGEX */
37 #include "sockunion.h"
39 #include "bgpd/bgpd.h"
40 #include "bgpd/bgp_table.h"
41 #include "bgpd/bgp_attr.h"
42 #include "bgpd/bgp_aspath.h"
43 #include "bgpd/bgp_route.h"
44 #include "bgpd/bgp_regex.h"
45 #include "bgpd/bgp_community.h"
46 #include "bgpd/bgp_clist.h"
47 #include "bgpd/bgp_filter.h"
48 #include "bgpd/bgp_mplsvpn.h"
49 #include "bgpd/bgp_ecommunity.h"
51 /* Memo of route-map commands.
60 ip route-source : Done
64 ipv6 route-source: (This will not be implemented by bgpd)
65 ipv6 prefix-list : Done
66 length : (This will not be implemented by bgpd)
68 route-type : (This will not be implemented by bgpd)
69 tag : (This will not be implemented by bgpd)
71 set as-path prepend : Done
73 automatic-tag : (This will not be implemented by bgpd)
77 default : (This will not be implemented by bgpd)
78 interface : (This will not be implemented by bgpd)
79 ip default : (This will not be implemented by bgpd)
81 ip precedence : (This will not be implemented by bgpd)
82 ip tos : (This will not be implemented by bgpd)
83 level : (This will not be implemented by bgpd)
84 local-preference : Done
88 tag : (This will not be implemented by bgpd)
94 set ipv6 next-hop global: Done
95 set ipv6 next-hop local : Done
96 set pathlimit ttl : Done
97 match pathlimit as : Done
101 /* Compiles either AS or TTL argument. It is amused the VTY code
102 * has already range-checked the values to be suitable as TTL or ASN
105 route_pathlimit_compile (const char *arg
)
111 /* TTL or AS value shoud be integer. */
112 if (! all_digit (arg
))
115 tmp
= strtoul (arg
, &endptr
, 10);
116 if (*endptr
!= '\0' || tmp
== ULONG_MAX
|| tmp
> UINT32_MAX
)
119 if (!(val
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_int32_t
))))
128 route_pathlimit_free (void *rule
)
130 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
133 static route_map_result_t
134 route_match_pathlimit_as (void *rule
, struct prefix
*prefix
, route_map_object_t type
,
137 struct bgp_info
*info
= object
;
138 struct attr
*attr
= info
->attr
;
139 uint32_t as
= *(uint32_t *)rule
;
141 if (type
!= RMAP_BGP
)
144 if (!attr
->pathlimit
.as
)
147 if (as
== attr
->pathlimit
.as
)
153 /* 'match pathlimit as' */
154 struct route_map_rule_cmd route_match_pathlimit_as_cmd
=
157 route_match_pathlimit_as
,
158 route_pathlimit_compile
,
162 /* Set pathlimit TTL. */
163 static route_map_result_t
164 route_set_pathlimit_ttl (void *rule
, struct prefix
*prefix
,
165 route_map_object_t type
, void *object
)
167 struct bgp_info
*info
= object
;
168 struct attr
*attr
= info
->attr
;
169 u_char ttl
= *(uint32_t *)rule
;
171 if (type
== RMAP_BGP
)
173 attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_AS_PATHLIMIT
);
174 attr
->pathlimit
.ttl
= ttl
;
175 attr
->pathlimit
.as
= 0;
181 /* Set local preference rule structure. */
182 struct route_map_rule_cmd route_set_pathlimit_ttl_cmd
=
185 route_set_pathlimit_ttl
,
186 route_pathlimit_compile
,
187 route_pathlimit_free
,
190 /* 'match peer (A.B.C.D|X:X::X:X)' */
192 /* Compares the peer specified in the 'match peer' clause with the peer
193 received in bgp_info->peer. If it is the same, or if the peer structure
194 received is a peer_group containing it, returns RMAP_MATCH. */
195 static route_map_result_t
196 route_match_peer (void *rule
, struct prefix
*prefix
, route_map_object_t type
,
200 union sockunion
*su2
;
201 struct peer_group
*group
;
203 struct listnode
*node
, *nnode
;
205 if (type
== RMAP_BGP
)
208 peer
= ((struct bgp_info
*) object
)->peer
;
210 if ( ! CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IMPORT
) &&
211 ! CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_EXPORT
) )
214 /* If su='0.0.0.0' (command 'match peer local'), and it's a NETWORK,
215 REDISTRIBUTE or DEFAULT_GENERATED route => return RMAP_MATCH */
216 su2
= sockunion_str2su ("0.0.0.0");
217 if ( sockunion_same (su
, su2
) )
220 if ( CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_NETWORK
) ||
221 CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
) ||
222 CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_DEFAULT
))
227 sockunion_free (su2
);
230 sockunion_free (su2
);
232 if (! CHECK_FLAG (peer
->sflags
, PEER_STATUS_GROUP
))
234 if (sockunion_same (su
, &peer
->su
))
242 for (ALL_LIST_ELEMENTS (group
->peer
, node
, nnode
, peer
))
244 if (sockunion_same (su
, &peer
->su
))
255 route_match_peer_compile (const char *arg
)
260 su
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (union sockunion
));
262 ret
= str2sockunion ( (arg
)? arg
: "0.0.0.0", su
);
264 XFREE (MTYPE_ROUTE_MAP_COMPILED
, su
);
271 /* Free route map's compiled `ip address' value. */
273 route_match_peer_free (void *rule
)
275 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
278 /* Route map commands for ip address matching. */
279 struct route_map_rule_cmd route_match_peer_cmd
=
283 route_match_peer_compile
,
284 route_match_peer_free
287 /* `match ip address IP_ACCESS_LIST' */
289 /* Match function should return 1 if match is success else return
291 static route_map_result_t
292 route_match_ip_address (void *rule
, struct prefix
*prefix
,
293 route_map_object_t type
, void *object
)
295 struct access_list
*alist
;
296 /* struct prefix_ipv4 match; */
298 if (type
== RMAP_BGP
)
300 alist
= access_list_lookup (AFI_IP
, (char *) rule
);
304 return (access_list_apply (alist
, prefix
) == FILTER_DENY
?
305 RMAP_NOMATCH
: RMAP_MATCH
);
310 /* Route map `ip address' match statement. `arg' should be
313 route_match_ip_address_compile (const char *arg
)
315 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
318 /* Free route map's compiled `ip address' value. */
320 route_match_ip_address_free (void *rule
)
322 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
325 /* Route map commands for ip address matching. */
326 struct route_map_rule_cmd route_match_ip_address_cmd
=
329 route_match_ip_address
,
330 route_match_ip_address_compile
,
331 route_match_ip_address_free
334 /* `match ip next-hop IP_ADDRESS' */
336 /* Match function return 1 if match is success else return zero. */
337 static route_map_result_t
338 route_match_ip_next_hop (void *rule
, struct prefix
*prefix
,
339 route_map_object_t type
, void *object
)
341 struct access_list
*alist
;
342 struct bgp_info
*bgp_info
;
343 struct prefix_ipv4 p
;
345 if (type
== RMAP_BGP
)
349 p
.prefix
= bgp_info
->attr
->nexthop
;
350 p
.prefixlen
= IPV4_MAX_BITLEN
;
352 alist
= access_list_lookup (AFI_IP
, (char *) rule
);
356 return (access_list_apply (alist
, &p
) == FILTER_DENY
?
357 RMAP_NOMATCH
: RMAP_MATCH
);
362 /* Route map `ip next-hop' match statement. `arg' is
365 route_match_ip_next_hop_compile (const char *arg
)
367 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
370 /* Free route map's compiled `ip address' value. */
372 route_match_ip_next_hop_free (void *rule
)
374 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
377 /* Route map commands for ip next-hop matching. */
378 struct route_map_rule_cmd route_match_ip_next_hop_cmd
=
381 route_match_ip_next_hop
,
382 route_match_ip_next_hop_compile
,
383 route_match_ip_next_hop_free
386 /* `match ip route-source ACCESS-LIST' */
388 /* Match function return 1 if match is success else return zero. */
389 static route_map_result_t
390 route_match_ip_route_source (void *rule
, struct prefix
*prefix
,
391 route_map_object_t type
, void *object
)
393 struct access_list
*alist
;
394 struct bgp_info
*bgp_info
;
396 struct prefix_ipv4 p
;
398 if (type
== RMAP_BGP
)
401 peer
= bgp_info
->peer
;
403 if (! peer
|| sockunion_family (&peer
->su
) != AF_INET
)
407 p
.prefix
= peer
->su
.sin
.sin_addr
;
408 p
.prefixlen
= IPV4_MAX_BITLEN
;
410 alist
= access_list_lookup (AFI_IP
, (char *) rule
);
414 return (access_list_apply (alist
, &p
) == FILTER_DENY
?
415 RMAP_NOMATCH
: RMAP_MATCH
);
420 /* Route map `ip route-source' match statement. `arg' is
423 route_match_ip_route_source_compile (const char *arg
)
425 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
428 /* Free route map's compiled `ip address' value. */
430 route_match_ip_route_source_free (void *rule
)
432 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
435 /* Route map commands for ip route-source matching. */
436 struct route_map_rule_cmd route_match_ip_route_source_cmd
=
439 route_match_ip_route_source
,
440 route_match_ip_route_source_compile
,
441 route_match_ip_route_source_free
444 /* `match ip address prefix-list PREFIX_LIST' */
446 static route_map_result_t
447 route_match_ip_address_prefix_list (void *rule
, struct prefix
*prefix
,
448 route_map_object_t type
, void *object
)
450 struct prefix_list
*plist
;
452 if (type
== RMAP_BGP
)
454 plist
= prefix_list_lookup (AFI_IP
, (char *) rule
);
458 return (prefix_list_apply (plist
, prefix
) == PREFIX_DENY
?
459 RMAP_NOMATCH
: RMAP_MATCH
);
465 route_match_ip_address_prefix_list_compile (const char *arg
)
467 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
471 route_match_ip_address_prefix_list_free (void *rule
)
473 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
476 struct route_map_rule_cmd route_match_ip_address_prefix_list_cmd
=
478 "ip address prefix-list",
479 route_match_ip_address_prefix_list
,
480 route_match_ip_address_prefix_list_compile
,
481 route_match_ip_address_prefix_list_free
484 /* `match ip next-hop prefix-list PREFIX_LIST' */
486 static route_map_result_t
487 route_match_ip_next_hop_prefix_list (void *rule
, struct prefix
*prefix
,
488 route_map_object_t type
, void *object
)
490 struct prefix_list
*plist
;
491 struct bgp_info
*bgp_info
;
492 struct prefix_ipv4 p
;
494 if (type
== RMAP_BGP
)
498 p
.prefix
= bgp_info
->attr
->nexthop
;
499 p
.prefixlen
= IPV4_MAX_BITLEN
;
501 plist
= prefix_list_lookup (AFI_IP
, (char *) rule
);
505 return (prefix_list_apply (plist
, &p
) == PREFIX_DENY
?
506 RMAP_NOMATCH
: RMAP_MATCH
);
512 route_match_ip_next_hop_prefix_list_compile (const char *arg
)
514 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
518 route_match_ip_next_hop_prefix_list_free (void *rule
)
520 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
523 struct route_map_rule_cmd route_match_ip_next_hop_prefix_list_cmd
=
525 "ip next-hop prefix-list",
526 route_match_ip_next_hop_prefix_list
,
527 route_match_ip_next_hop_prefix_list_compile
,
528 route_match_ip_next_hop_prefix_list_free
531 /* `match ip route-source prefix-list PREFIX_LIST' */
533 static route_map_result_t
534 route_match_ip_route_source_prefix_list (void *rule
, struct prefix
*prefix
,
535 route_map_object_t type
, void *object
)
537 struct prefix_list
*plist
;
538 struct bgp_info
*bgp_info
;
540 struct prefix_ipv4 p
;
542 if (type
== RMAP_BGP
)
545 peer
= bgp_info
->peer
;
547 if (! peer
|| sockunion_family (&peer
->su
) != AF_INET
)
551 p
.prefix
= peer
->su
.sin
.sin_addr
;
552 p
.prefixlen
= IPV4_MAX_BITLEN
;
554 plist
= prefix_list_lookup (AFI_IP
, (char *) rule
);
558 return (prefix_list_apply (plist
, &p
) == PREFIX_DENY
?
559 RMAP_NOMATCH
: RMAP_MATCH
);
565 route_match_ip_route_source_prefix_list_compile (const char *arg
)
567 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
571 route_match_ip_route_source_prefix_list_free (void *rule
)
573 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
576 struct route_map_rule_cmd route_match_ip_route_source_prefix_list_cmd
=
578 "ip route-source prefix-list",
579 route_match_ip_route_source_prefix_list
,
580 route_match_ip_route_source_prefix_list_compile
,
581 route_match_ip_route_source_prefix_list_free
584 /* `match metric METRIC' */
586 /* Match function return 1 if match is success else return zero. */
587 static route_map_result_t
588 route_match_metric (void *rule
, struct prefix
*prefix
,
589 route_map_object_t type
, void *object
)
592 struct bgp_info
*bgp_info
;
594 if (type
== RMAP_BGP
)
599 if (bgp_info
->attr
->med
== *med
)
607 /* Route map `match metric' match statement. `arg' is MED value */
609 route_match_metric_compile (const char *arg
)
613 unsigned long tmpval
;
615 tmpval
= strtoul (arg
, &endptr
, 10);
616 if (*endptr
!= '\0' || tmpval
== ULONG_MAX
|| tmpval
> UINT32_MAX
)
619 med
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_int32_t
));
628 /* Free route map's compiled `match metric' value. */
630 route_match_metric_free (void *rule
)
632 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
635 /* Route map commands for metric matching. */
636 struct route_map_rule_cmd route_match_metric_cmd
=
640 route_match_metric_compile
,
641 route_match_metric_free
644 /* `match as-path ASPATH' */
646 /* Match function for as-path match. I assume given object is */
647 static route_map_result_t
648 route_match_aspath (void *rule
, struct prefix
*prefix
,
649 route_map_object_t type
, void *object
)
652 struct as_list
*as_list
;
653 struct bgp_info
*bgp_info
;
655 if (type
== RMAP_BGP
)
657 as_list
= as_list_lookup ((char *) rule
);
664 return ((as_list_apply (as_list
, bgp_info
->attr
->aspath
) == AS_FILTER_DENY
) ? RMAP_NOMATCH
: RMAP_MATCH
);
669 /* Compile function for as-path match. */
671 route_match_aspath_compile (const char *arg
)
673 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
676 /* Compile function for as-path match. */
678 route_match_aspath_free (void *rule
)
680 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
683 /* Route map commands for aspath matching. */
684 struct route_map_rule_cmd route_match_aspath_cmd
=
688 route_match_aspath_compile
,
689 route_match_aspath_free
692 /* `match community COMMUNIY' */
693 struct rmap_community
699 /* Match function for community match. */
700 static route_map_result_t
701 route_match_community (void *rule
, struct prefix
*prefix
,
702 route_map_object_t type
, void *object
)
704 struct community_list
*list
;
705 struct bgp_info
*bgp_info
;
706 struct rmap_community
*rcom
;
708 if (type
== RMAP_BGP
)
713 list
= community_list_lookup (bgp_clist
, rcom
->name
, COMMUNITY_LIST_MASTER
);
719 if (community_list_exact_match (bgp_info
->attr
->community
, list
))
724 if (community_list_match (bgp_info
->attr
->community
, list
))
731 /* Compile function for community match. */
733 route_match_community_compile (const char *arg
)
735 struct rmap_community
*rcom
;
739 rcom
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct rmap_community
));
741 p
= strchr (arg
, ' ');
745 rcom
->name
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, len
+ 1);
746 memcpy (rcom
->name
, arg
, len
);
751 rcom
->name
= XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
757 /* Compile function for community match. */
759 route_match_community_free (void *rule
)
761 struct rmap_community
*rcom
= rule
;
763 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rcom
->name
);
764 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rcom
);
767 /* Route map commands for community matching. */
768 struct route_map_rule_cmd route_match_community_cmd
=
771 route_match_community
,
772 route_match_community_compile
,
773 route_match_community_free
776 /* Match function for extcommunity match. */
777 static route_map_result_t
778 route_match_ecommunity (void *rule
, struct prefix
*prefix
,
779 route_map_object_t type
, void *object
)
781 struct community_list
*list
;
782 struct bgp_info
*bgp_info
;
784 if (type
== RMAP_BGP
)
788 if (!bgp_info
->attr
->extra
)
791 list
= community_list_lookup (bgp_clist
, (char *) rule
,
792 EXTCOMMUNITY_LIST_MASTER
);
796 if (ecommunity_list_match (bgp_info
->attr
->extra
->ecommunity
, list
))
802 /* Compile function for extcommunity match. */
804 route_match_ecommunity_compile (const char *arg
)
806 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
809 /* Compile function for extcommunity match. */
811 route_match_ecommunity_free (void *rule
)
813 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
816 /* Route map commands for community matching. */
817 struct route_map_rule_cmd route_match_ecommunity_cmd
=
820 route_match_ecommunity
,
821 route_match_ecommunity_compile
,
822 route_match_ecommunity_free
825 /* `match nlri` and `set nlri` are replaced by `address-family ipv4`
826 and `address-family vpnv4'. */
829 static route_map_result_t
830 route_match_origin (void *rule
, struct prefix
*prefix
,
831 route_map_object_t type
, void *object
)
834 struct bgp_info
*bgp_info
;
836 if (type
== RMAP_BGP
)
841 if (bgp_info
->attr
->origin
== *origin
)
849 route_match_origin_compile (const char *arg
)
853 origin
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_char
));
855 if (strcmp (arg
, "igp") == 0)
857 else if (strcmp (arg
, "egp") == 0)
865 /* Free route map's compiled `ip address' value. */
867 route_match_origin_free (void *rule
)
869 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
872 /* Route map commands for origin matching. */
873 struct route_map_rule_cmd route_match_origin_cmd
=
877 route_match_origin_compile
,
878 route_match_origin_free
880 /* `set ip next-hop IP_ADDRESS' */
882 /* Set nexthop to object. ojbect must be pointer to struct attr. */
883 struct rmap_ip_nexthop_set
885 struct in_addr
*address
;
889 static route_map_result_t
890 route_set_ip_nexthop (void *rule
, struct prefix
*prefix
,
891 route_map_object_t type
, void *object
)
893 struct rmap_ip_nexthop_set
*rins
= rule
;
894 struct in_addr peer_address
;
895 struct bgp_info
*bgp_info
;
898 if (type
== RMAP_BGP
)
901 peer
= bgp_info
->peer
;
903 if (rins
->peer_address
)
905 if ((CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IN
) ||
906 CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IMPORT
))
908 && sockunion_family (peer
->su_remote
) == AF_INET
)
910 inet_aton (sockunion_su2str (peer
->su_remote
), &peer_address
);
911 bgp_info
->attr
->nexthop
= peer_address
;
912 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
);
914 else if (CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
)
916 && sockunion_family (peer
->su_local
) == AF_INET
)
918 inet_aton (sockunion_su2str (peer
->su_local
), &peer_address
);
919 bgp_info
->attr
->nexthop
= peer_address
;
920 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
);
925 /* Set next hop value. */
926 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
);
927 bgp_info
->attr
->nexthop
= *rins
->address
;
934 /* Route map `ip nexthop' compile function. Given string is converted
935 to struct in_addr structure. */
937 route_set_ip_nexthop_compile (const char *arg
)
939 struct rmap_ip_nexthop_set
*rins
;
940 struct in_addr
*address
= NULL
;
941 int peer_address
= 0;
944 if (strcmp (arg
, "peer-address") == 0)
948 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in_addr
));
949 ret
= inet_aton (arg
, address
);
953 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
958 rins
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct rmap_ip_nexthop_set
));
959 memset (rins
, 0, sizeof (struct rmap_ip_nexthop_set
));
961 rins
->address
= address
;
962 rins
->peer_address
= peer_address
;
967 /* Free route map's compiled `ip nexthop' value. */
969 route_set_ip_nexthop_free (void *rule
)
971 struct rmap_ip_nexthop_set
*rins
= rule
;
974 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rins
->address
);
976 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rins
);
979 /* Route map commands for ip nexthop set. */
980 struct route_map_rule_cmd route_set_ip_nexthop_cmd
=
983 route_set_ip_nexthop
,
984 route_set_ip_nexthop_compile
,
985 route_set_ip_nexthop_free
988 /* `set local-preference LOCAL_PREF' */
990 /* Set local preference. */
991 static route_map_result_t
992 route_set_local_pref (void *rule
, struct prefix
*prefix
,
993 route_map_object_t type
, void *object
)
995 u_int32_t
*local_pref
;
996 struct bgp_info
*bgp_info
;
998 if (type
== RMAP_BGP
)
1000 /* Fetch routemap's rule information. */
1004 /* Set local preference value. */
1005 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
);
1006 bgp_info
->attr
->local_pref
= *local_pref
;
1012 /* set local preference compilation. */
1014 route_set_local_pref_compile (const char *arg
)
1017 u_int32_t
*local_pref
;
1018 char *endptr
= NULL
;
1020 /* Local preference value shoud be integer. */
1021 if (! all_digit (arg
))
1024 tmp
= strtoul (arg
, &endptr
, 10);
1025 if (*endptr
!= '\0' || tmp
== ULONG_MAX
|| tmp
> UINT32_MAX
)
1028 local_pref
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_int32_t
));
1038 /* Free route map's local preference value. */
1040 route_set_local_pref_free (void *rule
)
1042 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1045 /* Set local preference rule structure. */
1046 struct route_map_rule_cmd route_set_local_pref_cmd
=
1049 route_set_local_pref
,
1050 route_set_local_pref_compile
,
1051 route_set_local_pref_free
,
1054 /* `set weight WEIGHT' */
1057 static route_map_result_t
1058 route_set_weight (void *rule
, struct prefix
*prefix
, route_map_object_t type
,
1062 struct bgp_info
*bgp_info
;
1064 if (type
== RMAP_BGP
)
1066 /* Fetch routemap's rule information. */
1070 /* Set weight value. */
1072 (bgp_attr_extra_get (bgp_info
->attr
))->weight
= *weight
;
1073 else if (bgp_info
->attr
->extra
)
1074 bgp_info
->attr
->extra
->weight
= 0;
1080 /* set local preference compilation. */
1082 route_set_weight_compile (const char *arg
)
1086 char *endptr
= NULL
;
1088 /* Local preference value shoud be integer. */
1089 if (! all_digit (arg
))
1093 tmp
= strtoul (arg
, &endptr
, 10);
1094 if (*endptr
!= '\0' || tmp
== ULONG_MAX
|| tmp
> UINT32_MAX
)
1097 weight
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_int32_t
));
1107 /* Free route map's local preference value. */
1109 route_set_weight_free (void *rule
)
1111 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1114 /* Set local preference rule structure. */
1115 struct route_map_rule_cmd route_set_weight_cmd
=
1119 route_set_weight_compile
,
1120 route_set_weight_free
,
1123 /* `set metric METRIC' */
1125 /* Set metric to attribute. */
1126 static route_map_result_t
1127 route_set_metric (void *rule
, struct prefix
*prefix
,
1128 route_map_object_t type
, void *object
)
1131 u_int32_t metric_val
;
1132 struct bgp_info
*bgp_info
;
1134 if (type
== RMAP_BGP
)
1136 /* Fetch routemap's rule information. */
1140 if (! (bgp_info
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
)))
1141 bgp_info
->attr
->med
= 0;
1142 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
1144 if (all_digit (metric
))
1146 metric_val
= strtoul (metric
, (char **)NULL
, 10);
1147 bgp_info
->attr
->med
= metric_val
;
1151 metric_val
= strtoul (metric
+1, (char **)NULL
, 10);
1153 if (strncmp (metric
, "+", 1) == 0)
1155 if (bgp_info
->attr
->med
/2 + metric_val
/2 > BGP_MED_MAX
/2)
1156 bgp_info
->attr
->med
= BGP_MED_MAX
- 1;
1158 bgp_info
->attr
->med
+= metric_val
;
1160 else if (strncmp (metric
, "-", 1) == 0)
1162 if (bgp_info
->attr
->med
<= metric_val
)
1163 bgp_info
->attr
->med
= 0;
1165 bgp_info
->attr
->med
-= metric_val
;
1172 /* set metric compilation. */
1174 route_set_metric_compile (const char *arg
)
1178 char *endptr
= NULL
;
1180 if (all_digit (arg
))
1182 /* set metric value check*/
1183 larg
= strtoul (arg
, &endptr
, 10);
1184 if (*endptr
!= '\0' || larg
== ULONG_MAX
|| larg
> UINT32_MAX
)
1190 /* set metric +/-value check */
1191 if ((strncmp (arg
, "+", 1) != 0
1192 && strncmp (arg
, "-", 1) != 0)
1193 || (! all_digit (arg
+1)))
1196 larg
= strtoul (arg
+1, &endptr
, 10);
1197 if (*endptr
!= '\0' || larg
== ULONG_MAX
|| larg
> UINT32_MAX
)
1202 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
1205 /* Free route map's compiled `set metric' value. */
1207 route_set_metric_free (void *rule
)
1209 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1212 /* Set metric rule structure. */
1213 struct route_map_rule_cmd route_set_metric_cmd
=
1217 route_set_metric_compile
,
1218 route_set_metric_free
,
1221 /* `set as-path prepend ASPATH' */
1223 /* For AS path prepend mechanism. */
1224 static route_map_result_t
1225 route_set_aspath_prepend (void *rule
, struct prefix
*prefix
, route_map_object_t type
, void *object
)
1227 struct aspath
*aspath
;
1229 struct bgp_info
*binfo
;
1231 if (type
== RMAP_BGP
)
1236 if (binfo
->attr
->aspath
->refcnt
)
1237 new = aspath_dup (binfo
->attr
->aspath
);
1239 new = binfo
->attr
->aspath
;
1241 aspath_prepend (aspath
, new);
1242 binfo
->attr
->aspath
= new;
1248 /* Compile function for as-path prepend. */
1250 route_set_aspath_prepend_compile (const char *arg
)
1252 struct aspath
*aspath
;
1254 aspath
= aspath_str2aspath (arg
);
1260 /* Compile function for as-path prepend. */
1262 route_set_aspath_prepend_free (void *rule
)
1264 struct aspath
*aspath
= rule
;
1265 aspath_free (aspath
);
1268 /* Set metric rule structure. */
1269 struct route_map_rule_cmd route_set_aspath_prepend_cmd
=
1272 route_set_aspath_prepend
,
1273 route_set_aspath_prepend_compile
,
1274 route_set_aspath_prepend_free
,
1277 /* `set community COMMUNITY' */
1280 struct community
*com
;
1285 /* For community set mechanism. */
1286 static route_map_result_t
1287 route_set_community (void *rule
, struct prefix
*prefix
,
1288 route_map_object_t type
, void *object
)
1290 struct rmap_com_set
*rcs
;
1291 struct bgp_info
*binfo
;
1293 struct community
*new = NULL
;
1294 struct community
*old
;
1295 struct community
*merge
;
1297 if (type
== RMAP_BGP
)
1302 old
= attr
->community
;
1307 attr
->flag
&= ~(ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
));
1308 attr
->community
= NULL
;
1312 /* "additive" case. */
1313 if (rcs
->additive
&& old
)
1315 merge
= community_merge (community_dup (old
), rcs
->com
);
1317 /* HACK: if the old community is not intern'd,
1318 * we should free it here, or all reference to it may be lost.
1319 * Really need to cleanup attribute caching sometime.
1321 if (old
->refcnt
== 0)
1322 community_free (old
);
1323 new = community_uniq_sort (merge
);
1324 community_free (merge
);
1327 new = community_dup (rcs
->com
);
1329 /* will be interned by caller if required */
1330 attr
->community
= new;
1332 attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
);
1338 /* Compile function for set community. */
1340 route_set_community_compile (const char *arg
)
1342 struct rmap_com_set
*rcs
;
1343 struct community
*com
= NULL
;
1348 if (strcmp (arg
, "none") == 0)
1352 sp
= strstr (arg
, "additive");
1356 /* "additive" keyworkd is included. */
1361 com
= community_str2com (arg
);
1370 rcs
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct rmap_com_set
));
1371 memset (rcs
, 0, sizeof (struct rmap_com_set
));
1374 rcs
->additive
= additive
;
1380 /* Free function for set community. */
1382 route_set_community_free (void *rule
)
1384 struct rmap_com_set
*rcs
= rule
;
1387 community_free (rcs
->com
);
1388 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rcs
);
1391 /* Set community rule structure. */
1392 struct route_map_rule_cmd route_set_community_cmd
=
1395 route_set_community
,
1396 route_set_community_compile
,
1397 route_set_community_free
,
1400 /* `set comm-list (<1-99>|<100-500>|WORD) delete' */
1402 /* For community set mechanism. */
1403 static route_map_result_t
1404 route_set_community_delete (void *rule
, struct prefix
*prefix
,
1405 route_map_object_t type
, void *object
)
1407 struct community_list
*list
;
1408 struct community
*merge
;
1409 struct community
*new;
1410 struct community
*old
;
1411 struct bgp_info
*binfo
;
1413 if (type
== RMAP_BGP
)
1419 list
= community_list_lookup (bgp_clist
, rule
, COMMUNITY_LIST_MASTER
);
1420 old
= binfo
->attr
->community
;
1424 merge
= community_list_match_delete (community_dup (old
), list
);
1425 new = community_uniq_sort (merge
);
1426 community_free (merge
);
1430 binfo
->attr
->community
= NULL
;
1431 binfo
->attr
->flag
&= ~ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
);
1432 community_free (new);
1436 binfo
->attr
->community
= new;
1437 binfo
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
);
1445 /* Compile function for set community. */
1447 route_set_community_delete_compile (const char *arg
)
1453 p
= strchr (arg
, ' ');
1457 str
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, len
+ 1);
1458 memcpy (str
, arg
, len
);
1466 /* Free function for set community. */
1468 route_set_community_delete_free (void *rule
)
1470 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1473 /* Set community rule structure. */
1474 struct route_map_rule_cmd route_set_community_delete_cmd
=
1477 route_set_community_delete
,
1478 route_set_community_delete_compile
,
1479 route_set_community_delete_free
,
1482 /* `set extcommunity rt COMMUNITY' */
1484 /* For community set mechanism. */
1485 static route_map_result_t
1486 route_set_ecommunity_rt (void *rule
, struct prefix
*prefix
,
1487 route_map_object_t type
, void *object
)
1489 struct ecommunity
*ecom
;
1490 struct ecommunity
*new_ecom
;
1491 struct ecommunity
*old_ecom
;
1492 struct bgp_info
*bgp_info
;
1494 if (type
== RMAP_BGP
)
1502 /* We assume additive for Extended Community. */
1503 old_ecom
= (bgp_attr_extra_get (bgp_info
->attr
))->ecommunity
;
1506 new_ecom
= ecommunity_merge (ecommunity_dup (old_ecom
), ecom
);
1508 new_ecom
= ecommunity_dup (ecom
);
1510 bgp_info
->attr
->extra
->ecommunity
= new_ecom
;
1513 ecommunity_free (old_ecom
);
1515 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES
);
1520 /* Compile function for set community. */
1522 route_set_ecommunity_rt_compile (const char *arg
)
1524 struct ecommunity
*ecom
;
1526 ecom
= ecommunity_str2com (arg
, ECOMMUNITY_ROUTE_TARGET
, 0);
1532 /* Free function for set community. */
1534 route_set_ecommunity_rt_free (void *rule
)
1536 struct ecommunity
*ecom
= rule
;
1537 ecommunity_free (ecom
);
1540 /* Set community rule structure. */
1541 struct route_map_rule_cmd route_set_ecommunity_rt_cmd
=
1544 route_set_ecommunity_rt
,
1545 route_set_ecommunity_rt_compile
,
1546 route_set_ecommunity_rt_free
,
1549 /* `set extcommunity soo COMMUNITY' */
1551 /* For community set mechanism. */
1552 static route_map_result_t
1553 route_set_ecommunity_soo (void *rule
, struct prefix
*prefix
,
1554 route_map_object_t type
, void *object
)
1556 struct ecommunity
*ecom
;
1557 struct bgp_info
*bgp_info
;
1559 if (type
== RMAP_BGP
)
1567 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES
);
1568 (bgp_attr_extra_get (bgp_info
->attr
))->ecommunity
= ecommunity_dup (ecom
);
1573 /* Compile function for set community. */
1575 route_set_ecommunity_soo_compile (const char *arg
)
1577 struct ecommunity
*ecom
;
1579 ecom
= ecommunity_str2com (arg
, ECOMMUNITY_SITE_ORIGIN
, 0);
1586 /* Free function for set community. */
1588 route_set_ecommunity_soo_free (void *rule
)
1590 struct ecommunity
*ecom
= rule
;
1591 ecommunity_free (ecom
);
1594 /* Set community rule structure. */
1595 struct route_map_rule_cmd route_set_ecommunity_soo_cmd
=
1598 route_set_ecommunity_soo
,
1599 route_set_ecommunity_soo_compile
,
1600 route_set_ecommunity_soo_free
,
1603 /* `set origin ORIGIN' */
1605 /* For origin set. */
1606 static route_map_result_t
1607 route_set_origin (void *rule
, struct prefix
*prefix
, route_map_object_t type
, void *object
)
1610 struct bgp_info
*bgp_info
;
1612 if (type
== RMAP_BGP
)
1617 bgp_info
->attr
->origin
= *origin
;
1623 /* Compile function for origin set. */
1625 route_set_origin_compile (const char *arg
)
1629 origin
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_char
));
1631 if (strcmp (arg
, "igp") == 0)
1633 else if (strcmp (arg
, "egp") == 0)
1641 /* Compile function for origin set. */
1643 route_set_origin_free (void *rule
)
1645 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1648 /* Set metric rule structure. */
1649 struct route_map_rule_cmd route_set_origin_cmd
=
1653 route_set_origin_compile
,
1654 route_set_origin_free
,
1657 /* `set atomic-aggregate' */
1659 /* For atomic aggregate set. */
1660 static route_map_result_t
1661 route_set_atomic_aggregate (void *rule
, struct prefix
*prefix
,
1662 route_map_object_t type
, void *object
)
1664 struct bgp_info
*bgp_info
;
1666 if (type
== RMAP_BGP
)
1669 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
1675 /* Compile function for atomic aggregate. */
1677 route_set_atomic_aggregate_compile (const char *arg
)
1682 /* Compile function for atomic aggregate. */
1684 route_set_atomic_aggregate_free (void *rule
)
1689 /* Set atomic aggregate rule structure. */
1690 struct route_map_rule_cmd route_set_atomic_aggregate_cmd
=
1693 route_set_atomic_aggregate
,
1694 route_set_atomic_aggregate_compile
,
1695 route_set_atomic_aggregate_free
,
1698 /* `set aggregator as AS A.B.C.D' */
1702 struct in_addr address
;
1705 static route_map_result_t
1706 route_set_aggregator_as (void *rule
, struct prefix
*prefix
,
1707 route_map_object_t type
, void *object
)
1709 struct bgp_info
*bgp_info
;
1710 struct aggregator
*aggregator
;
1711 struct attr_extra
*ae
;
1713 if (type
== RMAP_BGP
)
1717 ae
= bgp_attr_extra_get (bgp_info
->attr
);
1719 ae
->aggregator_as
= aggregator
->as
;
1720 ae
->aggregator_addr
= aggregator
->address
;
1721 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
);
1728 route_set_aggregator_as_compile (const char *arg
)
1730 struct aggregator
*aggregator
;
1734 aggregator
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct aggregator
));
1735 memset (aggregator
, 0, sizeof (struct aggregator
));
1737 sscanf (arg
, "%s %s", as
, address
);
1739 aggregator
->as
= strtoul (as
, NULL
, 10);
1740 inet_aton (address
, &aggregator
->address
);
1746 route_set_aggregator_as_free (void *rule
)
1748 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1751 struct route_map_rule_cmd route_set_aggregator_as_cmd
=
1754 route_set_aggregator_as
,
1755 route_set_aggregator_as_compile
,
1756 route_set_aggregator_as_free
,
1760 /* `match ipv6 address IP_ACCESS_LIST' */
1762 static route_map_result_t
1763 route_match_ipv6_address (void *rule
, struct prefix
*prefix
,
1764 route_map_object_t type
, void *object
)
1766 struct access_list
*alist
;
1768 if (type
== RMAP_BGP
)
1770 alist
= access_list_lookup (AFI_IP6
, (char *) rule
);
1772 return RMAP_NOMATCH
;
1774 return (access_list_apply (alist
, prefix
) == FILTER_DENY
?
1775 RMAP_NOMATCH
: RMAP_MATCH
);
1777 return RMAP_NOMATCH
;
1781 route_match_ipv6_address_compile (const char *arg
)
1783 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
1787 route_match_ipv6_address_free (void *rule
)
1789 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1792 /* Route map commands for ip address matching. */
1793 struct route_map_rule_cmd route_match_ipv6_address_cmd
=
1796 route_match_ipv6_address
,
1797 route_match_ipv6_address_compile
,
1798 route_match_ipv6_address_free
1801 /* `match ipv6 next-hop IP_ADDRESS' */
1803 static route_map_result_t
1804 route_match_ipv6_next_hop (void *rule
, struct prefix
*prefix
,
1805 route_map_object_t type
, void *object
)
1807 struct in6_addr
*addr
;
1808 struct bgp_info
*bgp_info
;
1810 if (type
== RMAP_BGP
)
1815 if (!bgp_info
->attr
->extra
)
1816 return RMAP_NOMATCH
;
1818 if (IPV6_ADDR_SAME (&bgp_info
->attr
->extra
->mp_nexthop_global
, rule
))
1821 if (bgp_info
->attr
->extra
->mp_nexthop_len
== 32 &&
1822 IPV6_ADDR_SAME (&bgp_info
->attr
->extra
->mp_nexthop_local
, rule
))
1825 return RMAP_NOMATCH
;
1828 return RMAP_NOMATCH
;
1832 route_match_ipv6_next_hop_compile (const char *arg
)
1834 struct in6_addr
*address
;
1837 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in6_addr
));
1839 ret
= inet_pton (AF_INET6
, arg
, address
);
1842 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
1850 route_match_ipv6_next_hop_free (void *rule
)
1852 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1855 struct route_map_rule_cmd route_match_ipv6_next_hop_cmd
=
1858 route_match_ipv6_next_hop
,
1859 route_match_ipv6_next_hop_compile
,
1860 route_match_ipv6_next_hop_free
1863 /* `match ipv6 address prefix-list PREFIX_LIST' */
1865 static route_map_result_t
1866 route_match_ipv6_address_prefix_list (void *rule
, struct prefix
*prefix
,
1867 route_map_object_t type
, void *object
)
1869 struct prefix_list
*plist
;
1871 if (type
== RMAP_BGP
)
1873 plist
= prefix_list_lookup (AFI_IP6
, (char *) rule
);
1875 return RMAP_NOMATCH
;
1877 return (prefix_list_apply (plist
, prefix
) == PREFIX_DENY
?
1878 RMAP_NOMATCH
: RMAP_MATCH
);
1880 return RMAP_NOMATCH
;
1884 route_match_ipv6_address_prefix_list_compile (const char *arg
)
1886 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
1890 route_match_ipv6_address_prefix_list_free (void *rule
)
1892 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1895 struct route_map_rule_cmd route_match_ipv6_address_prefix_list_cmd
=
1897 "ipv6 address prefix-list",
1898 route_match_ipv6_address_prefix_list
,
1899 route_match_ipv6_address_prefix_list_compile
,
1900 route_match_ipv6_address_prefix_list_free
1903 /* `set ipv6 nexthop global IP_ADDRESS' */
1905 /* Set nexthop to object. ojbect must be pointer to struct attr. */
1906 static route_map_result_t
1907 route_set_ipv6_nexthop_global (void *rule
, struct prefix
*prefix
,
1908 route_map_object_t type
, void *object
)
1910 struct in6_addr
*address
;
1911 struct bgp_info
*bgp_info
;
1913 if (type
== RMAP_BGP
)
1915 /* Fetch routemap's rule information. */
1919 /* Set next hop value. */
1920 (bgp_attr_extra_get (bgp_info
->attr
))->mp_nexthop_global
= *address
;
1922 /* Set nexthop length. */
1923 if (bgp_info
->attr
->extra
->mp_nexthop_len
== 0)
1924 bgp_info
->attr
->extra
->mp_nexthop_len
= 16;
1930 /* Route map `ip next-hop' compile function. Given string is converted
1931 to struct in_addr structure. */
1933 route_set_ipv6_nexthop_global_compile (const char *arg
)
1936 struct in6_addr
*address
;
1938 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in6_addr
));
1940 ret
= inet_pton (AF_INET6
, arg
, address
);
1944 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
1951 /* Free route map's compiled `ip next-hop' value. */
1953 route_set_ipv6_nexthop_global_free (void *rule
)
1955 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1958 /* Route map commands for ip nexthop set. */
1959 struct route_map_rule_cmd route_set_ipv6_nexthop_global_cmd
=
1961 "ipv6 next-hop global",
1962 route_set_ipv6_nexthop_global
,
1963 route_set_ipv6_nexthop_global_compile
,
1964 route_set_ipv6_nexthop_global_free
1967 /* `set ipv6 nexthop local IP_ADDRESS' */
1969 /* Set nexthop to object. ojbect must be pointer to struct attr. */
1970 static route_map_result_t
1971 route_set_ipv6_nexthop_local (void *rule
, struct prefix
*prefix
,
1972 route_map_object_t type
, void *object
)
1974 struct in6_addr
*address
;
1975 struct bgp_info
*bgp_info
;
1977 if (type
== RMAP_BGP
)
1979 /* Fetch routemap's rule information. */
1983 /* Set next hop value. */
1984 (bgp_attr_extra_get (bgp_info
->attr
))->mp_nexthop_local
= *address
;
1986 /* Set nexthop length. */
1987 if (bgp_info
->attr
->extra
->mp_nexthop_len
!= 32)
1988 bgp_info
->attr
->extra
->mp_nexthop_len
= 32;
1994 /* Route map `ip nexthop' compile function. Given string is converted
1995 to struct in_addr structure. */
1997 route_set_ipv6_nexthop_local_compile (const char *arg
)
2000 struct in6_addr
*address
;
2002 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in6_addr
));
2004 ret
= inet_pton (AF_INET6
, arg
, address
);
2008 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
2015 /* Free route map's compiled `ip nexthop' value. */
2017 route_set_ipv6_nexthop_local_free (void *rule
)
2019 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2022 /* Route map commands for ip nexthop set. */
2023 struct route_map_rule_cmd route_set_ipv6_nexthop_local_cmd
=
2025 "ipv6 next-hop local",
2026 route_set_ipv6_nexthop_local
,
2027 route_set_ipv6_nexthop_local_compile
,
2028 route_set_ipv6_nexthop_local_free
2030 #endif /* HAVE_IPV6 */
2032 /* `set vpnv4 nexthop A.B.C.D' */
2034 static route_map_result_t
2035 route_set_vpnv4_nexthop (void *rule
, struct prefix
*prefix
,
2036 route_map_object_t type
, void *object
)
2038 struct in_addr
*address
;
2039 struct bgp_info
*bgp_info
;
2041 if (type
== RMAP_BGP
)
2043 /* Fetch routemap's rule information. */
2047 /* Set next hop value. */
2048 (bgp_attr_extra_get (bgp_info
->attr
))->mp_nexthop_global_in
= *address
;
2055 route_set_vpnv4_nexthop_compile (const char *arg
)
2058 struct in_addr
*address
;
2060 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in_addr
));
2062 ret
= inet_aton (arg
, address
);
2066 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
2074 route_set_vpnv4_nexthop_free (void *rule
)
2076 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2079 /* Route map commands for ip nexthop set. */
2080 struct route_map_rule_cmd route_set_vpnv4_nexthop_cmd
=
2083 route_set_vpnv4_nexthop
,
2084 route_set_vpnv4_nexthop_compile
,
2085 route_set_vpnv4_nexthop_free
2088 /* `set originator-id' */
2090 /* For origin set. */
2091 static route_map_result_t
2092 route_set_originator_id (void *rule
, struct prefix
*prefix
, route_map_object_t type
, void *object
)
2094 struct in_addr
*address
;
2095 struct bgp_info
*bgp_info
;
2097 if (type
== RMAP_BGP
)
2102 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
);
2103 (bgp_attr_extra_get (bgp_info
->attr
))->originator_id
= *address
;
2109 /* Compile function for originator-id set. */
2111 route_set_originator_id_compile (const char *arg
)
2114 struct in_addr
*address
;
2116 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in_addr
));
2118 ret
= inet_aton (arg
, address
);
2122 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
2129 /* Compile function for originator_id set. */
2131 route_set_originator_id_free (void *rule
)
2133 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2136 /* Set metric rule structure. */
2137 struct route_map_rule_cmd route_set_originator_id_cmd
=
2140 route_set_originator_id
,
2141 route_set_originator_id_compile
,
2142 route_set_originator_id_free
,
2145 /* Add bgp route map rule. */
2147 bgp_route_match_add (struct vty
*vty
, struct route_map_index
*index
,
2148 const char *command
, const char *arg
)
2152 ret
= route_map_add_match (index
, command
, arg
);
2157 case RMAP_RULE_MISSING
:
2158 vty_out (vty
, "%% Can't find rule.%s", VTY_NEWLINE
);
2160 case RMAP_COMPILE_ERROR
:
2161 vty_out (vty
, "%% Argument is malformed.%s", VTY_NEWLINE
);
2168 /* Delete bgp route map rule. */
2170 bgp_route_match_delete (struct vty
*vty
, struct route_map_index
*index
,
2171 const char *command
, const char *arg
)
2175 ret
= route_map_delete_match (index
, command
, arg
);
2180 case RMAP_RULE_MISSING
:
2181 vty_out (vty
, "%% Can't find rule.%s", VTY_NEWLINE
);
2183 case RMAP_COMPILE_ERROR
:
2184 vty_out (vty
, "%% Argument is malformed.%s", VTY_NEWLINE
);
2191 /* Add bgp route map rule. */
2193 bgp_route_set_add (struct vty
*vty
, struct route_map_index
*index
,
2194 const char *command
, const char *arg
)
2198 ret
= route_map_add_set (index
, command
, arg
);
2203 case RMAP_RULE_MISSING
:
2204 vty_out (vty
, "%% Can't find rule.%s", VTY_NEWLINE
);
2206 case RMAP_COMPILE_ERROR
:
2207 vty_out (vty
, "%% Argument is malformed.%s", VTY_NEWLINE
);
2214 /* Delete bgp route map rule. */
2216 bgp_route_set_delete (struct vty
*vty
, struct route_map_index
*index
,
2217 const char *command
, const char *arg
)
2221 ret
= route_map_delete_set (index
, command
, arg
);
2226 case RMAP_RULE_MISSING
:
2227 vty_out (vty
, "%% Can't find rule.%s", VTY_NEWLINE
);
2229 case RMAP_COMPILE_ERROR
:
2230 vty_out (vty
, "%% Argument is malformed.%s", VTY_NEWLINE
);
2237 /* Hook function for updating route_map assignment. */
2239 bgp_route_map_update (const char *unused
)
2245 struct listnode
*node
, *nnode
;
2246 struct listnode
*mnode
, *mnnode
;
2249 struct peer_group
*group
;
2250 struct bgp_filter
*filter
;
2251 struct bgp_node
*bn
;
2252 struct bgp_static
*bgp_static
;
2254 /* For neighbor route-map updates. */
2255 for (ALL_LIST_ELEMENTS (bm
->bgp
, mnode
, mnnode
, bgp
))
2257 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
2259 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2260 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2262 filter
= &peer
->filter
[afi
][safi
];
2264 for (direct
= RMAP_IN
; direct
< RMAP_MAX
; direct
++)
2266 if (filter
->map
[direct
].name
)
2267 filter
->map
[direct
].map
=
2268 route_map_lookup_by_name (filter
->map
[direct
].name
);
2270 filter
->map
[direct
].map
= NULL
;
2273 if (filter
->usmap
.name
)
2274 filter
->usmap
.map
= route_map_lookup_by_name (filter
->usmap
.name
);
2276 filter
->usmap
.map
= NULL
;
2279 for (ALL_LIST_ELEMENTS (bgp
->group
, node
, nnode
, group
))
2281 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2282 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2284 filter
= &group
->conf
->filter
[afi
][safi
];
2286 for (direct
= RMAP_IN
; direct
< RMAP_MAX
; direct
++)
2288 if (filter
->map
[direct
].name
)
2289 filter
->map
[direct
].map
=
2290 route_map_lookup_by_name (filter
->map
[direct
].name
);
2292 filter
->map
[direct
].map
= NULL
;
2295 if (filter
->usmap
.name
)
2296 filter
->usmap
.map
= route_map_lookup_by_name (filter
->usmap
.name
);
2298 filter
->usmap
.map
= NULL
;
2303 /* For default-originate route-map updates. */
2304 for (ALL_LIST_ELEMENTS (bm
->bgp
, mnode
, mnnode
, bgp
))
2306 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
2308 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2309 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2311 if (peer
->default_rmap
[afi
][safi
].name
)
2312 peer
->default_rmap
[afi
][safi
].map
=
2313 route_map_lookup_by_name (peer
->default_rmap
[afi
][safi
].name
);
2315 peer
->default_rmap
[afi
][safi
].map
= NULL
;
2320 /* For network route-map updates. */
2321 for (ALL_LIST_ELEMENTS (bm
->bgp
, mnode
, mnnode
, bgp
))
2323 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2324 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2325 for (bn
= bgp_table_top (bgp
->route
[afi
][safi
]); bn
;
2326 bn
= bgp_route_next (bn
))
2327 if ((bgp_static
= bn
->info
) != NULL
)
2329 if (bgp_static
->rmap
.name
)
2330 bgp_static
->rmap
.map
=
2331 route_map_lookup_by_name (bgp_static
->rmap
.name
);
2333 bgp_static
->rmap
.map
= NULL
;
2337 /* For redistribute route-map updates. */
2338 for (ALL_LIST_ELEMENTS (bm
->bgp
, mnode
, mnnode
, bgp
))
2340 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++)
2342 if (bgp
->rmap
[ZEBRA_FAMILY_IPV4
][i
].name
)
2343 bgp
->rmap
[ZEBRA_FAMILY_IPV4
][i
].map
=
2344 route_map_lookup_by_name (bgp
->rmap
[ZEBRA_FAMILY_IPV4
][i
].name
);
2346 if (bgp
->rmap
[ZEBRA_FAMILY_IPV6
][i
].name
)
2347 bgp
->rmap
[ZEBRA_FAMILY_IPV6
][i
].map
=
2348 route_map_lookup_by_name (bgp
->rmap
[ZEBRA_FAMILY_IPV6
][i
].name
);
2349 #endif /* HAVE_IPV6 */
2356 "match peer (A.B.C.D|X:X::X:X)",
2358 "Match peer address\n"
2359 "IPv6 address of peer\n"
2360 "IP address of peer\n")
2362 return bgp_route_match_add (vty
, vty
->index
, "peer", argv
[0]);
2365 DEFUN (match_peer_local
,
2366 match_peer_local_cmd
,
2369 "Match peer address\n"
2370 "Static or Redistributed routes\n")
2372 return bgp_route_match_add (vty
, vty
->index
, "peer", NULL
);
2375 DEFUN (no_match_peer
,
2380 "Match peer address\n")
2383 return bgp_route_match_delete (vty
, vty
->index
, "peer", NULL
);
2385 return bgp_route_match_delete (vty
, vty
->index
, "peer", argv
[0]);
2388 ALIAS (no_match_peer
,
2389 no_match_peer_val_cmd
,
2390 "no match peer (A.B.C.D|X:X::X:X)",
2393 "Match peer address\n"
2394 "IPv6 address of peer\n"
2395 "IP address of peer\n")
2397 ALIAS (no_match_peer
,
2398 no_match_peer_local_cmd
,
2399 "no match peer local",
2402 "Match peer address\n"
2403 "Static or Redistributed routes\n")
2405 DEFUN (match_ip_address
,
2406 match_ip_address_cmd
,
2407 "match ip address (<1-199>|<1300-2699>|WORD)",
2410 "Match address of route\n"
2411 "IP access-list number\n"
2412 "IP access-list number (expanded range)\n"
2413 "IP Access-list name\n")
2415 return bgp_route_match_add (vty
, vty
->index
, "ip address", argv
[0]);
2418 DEFUN (no_match_ip_address
,
2419 no_match_ip_address_cmd
,
2420 "no match ip address",
2424 "Match address of route\n")
2427 return bgp_route_match_delete (vty
, vty
->index
, "ip address", NULL
);
2429 return bgp_route_match_delete (vty
, vty
->index
, "ip address", argv
[0]);
2432 ALIAS (no_match_ip_address
,
2433 no_match_ip_address_val_cmd
,
2434 "no match ip address (<1-199>|<1300-2699>|WORD)",
2438 "Match address of route\n"
2439 "IP access-list number\n"
2440 "IP access-list number (expanded range)\n"
2441 "IP Access-list name\n")
2443 DEFUN (match_ip_next_hop
,
2444 match_ip_next_hop_cmd
,
2445 "match ip next-hop (<1-199>|<1300-2699>|WORD)",
2448 "Match next-hop address of route\n"
2449 "IP access-list number\n"
2450 "IP access-list number (expanded range)\n"
2451 "IP Access-list name\n")
2453 return bgp_route_match_add (vty
, vty
->index
, "ip next-hop", argv
[0]);
2456 DEFUN (no_match_ip_next_hop
,
2457 no_match_ip_next_hop_cmd
,
2458 "no match ip next-hop",
2462 "Match next-hop address of route\n")
2465 return bgp_route_match_delete (vty
, vty
->index
, "ip next-hop", NULL
);
2467 return bgp_route_match_delete (vty
, vty
->index
, "ip next-hop", argv
[0]);
2470 ALIAS (no_match_ip_next_hop
,
2471 no_match_ip_next_hop_val_cmd
,
2472 "no match ip next-hop (<1-199>|<1300-2699>|WORD)",
2476 "Match next-hop address of route\n"
2477 "IP access-list number\n"
2478 "IP access-list number (expanded range)\n"
2479 "IP Access-list name\n")
2481 DEFUN (match_ip_route_source
,
2482 match_ip_route_source_cmd
,
2483 "match ip route-source (<1-199>|<1300-2699>|WORD)",
2486 "Match advertising source address of route\n"
2487 "IP access-list number\n"
2488 "IP access-list number (expanded range)\n"
2489 "IP standard access-list name\n")
2491 return bgp_route_match_add (vty
, vty
->index
, "ip route-source", argv
[0]);
2494 DEFUN (no_match_ip_route_source
,
2495 no_match_ip_route_source_cmd
,
2496 "no match ip route-source",
2500 "Match advertising source address of route\n")
2503 return bgp_route_match_delete (vty
, vty
->index
, "ip route-source", NULL
);
2505 return bgp_route_match_delete (vty
, vty
->index
, "ip route-source", argv
[0]);
2508 ALIAS (no_match_ip_route_source
,
2509 no_match_ip_route_source_val_cmd
,
2510 "no match ip route-source (<1-199>|<1300-2699>|WORD)",
2514 "Match advertising source address of route\n"
2515 "IP access-list number\n"
2516 "IP access-list number (expanded range)\n"
2517 "IP standard access-list name\n");
2519 DEFUN (match_ip_address_prefix_list
,
2520 match_ip_address_prefix_list_cmd
,
2521 "match ip address prefix-list WORD",
2524 "Match address of route\n"
2525 "Match entries of prefix-lists\n"
2526 "IP prefix-list name\n")
2528 return bgp_route_match_add (vty
, vty
->index
, "ip address prefix-list", argv
[0]);
2531 DEFUN (no_match_ip_address_prefix_list
,
2532 no_match_ip_address_prefix_list_cmd
,
2533 "no match ip address prefix-list",
2537 "Match address of route\n"
2538 "Match entries of prefix-lists\n")
2541 return bgp_route_match_delete (vty
, vty
->index
, "ip address prefix-list", NULL
);
2543 return bgp_route_match_delete (vty
, vty
->index
, "ip address prefix-list", argv
[0]);
2546 ALIAS (no_match_ip_address_prefix_list
,
2547 no_match_ip_address_prefix_list_val_cmd
,
2548 "no match ip address prefix-list WORD",
2552 "Match address of route\n"
2553 "Match entries of prefix-lists\n"
2554 "IP prefix-list name\n")
2556 DEFUN (match_ip_next_hop_prefix_list
,
2557 match_ip_next_hop_prefix_list_cmd
,
2558 "match ip next-hop prefix-list WORD",
2561 "Match next-hop address of route\n"
2562 "Match entries of prefix-lists\n"
2563 "IP prefix-list name\n")
2565 return bgp_route_match_add (vty
, vty
->index
, "ip next-hop prefix-list", argv
[0]);
2568 DEFUN (no_match_ip_next_hop_prefix_list
,
2569 no_match_ip_next_hop_prefix_list_cmd
,
2570 "no match ip next-hop prefix-list",
2574 "Match next-hop address of route\n"
2575 "Match entries of prefix-lists\n")
2578 return bgp_route_match_delete (vty
, vty
->index
, "ip next-hop prefix-list", NULL
);
2580 return bgp_route_match_delete (vty
, vty
->index
, "ip next-hop prefix-list", argv
[0]);
2583 ALIAS (no_match_ip_next_hop_prefix_list
,
2584 no_match_ip_next_hop_prefix_list_val_cmd
,
2585 "no match ip next-hop prefix-list WORD",
2589 "Match next-hop address of route\n"
2590 "Match entries of prefix-lists\n"
2591 "IP prefix-list name\n")
2593 DEFUN (match_ip_route_source_prefix_list
,
2594 match_ip_route_source_prefix_list_cmd
,
2595 "match ip route-source prefix-list WORD",
2598 "Match advertising source address of route\n"
2599 "Match entries of prefix-lists\n"
2600 "IP prefix-list name\n")
2602 return bgp_route_match_add (vty
, vty
->index
, "ip route-source prefix-list", argv
[0]);
2605 DEFUN (no_match_ip_route_source_prefix_list
,
2606 no_match_ip_route_source_prefix_list_cmd
,
2607 "no match ip route-source prefix-list",
2611 "Match advertising source address of route\n"
2612 "Match entries of prefix-lists\n")
2615 return bgp_route_match_delete (vty
, vty
->index
, "ip route-source prefix-list", NULL
);
2617 return bgp_route_match_delete (vty
, vty
->index
, "ip route-source prefix-list", argv
[0]);
2620 ALIAS (no_match_ip_route_source_prefix_list
,
2621 no_match_ip_route_source_prefix_list_val_cmd
,
2622 "no match ip route-source prefix-list WORD",
2626 "Match advertising source address of route\n"
2627 "Match entries of prefix-lists\n"
2628 "IP prefix-list name\n");
2630 DEFUN (match_metric
,
2632 "match metric <0-4294967295>",
2634 "Match metric of route\n"
2637 return bgp_route_match_add (vty
, vty
->index
, "metric", argv
[0]);
2640 DEFUN (no_match_metric
,
2641 no_match_metric_cmd
,
2645 "Match metric of route\n")
2648 return bgp_route_match_delete (vty
, vty
->index
, "metric", NULL
);
2650 return bgp_route_match_delete (vty
, vty
->index
, "metric", argv
[0]);
2653 ALIAS (no_match_metric
,
2654 no_match_metric_val_cmd
,
2655 "no match metric <0-4294967295>",
2658 "Match metric of route\n"
2661 DEFUN (match_community
,
2662 match_community_cmd
,
2663 "match community (<1-99>|<100-500>|WORD)",
2665 "Match BGP community list\n"
2666 "Community-list number (standard)\n"
2667 "Community-list number (expanded)\n"
2668 "Community-list name\n")
2670 return bgp_route_match_add (vty
, vty
->index
, "community", argv
[0]);
2673 DEFUN (match_community_exact
,
2674 match_community_exact_cmd
,
2675 "match community (<1-99>|<100-500>|WORD) exact-match",
2677 "Match BGP community list\n"
2678 "Community-list number (standard)\n"
2679 "Community-list number (expanded)\n"
2680 "Community-list name\n"
2681 "Do exact matching of communities\n")
2686 argstr
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
,
2687 strlen (argv
[0]) + strlen ("exact-match") + 2);
2689 sprintf (argstr
, "%s exact-match", argv
[0]);
2691 ret
= bgp_route_match_add (vty
, vty
->index
, "community", argstr
);
2693 XFREE (MTYPE_ROUTE_MAP_COMPILED
, argstr
);
2698 DEFUN (no_match_community
,
2699 no_match_community_cmd
,
2700 "no match community",
2703 "Match BGP community list\n")
2705 return bgp_route_match_delete (vty
, vty
->index
, "community", NULL
);
2708 ALIAS (no_match_community
,
2709 no_match_community_val_cmd
,
2710 "no match community (<1-99>|<100-500>|WORD)",
2713 "Match BGP community list\n"
2714 "Community-list number (standard)\n"
2715 "Community-list number (expanded)\n"
2716 "Community-list name\n")
2718 ALIAS (no_match_community
,
2719 no_match_community_exact_cmd
,
2720 "no match community (<1-99>|<100-500>|WORD) exact-match",
2723 "Match BGP community list\n"
2724 "Community-list number (standard)\n"
2725 "Community-list number (expanded)\n"
2726 "Community-list name\n"
2727 "Do exact matching of communities\n")
2729 DEFUN (match_ecommunity
,
2730 match_ecommunity_cmd
,
2731 "match extcommunity (<1-99>|<100-500>|WORD)",
2733 "Match BGP/VPN extended community list\n"
2734 "Extended community-list number (standard)\n"
2735 "Extended community-list number (expanded)\n"
2736 "Extended community-list name\n")
2738 return bgp_route_match_add (vty
, vty
->index
, "extcommunity", argv
[0]);
2741 DEFUN (no_match_ecommunity
,
2742 no_match_ecommunity_cmd
,
2743 "no match extcommunity",
2746 "Match BGP/VPN extended community list\n")
2748 return bgp_route_match_delete (vty
, vty
->index
, "extcommunity", NULL
);
2751 ALIAS (no_match_ecommunity
,
2752 no_match_ecommunity_val_cmd
,
2753 "no match extcommunity (<1-99>|<100-500>|WORD)",
2756 "Match BGP/VPN extended community list\n"
2757 "Extended community-list number (standard)\n"
2758 "Extended community-list number (expanded)\n"
2759 "Extended community-list name\n")
2761 DEFUN (match_aspath
,
2763 "match as-path WORD",
2765 "Match BGP AS path list\n"
2766 "AS path access-list name\n")
2768 return bgp_route_match_add (vty
, vty
->index
, "as-path", argv
[0]);
2771 DEFUN (no_match_aspath
,
2772 no_match_aspath_cmd
,
2776 "Match BGP AS path list\n")
2778 return bgp_route_match_delete (vty
, vty
->index
, "as-path", NULL
);
2781 ALIAS (no_match_aspath
,
2782 no_match_aspath_val_cmd
,
2783 "no match as-path WORD",
2786 "Match BGP AS path list\n"
2787 "AS path access-list name\n")
2789 DEFUN (match_origin
,
2791 "match origin (egp|igp|incomplete)",
2796 "unknown heritage\n")
2798 if (strncmp (argv
[0], "igp", 2) == 0)
2799 return bgp_route_match_add (vty
, vty
->index
, "origin", "igp");
2800 if (strncmp (argv
[0], "egp", 1) == 0)
2801 return bgp_route_match_add (vty
, vty
->index
, "origin", "egp");
2802 if (strncmp (argv
[0], "incomplete", 2) == 0)
2803 return bgp_route_match_add (vty
, vty
->index
, "origin", "incomplete");
2808 DEFUN (no_match_origin
,
2809 no_match_origin_cmd
,
2813 "BGP origin code\n")
2815 return bgp_route_match_delete (vty
, vty
->index
, "origin", NULL
);
2818 ALIAS (no_match_origin
,
2819 no_match_origin_val_cmd
,
2820 "no match origin (egp|igp|incomplete)",
2826 "unknown heritage\n")
2828 DEFUN (set_ip_nexthop
,
2830 "set ip next-hop A.B.C.D",
2833 "Next hop address\n"
2834 "IP address of next hop\n")
2839 ret
= str2sockunion (argv
[0], &su
);
2842 vty_out (vty
, "%% Malformed Next-hop address%s", VTY_NEWLINE
);
2846 return bgp_route_set_add (vty
, vty
->index
, "ip next-hop", argv
[0]);
2849 DEFUN (set_ip_nexthop_peer
,
2850 set_ip_nexthop_peer_cmd
,
2851 "set ip next-hop peer-address",
2854 "Next hop address\n"
2855 "Use peer address (for BGP only)\n")
2857 return bgp_route_set_add (vty
, vty
->index
, "ip next-hop", "peer-address");
2860 DEFUN_DEPRECATED (no_set_ip_nexthop_peer
,
2861 no_set_ip_nexthop_peer_cmd
,
2862 "no set ip next-hop peer-address",
2866 "Next hop address\n"
2867 "Use peer address (for BGP only)\n")
2869 return bgp_route_set_delete (vty
, vty
->index
, "ip next-hop", NULL
);
2873 DEFUN (no_set_ip_nexthop
,
2874 no_set_ip_nexthop_cmd
,
2875 "no set ip next-hop",
2878 "Next hop address\n")
2881 return bgp_route_set_delete (vty
, vty
->index
, "ip next-hop", NULL
);
2883 return bgp_route_set_delete (vty
, vty
->index
, "ip next-hop", argv
[0]);
2886 ALIAS (no_set_ip_nexthop
,
2887 no_set_ip_nexthop_val_cmd
,
2888 "no set ip next-hop A.B.C.D",
2892 "Next hop address\n"
2893 "IP address of next hop\n")
2897 "set metric <0-4294967295>",
2899 "Metric value for destination routing protocol\n"
2902 return bgp_route_set_add (vty
, vty
->index
, "metric", argv
[0]);
2906 set_metric_addsub_cmd
,
2907 "set metric <+/-metric>",
2909 "Metric value for destination routing protocol\n"
2910 "Add or subtract metric\n")
2912 DEFUN (no_set_metric
,
2917 "Metric value for destination routing protocol\n")
2920 return bgp_route_set_delete (vty
, vty
->index
, "metric", NULL
);
2922 return bgp_route_set_delete (vty
, vty
->index
, "metric", argv
[0]);
2925 ALIAS (no_set_metric
,
2926 no_set_metric_val_cmd
,
2927 "no set metric <0-4294967295>",
2930 "Metric value for destination routing protocol\n"
2933 DEFUN (set_local_pref
,
2935 "set local-preference <0-4294967295>",
2937 "BGP local preference path attribute\n"
2938 "Preference value\n")
2940 return bgp_route_set_add (vty
, vty
->index
, "local-preference", argv
[0]);
2943 DEFUN (no_set_local_pref
,
2944 no_set_local_pref_cmd
,
2945 "no set local-preference",
2948 "BGP local preference path attribute\n")
2951 return bgp_route_set_delete (vty
, vty
->index
, "local-preference", NULL
);
2953 return bgp_route_set_delete (vty
, vty
->index
, "local-preference", argv
[0]);
2956 ALIAS (no_set_local_pref
,
2957 no_set_local_pref_val_cmd
,
2958 "no set local-preference <0-4294967295>",
2961 "BGP local preference path attribute\n"
2962 "Preference value\n")
2966 "set weight <0-4294967295>",
2968 "BGP weight for routing table\n"
2971 return bgp_route_set_add (vty
, vty
->index
, "weight", argv
[0]);
2974 DEFUN (no_set_weight
,
2979 "BGP weight for routing table\n")
2982 return bgp_route_set_delete (vty
, vty
->index
, "weight", NULL
);
2984 return bgp_route_set_delete (vty
, vty
->index
, "weight", argv
[0]);
2987 ALIAS (no_set_weight
,
2988 no_set_weight_val_cmd
,
2989 "no set weight <0-4294967295>",
2992 "BGP weight for routing table\n"
2995 DEFUN (set_aspath_prepend
,
2996 set_aspath_prepend_cmd
,
2997 "set as-path prepend .<1-65535>",
2999 "Prepend string for a BGP AS-path attribute\n"
3000 "Prepend to the as-path\n"
3006 str
= argv_concat (argv
, argc
, 0);
3007 ret
= bgp_route_set_add (vty
, vty
->index
, "as-path prepend", str
);
3008 XFREE (MTYPE_TMP
, str
);
3013 DEFUN (no_set_aspath_prepend
,
3014 no_set_aspath_prepend_cmd
,
3015 "no set as-path prepend",
3018 "Prepend string for a BGP AS-path attribute\n"
3019 "Prepend to the as-path\n")
3021 return bgp_route_set_delete (vty
, vty
->index
, "as-path prepend", NULL
);
3024 ALIAS (no_set_aspath_prepend
,
3025 no_set_aspath_prepend_val_cmd
,
3026 "no set as-path prepend .<1-65535>",
3029 "Prepend string for a BGP AS-path attribute\n"
3030 "Prepend to the as-path\n"
3033 DEFUN (set_community
,
3035 "set community .AA:NN",
3037 "BGP community attribute\n"
3038 "Community number in aa:nn format or local-AS|no-advertise|no-export|internet or additive\n")
3044 struct community
*com
= NULL
;
3049 b
= buffer_new (1024);
3051 for (i
= 0; i
< argc
; i
++)
3053 if (strncmp (argv
[i
], "additive", strlen (argv
[i
])) == 0)
3060 buffer_putc (b
, ' ');
3064 if (strncmp (argv
[i
], "internet", strlen (argv
[i
])) == 0)
3066 buffer_putstr (b
, "internet");
3069 if (strncmp (argv
[i
], "local-AS", strlen (argv
[i
])) == 0)
3071 buffer_putstr (b
, "local-AS");
3074 if (strncmp (argv
[i
], "no-a", strlen ("no-a")) == 0
3075 && strncmp (argv
[i
], "no-advertise", strlen (argv
[i
])) == 0)
3077 buffer_putstr (b
, "no-advertise");
3080 if (strncmp (argv
[i
], "no-e", strlen ("no-e"))== 0
3081 && strncmp (argv
[i
], "no-export", strlen (argv
[i
])) == 0)
3083 buffer_putstr (b
, "no-export");
3086 buffer_putstr (b
, argv
[i
]);
3088 buffer_putc (b
, '\0');
3090 /* Fetch result string then compile it to communities attribute. */
3091 str
= buffer_getstr (b
);
3096 com
= community_str2com (str
);
3097 XFREE (MTYPE_TMP
, str
);
3100 /* Can't compile user input into communities attribute. */
3103 vty_out (vty
, "%% Malformed communities attribute%s", VTY_NEWLINE
);
3107 /* Set communites attribute string. */
3108 str
= community_str (com
);
3112 argstr
= XCALLOC (MTYPE_TMP
, strlen (str
) + strlen (" additive") + 1);
3113 strcpy (argstr
, str
);
3114 strcpy (argstr
+ strlen (str
), " additive");
3115 ret
= bgp_route_set_add (vty
, vty
->index
, "community", argstr
);
3116 XFREE (MTYPE_TMP
, argstr
);
3119 ret
= bgp_route_set_add (vty
, vty
->index
, "community", str
);
3121 community_free (com
);
3126 DEFUN (set_community_none
,
3127 set_community_none_cmd
,
3128 "set community none",
3130 "BGP community attribute\n"
3131 "No community attribute\n")
3133 return bgp_route_set_add (vty
, vty
->index
, "community", "none");
3136 DEFUN (no_set_community
,
3137 no_set_community_cmd
,
3141 "BGP community attribute\n")
3143 return bgp_route_set_delete (vty
, vty
->index
, "community", NULL
);
3146 ALIAS (no_set_community
,
3147 no_set_community_val_cmd
,
3148 "no set community .AA:NN",
3151 "BGP community attribute\n"
3152 "Community number in aa:nn format or local-AS|no-advertise|no-export|internet or additive\n")
3154 ALIAS (no_set_community
,
3155 no_set_community_none_cmd
,
3156 "no set community none",
3159 "BGP community attribute\n"
3160 "No community attribute\n")
3162 DEFUN (set_community_delete
,
3163 set_community_delete_cmd
,
3164 "set comm-list (<1-99>|<100-500>|WORD) delete",
3166 "set BGP community list (for deletion)\n"
3167 "Community-list number (standard)\n"
3168 "Communitly-list number (expanded)\n"
3169 "Community-list name\n"
3170 "Delete matching communities\n")
3174 str
= XCALLOC (MTYPE_TMP
, strlen (argv
[0]) + strlen (" delete") + 1);
3175 strcpy (str
, argv
[0]);
3176 strcpy (str
+ strlen (argv
[0]), " delete");
3178 bgp_route_set_add (vty
, vty
->index
, "comm-list", str
);
3180 XFREE (MTYPE_TMP
, str
);
3184 DEFUN (no_set_community_delete
,
3185 no_set_community_delete_cmd
,
3189 "set BGP community list (for deletion)\n")
3191 return bgp_route_set_delete (vty
, vty
->index
, "comm-list", NULL
);
3194 ALIAS (no_set_community_delete
,
3195 no_set_community_delete_val_cmd
,
3196 "no set comm-list (<1-99>|<100-500>|WORD) delete",
3199 "set BGP community list (for deletion)\n"
3200 "Community-list number (standard)\n"
3201 "Communitly-list number (expanded)\n"
3202 "Community-list name\n"
3203 "Delete matching communities\n")
3205 DEFUN (set_ecommunity_rt
,
3206 set_ecommunity_rt_cmd
,
3207 "set extcommunity rt .ASN:nn_or_IP-address:nn",
3209 "BGP extended community attribute\n"
3210 "Route Target extened communityt\n"
3211 "VPN extended community\n")
3216 str
= argv_concat (argv
, argc
, 0);
3217 ret
= bgp_route_set_add (vty
, vty
->index
, "extcommunity rt", str
);
3218 XFREE (MTYPE_TMP
, str
);
3223 DEFUN (no_set_ecommunity_rt
,
3224 no_set_ecommunity_rt_cmd
,
3225 "no set extcommunity rt",
3228 "BGP extended community attribute\n"
3229 "Route Target extened communityt\n")
3231 return bgp_route_set_delete (vty
, vty
->index
, "extcommunity rt", NULL
);
3234 ALIAS (no_set_ecommunity_rt
,
3235 no_set_ecommunity_rt_val_cmd
,
3236 "no set extcommunity rt .ASN:nn_or_IP-address:nn",
3239 "BGP extended community attribute\n"
3240 "Route Target extened communityt\n"
3241 "VPN extended community\n")
3243 DEFUN (set_ecommunity_soo
,
3244 set_ecommunity_soo_cmd
,
3245 "set extcommunity soo .ASN:nn_or_IP-address:nn",
3247 "BGP extended community attribute\n"
3248 "Site-of-Origin extended community\n"
3249 "VPN extended community\n")
3254 str
= argv_concat (argv
, argc
, 0);
3255 ret
= bgp_route_set_add (vty
, vty
->index
, "extcommunity soo", str
);
3256 XFREE (MTYPE_TMP
, str
);
3260 DEFUN (no_set_ecommunity_soo
,
3261 no_set_ecommunity_soo_cmd
,
3262 "no set extcommunity soo",
3265 "BGP extended community attribute\n"
3266 "Site-of-Origin extended community\n")
3268 return bgp_route_set_delete (vty
, vty
->index
, "extcommunity soo", NULL
);
3271 ALIAS (no_set_ecommunity_soo
,
3272 no_set_ecommunity_soo_val_cmd
,
3273 "no set extcommunity soo .ASN:nn_or_IP-address:nn",
3276 "BGP extended community attribute\n"
3277 "Site-of-Origin extended community\n"
3278 "VPN extended community\n")
3282 "set origin (egp|igp|incomplete)",
3287 "unknown heritage\n")
3289 if (strncmp (argv
[0], "igp", 2) == 0)
3290 return bgp_route_set_add (vty
, vty
->index
, "origin", "igp");
3291 if (strncmp (argv
[0], "egp", 1) == 0)
3292 return bgp_route_set_add (vty
, vty
->index
, "origin", "egp");
3293 if (strncmp (argv
[0], "incomplete", 2) == 0)
3294 return bgp_route_set_add (vty
, vty
->index
, "origin", "incomplete");
3299 DEFUN (no_set_origin
,
3304 "BGP origin code\n")
3306 return bgp_route_set_delete (vty
, vty
->index
, "origin", NULL
);
3309 ALIAS (no_set_origin
,
3310 no_set_origin_val_cmd
,
3311 "no set origin (egp|igp|incomplete)",
3317 "unknown heritage\n")
3319 DEFUN (set_atomic_aggregate
,
3320 set_atomic_aggregate_cmd
,
3321 "set atomic-aggregate",
3323 "BGP atomic aggregate attribute\n" )
3325 return bgp_route_set_add (vty
, vty
->index
, "atomic-aggregate", NULL
);
3328 DEFUN (no_set_atomic_aggregate
,
3329 no_set_atomic_aggregate_cmd
,
3330 "no set atomic-aggregate",
3333 "BGP atomic aggregate attribute\n" )
3335 return bgp_route_set_delete (vty
, vty
->index
, "atomic-aggregate", NULL
);
3338 DEFUN (set_aggregator_as
,
3339 set_aggregator_as_cmd
,
3340 "set aggregator as CMD_AS_RANGE A.B.C.D",
3342 "BGP aggregator attribute\n"
3343 "AS number of aggregator\n"
3345 "IP address of aggregator\n")
3349 struct in_addr address
;
3352 VTY_GET_INTEGER_RANGE ("AS", as
, argv
[0], 1, BGP_AS4_MAX
);
3354 ret
= inet_aton (argv
[1], &address
);
3357 vty_out (vty
, "Aggregator IP address is invalid%s", VTY_NEWLINE
);
3361 argstr
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
,
3362 strlen (argv
[0]) + strlen (argv
[1]) + 2);
3364 sprintf (argstr
, "%s %s", argv
[0], argv
[1]);
3366 ret
= bgp_route_set_add (vty
, vty
->index
, "aggregator as", argstr
);
3368 XFREE (MTYPE_ROUTE_MAP_COMPILED
, argstr
);
3373 DEFUN (no_set_aggregator_as
,
3374 no_set_aggregator_as_cmd
,
3375 "no set aggregator as",
3378 "BGP aggregator attribute\n"
3379 "AS number of aggregator\n")
3383 struct in_addr address
;
3387 return bgp_route_set_delete (vty
, vty
->index
, "aggregator as", NULL
);
3389 VTY_GET_INTEGER_RANGE ("AS", as
, argv
[0], 1, BGP_AS4_MAX
);
3391 ret
= inet_aton (argv
[1], &address
);
3394 vty_out (vty
, "Aggregator IP address is invalid%s", VTY_NEWLINE
);
3398 argstr
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
,
3399 strlen (argv
[0]) + strlen (argv
[1]) + 2);
3401 sprintf (argstr
, "%s %s", argv
[0], argv
[1]);
3403 ret
= bgp_route_set_delete (vty
, vty
->index
, "aggregator as", argstr
);
3405 XFREE (MTYPE_ROUTE_MAP_COMPILED
, argstr
);
3410 ALIAS (no_set_aggregator_as
,
3411 no_set_aggregator_as_val_cmd
,
3412 "no set aggregator as CMD_AS_RANGE A.B.C.D",
3415 "BGP aggregator attribute\n"
3416 "AS number of aggregator\n"
3418 "IP address of aggregator\n")
3422 DEFUN (match_ipv6_address
,
3423 match_ipv6_address_cmd
,
3424 "match ipv6 address WORD",
3427 "Match IPv6 address of route\n"
3428 "IPv6 access-list name\n")
3430 return bgp_route_match_add (vty
, vty
->index
, "ipv6 address", argv
[0]);
3433 DEFUN (no_match_ipv6_address
,
3434 no_match_ipv6_address_cmd
,
3435 "no match ipv6 address WORD",
3439 "Match IPv6 address of route\n"
3440 "IPv6 access-list name\n")
3442 return bgp_route_match_delete (vty
, vty
->index
, "ipv6 address", argv
[0]);
3445 DEFUN (match_ipv6_next_hop
,
3446 match_ipv6_next_hop_cmd
,
3447 "match ipv6 next-hop X:X::X:X",
3450 "Match IPv6 next-hop address of route\n"
3451 "IPv6 address of next hop\n")
3453 return bgp_route_match_add (vty
, vty
->index
, "ipv6 next-hop", argv
[0]);
3456 DEFUN (no_match_ipv6_next_hop
,
3457 no_match_ipv6_next_hop_cmd
,
3458 "no match ipv6 next-hop X:X::X:X",
3462 "Match IPv6 next-hop address of route\n"
3463 "IPv6 address of next hop\n")
3465 return bgp_route_match_delete (vty
, vty
->index
, "ipv6 next-hop", argv
[0]);
3468 DEFUN (match_ipv6_address_prefix_list
,
3469 match_ipv6_address_prefix_list_cmd
,
3470 "match ipv6 address prefix-list WORD",
3473 "Match address of route\n"
3474 "Match entries of prefix-lists\n"
3475 "IP prefix-list name\n")
3477 return bgp_route_match_add (vty
, vty
->index
, "ipv6 address prefix-list", argv
[0]);
3480 DEFUN (no_match_ipv6_address_prefix_list
,
3481 no_match_ipv6_address_prefix_list_cmd
,
3482 "no match ipv6 address prefix-list WORD",
3486 "Match address of route\n"
3487 "Match entries of prefix-lists\n"
3488 "IP prefix-list name\n")
3490 return bgp_route_match_delete (vty
, vty
->index
, "ipv6 address prefix-list", argv
[0]);
3493 DEFUN (set_ipv6_nexthop_global
,
3494 set_ipv6_nexthop_global_cmd
,
3495 "set ipv6 next-hop global X:X::X:X",
3498 "IPv6 next-hop address\n"
3499 "IPv6 global address\n"
3500 "IPv6 address of next hop\n")
3502 return bgp_route_set_add (vty
, vty
->index
, "ipv6 next-hop global", argv
[0]);
3505 DEFUN (no_set_ipv6_nexthop_global
,
3506 no_set_ipv6_nexthop_global_cmd
,
3507 "no set ipv6 next-hop global",
3511 "IPv6 next-hop address\n"
3512 "IPv6 global address\n")
3515 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop global", NULL
);
3517 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop global", argv
[0]);
3520 ALIAS (no_set_ipv6_nexthop_global
,
3521 no_set_ipv6_nexthop_global_val_cmd
,
3522 "no set ipv6 next-hop global X:X::X:X",
3526 "IPv6 next-hop address\n"
3527 "IPv6 global address\n"
3528 "IPv6 address of next hop\n")
3530 DEFUN (set_ipv6_nexthop_local
,
3531 set_ipv6_nexthop_local_cmd
,
3532 "set ipv6 next-hop local X:X::X:X",
3535 "IPv6 next-hop address\n"
3536 "IPv6 local address\n"
3537 "IPv6 address of next hop\n")
3539 return bgp_route_set_add (vty
, vty
->index
, "ipv6 next-hop local", argv
[0]);
3542 DEFUN (no_set_ipv6_nexthop_local
,
3543 no_set_ipv6_nexthop_local_cmd
,
3544 "no set ipv6 next-hop local",
3548 "IPv6 next-hop address\n"
3549 "IPv6 local address\n")
3552 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop local", NULL
);
3554 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop local", argv
[0]);
3557 ALIAS (no_set_ipv6_nexthop_local
,
3558 no_set_ipv6_nexthop_local_val_cmd
,
3559 "no set ipv6 next-hop local X:X::X:X",
3563 "IPv6 next-hop address\n"
3564 "IPv6 local address\n"
3565 "IPv6 address of next hop\n")
3566 #endif /* HAVE_IPV6 */
3568 DEFUN (set_vpnv4_nexthop
,
3569 set_vpnv4_nexthop_cmd
,
3570 "set vpnv4 next-hop A.B.C.D",
3572 "VPNv4 information\n"
3573 "VPNv4 next-hop address\n"
3574 "IP address of next hop\n")
3576 return bgp_route_set_add (vty
, vty
->index
, "vpnv4 next-hop", argv
[0]);
3579 DEFUN (no_set_vpnv4_nexthop
,
3580 no_set_vpnv4_nexthop_cmd
,
3581 "no set vpnv4 next-hop",
3584 "VPNv4 information\n"
3585 "VPNv4 next-hop address\n")
3588 return bgp_route_set_delete (vty
, vty
->index
, "vpnv4 next-hop", NULL
);
3590 return bgp_route_set_delete (vty
, vty
->index
, "vpnv4 next-hop", argv
[0]);
3593 ALIAS (no_set_vpnv4_nexthop
,
3594 no_set_vpnv4_nexthop_val_cmd
,
3595 "no set vpnv4 next-hop A.B.C.D",
3598 "VPNv4 information\n"
3599 "VPNv4 next-hop address\n"
3600 "IP address of next hop\n")
3602 DEFUN (set_originator_id
,
3603 set_originator_id_cmd
,
3604 "set originator-id A.B.C.D",
3606 "BGP originator ID attribute\n"
3607 "IP address of originator\n")
3609 return bgp_route_set_add (vty
, vty
->index
, "originator-id", argv
[0]);
3612 DEFUN (no_set_originator_id
,
3613 no_set_originator_id_cmd
,
3614 "no set originator-id",
3617 "BGP originator ID attribute\n")
3620 return bgp_route_set_delete (vty
, vty
->index
, "originator-id", NULL
);
3622 return bgp_route_set_delete (vty
, vty
->index
, "originator-id", argv
[0]);
3625 ALIAS (no_set_originator_id
,
3626 no_set_originator_id_val_cmd
,
3627 "no set originator-id A.B.C.D",
3630 "BGP originator ID attribute\n"
3631 "IP address of originator\n")
3633 DEFUN (set_pathlimit_ttl
,
3634 set_pathlimit_ttl_cmd
,
3635 "set pathlimit ttl <1-255>",
3637 "BGP AS-Pathlimit attribute\n"
3638 "Set AS-Path Hop-count TTL\n")
3640 return bgp_route_set_add (vty
, vty
->index
, "pathlimit ttl", argv
[0]);
3643 DEFUN (no_set_pathlimit_ttl
,
3644 no_set_pathlimit_ttl_cmd
,
3645 "no set pathlimit ttl",
3648 "BGP AS-Pathlimit attribute\n"
3649 "Set AS-Path Hop-count TTL\n")
3652 return bgp_route_set_delete (vty
, vty
->index
, "pathlimit ttl", NULL
);
3654 return bgp_route_set_delete (vty
, vty
->index
, "pathlimit ttl", argv
[0]);
3657 ALIAS (no_set_pathlimit_ttl
,
3658 no_set_pathlimit_ttl_val_cmd
,
3659 "no set pathlimit ttl <1-255>",
3662 "BGP AS-Pathlimit attribute\n"
3663 "Set AS-Path Hop-count TTL\n")
3665 DEFUN (match_pathlimit_as
,
3666 match_pathlimit_as_cmd
,
3667 "match pathlimit as <1-65535>",
3669 "BGP AS-Pathlimit attribute\n"
3670 "Match Pathlimit AS number\n")
3672 return bgp_route_match_add (vty
, vty
->index
, "pathlimit as", argv
[0]);
3675 DEFUN (no_match_pathlimit_as
,
3676 no_match_pathlimit_as_cmd
,
3677 "no match pathlimit as",
3680 "BGP AS-Pathlimit attribute\n"
3681 "Match Pathlimit AS number\n")
3684 return bgp_route_match_delete (vty
, vty
->index
, "pathlimit as", NULL
);
3686 return bgp_route_match_delete (vty
, vty
->index
, "pathlimit as", argv
[0]);
3689 ALIAS (no_match_pathlimit_as
,
3690 no_match_pathlimit_as_val_cmd
,
3691 "no match pathlimit as <1-65535>",
3694 "BGP AS-Pathlimit attribute\n"
3695 "Match Pathlimit ASN\n")
3698 /* Initialization of route map. */
3700 bgp_route_map_init (void)
3703 route_map_init_vty ();
3704 route_map_add_hook (bgp_route_map_update
);
3705 route_map_delete_hook (bgp_route_map_update
);
3707 route_map_install_match (&route_match_peer_cmd
);
3708 route_map_install_match (&route_match_ip_address_cmd
);
3709 route_map_install_match (&route_match_ip_next_hop_cmd
);
3710 route_map_install_match (&route_match_ip_route_source_cmd
);
3711 route_map_install_match (&route_match_ip_address_prefix_list_cmd
);
3712 route_map_install_match (&route_match_ip_next_hop_prefix_list_cmd
);
3713 route_map_install_match (&route_match_ip_route_source_prefix_list_cmd
);
3714 route_map_install_match (&route_match_aspath_cmd
);
3715 route_map_install_match (&route_match_community_cmd
);
3716 route_map_install_match (&route_match_ecommunity_cmd
);
3717 route_map_install_match (&route_match_metric_cmd
);
3718 route_map_install_match (&route_match_origin_cmd
);
3720 route_map_install_set (&route_set_ip_nexthop_cmd
);
3721 route_map_install_set (&route_set_local_pref_cmd
);
3722 route_map_install_set (&route_set_weight_cmd
);
3723 route_map_install_set (&route_set_metric_cmd
);
3724 route_map_install_set (&route_set_aspath_prepend_cmd
);
3725 route_map_install_set (&route_set_origin_cmd
);
3726 route_map_install_set (&route_set_atomic_aggregate_cmd
);
3727 route_map_install_set (&route_set_aggregator_as_cmd
);
3728 route_map_install_set (&route_set_community_cmd
);
3729 route_map_install_set (&route_set_community_delete_cmd
);
3730 route_map_install_set (&route_set_vpnv4_nexthop_cmd
);
3731 route_map_install_set (&route_set_originator_id_cmd
);
3732 route_map_install_set (&route_set_ecommunity_rt_cmd
);
3733 route_map_install_set (&route_set_ecommunity_soo_cmd
);
3735 install_element (RMAP_NODE
, &match_peer_cmd
);
3736 install_element (RMAP_NODE
, &match_peer_local_cmd
);
3737 install_element (RMAP_NODE
, &no_match_peer_cmd
);
3738 install_element (RMAP_NODE
, &no_match_peer_val_cmd
);
3739 install_element (RMAP_NODE
, &no_match_peer_local_cmd
);
3740 install_element (RMAP_NODE
, &match_ip_address_cmd
);
3741 install_element (RMAP_NODE
, &no_match_ip_address_cmd
);
3742 install_element (RMAP_NODE
, &no_match_ip_address_val_cmd
);
3743 install_element (RMAP_NODE
, &match_ip_next_hop_cmd
);
3744 install_element (RMAP_NODE
, &no_match_ip_next_hop_cmd
);
3745 install_element (RMAP_NODE
, &no_match_ip_next_hop_val_cmd
);
3746 install_element (RMAP_NODE
, &match_ip_route_source_cmd
);
3747 install_element (RMAP_NODE
, &no_match_ip_route_source_cmd
);
3748 install_element (RMAP_NODE
, &no_match_ip_route_source_val_cmd
);
3750 install_element (RMAP_NODE
, &match_ip_address_prefix_list_cmd
);
3751 install_element (RMAP_NODE
, &no_match_ip_address_prefix_list_cmd
);
3752 install_element (RMAP_NODE
, &no_match_ip_address_prefix_list_val_cmd
);
3753 install_element (RMAP_NODE
, &match_ip_next_hop_prefix_list_cmd
);
3754 install_element (RMAP_NODE
, &no_match_ip_next_hop_prefix_list_cmd
);
3755 install_element (RMAP_NODE
, &no_match_ip_next_hop_prefix_list_val_cmd
);
3756 install_element (RMAP_NODE
, &match_ip_route_source_prefix_list_cmd
);
3757 install_element (RMAP_NODE
, &no_match_ip_route_source_prefix_list_cmd
);
3758 install_element (RMAP_NODE
, &no_match_ip_route_source_prefix_list_val_cmd
);
3760 install_element (RMAP_NODE
, &match_aspath_cmd
);
3761 install_element (RMAP_NODE
, &no_match_aspath_cmd
);
3762 install_element (RMAP_NODE
, &no_match_aspath_val_cmd
);
3763 install_element (RMAP_NODE
, &match_metric_cmd
);
3764 install_element (RMAP_NODE
, &no_match_metric_cmd
);
3765 install_element (RMAP_NODE
, &no_match_metric_val_cmd
);
3766 install_element (RMAP_NODE
, &match_community_cmd
);
3767 install_element (RMAP_NODE
, &match_community_exact_cmd
);
3768 install_element (RMAP_NODE
, &no_match_community_cmd
);
3769 install_element (RMAP_NODE
, &no_match_community_val_cmd
);
3770 install_element (RMAP_NODE
, &no_match_community_exact_cmd
);
3771 install_element (RMAP_NODE
, &match_ecommunity_cmd
);
3772 install_element (RMAP_NODE
, &no_match_ecommunity_cmd
);
3773 install_element (RMAP_NODE
, &no_match_ecommunity_val_cmd
);
3774 install_element (RMAP_NODE
, &match_origin_cmd
);
3775 install_element (RMAP_NODE
, &no_match_origin_cmd
);
3776 install_element (RMAP_NODE
, &no_match_origin_val_cmd
);
3778 install_element (RMAP_NODE
, &set_ip_nexthop_cmd
);
3779 install_element (RMAP_NODE
, &set_ip_nexthop_peer_cmd
);
3780 install_element (RMAP_NODE
, &no_set_ip_nexthop_cmd
);
3781 install_element (RMAP_NODE
, &no_set_ip_nexthop_val_cmd
);
3782 install_element (RMAP_NODE
, &set_local_pref_cmd
);
3783 install_element (RMAP_NODE
, &no_set_local_pref_cmd
);
3784 install_element (RMAP_NODE
, &no_set_local_pref_val_cmd
);
3785 install_element (RMAP_NODE
, &set_weight_cmd
);
3786 install_element (RMAP_NODE
, &no_set_weight_cmd
);
3787 install_element (RMAP_NODE
, &no_set_weight_val_cmd
);
3788 install_element (RMAP_NODE
, &set_metric_cmd
);
3789 install_element (RMAP_NODE
, &set_metric_addsub_cmd
);
3790 install_element (RMAP_NODE
, &no_set_metric_cmd
);
3791 install_element (RMAP_NODE
, &no_set_metric_val_cmd
);
3792 install_element (RMAP_NODE
, &set_aspath_prepend_cmd
);
3793 install_element (RMAP_NODE
, &no_set_aspath_prepend_cmd
);
3794 install_element (RMAP_NODE
, &no_set_aspath_prepend_val_cmd
);
3795 install_element (RMAP_NODE
, &set_origin_cmd
);
3796 install_element (RMAP_NODE
, &no_set_origin_cmd
);
3797 install_element (RMAP_NODE
, &no_set_origin_val_cmd
);
3798 install_element (RMAP_NODE
, &set_atomic_aggregate_cmd
);
3799 install_element (RMAP_NODE
, &no_set_atomic_aggregate_cmd
);
3800 install_element (RMAP_NODE
, &set_aggregator_as_cmd
);
3801 install_element (RMAP_NODE
, &no_set_aggregator_as_cmd
);
3802 install_element (RMAP_NODE
, &no_set_aggregator_as_val_cmd
);
3803 install_element (RMAP_NODE
, &set_community_cmd
);
3804 install_element (RMAP_NODE
, &set_community_none_cmd
);
3805 install_element (RMAP_NODE
, &no_set_community_cmd
);
3806 install_element (RMAP_NODE
, &no_set_community_val_cmd
);
3807 install_element (RMAP_NODE
, &no_set_community_none_cmd
);
3808 install_element (RMAP_NODE
, &set_community_delete_cmd
);
3809 install_element (RMAP_NODE
, &no_set_community_delete_cmd
);
3810 install_element (RMAP_NODE
, &no_set_community_delete_val_cmd
);
3811 install_element (RMAP_NODE
, &set_ecommunity_rt_cmd
);
3812 install_element (RMAP_NODE
, &no_set_ecommunity_rt_cmd
);
3813 install_element (RMAP_NODE
, &no_set_ecommunity_rt_val_cmd
);
3814 install_element (RMAP_NODE
, &set_ecommunity_soo_cmd
);
3815 install_element (RMAP_NODE
, &no_set_ecommunity_soo_cmd
);
3816 install_element (RMAP_NODE
, &no_set_ecommunity_soo_val_cmd
);
3817 install_element (RMAP_NODE
, &set_vpnv4_nexthop_cmd
);
3818 install_element (RMAP_NODE
, &no_set_vpnv4_nexthop_cmd
);
3819 install_element (RMAP_NODE
, &no_set_vpnv4_nexthop_val_cmd
);
3820 install_element (RMAP_NODE
, &set_originator_id_cmd
);
3821 install_element (RMAP_NODE
, &no_set_originator_id_cmd
);
3822 install_element (RMAP_NODE
, &no_set_originator_id_val_cmd
);
3825 route_map_install_match (&route_match_ipv6_address_cmd
);
3826 route_map_install_match (&route_match_ipv6_next_hop_cmd
);
3827 route_map_install_match (&route_match_ipv6_address_prefix_list_cmd
);
3828 route_map_install_set (&route_set_ipv6_nexthop_global_cmd
);
3829 route_map_install_set (&route_set_ipv6_nexthop_local_cmd
);
3831 install_element (RMAP_NODE
, &match_ipv6_address_cmd
);
3832 install_element (RMAP_NODE
, &no_match_ipv6_address_cmd
);
3833 install_element (RMAP_NODE
, &match_ipv6_next_hop_cmd
);
3834 install_element (RMAP_NODE
, &no_match_ipv6_next_hop_cmd
);
3835 install_element (RMAP_NODE
, &match_ipv6_address_prefix_list_cmd
);
3836 install_element (RMAP_NODE
, &no_match_ipv6_address_prefix_list_cmd
);
3837 install_element (RMAP_NODE
, &set_ipv6_nexthop_global_cmd
);
3838 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_global_cmd
);
3839 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_global_val_cmd
);
3840 install_element (RMAP_NODE
, &set_ipv6_nexthop_local_cmd
);
3841 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_local_cmd
);
3842 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_local_val_cmd
);
3843 #endif /* HAVE_IPV6 */
3846 route_map_install_match (&route_match_pathlimit_as_cmd
);
3847 route_map_install_set (&route_set_pathlimit_ttl_cmd
);
3849 install_element (RMAP_NODE
, &set_pathlimit_ttl_cmd
);
3850 install_element (RMAP_NODE
, &no_set_pathlimit_ttl_cmd
);
3851 install_element (RMAP_NODE
, &no_set_pathlimit_ttl_val_cmd
);
3852 install_element (RMAP_NODE
, &match_pathlimit_as_cmd
);
3853 install_element (RMAP_NODE
, &no_match_pathlimit_as_cmd
);
3854 install_element (RMAP_NODE
, &no_match_pathlimit_as_val_cmd
);