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"
50 #include "bgpd/bgp_vty.h"
52 /* Memo of route-map commands.
61 ip route-source : Done
65 ipv6 route-source: (This will not be implemented by bgpd)
66 ipv6 prefix-list : Done
67 length : (This will not be implemented by bgpd)
69 route-type : (This will not be implemented by bgpd)
70 tag : (This will not be implemented by bgpd)
72 set as-path prepend : Done
74 automatic-tag : (This will not be implemented by bgpd)
78 default : (This will not be implemented by bgpd)
79 interface : (This will not be implemented by bgpd)
80 ip default : (This will not be implemented by bgpd)
82 ip precedence : (This will not be implemented by bgpd)
83 ip tos : (This will not be implemented by bgpd)
84 level : (This will not be implemented by bgpd)
85 local-preference : Done
89 tag : (This will not be implemented by bgpd)
95 set ipv6 next-hop global: Done
96 set ipv6 next-hop local : Done
97 set pathlimit ttl : Done
98 set as-path exclude : Done
99 match pathlimit as : Done
103 /* Compiles either AS or TTL argument. It is amused the VTY code
104 * has already range-checked the values to be suitable as TTL or ASN
107 route_pathlimit_compile (const char *arg
)
113 /* TTL or AS value shoud be integer. */
114 if (! all_digit (arg
))
117 tmp
= strtoul (arg
, &endptr
, 10);
118 if (*endptr
!= '\0' || tmp
== ULONG_MAX
|| tmp
> UINT32_MAX
)
121 if (!(val
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_int32_t
))))
130 route_pathlimit_free (void *rule
)
132 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
135 static route_map_result_t
136 route_match_pathlimit_as (void *rule
, struct prefix
*prefix
, route_map_object_t type
,
139 struct bgp_info
*info
= object
;
140 struct attr
*attr
= info
->attr
;
141 uint32_t as
= *(uint32_t *)rule
;
143 if (type
!= RMAP_BGP
)
146 if (!attr
->pathlimit
.as
)
149 if (as
== attr
->pathlimit
.as
)
155 /* 'match pathlimit as' */
156 struct route_map_rule_cmd route_match_pathlimit_as_cmd
=
159 route_match_pathlimit_as
,
160 route_pathlimit_compile
,
164 /* Set pathlimit TTL. */
165 static route_map_result_t
166 route_set_pathlimit_ttl (void *rule
, struct prefix
*prefix
,
167 route_map_object_t type
, void *object
)
169 struct bgp_info
*info
= object
;
170 struct attr
*attr
= info
->attr
;
171 u_char ttl
= *(uint32_t *)rule
;
173 if (type
== RMAP_BGP
)
175 attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_AS_PATHLIMIT
);
176 attr
->pathlimit
.ttl
= ttl
;
177 attr
->pathlimit
.as
= 0;
183 /* Set local preference rule structure. */
184 struct route_map_rule_cmd route_set_pathlimit_ttl_cmd
=
187 route_set_pathlimit_ttl
,
188 route_pathlimit_compile
,
189 route_pathlimit_free
,
192 /* 'match peer (A.B.C.D|X:X::X:X)' */
194 /* Compares the peer specified in the 'match peer' clause with the peer
195 received in bgp_info->peer. If it is the same, or if the peer structure
196 received is a peer_group containing it, returns RMAP_MATCH. */
197 static route_map_result_t
198 route_match_peer (void *rule
, struct prefix
*prefix
, route_map_object_t type
,
202 union sockunion
*su2
;
203 struct peer_group
*group
;
205 struct listnode
*node
, *nnode
;
207 if (type
== RMAP_BGP
)
210 peer
= ((struct bgp_info
*) object
)->peer
;
212 if ( ! CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IMPORT
) &&
213 ! CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_EXPORT
) )
216 /* If su='0.0.0.0' (command 'match peer local'), and it's a NETWORK,
217 REDISTRIBUTE or DEFAULT_GENERATED route => return RMAP_MATCH */
218 su2
= sockunion_str2su ("0.0.0.0");
219 if ( sockunion_same (su
, su2
) )
222 if ( CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_NETWORK
) ||
223 CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
) ||
224 CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_DEFAULT
))
229 sockunion_free (su2
);
232 sockunion_free (su2
);
234 if (! CHECK_FLAG (peer
->sflags
, PEER_STATUS_GROUP
))
236 if (sockunion_same (su
, &peer
->su
))
244 for (ALL_LIST_ELEMENTS (group
->peer
, node
, nnode
, peer
))
246 if (sockunion_same (su
, &peer
->su
))
256 route_match_peer_compile (const char *arg
)
261 su
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (union sockunion
));
263 ret
= str2sockunion ( (arg
)? arg
: "0.0.0.0", su
);
265 XFREE (MTYPE_ROUTE_MAP_COMPILED
, su
);
272 /* Free route map's compiled `ip address' value. */
274 route_match_peer_free (void *rule
)
276 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
279 /* Route map commands for ip address matching. */
280 struct route_map_rule_cmd route_match_peer_cmd
=
284 route_match_peer_compile
,
285 route_match_peer_free
288 /* `match ip address IP_ACCESS_LIST' */
290 /* Match function should return 1 if match is success else return
292 static route_map_result_t
293 route_match_ip_address (void *rule
, struct prefix
*prefix
,
294 route_map_object_t type
, void *object
)
296 struct access_list
*alist
;
297 /* struct prefix_ipv4 match; */
299 if (type
== RMAP_BGP
)
301 alist
= access_list_lookup (AFI_IP
, (char *) rule
);
305 return (access_list_apply (alist
, prefix
) == FILTER_DENY
?
306 RMAP_NOMATCH
: RMAP_MATCH
);
311 /* Route map `ip address' match statement. `arg' should be
314 route_match_ip_address_compile (const char *arg
)
316 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
319 /* Free route map's compiled `ip address' value. */
321 route_match_ip_address_free (void *rule
)
323 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
326 /* Route map commands for ip address matching. */
327 struct route_map_rule_cmd route_match_ip_address_cmd
=
330 route_match_ip_address
,
331 route_match_ip_address_compile
,
332 route_match_ip_address_free
335 /* `match ip next-hop IP_ADDRESS' */
337 /* Match function return 1 if match is success else return zero. */
338 static route_map_result_t
339 route_match_ip_next_hop (void *rule
, struct prefix
*prefix
,
340 route_map_object_t type
, void *object
)
342 struct access_list
*alist
;
343 struct bgp_info
*bgp_info
;
344 struct prefix_ipv4 p
;
346 if (type
== RMAP_BGP
)
350 p
.prefix
= bgp_info
->attr
->nexthop
;
351 p
.prefixlen
= IPV4_MAX_BITLEN
;
353 alist
= access_list_lookup (AFI_IP
, (char *) rule
);
357 return (access_list_apply (alist
, &p
) == FILTER_DENY
?
358 RMAP_NOMATCH
: RMAP_MATCH
);
363 /* Route map `ip next-hop' match statement. `arg' is
366 route_match_ip_next_hop_compile (const char *arg
)
368 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
371 /* Free route map's compiled `ip address' value. */
373 route_match_ip_next_hop_free (void *rule
)
375 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
378 /* Route map commands for ip next-hop matching. */
379 struct route_map_rule_cmd route_match_ip_next_hop_cmd
=
382 route_match_ip_next_hop
,
383 route_match_ip_next_hop_compile
,
384 route_match_ip_next_hop_free
387 /* `match ip route-source ACCESS-LIST' */
389 /* Match function return 1 if match is success else return zero. */
390 static route_map_result_t
391 route_match_ip_route_source (void *rule
, struct prefix
*prefix
,
392 route_map_object_t type
, void *object
)
394 struct access_list
*alist
;
395 struct bgp_info
*bgp_info
;
397 struct prefix_ipv4 p
;
399 if (type
== RMAP_BGP
)
402 peer
= bgp_info
->peer
;
404 if (! peer
|| sockunion_family (&peer
->su
) != AF_INET
)
408 p
.prefix
= peer
->su
.sin
.sin_addr
;
409 p
.prefixlen
= IPV4_MAX_BITLEN
;
411 alist
= access_list_lookup (AFI_IP
, (char *) rule
);
415 return (access_list_apply (alist
, &p
) == FILTER_DENY
?
416 RMAP_NOMATCH
: RMAP_MATCH
);
421 /* Route map `ip route-source' match statement. `arg' is
424 route_match_ip_route_source_compile (const char *arg
)
426 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
429 /* Free route map's compiled `ip address' value. */
431 route_match_ip_route_source_free (void *rule
)
433 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
436 /* Route map commands for ip route-source matching. */
437 struct route_map_rule_cmd route_match_ip_route_source_cmd
=
440 route_match_ip_route_source
,
441 route_match_ip_route_source_compile
,
442 route_match_ip_route_source_free
445 /* `match ip address prefix-list PREFIX_LIST' */
447 static route_map_result_t
448 route_match_ip_address_prefix_list (void *rule
, struct prefix
*prefix
,
449 route_map_object_t type
, void *object
)
451 struct prefix_list
*plist
;
453 if (type
== RMAP_BGP
)
455 plist
= prefix_list_lookup (AFI_IP
, (char *) rule
);
459 return (prefix_list_apply (plist
, prefix
) == PREFIX_DENY
?
460 RMAP_NOMATCH
: RMAP_MATCH
);
466 route_match_ip_address_prefix_list_compile (const char *arg
)
468 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
472 route_match_ip_address_prefix_list_free (void *rule
)
474 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
477 struct route_map_rule_cmd route_match_ip_address_prefix_list_cmd
=
479 "ip address prefix-list",
480 route_match_ip_address_prefix_list
,
481 route_match_ip_address_prefix_list_compile
,
482 route_match_ip_address_prefix_list_free
485 /* `match ip next-hop prefix-list PREFIX_LIST' */
487 static route_map_result_t
488 route_match_ip_next_hop_prefix_list (void *rule
, struct prefix
*prefix
,
489 route_map_object_t type
, void *object
)
491 struct prefix_list
*plist
;
492 struct bgp_info
*bgp_info
;
493 struct prefix_ipv4 p
;
495 if (type
== RMAP_BGP
)
499 p
.prefix
= bgp_info
->attr
->nexthop
;
500 p
.prefixlen
= IPV4_MAX_BITLEN
;
502 plist
= prefix_list_lookup (AFI_IP
, (char *) rule
);
506 return (prefix_list_apply (plist
, &p
) == PREFIX_DENY
?
507 RMAP_NOMATCH
: RMAP_MATCH
);
513 route_match_ip_next_hop_prefix_list_compile (const char *arg
)
515 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
519 route_match_ip_next_hop_prefix_list_free (void *rule
)
521 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
524 struct route_map_rule_cmd route_match_ip_next_hop_prefix_list_cmd
=
526 "ip next-hop prefix-list",
527 route_match_ip_next_hop_prefix_list
,
528 route_match_ip_next_hop_prefix_list_compile
,
529 route_match_ip_next_hop_prefix_list_free
532 /* `match ip route-source prefix-list PREFIX_LIST' */
534 static route_map_result_t
535 route_match_ip_route_source_prefix_list (void *rule
, struct prefix
*prefix
,
536 route_map_object_t type
, void *object
)
538 struct prefix_list
*plist
;
539 struct bgp_info
*bgp_info
;
541 struct prefix_ipv4 p
;
543 if (type
== RMAP_BGP
)
546 peer
= bgp_info
->peer
;
548 if (! peer
|| sockunion_family (&peer
->su
) != AF_INET
)
552 p
.prefix
= peer
->su
.sin
.sin_addr
;
553 p
.prefixlen
= IPV4_MAX_BITLEN
;
555 plist
= prefix_list_lookup (AFI_IP
, (char *) rule
);
559 return (prefix_list_apply (plist
, &p
) == PREFIX_DENY
?
560 RMAP_NOMATCH
: RMAP_MATCH
);
566 route_match_ip_route_source_prefix_list_compile (const char *arg
)
568 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
572 route_match_ip_route_source_prefix_list_free (void *rule
)
574 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
577 struct route_map_rule_cmd route_match_ip_route_source_prefix_list_cmd
=
579 "ip route-source prefix-list",
580 route_match_ip_route_source_prefix_list
,
581 route_match_ip_route_source_prefix_list_compile
,
582 route_match_ip_route_source_prefix_list_free
585 /* `match metric METRIC' */
587 /* Match function return 1 if match is success else return zero. */
588 static route_map_result_t
589 route_match_metric (void *rule
, struct prefix
*prefix
,
590 route_map_object_t type
, void *object
)
593 struct bgp_info
*bgp_info
;
595 if (type
== RMAP_BGP
)
600 if (bgp_info
->attr
->med
== *med
)
608 /* Route map `match metric' match statement. `arg' is MED value */
610 route_match_metric_compile (const char *arg
)
614 unsigned long tmpval
;
616 tmpval
= strtoul (arg
, &endptr
, 10);
617 if (*endptr
!= '\0' || tmpval
== ULONG_MAX
|| tmpval
> UINT32_MAX
)
620 med
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_int32_t
));
629 /* Free route map's compiled `match metric' value. */
631 route_match_metric_free (void *rule
)
633 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
636 /* Route map commands for metric matching. */
637 struct route_map_rule_cmd route_match_metric_cmd
=
641 route_match_metric_compile
,
642 route_match_metric_free
645 /* `match as-path ASPATH' */
647 /* Match function for as-path match. I assume given object is */
648 static route_map_result_t
649 route_match_aspath (void *rule
, struct prefix
*prefix
,
650 route_map_object_t type
, void *object
)
653 struct as_list
*as_list
;
654 struct bgp_info
*bgp_info
;
656 if (type
== RMAP_BGP
)
658 as_list
= as_list_lookup ((char *) rule
);
665 return ((as_list_apply (as_list
, bgp_info
->attr
->aspath
) == AS_FILTER_DENY
) ? RMAP_NOMATCH
: RMAP_MATCH
);
670 /* Compile function for as-path match. */
672 route_match_aspath_compile (const char *arg
)
674 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
677 /* Compile function for as-path match. */
679 route_match_aspath_free (void *rule
)
681 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
684 /* Route map commands for aspath matching. */
685 struct route_map_rule_cmd route_match_aspath_cmd
=
689 route_match_aspath_compile
,
690 route_match_aspath_free
693 /* `match community COMMUNIY' */
694 struct rmap_community
700 /* Match function for community match. */
701 static route_map_result_t
702 route_match_community (void *rule
, struct prefix
*prefix
,
703 route_map_object_t type
, void *object
)
705 struct community_list
*list
;
706 struct bgp_info
*bgp_info
;
707 struct rmap_community
*rcom
;
709 if (type
== RMAP_BGP
)
714 list
= community_list_lookup (bgp_clist
, rcom
->name
, COMMUNITY_LIST_MASTER
);
720 if (community_list_exact_match (bgp_info
->attr
->community
, list
))
725 if (community_list_match (bgp_info
->attr
->community
, list
))
732 /* Compile function for community match. */
734 route_match_community_compile (const char *arg
)
736 struct rmap_community
*rcom
;
740 rcom
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct rmap_community
));
742 p
= strchr (arg
, ' ');
746 rcom
->name
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, len
+ 1);
747 memcpy (rcom
->name
, arg
, len
);
752 rcom
->name
= XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
758 /* Compile function for community match. */
760 route_match_community_free (void *rule
)
762 struct rmap_community
*rcom
= rule
;
764 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rcom
->name
);
765 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rcom
);
768 /* Route map commands for community matching. */
769 struct route_map_rule_cmd route_match_community_cmd
=
772 route_match_community
,
773 route_match_community_compile
,
774 route_match_community_free
777 /* Match function for extcommunity match. */
778 static route_map_result_t
779 route_match_ecommunity (void *rule
, struct prefix
*prefix
,
780 route_map_object_t type
, void *object
)
782 struct community_list
*list
;
783 struct bgp_info
*bgp_info
;
785 if (type
== RMAP_BGP
)
789 if (!bgp_info
->attr
->extra
)
792 list
= community_list_lookup (bgp_clist
, (char *) rule
,
793 EXTCOMMUNITY_LIST_MASTER
);
797 if (ecommunity_list_match (bgp_info
->attr
->extra
->ecommunity
, list
))
803 /* Compile function for extcommunity match. */
805 route_match_ecommunity_compile (const char *arg
)
807 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
810 /* Compile function for extcommunity match. */
812 route_match_ecommunity_free (void *rule
)
814 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
817 /* Route map commands for community matching. */
818 struct route_map_rule_cmd route_match_ecommunity_cmd
=
821 route_match_ecommunity
,
822 route_match_ecommunity_compile
,
823 route_match_ecommunity_free
826 /* `match nlri` and `set nlri` are replaced by `address-family ipv4`
827 and `address-family vpnv4'. */
830 static route_map_result_t
831 route_match_origin (void *rule
, struct prefix
*prefix
,
832 route_map_object_t type
, void *object
)
835 struct bgp_info
*bgp_info
;
837 if (type
== RMAP_BGP
)
842 if (bgp_info
->attr
->origin
== *origin
)
850 route_match_origin_compile (const char *arg
)
854 origin
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_char
));
856 if (strcmp (arg
, "igp") == 0)
858 else if (strcmp (arg
, "egp") == 0)
866 /* Free route map's compiled `ip address' value. */
868 route_match_origin_free (void *rule
)
870 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
873 /* Route map commands for origin matching. */
874 struct route_map_rule_cmd route_match_origin_cmd
=
878 route_match_origin_compile
,
879 route_match_origin_free
881 /* `set ip next-hop IP_ADDRESS' */
883 /* Set nexthop to object. ojbect must be pointer to struct attr. */
884 struct rmap_ip_nexthop_set
886 struct in_addr
*address
;
890 static route_map_result_t
891 route_set_ip_nexthop (void *rule
, struct prefix
*prefix
,
892 route_map_object_t type
, void *object
)
894 struct rmap_ip_nexthop_set
*rins
= rule
;
895 struct in_addr peer_address
;
896 struct bgp_info
*bgp_info
;
899 if (type
== RMAP_BGP
)
902 peer
= bgp_info
->peer
;
904 if (rins
->peer_address
)
906 if ((CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IN
) ||
907 CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IMPORT
))
909 && sockunion_family (peer
->su_remote
) == AF_INET
)
911 inet_aton (sockunion_su2str (peer
->su_remote
), &peer_address
);
912 bgp_info
->attr
->nexthop
= peer_address
;
913 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
);
915 else if (CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
)
917 && sockunion_family (peer
->su_local
) == AF_INET
)
919 inet_aton (sockunion_su2str (peer
->su_local
), &peer_address
);
920 bgp_info
->attr
->nexthop
= peer_address
;
921 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
);
926 /* Set next hop value. */
927 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
);
928 bgp_info
->attr
->nexthop
= *rins
->address
;
935 /* Route map `ip nexthop' compile function. Given string is converted
936 to struct in_addr structure. */
938 route_set_ip_nexthop_compile (const char *arg
)
940 struct rmap_ip_nexthop_set
*rins
;
941 struct in_addr
*address
= NULL
;
942 int peer_address
= 0;
945 if (strcmp (arg
, "peer-address") == 0)
949 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in_addr
));
950 ret
= inet_aton (arg
, address
);
954 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
959 rins
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct rmap_ip_nexthop_set
));
960 memset (rins
, 0, sizeof (struct rmap_ip_nexthop_set
));
962 rins
->address
= address
;
963 rins
->peer_address
= peer_address
;
968 /* Free route map's compiled `ip nexthop' value. */
970 route_set_ip_nexthop_free (void *rule
)
972 struct rmap_ip_nexthop_set
*rins
= rule
;
975 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rins
->address
);
977 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rins
);
980 /* Route map commands for ip nexthop set. */
981 struct route_map_rule_cmd route_set_ip_nexthop_cmd
=
984 route_set_ip_nexthop
,
985 route_set_ip_nexthop_compile
,
986 route_set_ip_nexthop_free
989 /* `set local-preference LOCAL_PREF' */
991 /* Set local preference. */
992 static route_map_result_t
993 route_set_local_pref (void *rule
, struct prefix
*prefix
,
994 route_map_object_t type
, void *object
)
996 u_int32_t
*local_pref
;
997 struct bgp_info
*bgp_info
;
999 if (type
== RMAP_BGP
)
1001 /* Fetch routemap's rule information. */
1005 /* Set local preference value. */
1006 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
);
1007 bgp_info
->attr
->local_pref
= *local_pref
;
1013 /* set local preference compilation. */
1015 route_set_local_pref_compile (const char *arg
)
1018 u_int32_t
*local_pref
;
1019 char *endptr
= NULL
;
1021 /* Local preference value shoud be integer. */
1022 if (! all_digit (arg
))
1025 tmp
= strtoul (arg
, &endptr
, 10);
1026 if (*endptr
!= '\0' || tmp
== ULONG_MAX
|| tmp
> UINT32_MAX
)
1029 local_pref
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_int32_t
));
1039 /* Free route map's local preference value. */
1041 route_set_local_pref_free (void *rule
)
1043 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1046 /* Set local preference rule structure. */
1047 struct route_map_rule_cmd route_set_local_pref_cmd
=
1050 route_set_local_pref
,
1051 route_set_local_pref_compile
,
1052 route_set_local_pref_free
,
1055 /* `set weight WEIGHT' */
1058 static route_map_result_t
1059 route_set_weight (void *rule
, struct prefix
*prefix
, route_map_object_t type
,
1063 struct bgp_info
*bgp_info
;
1065 if (type
== RMAP_BGP
)
1067 /* Fetch routemap's rule information. */
1071 /* Set weight value. */
1073 (bgp_attr_extra_get (bgp_info
->attr
))->weight
= *weight
;
1074 else if (bgp_info
->attr
->extra
)
1075 bgp_info
->attr
->extra
->weight
= 0;
1081 /* set local preference compilation. */
1083 route_set_weight_compile (const char *arg
)
1087 char *endptr
= NULL
;
1089 /* Local preference value shoud be integer. */
1090 if (! all_digit (arg
))
1094 tmp
= strtoul (arg
, &endptr
, 10);
1095 if (*endptr
!= '\0' || tmp
== ULONG_MAX
|| tmp
> UINT32_MAX
)
1098 weight
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_int32_t
));
1108 /* Free route map's local preference value. */
1110 route_set_weight_free (void *rule
)
1112 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1115 /* Set local preference rule structure. */
1116 struct route_map_rule_cmd route_set_weight_cmd
=
1120 route_set_weight_compile
,
1121 route_set_weight_free
,
1124 /* `set metric METRIC' */
1126 /* Set metric to attribute. */
1127 static route_map_result_t
1128 route_set_metric (void *rule
, struct prefix
*prefix
,
1129 route_map_object_t type
, void *object
)
1132 u_int32_t metric_val
;
1133 struct bgp_info
*bgp_info
;
1135 if (type
== RMAP_BGP
)
1137 /* Fetch routemap's rule information. */
1141 if (! (bgp_info
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
)))
1142 bgp_info
->attr
->med
= 0;
1143 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
1145 if (all_digit (metric
))
1147 metric_val
= strtoul (metric
, (char **)NULL
, 10);
1148 bgp_info
->attr
->med
= metric_val
;
1152 metric_val
= strtoul (metric
+1, (char **)NULL
, 10);
1154 if (strncmp (metric
, "+", 1) == 0)
1156 if (bgp_info
->attr
->med
/2 + metric_val
/2 > BGP_MED_MAX
/2)
1157 bgp_info
->attr
->med
= BGP_MED_MAX
- 1;
1159 bgp_info
->attr
->med
+= metric_val
;
1161 else if (strncmp (metric
, "-", 1) == 0)
1163 if (bgp_info
->attr
->med
<= metric_val
)
1164 bgp_info
->attr
->med
= 0;
1166 bgp_info
->attr
->med
-= metric_val
;
1173 /* set metric compilation. */
1175 route_set_metric_compile (const char *arg
)
1179 char *endptr
= NULL
;
1181 if (all_digit (arg
))
1183 /* set metric value check*/
1184 larg
= strtoul (arg
, &endptr
, 10);
1185 if (*endptr
!= '\0' || larg
== ULONG_MAX
|| larg
> UINT32_MAX
)
1191 /* set metric +/-value check */
1192 if ((strncmp (arg
, "+", 1) != 0
1193 && strncmp (arg
, "-", 1) != 0)
1194 || (! all_digit (arg
+1)))
1197 larg
= strtoul (arg
+1, &endptr
, 10);
1198 if (*endptr
!= '\0' || larg
== ULONG_MAX
|| larg
> UINT32_MAX
)
1203 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
1206 /* Free route map's compiled `set metric' value. */
1208 route_set_metric_free (void *rule
)
1210 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1213 /* Set metric rule structure. */
1214 struct route_map_rule_cmd route_set_metric_cmd
=
1218 route_set_metric_compile
,
1219 route_set_metric_free
,
1222 /* `set as-path prepend ASPATH' */
1224 /* For AS path prepend mechanism. */
1225 static route_map_result_t
1226 route_set_aspath_prepend (void *rule
, struct prefix
*prefix
, route_map_object_t type
, void *object
)
1228 struct aspath
*aspath
;
1230 struct bgp_info
*binfo
;
1232 if (type
== RMAP_BGP
)
1237 if (binfo
->attr
->aspath
->refcnt
)
1238 new = aspath_dup (binfo
->attr
->aspath
);
1240 new = binfo
->attr
->aspath
;
1242 aspath_prepend (aspath
, new);
1243 binfo
->attr
->aspath
= new;
1249 /* Compile function for as-path prepend. */
1251 route_set_aspath_prepend_compile (const char *arg
)
1253 struct aspath
*aspath
;
1255 aspath
= aspath_str2aspath (arg
);
1261 /* Compile function for as-path prepend. */
1263 route_set_aspath_prepend_free (void *rule
)
1265 struct aspath
*aspath
= rule
;
1266 aspath_free (aspath
);
1269 /* Set metric rule structure. */
1270 struct route_map_rule_cmd route_set_aspath_prepend_cmd
=
1273 route_set_aspath_prepend
,
1274 route_set_aspath_prepend_compile
,
1275 route_set_aspath_prepend_free
,
1278 /* `set as-path exclude ASn' */
1280 /* For ASN exclude mechanism.
1281 * Iterate over ASns requested and filter them from the given AS_PATH one by one.
1282 * Make a deep copy of existing AS_PATH, but for the first ASn only.
1284 static route_map_result_t
1285 route_set_aspath_exclude (void *rule
, struct prefix
*dummy
, route_map_object_t type
, void *object
)
1287 struct aspath
* new_path
, * exclude_path
;
1288 struct bgp_info
*binfo
;
1290 if (type
== RMAP_BGP
)
1292 exclude_path
= rule
;
1294 if (binfo
->attr
->aspath
->refcnt
)
1295 new_path
= aspath_dup (binfo
->attr
->aspath
);
1297 new_path
= binfo
->attr
->aspath
;
1298 binfo
->attr
->aspath
= aspath_filter_exclude (new_path
, exclude_path
);
1303 /* FIXME: consider using route_set_aspath_prepend_compile() and
1304 * route_set_aspath_prepend_free(), which two below function are
1308 /* Compile function for as-path exclude. */
1310 route_set_aspath_exclude_compile (const char *arg
)
1312 struct aspath
*aspath
;
1314 aspath
= aspath_str2aspath (arg
);
1321 route_set_aspath_exclude_free (void *rule
)
1323 struct aspath
*aspath
= rule
;
1324 aspath_free (aspath
);
1327 /* Set ASn exlude rule structure. */
1328 struct route_map_rule_cmd route_set_aspath_exclude_cmd
=
1331 route_set_aspath_exclude
,
1332 route_set_aspath_exclude_compile
,
1333 route_set_aspath_exclude_free
,
1336 /* `set community COMMUNITY' */
1339 struct community
*com
;
1344 /* For community set mechanism. */
1345 static route_map_result_t
1346 route_set_community (void *rule
, struct prefix
*prefix
,
1347 route_map_object_t type
, void *object
)
1349 struct rmap_com_set
*rcs
;
1350 struct bgp_info
*binfo
;
1352 struct community
*new = NULL
;
1353 struct community
*old
;
1354 struct community
*merge
;
1356 if (type
== RMAP_BGP
)
1361 old
= attr
->community
;
1366 attr
->flag
&= ~(ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
));
1367 attr
->community
= NULL
;
1371 /* "additive" case. */
1372 if (rcs
->additive
&& old
)
1374 merge
= community_merge (community_dup (old
), rcs
->com
);
1376 /* HACK: if the old community is not intern'd,
1377 * we should free it here, or all reference to it may be lost.
1378 * Really need to cleanup attribute caching sometime.
1380 if (old
->refcnt
== 0)
1381 community_free (old
);
1382 new = community_uniq_sort (merge
);
1383 community_free (merge
);
1386 new = community_dup (rcs
->com
);
1388 /* will be interned by caller if required */
1389 attr
->community
= new;
1391 attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
);
1397 /* Compile function for set community. */
1399 route_set_community_compile (const char *arg
)
1401 struct rmap_com_set
*rcs
;
1402 struct community
*com
= NULL
;
1407 if (strcmp (arg
, "none") == 0)
1411 sp
= strstr (arg
, "additive");
1415 /* "additive" keyworkd is included. */
1420 com
= community_str2com (arg
);
1429 rcs
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct rmap_com_set
));
1430 memset (rcs
, 0, sizeof (struct rmap_com_set
));
1433 rcs
->additive
= additive
;
1439 /* Free function for set community. */
1441 route_set_community_free (void *rule
)
1443 struct rmap_com_set
*rcs
= rule
;
1446 community_free (rcs
->com
);
1447 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rcs
);
1450 /* Set community rule structure. */
1451 struct route_map_rule_cmd route_set_community_cmd
=
1454 route_set_community
,
1455 route_set_community_compile
,
1456 route_set_community_free
,
1459 /* `set comm-list (<1-99>|<100-500>|WORD) delete' */
1461 /* For community set mechanism. */
1462 static route_map_result_t
1463 route_set_community_delete (void *rule
, struct prefix
*prefix
,
1464 route_map_object_t type
, void *object
)
1466 struct community_list
*list
;
1467 struct community
*merge
;
1468 struct community
*new;
1469 struct community
*old
;
1470 struct bgp_info
*binfo
;
1472 if (type
== RMAP_BGP
)
1478 list
= community_list_lookup (bgp_clist
, rule
, COMMUNITY_LIST_MASTER
);
1479 old
= binfo
->attr
->community
;
1483 merge
= community_list_match_delete (community_dup (old
), list
);
1484 new = community_uniq_sort (merge
);
1485 community_free (merge
);
1489 binfo
->attr
->community
= NULL
;
1490 binfo
->attr
->flag
&= ~ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
);
1491 community_free (new);
1495 binfo
->attr
->community
= new;
1496 binfo
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
);
1504 /* Compile function for set community. */
1506 route_set_community_delete_compile (const char *arg
)
1512 p
= strchr (arg
, ' ');
1516 str
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, len
+ 1);
1517 memcpy (str
, arg
, len
);
1525 /* Free function for set community. */
1527 route_set_community_delete_free (void *rule
)
1529 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1532 /* Set community rule structure. */
1533 struct route_map_rule_cmd route_set_community_delete_cmd
=
1536 route_set_community_delete
,
1537 route_set_community_delete_compile
,
1538 route_set_community_delete_free
,
1541 /* `set extcommunity rt COMMUNITY' */
1543 /* For community set mechanism. */
1544 static route_map_result_t
1545 route_set_ecommunity_rt (void *rule
, struct prefix
*prefix
,
1546 route_map_object_t type
, void *object
)
1548 struct ecommunity
*ecom
;
1549 struct ecommunity
*new_ecom
;
1550 struct ecommunity
*old_ecom
;
1551 struct bgp_info
*bgp_info
;
1553 if (type
== RMAP_BGP
)
1561 /* We assume additive for Extended Community. */
1562 old_ecom
= (bgp_attr_extra_get (bgp_info
->attr
))->ecommunity
;
1565 new_ecom
= ecommunity_merge (ecommunity_dup (old_ecom
), ecom
);
1567 new_ecom
= ecommunity_dup (ecom
);
1569 bgp_info
->attr
->extra
->ecommunity
= new_ecom
;
1572 ecommunity_free (old_ecom
);
1574 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES
);
1579 /* Compile function for set community. */
1581 route_set_ecommunity_rt_compile (const char *arg
)
1583 struct ecommunity
*ecom
;
1585 ecom
= ecommunity_str2com (arg
, ECOMMUNITY_ROUTE_TARGET
, 0);
1591 /* Free function for set community. */
1593 route_set_ecommunity_rt_free (void *rule
)
1595 struct ecommunity
*ecom
= rule
;
1596 ecommunity_free (ecom
);
1599 /* Set community rule structure. */
1600 struct route_map_rule_cmd route_set_ecommunity_rt_cmd
=
1603 route_set_ecommunity_rt
,
1604 route_set_ecommunity_rt_compile
,
1605 route_set_ecommunity_rt_free
,
1608 /* `set extcommunity soo COMMUNITY' */
1610 /* For community set mechanism. */
1611 static route_map_result_t
1612 route_set_ecommunity_soo (void *rule
, struct prefix
*prefix
,
1613 route_map_object_t type
, void *object
)
1615 struct ecommunity
*ecom
;
1616 struct bgp_info
*bgp_info
;
1618 if (type
== RMAP_BGP
)
1626 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES
);
1627 (bgp_attr_extra_get (bgp_info
->attr
))->ecommunity
= ecommunity_dup (ecom
);
1632 /* Compile function for set community. */
1634 route_set_ecommunity_soo_compile (const char *arg
)
1636 struct ecommunity
*ecom
;
1638 ecom
= ecommunity_str2com (arg
, ECOMMUNITY_SITE_ORIGIN
, 0);
1645 /* Free function for set community. */
1647 route_set_ecommunity_soo_free (void *rule
)
1649 struct ecommunity
*ecom
= rule
;
1650 ecommunity_free (ecom
);
1653 /* Set community rule structure. */
1654 struct route_map_rule_cmd route_set_ecommunity_soo_cmd
=
1657 route_set_ecommunity_soo
,
1658 route_set_ecommunity_soo_compile
,
1659 route_set_ecommunity_soo_free
,
1662 /* `set origin ORIGIN' */
1664 /* For origin set. */
1665 static route_map_result_t
1666 route_set_origin (void *rule
, struct prefix
*prefix
, route_map_object_t type
, void *object
)
1669 struct bgp_info
*bgp_info
;
1671 if (type
== RMAP_BGP
)
1676 bgp_info
->attr
->origin
= *origin
;
1682 /* Compile function for origin set. */
1684 route_set_origin_compile (const char *arg
)
1688 origin
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_char
));
1690 if (strcmp (arg
, "igp") == 0)
1692 else if (strcmp (arg
, "egp") == 0)
1700 /* Compile function for origin set. */
1702 route_set_origin_free (void *rule
)
1704 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1707 /* Set metric rule structure. */
1708 struct route_map_rule_cmd route_set_origin_cmd
=
1712 route_set_origin_compile
,
1713 route_set_origin_free
,
1716 /* `set atomic-aggregate' */
1718 /* For atomic aggregate set. */
1719 static route_map_result_t
1720 route_set_atomic_aggregate (void *rule
, struct prefix
*prefix
,
1721 route_map_object_t type
, void *object
)
1723 struct bgp_info
*bgp_info
;
1725 if (type
== RMAP_BGP
)
1728 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
1734 /* Compile function for atomic aggregate. */
1736 route_set_atomic_aggregate_compile (const char *arg
)
1741 /* Compile function for atomic aggregate. */
1743 route_set_atomic_aggregate_free (void *rule
)
1748 /* Set atomic aggregate rule structure. */
1749 struct route_map_rule_cmd route_set_atomic_aggregate_cmd
=
1752 route_set_atomic_aggregate
,
1753 route_set_atomic_aggregate_compile
,
1754 route_set_atomic_aggregate_free
,
1757 /* `set aggregator as AS A.B.C.D' */
1761 struct in_addr address
;
1764 static route_map_result_t
1765 route_set_aggregator_as (void *rule
, struct prefix
*prefix
,
1766 route_map_object_t type
, void *object
)
1768 struct bgp_info
*bgp_info
;
1769 struct aggregator
*aggregator
;
1770 struct attr_extra
*ae
;
1772 if (type
== RMAP_BGP
)
1776 ae
= bgp_attr_extra_get (bgp_info
->attr
);
1778 ae
->aggregator_as
= aggregator
->as
;
1779 ae
->aggregator_addr
= aggregator
->address
;
1780 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
);
1787 route_set_aggregator_as_compile (const char *arg
)
1789 struct aggregator
*aggregator
;
1793 aggregator
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct aggregator
));
1794 memset (aggregator
, 0, sizeof (struct aggregator
));
1796 sscanf (arg
, "%s %s", as
, address
);
1798 aggregator
->as
= strtoul (as
, NULL
, 10);
1799 inet_aton (address
, &aggregator
->address
);
1805 route_set_aggregator_as_free (void *rule
)
1807 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1810 struct route_map_rule_cmd route_set_aggregator_as_cmd
=
1813 route_set_aggregator_as
,
1814 route_set_aggregator_as_compile
,
1815 route_set_aggregator_as_free
,
1819 /* `match ipv6 address IP_ACCESS_LIST' */
1821 static route_map_result_t
1822 route_match_ipv6_address (void *rule
, struct prefix
*prefix
,
1823 route_map_object_t type
, void *object
)
1825 struct access_list
*alist
;
1827 if (type
== RMAP_BGP
)
1829 alist
= access_list_lookup (AFI_IP6
, (char *) rule
);
1831 return RMAP_NOMATCH
;
1833 return (access_list_apply (alist
, prefix
) == FILTER_DENY
?
1834 RMAP_NOMATCH
: RMAP_MATCH
);
1836 return RMAP_NOMATCH
;
1840 route_match_ipv6_address_compile (const char *arg
)
1842 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
1846 route_match_ipv6_address_free (void *rule
)
1848 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1851 /* Route map commands for ip address matching. */
1852 struct route_map_rule_cmd route_match_ipv6_address_cmd
=
1855 route_match_ipv6_address
,
1856 route_match_ipv6_address_compile
,
1857 route_match_ipv6_address_free
1860 /* `match ipv6 next-hop IP_ADDRESS' */
1862 static route_map_result_t
1863 route_match_ipv6_next_hop (void *rule
, struct prefix
*prefix
,
1864 route_map_object_t type
, void *object
)
1866 struct in6_addr
*addr
;
1867 struct bgp_info
*bgp_info
;
1869 if (type
== RMAP_BGP
)
1874 if (!bgp_info
->attr
->extra
)
1875 return RMAP_NOMATCH
;
1877 if (IPV6_ADDR_SAME (&bgp_info
->attr
->extra
->mp_nexthop_global
, rule
))
1880 if (bgp_info
->attr
->extra
->mp_nexthop_len
== 32 &&
1881 IPV6_ADDR_SAME (&bgp_info
->attr
->extra
->mp_nexthop_local
, rule
))
1884 return RMAP_NOMATCH
;
1887 return RMAP_NOMATCH
;
1891 route_match_ipv6_next_hop_compile (const char *arg
)
1893 struct in6_addr
*address
;
1896 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in6_addr
));
1898 ret
= inet_pton (AF_INET6
, arg
, address
);
1901 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
1909 route_match_ipv6_next_hop_free (void *rule
)
1911 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1914 struct route_map_rule_cmd route_match_ipv6_next_hop_cmd
=
1917 route_match_ipv6_next_hop
,
1918 route_match_ipv6_next_hop_compile
,
1919 route_match_ipv6_next_hop_free
1922 /* `match ipv6 address prefix-list PREFIX_LIST' */
1924 static route_map_result_t
1925 route_match_ipv6_address_prefix_list (void *rule
, struct prefix
*prefix
,
1926 route_map_object_t type
, void *object
)
1928 struct prefix_list
*plist
;
1930 if (type
== RMAP_BGP
)
1932 plist
= prefix_list_lookup (AFI_IP6
, (char *) rule
);
1934 return RMAP_NOMATCH
;
1936 return (prefix_list_apply (plist
, prefix
) == PREFIX_DENY
?
1937 RMAP_NOMATCH
: RMAP_MATCH
);
1939 return RMAP_NOMATCH
;
1943 route_match_ipv6_address_prefix_list_compile (const char *arg
)
1945 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
1949 route_match_ipv6_address_prefix_list_free (void *rule
)
1951 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1954 struct route_map_rule_cmd route_match_ipv6_address_prefix_list_cmd
=
1956 "ipv6 address prefix-list",
1957 route_match_ipv6_address_prefix_list
,
1958 route_match_ipv6_address_prefix_list_compile
,
1959 route_match_ipv6_address_prefix_list_free
1962 /* `set ipv6 nexthop global IP_ADDRESS' */
1964 /* Set nexthop to object. ojbect must be pointer to struct attr. */
1965 static route_map_result_t
1966 route_set_ipv6_nexthop_global (void *rule
, struct prefix
*prefix
,
1967 route_map_object_t type
, void *object
)
1969 struct in6_addr
*address
;
1970 struct bgp_info
*bgp_info
;
1972 if (type
== RMAP_BGP
)
1974 /* Fetch routemap's rule information. */
1978 /* Set next hop value. */
1979 (bgp_attr_extra_get (bgp_info
->attr
))->mp_nexthop_global
= *address
;
1981 /* Set nexthop length. */
1982 if (bgp_info
->attr
->extra
->mp_nexthop_len
== 0)
1983 bgp_info
->attr
->extra
->mp_nexthop_len
= 16;
1989 /* Route map `ip next-hop' compile function. Given string is converted
1990 to struct in_addr structure. */
1992 route_set_ipv6_nexthop_global_compile (const char *arg
)
1995 struct in6_addr
*address
;
1997 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in6_addr
));
1999 ret
= inet_pton (AF_INET6
, arg
, address
);
2003 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
2010 /* Free route map's compiled `ip next-hop' value. */
2012 route_set_ipv6_nexthop_global_free (void *rule
)
2014 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2017 /* Route map commands for ip nexthop set. */
2018 struct route_map_rule_cmd route_set_ipv6_nexthop_global_cmd
=
2020 "ipv6 next-hop global",
2021 route_set_ipv6_nexthop_global
,
2022 route_set_ipv6_nexthop_global_compile
,
2023 route_set_ipv6_nexthop_global_free
2026 /* `set ipv6 nexthop local IP_ADDRESS' */
2028 /* Set nexthop to object. ojbect must be pointer to struct attr. */
2029 static route_map_result_t
2030 route_set_ipv6_nexthop_local (void *rule
, struct prefix
*prefix
,
2031 route_map_object_t type
, void *object
)
2033 struct in6_addr
*address
;
2034 struct bgp_info
*bgp_info
;
2036 if (type
== RMAP_BGP
)
2038 /* Fetch routemap's rule information. */
2042 /* Set next hop value. */
2043 (bgp_attr_extra_get (bgp_info
->attr
))->mp_nexthop_local
= *address
;
2045 /* Set nexthop length. */
2046 if (bgp_info
->attr
->extra
->mp_nexthop_len
!= 32)
2047 bgp_info
->attr
->extra
->mp_nexthop_len
= 32;
2053 /* Route map `ip nexthop' compile function. Given string is converted
2054 to struct in_addr structure. */
2056 route_set_ipv6_nexthop_local_compile (const char *arg
)
2059 struct in6_addr
*address
;
2061 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in6_addr
));
2063 ret
= inet_pton (AF_INET6
, arg
, address
);
2067 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
2074 /* Free route map's compiled `ip nexthop' value. */
2076 route_set_ipv6_nexthop_local_free (void *rule
)
2078 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2081 /* Route map commands for ip nexthop set. */
2082 struct route_map_rule_cmd route_set_ipv6_nexthop_local_cmd
=
2084 "ipv6 next-hop local",
2085 route_set_ipv6_nexthop_local
,
2086 route_set_ipv6_nexthop_local_compile
,
2087 route_set_ipv6_nexthop_local_free
2089 #endif /* HAVE_IPV6 */
2091 /* `set vpnv4 nexthop A.B.C.D' */
2093 static route_map_result_t
2094 route_set_vpnv4_nexthop (void *rule
, struct prefix
*prefix
,
2095 route_map_object_t type
, void *object
)
2097 struct in_addr
*address
;
2098 struct bgp_info
*bgp_info
;
2100 if (type
== RMAP_BGP
)
2102 /* Fetch routemap's rule information. */
2106 /* Set next hop value. */
2107 (bgp_attr_extra_get (bgp_info
->attr
))->mp_nexthop_global_in
= *address
;
2114 route_set_vpnv4_nexthop_compile (const char *arg
)
2117 struct in_addr
*address
;
2119 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in_addr
));
2121 ret
= inet_aton (arg
, address
);
2125 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
2133 route_set_vpnv4_nexthop_free (void *rule
)
2135 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2138 /* Route map commands for ip nexthop set. */
2139 struct route_map_rule_cmd route_set_vpnv4_nexthop_cmd
=
2142 route_set_vpnv4_nexthop
,
2143 route_set_vpnv4_nexthop_compile
,
2144 route_set_vpnv4_nexthop_free
2147 /* `set originator-id' */
2149 /* For origin set. */
2150 static route_map_result_t
2151 route_set_originator_id (void *rule
, struct prefix
*prefix
, route_map_object_t type
, void *object
)
2153 struct in_addr
*address
;
2154 struct bgp_info
*bgp_info
;
2156 if (type
== RMAP_BGP
)
2161 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
);
2162 (bgp_attr_extra_get (bgp_info
->attr
))->originator_id
= *address
;
2168 /* Compile function for originator-id set. */
2170 route_set_originator_id_compile (const char *arg
)
2173 struct in_addr
*address
;
2175 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in_addr
));
2177 ret
= inet_aton (arg
, address
);
2181 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
2188 /* Compile function for originator_id set. */
2190 route_set_originator_id_free (void *rule
)
2192 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2195 /* Set metric rule structure. */
2196 struct route_map_rule_cmd route_set_originator_id_cmd
=
2199 route_set_originator_id
,
2200 route_set_originator_id_compile
,
2201 route_set_originator_id_free
,
2204 /* Add bgp route map rule. */
2206 bgp_route_match_add (struct vty
*vty
, struct route_map_index
*index
,
2207 const char *command
, const char *arg
)
2211 ret
= route_map_add_match (index
, command
, arg
);
2216 case RMAP_RULE_MISSING
:
2217 vty_out (vty
, "%% Can't find rule.%s", VTY_NEWLINE
);
2219 case RMAP_COMPILE_ERROR
:
2220 vty_out (vty
, "%% Argument is malformed.%s", VTY_NEWLINE
);
2227 /* Delete bgp route map rule. */
2229 bgp_route_match_delete (struct vty
*vty
, struct route_map_index
*index
,
2230 const char *command
, const char *arg
)
2234 ret
= route_map_delete_match (index
, command
, arg
);
2239 case RMAP_RULE_MISSING
:
2240 vty_out (vty
, "%% Can't find rule.%s", VTY_NEWLINE
);
2242 case RMAP_COMPILE_ERROR
:
2243 vty_out (vty
, "%% Argument is malformed.%s", VTY_NEWLINE
);
2250 /* Add bgp route map rule. */
2252 bgp_route_set_add (struct vty
*vty
, struct route_map_index
*index
,
2253 const char *command
, const char *arg
)
2257 ret
= route_map_add_set (index
, command
, arg
);
2262 case RMAP_RULE_MISSING
:
2263 vty_out (vty
, "%% Can't find rule.%s", VTY_NEWLINE
);
2265 case RMAP_COMPILE_ERROR
:
2266 vty_out (vty
, "%% Argument is malformed.%s", VTY_NEWLINE
);
2273 /* Delete bgp route map rule. */
2275 bgp_route_set_delete (struct vty
*vty
, struct route_map_index
*index
,
2276 const char *command
, const char *arg
)
2280 ret
= route_map_delete_set (index
, command
, arg
);
2285 case RMAP_RULE_MISSING
:
2286 vty_out (vty
, "%% Can't find rule.%s", VTY_NEWLINE
);
2288 case RMAP_COMPILE_ERROR
:
2289 vty_out (vty
, "%% Argument is malformed.%s", VTY_NEWLINE
);
2296 /* Hook function for updating route_map assignment. */
2298 bgp_route_map_update (const char *unused
)
2304 struct listnode
*node
, *nnode
;
2305 struct listnode
*mnode
, *mnnode
;
2308 struct peer_group
*group
;
2309 struct bgp_filter
*filter
;
2310 struct bgp_node
*bn
;
2311 struct bgp_static
*bgp_static
;
2313 /* For neighbor route-map updates. */
2314 for (ALL_LIST_ELEMENTS (bm
->bgp
, mnode
, mnnode
, bgp
))
2316 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
2318 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2319 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2321 filter
= &peer
->filter
[afi
][safi
];
2323 for (direct
= RMAP_IN
; direct
< RMAP_MAX
; direct
++)
2325 if (filter
->map
[direct
].name
)
2326 filter
->map
[direct
].map
=
2327 route_map_lookup_by_name (filter
->map
[direct
].name
);
2329 filter
->map
[direct
].map
= NULL
;
2332 if (filter
->usmap
.name
)
2333 filter
->usmap
.map
= route_map_lookup_by_name (filter
->usmap
.name
);
2335 filter
->usmap
.map
= NULL
;
2338 for (ALL_LIST_ELEMENTS (bgp
->group
, node
, nnode
, group
))
2340 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2341 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2343 filter
= &group
->conf
->filter
[afi
][safi
];
2345 for (direct
= RMAP_IN
; direct
< RMAP_MAX
; direct
++)
2347 if (filter
->map
[direct
].name
)
2348 filter
->map
[direct
].map
=
2349 route_map_lookup_by_name (filter
->map
[direct
].name
);
2351 filter
->map
[direct
].map
= NULL
;
2354 if (filter
->usmap
.name
)
2355 filter
->usmap
.map
= route_map_lookup_by_name (filter
->usmap
.name
);
2357 filter
->usmap
.map
= NULL
;
2362 /* For default-originate route-map updates. */
2363 for (ALL_LIST_ELEMENTS (bm
->bgp
, mnode
, mnnode
, bgp
))
2365 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
2367 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2368 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2370 if (peer
->default_rmap
[afi
][safi
].name
)
2371 peer
->default_rmap
[afi
][safi
].map
=
2372 route_map_lookup_by_name (peer
->default_rmap
[afi
][safi
].name
);
2374 peer
->default_rmap
[afi
][safi
].map
= NULL
;
2379 /* For network route-map updates. */
2380 for (ALL_LIST_ELEMENTS (bm
->bgp
, mnode
, mnnode
, bgp
))
2382 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2383 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2384 for (bn
= bgp_table_top (bgp
->route
[afi
][safi
]); bn
;
2385 bn
= bgp_route_next (bn
))
2386 if ((bgp_static
= bn
->info
) != NULL
)
2388 if (bgp_static
->rmap
.name
)
2389 bgp_static
->rmap
.map
=
2390 route_map_lookup_by_name (bgp_static
->rmap
.name
);
2392 bgp_static
->rmap
.map
= NULL
;
2396 /* For redistribute route-map updates. */
2397 for (ALL_LIST_ELEMENTS (bm
->bgp
, mnode
, mnnode
, bgp
))
2399 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++)
2401 if (bgp
->rmap
[ZEBRA_FAMILY_IPV4
][i
].name
)
2402 bgp
->rmap
[ZEBRA_FAMILY_IPV4
][i
].map
=
2403 route_map_lookup_by_name (bgp
->rmap
[ZEBRA_FAMILY_IPV4
][i
].name
);
2405 if (bgp
->rmap
[ZEBRA_FAMILY_IPV6
][i
].name
)
2406 bgp
->rmap
[ZEBRA_FAMILY_IPV6
][i
].map
=
2407 route_map_lookup_by_name (bgp
->rmap
[ZEBRA_FAMILY_IPV6
][i
].name
);
2408 #endif /* HAVE_IPV6 */
2415 "match peer (A.B.C.D|X:X::X:X)",
2417 "Match peer address\n"
2418 "IPv6 address of peer\n"
2419 "IP address of peer\n")
2421 return bgp_route_match_add (vty
, vty
->index
, "peer", argv
[0]);
2424 DEFUN (match_peer_local
,
2425 match_peer_local_cmd
,
2428 "Match peer address\n"
2429 "Static or Redistributed routes\n")
2431 return bgp_route_match_add (vty
, vty
->index
, "peer", NULL
);
2434 DEFUN (no_match_peer
,
2439 "Match peer address\n")
2442 return bgp_route_match_delete (vty
, vty
->index
, "peer", NULL
);
2444 return bgp_route_match_delete (vty
, vty
->index
, "peer", argv
[0]);
2447 ALIAS (no_match_peer
,
2448 no_match_peer_val_cmd
,
2449 "no match peer (A.B.C.D|X:X::X:X)",
2452 "Match peer address\n"
2453 "IPv6 address of peer\n"
2454 "IP address of peer\n")
2456 ALIAS (no_match_peer
,
2457 no_match_peer_local_cmd
,
2458 "no match peer local",
2461 "Match peer address\n"
2462 "Static or Redistributed routes\n")
2464 DEFUN (match_ip_address
,
2465 match_ip_address_cmd
,
2466 "match ip address (<1-199>|<1300-2699>|WORD)",
2469 "Match address of route\n"
2470 "IP access-list number\n"
2471 "IP access-list number (expanded range)\n"
2472 "IP Access-list name\n")
2474 return bgp_route_match_add (vty
, vty
->index
, "ip address", argv
[0]);
2477 DEFUN (no_match_ip_address
,
2478 no_match_ip_address_cmd
,
2479 "no match ip address",
2483 "Match address of route\n")
2486 return bgp_route_match_delete (vty
, vty
->index
, "ip address", NULL
);
2488 return bgp_route_match_delete (vty
, vty
->index
, "ip address", argv
[0]);
2491 ALIAS (no_match_ip_address
,
2492 no_match_ip_address_val_cmd
,
2493 "no match ip address (<1-199>|<1300-2699>|WORD)",
2497 "Match address of route\n"
2498 "IP access-list number\n"
2499 "IP access-list number (expanded range)\n"
2500 "IP Access-list name\n")
2502 DEFUN (match_ip_next_hop
,
2503 match_ip_next_hop_cmd
,
2504 "match ip next-hop (<1-199>|<1300-2699>|WORD)",
2507 "Match next-hop address of route\n"
2508 "IP access-list number\n"
2509 "IP access-list number (expanded range)\n"
2510 "IP Access-list name\n")
2512 return bgp_route_match_add (vty
, vty
->index
, "ip next-hop", argv
[0]);
2515 DEFUN (no_match_ip_next_hop
,
2516 no_match_ip_next_hop_cmd
,
2517 "no match ip next-hop",
2521 "Match next-hop address of route\n")
2524 return bgp_route_match_delete (vty
, vty
->index
, "ip next-hop", NULL
);
2526 return bgp_route_match_delete (vty
, vty
->index
, "ip next-hop", argv
[0]);
2529 ALIAS (no_match_ip_next_hop
,
2530 no_match_ip_next_hop_val_cmd
,
2531 "no match ip next-hop (<1-199>|<1300-2699>|WORD)",
2535 "Match next-hop address of route\n"
2536 "IP access-list number\n"
2537 "IP access-list number (expanded range)\n"
2538 "IP Access-list name\n")
2540 DEFUN (match_ip_route_source
,
2541 match_ip_route_source_cmd
,
2542 "match ip route-source (<1-199>|<1300-2699>|WORD)",
2545 "Match advertising source address of route\n"
2546 "IP access-list number\n"
2547 "IP access-list number (expanded range)\n"
2548 "IP standard access-list name\n")
2550 return bgp_route_match_add (vty
, vty
->index
, "ip route-source", argv
[0]);
2553 DEFUN (no_match_ip_route_source
,
2554 no_match_ip_route_source_cmd
,
2555 "no match ip route-source",
2559 "Match advertising source address of route\n")
2562 return bgp_route_match_delete (vty
, vty
->index
, "ip route-source", NULL
);
2564 return bgp_route_match_delete (vty
, vty
->index
, "ip route-source", argv
[0]);
2567 ALIAS (no_match_ip_route_source
,
2568 no_match_ip_route_source_val_cmd
,
2569 "no match ip route-source (<1-199>|<1300-2699>|WORD)",
2573 "Match advertising source address of route\n"
2574 "IP access-list number\n"
2575 "IP access-list number (expanded range)\n"
2576 "IP standard access-list name\n")
2578 DEFUN (match_ip_address_prefix_list
,
2579 match_ip_address_prefix_list_cmd
,
2580 "match ip address prefix-list WORD",
2583 "Match address of route\n"
2584 "Match entries of prefix-lists\n"
2585 "IP prefix-list name\n")
2587 return bgp_route_match_add (vty
, vty
->index
, "ip address prefix-list", argv
[0]);
2590 DEFUN (no_match_ip_address_prefix_list
,
2591 no_match_ip_address_prefix_list_cmd
,
2592 "no match ip address prefix-list",
2596 "Match address of route\n"
2597 "Match entries of prefix-lists\n")
2600 return bgp_route_match_delete (vty
, vty
->index
, "ip address prefix-list", NULL
);
2602 return bgp_route_match_delete (vty
, vty
->index
, "ip address prefix-list", argv
[0]);
2605 ALIAS (no_match_ip_address_prefix_list
,
2606 no_match_ip_address_prefix_list_val_cmd
,
2607 "no match ip address prefix-list WORD",
2611 "Match address of route\n"
2612 "Match entries of prefix-lists\n"
2613 "IP prefix-list name\n")
2615 DEFUN (match_ip_next_hop_prefix_list
,
2616 match_ip_next_hop_prefix_list_cmd
,
2617 "match ip next-hop prefix-list WORD",
2620 "Match next-hop address of route\n"
2621 "Match entries of prefix-lists\n"
2622 "IP prefix-list name\n")
2624 return bgp_route_match_add (vty
, vty
->index
, "ip next-hop prefix-list", argv
[0]);
2627 DEFUN (no_match_ip_next_hop_prefix_list
,
2628 no_match_ip_next_hop_prefix_list_cmd
,
2629 "no match ip next-hop prefix-list",
2633 "Match next-hop address of route\n"
2634 "Match entries of prefix-lists\n")
2637 return bgp_route_match_delete (vty
, vty
->index
, "ip next-hop prefix-list", NULL
);
2639 return bgp_route_match_delete (vty
, vty
->index
, "ip next-hop prefix-list", argv
[0]);
2642 ALIAS (no_match_ip_next_hop_prefix_list
,
2643 no_match_ip_next_hop_prefix_list_val_cmd
,
2644 "no match ip next-hop prefix-list WORD",
2648 "Match next-hop address of route\n"
2649 "Match entries of prefix-lists\n"
2650 "IP prefix-list name\n")
2652 DEFUN (match_ip_route_source_prefix_list
,
2653 match_ip_route_source_prefix_list_cmd
,
2654 "match ip route-source prefix-list WORD",
2657 "Match advertising source address of route\n"
2658 "Match entries of prefix-lists\n"
2659 "IP prefix-list name\n")
2661 return bgp_route_match_add (vty
, vty
->index
, "ip route-source prefix-list", argv
[0]);
2664 DEFUN (no_match_ip_route_source_prefix_list
,
2665 no_match_ip_route_source_prefix_list_cmd
,
2666 "no match ip route-source prefix-list",
2670 "Match advertising source address of route\n"
2671 "Match entries of prefix-lists\n")
2674 return bgp_route_match_delete (vty
, vty
->index
, "ip route-source prefix-list", NULL
);
2676 return bgp_route_match_delete (vty
, vty
->index
, "ip route-source prefix-list", argv
[0]);
2679 ALIAS (no_match_ip_route_source_prefix_list
,
2680 no_match_ip_route_source_prefix_list_val_cmd
,
2681 "no match ip route-source prefix-list WORD",
2685 "Match advertising source address of route\n"
2686 "Match entries of prefix-lists\n"
2687 "IP prefix-list name\n")
2689 DEFUN (match_metric
,
2691 "match metric <0-4294967295>",
2693 "Match metric of route\n"
2696 return bgp_route_match_add (vty
, vty
->index
, "metric", argv
[0]);
2699 DEFUN (no_match_metric
,
2700 no_match_metric_cmd
,
2704 "Match metric of route\n")
2707 return bgp_route_match_delete (vty
, vty
->index
, "metric", NULL
);
2709 return bgp_route_match_delete (vty
, vty
->index
, "metric", argv
[0]);
2712 ALIAS (no_match_metric
,
2713 no_match_metric_val_cmd
,
2714 "no match metric <0-4294967295>",
2717 "Match metric of route\n"
2720 DEFUN (match_community
,
2721 match_community_cmd
,
2722 "match community (<1-99>|<100-500>|WORD)",
2724 "Match BGP community list\n"
2725 "Community-list number (standard)\n"
2726 "Community-list number (expanded)\n"
2727 "Community-list name\n")
2729 return bgp_route_match_add (vty
, vty
->index
, "community", argv
[0]);
2732 DEFUN (match_community_exact
,
2733 match_community_exact_cmd
,
2734 "match community (<1-99>|<100-500>|WORD) exact-match",
2736 "Match BGP community list\n"
2737 "Community-list number (standard)\n"
2738 "Community-list number (expanded)\n"
2739 "Community-list name\n"
2740 "Do exact matching of communities\n")
2745 argstr
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
,
2746 strlen (argv
[0]) + strlen ("exact-match") + 2);
2748 sprintf (argstr
, "%s exact-match", argv
[0]);
2750 ret
= bgp_route_match_add (vty
, vty
->index
, "community", argstr
);
2752 XFREE (MTYPE_ROUTE_MAP_COMPILED
, argstr
);
2757 DEFUN (no_match_community
,
2758 no_match_community_cmd
,
2759 "no match community",
2762 "Match BGP community list\n")
2764 return bgp_route_match_delete (vty
, vty
->index
, "community", NULL
);
2767 ALIAS (no_match_community
,
2768 no_match_community_val_cmd
,
2769 "no match community (<1-99>|<100-500>|WORD)",
2772 "Match BGP community list\n"
2773 "Community-list number (standard)\n"
2774 "Community-list number (expanded)\n"
2775 "Community-list name\n")
2777 ALIAS (no_match_community
,
2778 no_match_community_exact_cmd
,
2779 "no match community (<1-99>|<100-500>|WORD) exact-match",
2782 "Match BGP community list\n"
2783 "Community-list number (standard)\n"
2784 "Community-list number (expanded)\n"
2785 "Community-list name\n"
2786 "Do exact matching of communities\n")
2788 DEFUN (match_ecommunity
,
2789 match_ecommunity_cmd
,
2790 "match extcommunity (<1-99>|<100-500>|WORD)",
2792 "Match BGP/VPN extended community list\n"
2793 "Extended community-list number (standard)\n"
2794 "Extended community-list number (expanded)\n"
2795 "Extended community-list name\n")
2797 return bgp_route_match_add (vty
, vty
->index
, "extcommunity", argv
[0]);
2800 DEFUN (no_match_ecommunity
,
2801 no_match_ecommunity_cmd
,
2802 "no match extcommunity",
2805 "Match BGP/VPN extended community list\n")
2807 return bgp_route_match_delete (vty
, vty
->index
, "extcommunity", NULL
);
2810 ALIAS (no_match_ecommunity
,
2811 no_match_ecommunity_val_cmd
,
2812 "no match extcommunity (<1-99>|<100-500>|WORD)",
2815 "Match BGP/VPN extended community list\n"
2816 "Extended community-list number (standard)\n"
2817 "Extended community-list number (expanded)\n"
2818 "Extended community-list name\n")
2820 DEFUN (match_aspath
,
2822 "match as-path WORD",
2824 "Match BGP AS path list\n"
2825 "AS path access-list name\n")
2827 return bgp_route_match_add (vty
, vty
->index
, "as-path", argv
[0]);
2830 DEFUN (no_match_aspath
,
2831 no_match_aspath_cmd
,
2835 "Match BGP AS path list\n")
2837 return bgp_route_match_delete (vty
, vty
->index
, "as-path", NULL
);
2840 ALIAS (no_match_aspath
,
2841 no_match_aspath_val_cmd
,
2842 "no match as-path WORD",
2845 "Match BGP AS path list\n"
2846 "AS path access-list name\n")
2848 DEFUN (match_origin
,
2850 "match origin (egp|igp|incomplete)",
2855 "unknown heritage\n")
2857 if (strncmp (argv
[0], "igp", 2) == 0)
2858 return bgp_route_match_add (vty
, vty
->index
, "origin", "igp");
2859 if (strncmp (argv
[0], "egp", 1) == 0)
2860 return bgp_route_match_add (vty
, vty
->index
, "origin", "egp");
2861 if (strncmp (argv
[0], "incomplete", 2) == 0)
2862 return bgp_route_match_add (vty
, vty
->index
, "origin", "incomplete");
2867 DEFUN (no_match_origin
,
2868 no_match_origin_cmd
,
2872 "BGP origin code\n")
2874 return bgp_route_match_delete (vty
, vty
->index
, "origin", NULL
);
2877 ALIAS (no_match_origin
,
2878 no_match_origin_val_cmd
,
2879 "no match origin (egp|igp|incomplete)",
2885 "unknown heritage\n")
2887 DEFUN (set_ip_nexthop
,
2889 "set ip next-hop A.B.C.D",
2892 "Next hop address\n"
2893 "IP address of next hop\n")
2898 ret
= str2sockunion (argv
[0], &su
);
2901 vty_out (vty
, "%% Malformed Next-hop address%s", VTY_NEWLINE
);
2905 return bgp_route_set_add (vty
, vty
->index
, "ip next-hop", argv
[0]);
2908 DEFUN (set_ip_nexthop_peer
,
2909 set_ip_nexthop_peer_cmd
,
2910 "set ip next-hop peer-address",
2913 "Next hop address\n"
2914 "Use peer address (for BGP only)\n")
2916 return bgp_route_set_add (vty
, vty
->index
, "ip next-hop", "peer-address");
2919 DEFUN_DEPRECATED (no_set_ip_nexthop_peer
,
2920 no_set_ip_nexthop_peer_cmd
,
2921 "no set ip next-hop peer-address",
2925 "Next hop address\n"
2926 "Use peer address (for BGP only)\n")
2928 return bgp_route_set_delete (vty
, vty
->index
, "ip next-hop", NULL
);
2932 DEFUN (no_set_ip_nexthop
,
2933 no_set_ip_nexthop_cmd
,
2934 "no set ip next-hop",
2937 "Next hop address\n")
2940 return bgp_route_set_delete (vty
, vty
->index
, "ip next-hop", NULL
);
2942 return bgp_route_set_delete (vty
, vty
->index
, "ip next-hop", argv
[0]);
2945 ALIAS (no_set_ip_nexthop
,
2946 no_set_ip_nexthop_val_cmd
,
2947 "no set ip next-hop A.B.C.D",
2951 "Next hop address\n"
2952 "IP address of next hop\n")
2956 "set metric <0-4294967295>",
2958 "Metric value for destination routing protocol\n"
2961 return bgp_route_set_add (vty
, vty
->index
, "metric", argv
[0]);
2965 set_metric_addsub_cmd
,
2966 "set metric <+/-metric>",
2968 "Metric value for destination routing protocol\n"
2969 "Add or subtract metric\n")
2971 DEFUN (no_set_metric
,
2976 "Metric value for destination routing protocol\n")
2979 return bgp_route_set_delete (vty
, vty
->index
, "metric", NULL
);
2981 return bgp_route_set_delete (vty
, vty
->index
, "metric", argv
[0]);
2984 ALIAS (no_set_metric
,
2985 no_set_metric_val_cmd
,
2986 "no set metric <0-4294967295>",
2989 "Metric value for destination routing protocol\n"
2992 DEFUN (set_local_pref
,
2994 "set local-preference <0-4294967295>",
2996 "BGP local preference path attribute\n"
2997 "Preference value\n")
2999 return bgp_route_set_add (vty
, vty
->index
, "local-preference", argv
[0]);
3002 DEFUN (no_set_local_pref
,
3003 no_set_local_pref_cmd
,
3004 "no set local-preference",
3007 "BGP local preference path attribute\n")
3010 return bgp_route_set_delete (vty
, vty
->index
, "local-preference", NULL
);
3012 return bgp_route_set_delete (vty
, vty
->index
, "local-preference", argv
[0]);
3015 ALIAS (no_set_local_pref
,
3016 no_set_local_pref_val_cmd
,
3017 "no set local-preference <0-4294967295>",
3020 "BGP local preference path attribute\n"
3021 "Preference value\n")
3025 "set weight <0-4294967295>",
3027 "BGP weight for routing table\n"
3030 return bgp_route_set_add (vty
, vty
->index
, "weight", argv
[0]);
3033 DEFUN (no_set_weight
,
3038 "BGP weight for routing table\n")
3041 return bgp_route_set_delete (vty
, vty
->index
, "weight", NULL
);
3043 return bgp_route_set_delete (vty
, vty
->index
, "weight", argv
[0]);
3046 ALIAS (no_set_weight
,
3047 no_set_weight_val_cmd
,
3048 "no set weight <0-4294967295>",
3051 "BGP weight for routing table\n"
3054 DEFUN (set_aspath_prepend
,
3055 set_aspath_prepend_cmd
,
3056 "set as-path prepend .<1-65535>",
3058 "Transform BGP AS_PATH attribute\n"
3059 "Prepend to the as-path\n"
3065 str
= argv_concat (argv
, argc
, 0);
3066 ret
= bgp_route_set_add (vty
, vty
->index
, "as-path prepend", str
);
3067 XFREE (MTYPE_TMP
, str
);
3072 DEFUN (no_set_aspath_prepend
,
3073 no_set_aspath_prepend_cmd
,
3074 "no set as-path prepend",
3077 "Transform BGP AS_PATH attribute\n"
3078 "Prepend to the as-path\n")
3084 return bgp_route_set_delete (vty
, vty
->index
, "as-path prepend", NULL
);
3086 str
= argv_concat (argv
, argc
, 0);
3087 ret
= bgp_route_set_delete (vty
, vty
->index
, "as-path prepend", str
);
3088 XFREE (MTYPE_TMP
, str
);
3092 ALIAS (no_set_aspath_prepend
,
3093 no_set_aspath_prepend_val_cmd
,
3094 "no set as-path prepend .<1-65535>",
3097 "Transform BGP AS_PATH attribute\n"
3098 "Prepend to the as-path\n"
3101 DEFUN (set_aspath_exclude
,
3102 set_aspath_exclude_cmd
,
3103 "set as-path exclude .<1-65535>",
3105 "Transform BGP AS-path attribute\n"
3106 "Exclude from the as-path\n"
3112 str
= argv_concat (argv
, argc
, 0);
3113 ret
= bgp_route_set_add (vty
, vty
->index
, "as-path exclude", str
);
3114 XFREE (MTYPE_TMP
, str
);
3118 DEFUN (no_set_aspath_exclude
,
3119 no_set_aspath_exclude_cmd
,
3120 "no set as-path exclude",
3123 "Transform BGP AS_PATH attribute\n"
3124 "Exclude from the as-path\n")
3130 return bgp_route_set_delete (vty
, vty
->index
, "as-path exclude", NULL
);
3132 str
= argv_concat (argv
, argc
, 0);
3133 ret
= bgp_route_set_delete (vty
, vty
->index
, "as-path exclude", str
);
3134 XFREE (MTYPE_TMP
, str
);
3138 ALIAS (no_set_aspath_exclude
,
3139 no_set_aspath_exclude_val_cmd
,
3140 "no set as-path exclude .<1-65535>",
3143 "Transform BGP AS_PATH attribute\n"
3144 "Exclude from the as-path\n"
3147 DEFUN (set_community
,
3149 "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")
3158 struct community
*com
= NULL
;
3163 b
= buffer_new (1024);
3165 for (i
= 0; i
< argc
; i
++)
3167 if (strncmp (argv
[i
], "additive", strlen (argv
[i
])) == 0)
3174 buffer_putc (b
, ' ');
3178 if (strncmp (argv
[i
], "internet", strlen (argv
[i
])) == 0)
3180 buffer_putstr (b
, "internet");
3183 if (strncmp (argv
[i
], "local-AS", strlen (argv
[i
])) == 0)
3185 buffer_putstr (b
, "local-AS");
3188 if (strncmp (argv
[i
], "no-a", strlen ("no-a")) == 0
3189 && strncmp (argv
[i
], "no-advertise", strlen (argv
[i
])) == 0)
3191 buffer_putstr (b
, "no-advertise");
3194 if (strncmp (argv
[i
], "no-e", strlen ("no-e"))== 0
3195 && strncmp (argv
[i
], "no-export", strlen (argv
[i
])) == 0)
3197 buffer_putstr (b
, "no-export");
3200 buffer_putstr (b
, argv
[i
]);
3202 buffer_putc (b
, '\0');
3204 /* Fetch result string then compile it to communities attribute. */
3205 str
= buffer_getstr (b
);
3210 com
= community_str2com (str
);
3211 XFREE (MTYPE_TMP
, str
);
3214 /* Can't compile user input into communities attribute. */
3217 vty_out (vty
, "%% Malformed communities attribute%s", VTY_NEWLINE
);
3221 /* Set communites attribute string. */
3222 str
= community_str (com
);
3226 argstr
= XCALLOC (MTYPE_TMP
, strlen (str
) + strlen (" additive") + 1);
3227 strcpy (argstr
, str
);
3228 strcpy (argstr
+ strlen (str
), " additive");
3229 ret
= bgp_route_set_add (vty
, vty
->index
, "community", argstr
);
3230 XFREE (MTYPE_TMP
, argstr
);
3233 ret
= bgp_route_set_add (vty
, vty
->index
, "community", str
);
3235 community_free (com
);
3240 DEFUN (set_community_none
,
3241 set_community_none_cmd
,
3242 "set community none",
3244 "BGP community attribute\n"
3245 "No community attribute\n")
3247 return bgp_route_set_add (vty
, vty
->index
, "community", "none");
3250 DEFUN (no_set_community
,
3251 no_set_community_cmd
,
3255 "BGP community attribute\n")
3257 return bgp_route_set_delete (vty
, vty
->index
, "community", NULL
);
3260 ALIAS (no_set_community
,
3261 no_set_community_val_cmd
,
3262 "no set community .AA:NN",
3265 "BGP community attribute\n"
3266 "Community number in aa:nn format or local-AS|no-advertise|no-export|internet or additive\n")
3268 ALIAS (no_set_community
,
3269 no_set_community_none_cmd
,
3270 "no set community none",
3273 "BGP community attribute\n"
3274 "No community attribute\n")
3276 DEFUN (set_community_delete
,
3277 set_community_delete_cmd
,
3278 "set comm-list (<1-99>|<100-500>|WORD) delete",
3280 "set BGP community list (for deletion)\n"
3281 "Community-list number (standard)\n"
3282 "Communitly-list number (expanded)\n"
3283 "Community-list name\n"
3284 "Delete matching communities\n")
3288 str
= XCALLOC (MTYPE_TMP
, strlen (argv
[0]) + strlen (" delete") + 1);
3289 strcpy (str
, argv
[0]);
3290 strcpy (str
+ strlen (argv
[0]), " delete");
3292 bgp_route_set_add (vty
, vty
->index
, "comm-list", str
);
3294 XFREE (MTYPE_TMP
, str
);
3298 DEFUN (no_set_community_delete
,
3299 no_set_community_delete_cmd
,
3303 "set BGP community list (for deletion)\n")
3305 return bgp_route_set_delete (vty
, vty
->index
, "comm-list", NULL
);
3308 ALIAS (no_set_community_delete
,
3309 no_set_community_delete_val_cmd
,
3310 "no set comm-list (<1-99>|<100-500>|WORD) delete",
3313 "set BGP community list (for deletion)\n"
3314 "Community-list number (standard)\n"
3315 "Communitly-list number (expanded)\n"
3316 "Community-list name\n"
3317 "Delete matching communities\n")
3319 DEFUN (set_ecommunity_rt
,
3320 set_ecommunity_rt_cmd
,
3321 "set extcommunity rt .ASN:nn_or_IP-address:nn",
3323 "BGP extended community attribute\n"
3324 "Route Target extened communityt\n"
3325 "VPN extended community\n")
3330 str
= argv_concat (argv
, argc
, 0);
3331 ret
= bgp_route_set_add (vty
, vty
->index
, "extcommunity rt", str
);
3332 XFREE (MTYPE_TMP
, str
);
3337 DEFUN (no_set_ecommunity_rt
,
3338 no_set_ecommunity_rt_cmd
,
3339 "no set extcommunity rt",
3342 "BGP extended community attribute\n"
3343 "Route Target extened communityt\n")
3345 return bgp_route_set_delete (vty
, vty
->index
, "extcommunity rt", NULL
);
3348 ALIAS (no_set_ecommunity_rt
,
3349 no_set_ecommunity_rt_val_cmd
,
3350 "no set extcommunity rt .ASN:nn_or_IP-address:nn",
3353 "BGP extended community attribute\n"
3354 "Route Target extened communityt\n"
3355 "VPN extended community\n")
3357 DEFUN (set_ecommunity_soo
,
3358 set_ecommunity_soo_cmd
,
3359 "set extcommunity soo .ASN:nn_or_IP-address:nn",
3361 "BGP extended community attribute\n"
3362 "Site-of-Origin extended community\n"
3363 "VPN extended community\n")
3368 str
= argv_concat (argv
, argc
, 0);
3369 ret
= bgp_route_set_add (vty
, vty
->index
, "extcommunity soo", str
);
3370 XFREE (MTYPE_TMP
, str
);
3374 DEFUN (no_set_ecommunity_soo
,
3375 no_set_ecommunity_soo_cmd
,
3376 "no set extcommunity soo",
3379 "BGP extended community attribute\n"
3380 "Site-of-Origin extended community\n")
3382 return bgp_route_set_delete (vty
, vty
->index
, "extcommunity soo", NULL
);
3385 ALIAS (no_set_ecommunity_soo
,
3386 no_set_ecommunity_soo_val_cmd
,
3387 "no set extcommunity soo .ASN:nn_or_IP-address:nn",
3390 "BGP extended community attribute\n"
3391 "Site-of-Origin extended community\n"
3392 "VPN extended community\n")
3396 "set origin (egp|igp|incomplete)",
3401 "unknown heritage\n")
3403 if (strncmp (argv
[0], "igp", 2) == 0)
3404 return bgp_route_set_add (vty
, vty
->index
, "origin", "igp");
3405 if (strncmp (argv
[0], "egp", 1) == 0)
3406 return bgp_route_set_add (vty
, vty
->index
, "origin", "egp");
3407 if (strncmp (argv
[0], "incomplete", 2) == 0)
3408 return bgp_route_set_add (vty
, vty
->index
, "origin", "incomplete");
3413 DEFUN (no_set_origin
,
3418 "BGP origin code\n")
3420 return bgp_route_set_delete (vty
, vty
->index
, "origin", NULL
);
3423 ALIAS (no_set_origin
,
3424 no_set_origin_val_cmd
,
3425 "no set origin (egp|igp|incomplete)",
3431 "unknown heritage\n")
3433 DEFUN (set_atomic_aggregate
,
3434 set_atomic_aggregate_cmd
,
3435 "set atomic-aggregate",
3437 "BGP atomic aggregate attribute\n" )
3439 return bgp_route_set_add (vty
, vty
->index
, "atomic-aggregate", NULL
);
3442 DEFUN (no_set_atomic_aggregate
,
3443 no_set_atomic_aggregate_cmd
,
3444 "no set atomic-aggregate",
3447 "BGP atomic aggregate attribute\n" )
3449 return bgp_route_set_delete (vty
, vty
->index
, "atomic-aggregate", NULL
);
3452 DEFUN (set_aggregator_as
,
3453 set_aggregator_as_cmd
,
3454 "set aggregator as " CMD_AS_RANGE
" A.B.C.D",
3456 "BGP aggregator attribute\n"
3457 "AS number of aggregator\n"
3459 "IP address of aggregator\n")
3463 struct in_addr address
;
3466 VTY_GET_INTEGER_RANGE ("AS", as
, argv
[0], 1, BGP_AS4_MAX
);
3468 ret
= inet_aton (argv
[1], &address
);
3471 vty_out (vty
, "Aggregator IP address is invalid%s", VTY_NEWLINE
);
3475 argstr
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
,
3476 strlen (argv
[0]) + strlen (argv
[1]) + 2);
3478 sprintf (argstr
, "%s %s", argv
[0], argv
[1]);
3480 ret
= bgp_route_set_add (vty
, vty
->index
, "aggregator as", argstr
);
3482 XFREE (MTYPE_ROUTE_MAP_COMPILED
, argstr
);
3487 DEFUN (no_set_aggregator_as
,
3488 no_set_aggregator_as_cmd
,
3489 "no set aggregator as",
3492 "BGP aggregator attribute\n"
3493 "AS number of aggregator\n")
3497 struct in_addr address
;
3501 return bgp_route_set_delete (vty
, vty
->index
, "aggregator as", NULL
);
3503 VTY_GET_INTEGER_RANGE ("AS", as
, argv
[0], 1, BGP_AS4_MAX
);
3505 ret
= inet_aton (argv
[1], &address
);
3508 vty_out (vty
, "Aggregator IP address is invalid%s", VTY_NEWLINE
);
3512 argstr
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
,
3513 strlen (argv
[0]) + strlen (argv
[1]) + 2);
3515 sprintf (argstr
, "%s %s", argv
[0], argv
[1]);
3517 ret
= bgp_route_set_delete (vty
, vty
->index
, "aggregator as", argstr
);
3519 XFREE (MTYPE_ROUTE_MAP_COMPILED
, argstr
);
3524 ALIAS (no_set_aggregator_as
,
3525 no_set_aggregator_as_val_cmd
,
3526 "no set aggregator as " CMD_AS_RANGE
" A.B.C.D",
3529 "BGP aggregator attribute\n"
3530 "AS number of aggregator\n"
3532 "IP address of aggregator\n")
3536 DEFUN (match_ipv6_address
,
3537 match_ipv6_address_cmd
,
3538 "match ipv6 address WORD",
3541 "Match IPv6 address of route\n"
3542 "IPv6 access-list name\n")
3544 return bgp_route_match_add (vty
, vty
->index
, "ipv6 address", argv
[0]);
3547 DEFUN (no_match_ipv6_address
,
3548 no_match_ipv6_address_cmd
,
3549 "no match ipv6 address WORD",
3553 "Match IPv6 address of route\n"
3554 "IPv6 access-list name\n")
3556 return bgp_route_match_delete (vty
, vty
->index
, "ipv6 address", argv
[0]);
3559 DEFUN (match_ipv6_next_hop
,
3560 match_ipv6_next_hop_cmd
,
3561 "match ipv6 next-hop X:X::X:X",
3564 "Match IPv6 next-hop address of route\n"
3565 "IPv6 address of next hop\n")
3567 return bgp_route_match_add (vty
, vty
->index
, "ipv6 next-hop", argv
[0]);
3570 DEFUN (no_match_ipv6_next_hop
,
3571 no_match_ipv6_next_hop_cmd
,
3572 "no match ipv6 next-hop X:X::X:X",
3576 "Match IPv6 next-hop address of route\n"
3577 "IPv6 address of next hop\n")
3579 return bgp_route_match_delete (vty
, vty
->index
, "ipv6 next-hop", argv
[0]);
3582 DEFUN (match_ipv6_address_prefix_list
,
3583 match_ipv6_address_prefix_list_cmd
,
3584 "match ipv6 address prefix-list WORD",
3587 "Match address of route\n"
3588 "Match entries of prefix-lists\n"
3589 "IP prefix-list name\n")
3591 return bgp_route_match_add (vty
, vty
->index
, "ipv6 address prefix-list", argv
[0]);
3594 DEFUN (no_match_ipv6_address_prefix_list
,
3595 no_match_ipv6_address_prefix_list_cmd
,
3596 "no match ipv6 address prefix-list WORD",
3600 "Match address of route\n"
3601 "Match entries of prefix-lists\n"
3602 "IP prefix-list name\n")
3604 return bgp_route_match_delete (vty
, vty
->index
, "ipv6 address prefix-list", argv
[0]);
3607 DEFUN (set_ipv6_nexthop_global
,
3608 set_ipv6_nexthop_global_cmd
,
3609 "set ipv6 next-hop global X:X::X:X",
3612 "IPv6 next-hop address\n"
3613 "IPv6 global address\n"
3614 "IPv6 address of next hop\n")
3616 return bgp_route_set_add (vty
, vty
->index
, "ipv6 next-hop global", argv
[0]);
3619 DEFUN (no_set_ipv6_nexthop_global
,
3620 no_set_ipv6_nexthop_global_cmd
,
3621 "no set ipv6 next-hop global",
3625 "IPv6 next-hop address\n"
3626 "IPv6 global address\n")
3629 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop global", NULL
);
3631 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop global", argv
[0]);
3634 ALIAS (no_set_ipv6_nexthop_global
,
3635 no_set_ipv6_nexthop_global_val_cmd
,
3636 "no set ipv6 next-hop global X:X::X:X",
3640 "IPv6 next-hop address\n"
3641 "IPv6 global address\n"
3642 "IPv6 address of next hop\n")
3644 DEFUN (set_ipv6_nexthop_local
,
3645 set_ipv6_nexthop_local_cmd
,
3646 "set ipv6 next-hop local X:X::X:X",
3649 "IPv6 next-hop address\n"
3650 "IPv6 local address\n"
3651 "IPv6 address of next hop\n")
3653 return bgp_route_set_add (vty
, vty
->index
, "ipv6 next-hop local", argv
[0]);
3656 DEFUN (no_set_ipv6_nexthop_local
,
3657 no_set_ipv6_nexthop_local_cmd
,
3658 "no set ipv6 next-hop local",
3662 "IPv6 next-hop address\n"
3663 "IPv6 local address\n")
3666 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop local", NULL
);
3668 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop local", argv
[0]);
3671 ALIAS (no_set_ipv6_nexthop_local
,
3672 no_set_ipv6_nexthop_local_val_cmd
,
3673 "no set ipv6 next-hop local X:X::X:X",
3677 "IPv6 next-hop address\n"
3678 "IPv6 local address\n"
3679 "IPv6 address of next hop\n")
3680 #endif /* HAVE_IPV6 */
3682 DEFUN (set_vpnv4_nexthop
,
3683 set_vpnv4_nexthop_cmd
,
3684 "set vpnv4 next-hop A.B.C.D",
3686 "VPNv4 information\n"
3687 "VPNv4 next-hop address\n"
3688 "IP address of next hop\n")
3690 return bgp_route_set_add (vty
, vty
->index
, "vpnv4 next-hop", argv
[0]);
3693 DEFUN (no_set_vpnv4_nexthop
,
3694 no_set_vpnv4_nexthop_cmd
,
3695 "no set vpnv4 next-hop",
3698 "VPNv4 information\n"
3699 "VPNv4 next-hop address\n")
3702 return bgp_route_set_delete (vty
, vty
->index
, "vpnv4 next-hop", NULL
);
3704 return bgp_route_set_delete (vty
, vty
->index
, "vpnv4 next-hop", argv
[0]);
3707 ALIAS (no_set_vpnv4_nexthop
,
3708 no_set_vpnv4_nexthop_val_cmd
,
3709 "no set vpnv4 next-hop A.B.C.D",
3712 "VPNv4 information\n"
3713 "VPNv4 next-hop address\n"
3714 "IP address of next hop\n")
3716 DEFUN (set_originator_id
,
3717 set_originator_id_cmd
,
3718 "set originator-id A.B.C.D",
3720 "BGP originator ID attribute\n"
3721 "IP address of originator\n")
3723 return bgp_route_set_add (vty
, vty
->index
, "originator-id", argv
[0]);
3726 DEFUN (no_set_originator_id
,
3727 no_set_originator_id_cmd
,
3728 "no set originator-id",
3731 "BGP originator ID attribute\n")
3734 return bgp_route_set_delete (vty
, vty
->index
, "originator-id", NULL
);
3736 return bgp_route_set_delete (vty
, vty
->index
, "originator-id", argv
[0]);
3739 ALIAS (no_set_originator_id
,
3740 no_set_originator_id_val_cmd
,
3741 "no set originator-id A.B.C.D",
3744 "BGP originator ID attribute\n"
3745 "IP address of originator\n")
3747 DEFUN (set_pathlimit_ttl
,
3748 set_pathlimit_ttl_cmd
,
3749 "set pathlimit ttl <1-255>",
3751 "BGP AS-Pathlimit attribute\n"
3752 "Set AS-Path Hop-count TTL\n")
3754 return bgp_route_set_add (vty
, vty
->index
, "pathlimit ttl", argv
[0]);
3757 DEFUN (no_set_pathlimit_ttl
,
3758 no_set_pathlimit_ttl_cmd
,
3759 "no set pathlimit ttl",
3762 "BGP AS-Pathlimit attribute\n"
3763 "Set AS-Path Hop-count TTL\n")
3766 return bgp_route_set_delete (vty
, vty
->index
, "pathlimit ttl", NULL
);
3768 return bgp_route_set_delete (vty
, vty
->index
, "pathlimit ttl", argv
[0]);
3771 ALIAS (no_set_pathlimit_ttl
,
3772 no_set_pathlimit_ttl_val_cmd
,
3773 "no set pathlimit ttl <1-255>",
3776 "BGP AS-Pathlimit attribute\n"
3777 "Set AS-Path Hop-count TTL\n")
3779 DEFUN (match_pathlimit_as
,
3780 match_pathlimit_as_cmd
,
3781 "match pathlimit as <1-65535>",
3783 "BGP AS-Pathlimit attribute\n"
3784 "Match Pathlimit AS number\n")
3786 return bgp_route_match_add (vty
, vty
->index
, "pathlimit as", argv
[0]);
3789 DEFUN (no_match_pathlimit_as
,
3790 no_match_pathlimit_as_cmd
,
3791 "no match pathlimit as",
3794 "BGP AS-Pathlimit attribute\n"
3795 "Match Pathlimit AS number\n")
3798 return bgp_route_match_delete (vty
, vty
->index
, "pathlimit as", NULL
);
3800 return bgp_route_match_delete (vty
, vty
->index
, "pathlimit as", argv
[0]);
3803 ALIAS (no_match_pathlimit_as
,
3804 no_match_pathlimit_as_val_cmd
,
3805 "no match pathlimit as <1-65535>",
3808 "BGP AS-Pathlimit attribute\n"
3809 "Match Pathlimit ASN\n")
3812 /* Initialization of route map. */
3814 bgp_route_map_init (void)
3817 route_map_init_vty ();
3818 route_map_add_hook (bgp_route_map_update
);
3819 route_map_delete_hook (bgp_route_map_update
);
3821 route_map_install_match (&route_match_peer_cmd
);
3822 route_map_install_match (&route_match_ip_address_cmd
);
3823 route_map_install_match (&route_match_ip_next_hop_cmd
);
3824 route_map_install_match (&route_match_ip_route_source_cmd
);
3825 route_map_install_match (&route_match_ip_address_prefix_list_cmd
);
3826 route_map_install_match (&route_match_ip_next_hop_prefix_list_cmd
);
3827 route_map_install_match (&route_match_ip_route_source_prefix_list_cmd
);
3828 route_map_install_match (&route_match_aspath_cmd
);
3829 route_map_install_match (&route_match_community_cmd
);
3830 route_map_install_match (&route_match_ecommunity_cmd
);
3831 route_map_install_match (&route_match_metric_cmd
);
3832 route_map_install_match (&route_match_origin_cmd
);
3834 route_map_install_set (&route_set_ip_nexthop_cmd
);
3835 route_map_install_set (&route_set_local_pref_cmd
);
3836 route_map_install_set (&route_set_weight_cmd
);
3837 route_map_install_set (&route_set_metric_cmd
);
3838 route_map_install_set (&route_set_aspath_prepend_cmd
);
3839 route_map_install_set (&route_set_aspath_exclude_cmd
);
3840 route_map_install_set (&route_set_origin_cmd
);
3841 route_map_install_set (&route_set_atomic_aggregate_cmd
);
3842 route_map_install_set (&route_set_aggregator_as_cmd
);
3843 route_map_install_set (&route_set_community_cmd
);
3844 route_map_install_set (&route_set_community_delete_cmd
);
3845 route_map_install_set (&route_set_vpnv4_nexthop_cmd
);
3846 route_map_install_set (&route_set_originator_id_cmd
);
3847 route_map_install_set (&route_set_ecommunity_rt_cmd
);
3848 route_map_install_set (&route_set_ecommunity_soo_cmd
);
3850 install_element (RMAP_NODE
, &match_peer_cmd
);
3851 install_element (RMAP_NODE
, &match_peer_local_cmd
);
3852 install_element (RMAP_NODE
, &no_match_peer_cmd
);
3853 install_element (RMAP_NODE
, &no_match_peer_val_cmd
);
3854 install_element (RMAP_NODE
, &no_match_peer_local_cmd
);
3855 install_element (RMAP_NODE
, &match_ip_address_cmd
);
3856 install_element (RMAP_NODE
, &no_match_ip_address_cmd
);
3857 install_element (RMAP_NODE
, &no_match_ip_address_val_cmd
);
3858 install_element (RMAP_NODE
, &match_ip_next_hop_cmd
);
3859 install_element (RMAP_NODE
, &no_match_ip_next_hop_cmd
);
3860 install_element (RMAP_NODE
, &no_match_ip_next_hop_val_cmd
);
3861 install_element (RMAP_NODE
, &match_ip_route_source_cmd
);
3862 install_element (RMAP_NODE
, &no_match_ip_route_source_cmd
);
3863 install_element (RMAP_NODE
, &no_match_ip_route_source_val_cmd
);
3865 install_element (RMAP_NODE
, &match_ip_address_prefix_list_cmd
);
3866 install_element (RMAP_NODE
, &no_match_ip_address_prefix_list_cmd
);
3867 install_element (RMAP_NODE
, &no_match_ip_address_prefix_list_val_cmd
);
3868 install_element (RMAP_NODE
, &match_ip_next_hop_prefix_list_cmd
);
3869 install_element (RMAP_NODE
, &no_match_ip_next_hop_prefix_list_cmd
);
3870 install_element (RMAP_NODE
, &no_match_ip_next_hop_prefix_list_val_cmd
);
3871 install_element (RMAP_NODE
, &match_ip_route_source_prefix_list_cmd
);
3872 install_element (RMAP_NODE
, &no_match_ip_route_source_prefix_list_cmd
);
3873 install_element (RMAP_NODE
, &no_match_ip_route_source_prefix_list_val_cmd
);
3875 install_element (RMAP_NODE
, &match_aspath_cmd
);
3876 install_element (RMAP_NODE
, &no_match_aspath_cmd
);
3877 install_element (RMAP_NODE
, &no_match_aspath_val_cmd
);
3878 install_element (RMAP_NODE
, &match_metric_cmd
);
3879 install_element (RMAP_NODE
, &no_match_metric_cmd
);
3880 install_element (RMAP_NODE
, &no_match_metric_val_cmd
);
3881 install_element (RMAP_NODE
, &match_community_cmd
);
3882 install_element (RMAP_NODE
, &match_community_exact_cmd
);
3883 install_element (RMAP_NODE
, &no_match_community_cmd
);
3884 install_element (RMAP_NODE
, &no_match_community_val_cmd
);
3885 install_element (RMAP_NODE
, &no_match_community_exact_cmd
);
3886 install_element (RMAP_NODE
, &match_ecommunity_cmd
);
3887 install_element (RMAP_NODE
, &no_match_ecommunity_cmd
);
3888 install_element (RMAP_NODE
, &no_match_ecommunity_val_cmd
);
3889 install_element (RMAP_NODE
, &match_origin_cmd
);
3890 install_element (RMAP_NODE
, &no_match_origin_cmd
);
3891 install_element (RMAP_NODE
, &no_match_origin_val_cmd
);
3893 install_element (RMAP_NODE
, &set_ip_nexthop_cmd
);
3894 install_element (RMAP_NODE
, &set_ip_nexthop_peer_cmd
);
3895 install_element (RMAP_NODE
, &no_set_ip_nexthop_cmd
);
3896 install_element (RMAP_NODE
, &no_set_ip_nexthop_val_cmd
);
3897 install_element (RMAP_NODE
, &set_local_pref_cmd
);
3898 install_element (RMAP_NODE
, &no_set_local_pref_cmd
);
3899 install_element (RMAP_NODE
, &no_set_local_pref_val_cmd
);
3900 install_element (RMAP_NODE
, &set_weight_cmd
);
3901 install_element (RMAP_NODE
, &no_set_weight_cmd
);
3902 install_element (RMAP_NODE
, &no_set_weight_val_cmd
);
3903 install_element (RMAP_NODE
, &set_metric_cmd
);
3904 install_element (RMAP_NODE
, &set_metric_addsub_cmd
);
3905 install_element (RMAP_NODE
, &no_set_metric_cmd
);
3906 install_element (RMAP_NODE
, &no_set_metric_val_cmd
);
3907 install_element (RMAP_NODE
, &set_aspath_prepend_cmd
);
3908 install_element (RMAP_NODE
, &set_aspath_exclude_cmd
);
3909 install_element (RMAP_NODE
, &no_set_aspath_prepend_cmd
);
3910 install_element (RMAP_NODE
, &no_set_aspath_prepend_val_cmd
);
3911 install_element (RMAP_NODE
, &no_set_aspath_exclude_cmd
);
3912 install_element (RMAP_NODE
, &no_set_aspath_exclude_val_cmd
);
3913 install_element (RMAP_NODE
, &set_origin_cmd
);
3914 install_element (RMAP_NODE
, &no_set_origin_cmd
);
3915 install_element (RMAP_NODE
, &no_set_origin_val_cmd
);
3916 install_element (RMAP_NODE
, &set_atomic_aggregate_cmd
);
3917 install_element (RMAP_NODE
, &no_set_atomic_aggregate_cmd
);
3918 install_element (RMAP_NODE
, &set_aggregator_as_cmd
);
3919 install_element (RMAP_NODE
, &no_set_aggregator_as_cmd
);
3920 install_element (RMAP_NODE
, &no_set_aggregator_as_val_cmd
);
3921 install_element (RMAP_NODE
, &set_community_cmd
);
3922 install_element (RMAP_NODE
, &set_community_none_cmd
);
3923 install_element (RMAP_NODE
, &no_set_community_cmd
);
3924 install_element (RMAP_NODE
, &no_set_community_val_cmd
);
3925 install_element (RMAP_NODE
, &no_set_community_none_cmd
);
3926 install_element (RMAP_NODE
, &set_community_delete_cmd
);
3927 install_element (RMAP_NODE
, &no_set_community_delete_cmd
);
3928 install_element (RMAP_NODE
, &no_set_community_delete_val_cmd
);
3929 install_element (RMAP_NODE
, &set_ecommunity_rt_cmd
);
3930 install_element (RMAP_NODE
, &no_set_ecommunity_rt_cmd
);
3931 install_element (RMAP_NODE
, &no_set_ecommunity_rt_val_cmd
);
3932 install_element (RMAP_NODE
, &set_ecommunity_soo_cmd
);
3933 install_element (RMAP_NODE
, &no_set_ecommunity_soo_cmd
);
3934 install_element (RMAP_NODE
, &no_set_ecommunity_soo_val_cmd
);
3935 install_element (RMAP_NODE
, &set_vpnv4_nexthop_cmd
);
3936 install_element (RMAP_NODE
, &no_set_vpnv4_nexthop_cmd
);
3937 install_element (RMAP_NODE
, &no_set_vpnv4_nexthop_val_cmd
);
3938 install_element (RMAP_NODE
, &set_originator_id_cmd
);
3939 install_element (RMAP_NODE
, &no_set_originator_id_cmd
);
3940 install_element (RMAP_NODE
, &no_set_originator_id_val_cmd
);
3943 route_map_install_match (&route_match_ipv6_address_cmd
);
3944 route_map_install_match (&route_match_ipv6_next_hop_cmd
);
3945 route_map_install_match (&route_match_ipv6_address_prefix_list_cmd
);
3946 route_map_install_set (&route_set_ipv6_nexthop_global_cmd
);
3947 route_map_install_set (&route_set_ipv6_nexthop_local_cmd
);
3949 install_element (RMAP_NODE
, &match_ipv6_address_cmd
);
3950 install_element (RMAP_NODE
, &no_match_ipv6_address_cmd
);
3951 install_element (RMAP_NODE
, &match_ipv6_next_hop_cmd
);
3952 install_element (RMAP_NODE
, &no_match_ipv6_next_hop_cmd
);
3953 install_element (RMAP_NODE
, &match_ipv6_address_prefix_list_cmd
);
3954 install_element (RMAP_NODE
, &no_match_ipv6_address_prefix_list_cmd
);
3955 install_element (RMAP_NODE
, &set_ipv6_nexthop_global_cmd
);
3956 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_global_cmd
);
3957 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_global_val_cmd
);
3958 install_element (RMAP_NODE
, &set_ipv6_nexthop_local_cmd
);
3959 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_local_cmd
);
3960 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_local_val_cmd
);
3961 #endif /* HAVE_IPV6 */
3964 route_map_install_match (&route_match_pathlimit_as_cmd
);
3965 route_map_install_set (&route_set_pathlimit_ttl_cmd
);
3967 install_element (RMAP_NODE
, &set_pathlimit_ttl_cmd
);
3968 install_element (RMAP_NODE
, &no_set_pathlimit_ttl_cmd
);
3969 install_element (RMAP_NODE
, &no_set_pathlimit_ttl_val_cmd
);
3970 install_element (RMAP_NODE
, &match_pathlimit_as_cmd
);
3971 install_element (RMAP_NODE
, &no_match_pathlimit_as_cmd
);
3972 install_element (RMAP_NODE
, &no_match_pathlimit_as_val_cmd
);