1 /* Route map function of bgpd.
2 Copyright (C) 1998, 1999 Kunihiro Ishiguro
4 This file is part of GNU Zebra.
6 GNU Zebra is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 GNU Zebra is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Zebra; see the file COPYING. If not, write to the Free
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
31 #ifdef HAVE_LIBPCREPOSIX
32 # include <pcreposix.h>
34 # ifdef HAVE_GNU_REGEX
37 # include "regex-gnu.h"
38 # endif /* HAVE_GNU_REGEX */
39 #endif /* HAVE_LIBPCREPOSIX */
41 #include "sockunion.h"
45 #include "bgpd/bgpd.h"
46 #include "bgpd/bgp_table.h"
47 #include "bgpd/bgp_attr.h"
48 #include "bgpd/bgp_aspath.h"
49 #include "bgpd/bgp_packet.h"
50 #include "bgpd/bgp_route.h"
51 #include "bgpd/bgp_zebra.h"
52 #include "bgpd/bgp_regex.h"
53 #include "bgpd/bgp_community.h"
54 #include "bgpd/bgp_clist.h"
55 #include "bgpd/bgp_filter.h"
56 #include "bgpd/bgp_mplsvpn.h"
57 #include "bgpd/bgp_ecommunity.h"
58 #include "bgpd/bgp_vty.h"
59 #include "bgpd/bgp_debug.h"
62 /* Memo of route-map commands.
71 ip route-source : Done
75 ipv6 route-source: (This will not be implemented by bgpd)
76 ipv6 prefix-list : Done
77 length : (This will not be implemented by bgpd)
79 route-type : (This will not be implemented by bgpd)
81 local-preference : Done
83 set as-path prepend : Done
85 automatic-tag : (This will not be implemented by bgpd)
89 default : (This will not be implemented by bgpd)
90 interface : (This will not be implemented by bgpd)
91 ip default : (This will not be implemented by bgpd)
93 ip precedence : (This will not be implemented by bgpd)
94 ip tos : (This will not be implemented by bgpd)
95 level : (This will not be implemented by bgpd)
96 local-preference : Done
105 set ipv6 next-hop global: Done
106 set ipv6 next-hop local : Done
107 set as-path exclude : Done
111 /* generic as path object to be shared in multiple rules */
114 route_aspath_compile (const char *arg
)
116 struct aspath
*aspath
;
118 aspath
= aspath_str2aspath (arg
);
125 route_aspath_free (void *rule
)
127 struct aspath
*aspath
= rule
;
128 aspath_free (aspath
);
131 /* 'match peer (A.B.C.D|X:X::X:X)' */
133 /* Compares the peer specified in the 'match peer' clause with the peer
134 received in bgp_info->peer. If it is the same, or if the peer structure
135 received is a peer_group containing it, returns RMAP_MATCH. */
136 static route_map_result_t
137 route_match_peer (void *rule
, struct prefix
*prefix
, route_map_object_t type
,
141 union sockunion su_def
= { .sin
.sin_family
= AF_INET
,
142 .sin
.sin_addr
.s_addr
= INADDR_ANY
};
143 struct peer_group
*group
;
145 struct listnode
*node
, *nnode
;
147 if (type
== RMAP_BGP
)
150 peer
= ((struct bgp_info
*) object
)->peer
;
152 if ( ! CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IMPORT
) &&
153 ! CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_EXPORT
) )
156 /* If su='0.0.0.0' (command 'match peer local'), and it's a NETWORK,
157 REDISTRIBUTE or DEFAULT_GENERATED route => return RMAP_MATCH */
158 if (sockunion_same (su
, &su_def
))
161 if ( CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_NETWORK
) ||
162 CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
) ||
163 CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_DEFAULT
))
170 if (! CHECK_FLAG (peer
->sflags
, PEER_STATUS_GROUP
))
172 if (sockunion_same (su
, &peer
->su
))
180 for (ALL_LIST_ELEMENTS (group
->peer
, node
, nnode
, peer
))
182 if (sockunion_same (su
, &peer
->su
))
192 route_match_peer_compile (const char *arg
)
197 su
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (union sockunion
));
199 ret
= str2sockunion (strcmp(arg
, "local") ? arg
: "0.0.0.0", su
);
201 XFREE (MTYPE_ROUTE_MAP_COMPILED
, su
);
208 /* Free route map's compiled `ip address' value. */
210 route_match_peer_free (void *rule
)
212 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
215 /* Route map commands for ip address matching. */
216 struct route_map_rule_cmd route_match_peer_cmd
=
220 route_match_peer_compile
,
221 route_match_peer_free
224 /* `match ip address IP_ACCESS_LIST' */
226 /* Match function should return 1 if match is success else return
228 static route_map_result_t
229 route_match_ip_address (void *rule
, struct prefix
*prefix
,
230 route_map_object_t type
, void *object
)
232 struct access_list
*alist
;
233 /* struct prefix_ipv4 match; */
235 if (type
== RMAP_BGP
)
237 alist
= access_list_lookup (AFI_IP
, (char *) rule
);
241 return (access_list_apply (alist
, prefix
) == FILTER_DENY
?
242 RMAP_NOMATCH
: RMAP_MATCH
);
247 /* Route map `ip address' match statement. `arg' should be
250 route_match_ip_address_compile (const char *arg
)
252 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
255 /* Free route map's compiled `ip address' value. */
257 route_match_ip_address_free (void *rule
)
259 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
262 /* Route map commands for ip address matching. */
263 struct route_map_rule_cmd route_match_ip_address_cmd
=
266 route_match_ip_address
,
267 route_match_ip_address_compile
,
268 route_match_ip_address_free
271 /* `match ip next-hop IP_ADDRESS' */
273 /* Match function return 1 if match is success else return zero. */
274 static route_map_result_t
275 route_match_ip_next_hop (void *rule
, struct prefix
*prefix
,
276 route_map_object_t type
, void *object
)
278 struct access_list
*alist
;
279 struct bgp_info
*bgp_info
;
280 struct prefix_ipv4 p
;
282 if (type
== RMAP_BGP
)
286 p
.prefix
= bgp_info
->attr
->nexthop
;
287 p
.prefixlen
= IPV4_MAX_BITLEN
;
289 alist
= access_list_lookup (AFI_IP
, (char *) rule
);
293 return (access_list_apply (alist
, &p
) == FILTER_DENY
?
294 RMAP_NOMATCH
: RMAP_MATCH
);
299 /* Route map `ip next-hop' match statement. `arg' is
302 route_match_ip_next_hop_compile (const char *arg
)
304 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
307 /* Free route map's compiled `ip address' value. */
309 route_match_ip_next_hop_free (void *rule
)
311 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
314 /* Route map commands for ip next-hop matching. */
315 struct route_map_rule_cmd route_match_ip_next_hop_cmd
=
318 route_match_ip_next_hop
,
319 route_match_ip_next_hop_compile
,
320 route_match_ip_next_hop_free
323 /* `match ip route-source ACCESS-LIST' */
325 /* Match function return 1 if match is success else return zero. */
326 static route_map_result_t
327 route_match_ip_route_source (void *rule
, struct prefix
*prefix
,
328 route_map_object_t type
, void *object
)
330 struct access_list
*alist
;
331 struct bgp_info
*bgp_info
;
333 struct prefix_ipv4 p
;
335 if (type
== RMAP_BGP
)
338 peer
= bgp_info
->peer
;
340 if (! peer
|| sockunion_family (&peer
->su
) != AF_INET
)
344 p
.prefix
= peer
->su
.sin
.sin_addr
;
345 p
.prefixlen
= IPV4_MAX_BITLEN
;
347 alist
= access_list_lookup (AFI_IP
, (char *) rule
);
351 return (access_list_apply (alist
, &p
) == FILTER_DENY
?
352 RMAP_NOMATCH
: RMAP_MATCH
);
357 /* Route map `ip route-source' match statement. `arg' is
360 route_match_ip_route_source_compile (const char *arg
)
362 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
365 /* Free route map's compiled `ip address' value. */
367 route_match_ip_route_source_free (void *rule
)
369 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
372 /* Route map commands for ip route-source matching. */
373 struct route_map_rule_cmd route_match_ip_route_source_cmd
=
376 route_match_ip_route_source
,
377 route_match_ip_route_source_compile
,
378 route_match_ip_route_source_free
381 /* `match ip address prefix-list PREFIX_LIST' */
383 static route_map_result_t
384 route_match_ip_address_prefix_list (void *rule
, struct prefix
*prefix
,
385 route_map_object_t type
, void *object
)
387 struct prefix_list
*plist
;
389 if (type
== RMAP_BGP
)
391 plist
= prefix_list_lookup (AFI_IP
, (char *) rule
);
395 return (prefix_list_apply (plist
, prefix
) == PREFIX_DENY
?
396 RMAP_NOMATCH
: RMAP_MATCH
);
402 route_match_ip_address_prefix_list_compile (const char *arg
)
404 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
408 route_match_ip_address_prefix_list_free (void *rule
)
410 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
413 struct route_map_rule_cmd route_match_ip_address_prefix_list_cmd
=
415 "ip address prefix-list",
416 route_match_ip_address_prefix_list
,
417 route_match_ip_address_prefix_list_compile
,
418 route_match_ip_address_prefix_list_free
421 /* `match ip next-hop prefix-list PREFIX_LIST' */
423 static route_map_result_t
424 route_match_ip_next_hop_prefix_list (void *rule
, struct prefix
*prefix
,
425 route_map_object_t type
, void *object
)
427 struct prefix_list
*plist
;
428 struct bgp_info
*bgp_info
;
429 struct prefix_ipv4 p
;
431 if (type
== RMAP_BGP
)
435 p
.prefix
= bgp_info
->attr
->nexthop
;
436 p
.prefixlen
= IPV4_MAX_BITLEN
;
438 plist
= prefix_list_lookup (AFI_IP
, (char *) rule
);
442 return (prefix_list_apply (plist
, &p
) == PREFIX_DENY
?
443 RMAP_NOMATCH
: RMAP_MATCH
);
449 route_match_ip_next_hop_prefix_list_compile (const char *arg
)
451 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
455 route_match_ip_next_hop_prefix_list_free (void *rule
)
457 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
460 struct route_map_rule_cmd route_match_ip_next_hop_prefix_list_cmd
=
462 "ip next-hop prefix-list",
463 route_match_ip_next_hop_prefix_list
,
464 route_match_ip_next_hop_prefix_list_compile
,
465 route_match_ip_next_hop_prefix_list_free
468 /* `match ip route-source prefix-list PREFIX_LIST' */
470 static route_map_result_t
471 route_match_ip_route_source_prefix_list (void *rule
, struct prefix
*prefix
,
472 route_map_object_t type
, void *object
)
474 struct prefix_list
*plist
;
475 struct bgp_info
*bgp_info
;
477 struct prefix_ipv4 p
;
479 if (type
== RMAP_BGP
)
482 peer
= bgp_info
->peer
;
484 if (! peer
|| sockunion_family (&peer
->su
) != AF_INET
)
488 p
.prefix
= peer
->su
.sin
.sin_addr
;
489 p
.prefixlen
= IPV4_MAX_BITLEN
;
491 plist
= prefix_list_lookup (AFI_IP
, (char *) rule
);
495 return (prefix_list_apply (plist
, &p
) == PREFIX_DENY
?
496 RMAP_NOMATCH
: RMAP_MATCH
);
502 route_match_ip_route_source_prefix_list_compile (const char *arg
)
504 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
508 route_match_ip_route_source_prefix_list_free (void *rule
)
510 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
513 struct route_map_rule_cmd route_match_ip_route_source_prefix_list_cmd
=
515 "ip route-source prefix-list",
516 route_match_ip_route_source_prefix_list
,
517 route_match_ip_route_source_prefix_list_compile
,
518 route_match_ip_route_source_prefix_list_free
521 /* `match local-preference LOCAL-PREF' */
523 /* Match function return 1 if match is success else return zero. */
524 static route_map_result_t
525 route_match_local_pref (void *rule
, struct prefix
*prefix
,
526 route_map_object_t type
, void *object
)
528 u_int32_t
*local_pref
;
529 struct bgp_info
*bgp_info
;
531 if (type
== RMAP_BGP
)
536 if (bgp_info
->attr
->local_pref
== *local_pref
)
544 /* Route map `match local-preference' match statement.
545 `arg' is local-pref value */
547 route_match_local_pref_compile (const char *arg
)
549 u_int32_t
*local_pref
;
551 unsigned long tmpval
;
553 /* Locpref value shoud be integer. */
554 if (! all_digit (arg
))
558 tmpval
= strtoul (arg
, &endptr
, 10);
559 if (*endptr
!= '\0' || errno
|| tmpval
> UINT32_MAX
)
562 local_pref
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_int32_t
));
567 *local_pref
= tmpval
;
571 /* Free route map's compiled `match local-preference' value. */
573 route_match_local_pref_free (void *rule
)
575 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
578 /* Route map commands for metric matching. */
579 struct route_map_rule_cmd route_match_local_pref_cmd
=
582 route_match_local_pref
,
583 route_match_local_pref_compile
,
584 route_match_local_pref_free
587 /* `match metric METRIC' */
589 /* Match function return 1 if match is success else return zero. */
590 static route_map_result_t
591 route_match_metric (void *rule
, struct prefix
*prefix
,
592 route_map_object_t type
, void *object
)
595 struct bgp_info
*bgp_info
;
597 if (type
== RMAP_BGP
)
602 if (bgp_info
->attr
->med
== *med
)
610 /* Route map `match metric' match statement. `arg' is MED value */
612 route_match_metric_compile (const char *arg
)
616 unsigned long tmpval
;
618 /* Metric value shoud be integer. */
619 if (! all_digit (arg
))
623 tmpval
= strtoul (arg
, &endptr
, 10);
624 if (*endptr
!= '\0' || errno
|| tmpval
> UINT32_MAX
)
627 med
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_int32_t
));
636 /* Free route map's compiled `match metric' value. */
638 route_match_metric_free (void *rule
)
640 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
643 /* Route map commands for metric matching. */
644 struct route_map_rule_cmd route_match_metric_cmd
=
648 route_match_metric_compile
,
649 route_match_metric_free
652 /* `match as-path ASPATH' */
654 /* Match function for as-path match. I assume given object is */
655 static route_map_result_t
656 route_match_aspath (void *rule
, struct prefix
*prefix
,
657 route_map_object_t type
, void *object
)
660 struct as_list
*as_list
;
661 struct bgp_info
*bgp_info
;
663 if (type
== RMAP_BGP
)
665 as_list
= as_list_lookup ((char *) rule
);
672 return ((as_list_apply (as_list
, bgp_info
->attr
->aspath
) == AS_FILTER_DENY
) ? RMAP_NOMATCH
: RMAP_MATCH
);
677 /* Compile function for as-path match. */
679 route_match_aspath_compile (const char *arg
)
681 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
684 /* Compile function for as-path match. */
686 route_match_aspath_free (void *rule
)
688 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
691 /* Route map commands for aspath matching. */
692 struct route_map_rule_cmd route_match_aspath_cmd
=
696 route_match_aspath_compile
,
697 route_match_aspath_free
700 /* `match community COMMUNIY' */
701 struct rmap_community
707 /* Match function for community match. */
708 static route_map_result_t
709 route_match_community (void *rule
, struct prefix
*prefix
,
710 route_map_object_t type
, void *object
)
712 struct community_list
*list
;
713 struct bgp_info
*bgp_info
;
714 struct rmap_community
*rcom
;
716 if (type
== RMAP_BGP
)
721 list
= community_list_lookup (bgp_clist
, rcom
->name
, COMMUNITY_LIST_MASTER
);
727 if (community_list_exact_match (bgp_info
->attr
->community
, list
))
732 if (community_list_match (bgp_info
->attr
->community
, list
))
739 /* Compile function for community match. */
741 route_match_community_compile (const char *arg
)
743 struct rmap_community
*rcom
;
747 rcom
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct rmap_community
));
749 p
= strchr (arg
, ' ');
753 rcom
->name
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, len
+ 1);
754 memcpy (rcom
->name
, arg
, len
);
759 rcom
->name
= XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
765 /* Compile function for community match. */
767 route_match_community_free (void *rule
)
769 struct rmap_community
*rcom
= rule
;
771 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rcom
->name
);
772 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rcom
);
775 /* Route map commands for community matching. */
776 struct route_map_rule_cmd route_match_community_cmd
=
779 route_match_community
,
780 route_match_community_compile
,
781 route_match_community_free
784 /* Match function for extcommunity match. */
785 static route_map_result_t
786 route_match_ecommunity (void *rule
, struct prefix
*prefix
,
787 route_map_object_t type
, void *object
)
789 struct community_list
*list
;
790 struct bgp_info
*bgp_info
;
792 if (type
== RMAP_BGP
)
796 if (!bgp_info
->attr
->extra
)
799 list
= community_list_lookup (bgp_clist
, (char *) rule
,
800 EXTCOMMUNITY_LIST_MASTER
);
804 if (ecommunity_list_match (bgp_info
->attr
->extra
->ecommunity
, list
))
810 /* Compile function for extcommunity match. */
812 route_match_ecommunity_compile (const char *arg
)
814 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
817 /* Compile function for extcommunity match. */
819 route_match_ecommunity_free (void *rule
)
821 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
824 /* Route map commands for community matching. */
825 struct route_map_rule_cmd route_match_ecommunity_cmd
=
828 route_match_ecommunity
,
829 route_match_ecommunity_compile
,
830 route_match_ecommunity_free
833 /* `match nlri` and `set nlri` are replaced by `address-family ipv4`
834 and `address-family vpnv4'. */
837 static route_map_result_t
838 route_match_origin (void *rule
, struct prefix
*prefix
,
839 route_map_object_t type
, void *object
)
842 struct bgp_info
*bgp_info
;
844 if (type
== RMAP_BGP
)
849 if (bgp_info
->attr
->origin
== *origin
)
857 route_match_origin_compile (const char *arg
)
861 origin
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_char
));
863 if (strcmp (arg
, "igp") == 0)
865 else if (strcmp (arg
, "egp") == 0)
873 /* Free route map's compiled `ip address' value. */
875 route_match_origin_free (void *rule
)
877 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
880 /* Route map commands for origin matching. */
881 struct route_map_rule_cmd route_match_origin_cmd
=
885 route_match_origin_compile
,
886 route_match_origin_free
889 /* match probability { */
891 static route_map_result_t
892 route_match_probability (void *rule
, struct prefix
*prefix
,
893 route_map_object_t type
, void *object
)
896 #if _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE >= 500
899 r
= (unsigned long) rand();
902 switch (*(unsigned *) rule
)
905 case RAND_MAX
: return RMAP_MATCH
;
907 if (r
< *(unsigned *) rule
)
917 route_match_probability_compile (const char *arg
)
922 #if _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE >= 500
923 srandom (time (NULL
));
929 lobule
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (unsigned));
933 case 0: *lobule
= 0; break;
934 case 100: *lobule
= RAND_MAX
; break;
935 default: *lobule
= RAND_MAX
/ 100 * perc
;
942 route_match_probability_free (void *rule
)
944 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
947 struct route_map_rule_cmd route_match_probability_cmd
=
950 route_match_probability
,
951 route_match_probability_compile
,
952 route_match_probability_free
955 /* `match interface IFNAME' */
956 /* Match function should return 1 if match is success else return
958 static route_map_result_t
959 route_match_interface (void *rule
, struct prefix
*prefix
,
960 route_map_object_t type
, void *object
)
962 struct interface
*ifp
;
963 struct bgp_info
*info
;
965 if (type
== RMAP_BGP
)
969 if (!info
|| !info
->attr
)
972 ifp
= if_lookup_by_name_all_vrf ((char *)rule
);
974 if (ifp
== NULL
|| ifp
->ifindex
!= info
->attr
->nh_ifindex
)
982 /* Route map `interface' match statement. `arg' should be
985 route_match_interface_compile (const char *arg
)
987 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
990 /* Free route map's compiled `interface' value. */
992 route_match_interface_free (void *rule
)
994 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
997 /* Route map commands for ip address matching. */
998 struct route_map_rule_cmd route_match_interface_cmd
=
1001 route_match_interface
,
1002 route_match_interface_compile
,
1003 route_match_interface_free
1008 /* `set ip next-hop IP_ADDRESS' */
1010 /* Match function return 1 if match is success else return zero. */
1011 static route_map_result_t
1012 route_match_tag (void *rule
, struct prefix
*prefix
,
1013 route_map_object_t type
, void *object
)
1016 struct bgp_info
*bgp_info
;
1018 if (type
== RMAP_BGP
)
1023 if (!bgp_info
->attr
->extra
)
1024 return RMAP_NOMATCH
;
1026 return ((bgp_info
->attr
->extra
->tag
== *tag
)? RMAP_MATCH
: RMAP_NOMATCH
);
1029 return RMAP_NOMATCH
;
1033 /* Route map `match tag' match statement. `arg' is TAG value */
1035 route_match_tag_compile (const char *arg
)
1040 /* tag value shoud be integer. */
1041 if (! all_digit (arg
))
1048 tag
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_short
));
1059 /* Free route map's compiled 'match tag' value. */
1061 route_match_tag_free (void *rule
)
1063 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1066 /* Route map commands for tag matching. */
1067 struct route_map_rule_cmd route_match_tag_cmd
=
1071 route_match_tag_compile
,
1072 route_match_tag_free
,
1076 /* Set nexthop to object. ojbect must be pointer to struct attr. */
1077 struct rmap_ip_nexthop_set
1079 struct in_addr
*address
;
1084 static route_map_result_t
1085 route_set_ip_nexthop (void *rule
, struct prefix
*prefix
,
1086 route_map_object_t type
, void *object
)
1088 struct rmap_ip_nexthop_set
*rins
= rule
;
1089 struct bgp_info
*bgp_info
;
1092 if (type
== RMAP_BGP
)
1095 peer
= bgp_info
->peer
;
1097 if (rins
->unchanged
)
1099 SET_FLAG(bgp_info
->attr
->rmap_change_flags
,
1100 BATTR_RMAP_NEXTHOP_UNCHANGED
);
1102 else if (rins
->peer_address
)
1104 if ((CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IN
) ||
1105 CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IMPORT
))
1107 && sockunion_family (peer
->su_remote
) == AF_INET
)
1109 bgp_info
->attr
->nexthop
.s_addr
= sockunion2ip (peer
->su_remote
);
1110 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
);
1112 else if (CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
))
1114 /* The next hop value will be set as part of packet rewrite.
1115 * Set the flags here to indicate that rewrite needs to be done.
1116 * Also, clear the value.
1118 SET_FLAG(bgp_info
->attr
->rmap_change_flags
,
1119 BATTR_RMAP_NEXTHOP_PEER_ADDRESS
);
1120 bgp_info
->attr
->nexthop
.s_addr
= 0;
1125 /* Set next hop value. */
1126 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
);
1127 bgp_info
->attr
->nexthop
= *rins
->address
;
1128 SET_FLAG(bgp_info
->attr
->rmap_change_flags
,
1129 BATTR_RMAP_IPV4_NHOP_CHANGED
);
1136 /* Route map `ip nexthop' compile function. Given string is converted
1137 to struct in_addr structure. */
1139 route_set_ip_nexthop_compile (const char *arg
)
1141 struct rmap_ip_nexthop_set
*rins
;
1142 struct in_addr
*address
= NULL
;
1143 int peer_address
= 0;
1147 if (strcmp (arg
, "peer-address") == 0)
1149 else if (strcmp (arg
, "unchanged") == 0)
1153 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in_addr
));
1154 ret
= inet_aton (arg
, address
);
1158 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
1163 rins
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct rmap_ip_nexthop_set
));
1165 rins
->address
= address
;
1166 rins
->peer_address
= peer_address
;
1167 rins
->unchanged
= unchanged
;
1172 /* Free route map's compiled `ip nexthop' value. */
1174 route_set_ip_nexthop_free (void *rule
)
1176 struct rmap_ip_nexthop_set
*rins
= rule
;
1179 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rins
->address
);
1181 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rins
);
1184 /* Route map commands for ip nexthop set. */
1185 struct route_map_rule_cmd route_set_ip_nexthop_cmd
=
1188 route_set_ip_nexthop
,
1189 route_set_ip_nexthop_compile
,
1190 route_set_ip_nexthop_free
1193 /* `set local-preference LOCAL_PREF' */
1195 /* Set local preference. */
1196 static route_map_result_t
1197 route_set_local_pref (void *rule
, struct prefix
*prefix
,
1198 route_map_object_t type
, void *object
)
1200 u_int32_t
*local_pref
;
1201 struct bgp_info
*bgp_info
;
1203 if (type
== RMAP_BGP
)
1205 /* Fetch routemap's rule information. */
1209 /* Set local preference value. */
1210 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
);
1211 bgp_info
->attr
->local_pref
= *local_pref
;
1217 /* set local preference compilation. */
1219 route_set_local_pref_compile (const char *arg
)
1222 u_int32_t
*local_pref
;
1223 char *endptr
= NULL
;
1225 /* Local preference value shoud be integer. */
1226 if (! all_digit (arg
))
1230 tmp
= strtoul (arg
, &endptr
, 10);
1231 if (*endptr
!= '\0' || errno
|| tmp
> UINT32_MAX
)
1234 local_pref
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_int32_t
));
1244 /* Free route map's local preference value. */
1246 route_set_local_pref_free (void *rule
)
1248 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1251 /* Set local preference rule structure. */
1252 struct route_map_rule_cmd route_set_local_pref_cmd
=
1255 route_set_local_pref
,
1256 route_set_local_pref_compile
,
1257 route_set_local_pref_free
,
1260 /* `set weight WEIGHT' */
1263 static route_map_result_t
1264 route_set_weight (void *rule
, struct prefix
*prefix
, route_map_object_t type
,
1268 struct bgp_info
*bgp_info
;
1270 if (type
== RMAP_BGP
)
1272 /* Fetch routemap's rule information. */
1276 /* Set weight value. */
1278 (bgp_attr_extra_get (bgp_info
->attr
))->weight
= *weight
;
1279 else if (bgp_info
->attr
->extra
)
1280 bgp_info
->attr
->extra
->weight
= 0;
1286 /* set local preference compilation. */
1288 route_set_weight_compile (const char *arg
)
1292 char *endptr
= NULL
;
1294 /* Local preference value shoud be integer. */
1295 if (! all_digit (arg
))
1299 tmp
= strtoul (arg
, &endptr
, 10);
1300 if (*endptr
!= '\0' || errno
|| tmp
> UINT32_MAX
)
1303 weight
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_int32_t
));
1313 /* Free route map's local preference value. */
1315 route_set_weight_free (void *rule
)
1317 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1320 /* Set local preference rule structure. */
1321 struct route_map_rule_cmd route_set_weight_cmd
=
1325 route_set_weight_compile
,
1326 route_set_weight_free
,
1329 /* `set metric METRIC' */
1331 /* Set metric to attribute. */
1332 static route_map_result_t
1333 route_set_metric (void *rule
, struct prefix
*prefix
,
1334 route_map_object_t type
, void *object
)
1337 u_int32_t metric_val
;
1338 struct bgp_info
*bgp_info
;
1340 if (type
== RMAP_BGP
)
1342 /* Fetch routemap's rule information. */
1346 if (! (bgp_info
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
)))
1347 bgp_info
->attr
->med
= 0;
1348 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
1350 if (all_digit (metric
))
1352 metric_val
= strtoul (metric
, (char **)NULL
, 10);
1353 bgp_info
->attr
->med
= metric_val
;
1357 metric_val
= strtoul (metric
+1, (char **)NULL
, 10);
1359 if (strncmp (metric
, "+", 1) == 0)
1361 if (bgp_info
->attr
->med
/2 + metric_val
/2 > BGP_MED_MAX
/2)
1362 bgp_info
->attr
->med
= BGP_MED_MAX
- 1;
1364 bgp_info
->attr
->med
+= metric_val
;
1366 else if (strncmp (metric
, "-", 1) == 0)
1368 if (bgp_info
->attr
->med
<= metric_val
)
1369 bgp_info
->attr
->med
= 0;
1371 bgp_info
->attr
->med
-= metric_val
;
1378 /* set metric compilation. */
1380 route_set_metric_compile (const char *arg
)
1383 char *endptr
= NULL
;
1385 if (all_digit (arg
))
1387 /* set metric value check*/
1389 larg
= strtoul (arg
, &endptr
, 10);
1390 if (*endptr
!= '\0' || errno
|| larg
> UINT32_MAX
)
1395 /* set metric <+/-metric> check */
1396 if ((strncmp (arg
, "+", 1) != 0
1397 && strncmp (arg
, "-", 1) != 0)
1398 || (! all_digit (arg
+1)))
1402 larg
= strtoul (arg
+1, &endptr
, 10);
1403 if (*endptr
!= '\0' || errno
|| larg
> UINT32_MAX
)
1407 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
1410 /* Free route map's compiled `set metric' value. */
1412 route_set_metric_free (void *rule
)
1414 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1417 /* Set metric rule structure. */
1418 struct route_map_rule_cmd route_set_metric_cmd
=
1422 route_set_metric_compile
,
1423 route_set_metric_free
,
1426 /* `set as-path prepend ASPATH' */
1428 /* For AS path prepend mechanism. */
1429 static route_map_result_t
1430 route_set_aspath_prepend (void *rule
, struct prefix
*prefix
, route_map_object_t type
, void *object
)
1432 struct aspath
*aspath
;
1434 struct bgp_info
*binfo
;
1436 if (type
== RMAP_BGP
)
1440 if (binfo
->attr
->aspath
->refcnt
)
1441 new = aspath_dup (binfo
->attr
->aspath
);
1443 new = binfo
->attr
->aspath
;
1445 if ((uintptr_t)rule
> 10)
1448 aspath_prepend (aspath
, new);
1452 as_t as
= aspath_leftmost(new);
1453 if (!as
) as
= binfo
->peer
->as
;
1454 new = aspath_add_seq_n (new, as
, (uintptr_t) rule
);
1457 binfo
->attr
->aspath
= new;
1464 route_set_aspath_prepend_compile (const char *arg
)
1468 if (sscanf(arg
, "last-as %u", &num
) == 1 && num
> 0 && num
< 10)
1469 return (void*)(uintptr_t)num
;
1471 return route_aspath_compile(arg
);
1475 route_set_aspath_prepend_free (void *rule
)
1477 if ((uintptr_t)rule
> 10)
1478 route_aspath_free(rule
);
1482 /* Set as-path prepend rule structure. */
1483 struct route_map_rule_cmd route_set_aspath_prepend_cmd
=
1486 route_set_aspath_prepend
,
1487 route_set_aspath_prepend_compile
,
1488 route_set_aspath_prepend_free
,
1491 /* `set as-path exclude ASn' */
1493 /* For ASN exclude mechanism.
1494 * Iterate over ASns requested and filter them from the given AS_PATH one by one.
1495 * Make a deep copy of existing AS_PATH, but for the first ASn only.
1497 static route_map_result_t
1498 route_set_aspath_exclude (void *rule
, struct prefix
*dummy
, route_map_object_t type
, void *object
)
1500 struct aspath
* new_path
, * exclude_path
;
1501 struct bgp_info
*binfo
;
1503 if (type
== RMAP_BGP
)
1505 exclude_path
= rule
;
1507 if (binfo
->attr
->aspath
->refcnt
)
1508 new_path
= aspath_dup (binfo
->attr
->aspath
);
1510 new_path
= binfo
->attr
->aspath
;
1511 binfo
->attr
->aspath
= aspath_filter_exclude (new_path
, exclude_path
);
1516 /* Set ASn exlude rule structure. */
1517 struct route_map_rule_cmd route_set_aspath_exclude_cmd
=
1520 route_set_aspath_exclude
,
1521 route_aspath_compile
,
1525 /* `set community COMMUNITY' */
1528 struct community
*com
;
1533 /* For community set mechanism. */
1534 static route_map_result_t
1535 route_set_community (void *rule
, struct prefix
*prefix
,
1536 route_map_object_t type
, void *object
)
1538 struct rmap_com_set
*rcs
;
1539 struct bgp_info
*binfo
;
1541 struct community
*new = NULL
;
1542 struct community
*old
;
1543 struct community
*merge
;
1545 if (type
== RMAP_BGP
)
1550 old
= attr
->community
;
1555 attr
->flag
&= ~(ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
));
1556 attr
->community
= NULL
;
1557 /* See the longer comment down below. */
1558 if (old
&& old
->refcnt
== 0)
1559 community_free(old
);
1563 /* "additive" case. */
1564 if (rcs
->additive
&& old
)
1566 merge
= community_merge (community_dup (old
), rcs
->com
);
1568 /* HACK: if the old community is not intern'd,
1569 * we should free it here, or all reference to it may be lost.
1570 * Really need to cleanup attribute caching sometime.
1572 if (old
->refcnt
== 0)
1573 community_free (old
);
1574 new = community_uniq_sort (merge
);
1575 community_free (merge
);
1578 new = community_dup (rcs
->com
);
1580 /* will be interned by caller if required */
1581 attr
->community
= new;
1583 attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
);
1589 /* Compile function for set community. */
1591 route_set_community_compile (const char *arg
)
1593 struct rmap_com_set
*rcs
;
1594 struct community
*com
= NULL
;
1599 if (strcmp (arg
, "none") == 0)
1603 sp
= strstr (arg
, "additive");
1607 /* "additive" keyworkd is included. */
1612 com
= community_str2com (arg
);
1621 rcs
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct rmap_com_set
));
1623 rcs
->additive
= additive
;
1629 /* Free function for set community. */
1631 route_set_community_free (void *rule
)
1633 struct rmap_com_set
*rcs
= rule
;
1636 community_free (rcs
->com
);
1637 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rcs
);
1640 /* Set community rule structure. */
1641 struct route_map_rule_cmd route_set_community_cmd
=
1644 route_set_community
,
1645 route_set_community_compile
,
1646 route_set_community_free
,
1649 /* `set comm-list (<1-99>|<100-500>|WORD) delete' */
1651 /* For community set mechanism. */
1652 static route_map_result_t
1653 route_set_community_delete (void *rule
, struct prefix
*prefix
,
1654 route_map_object_t type
, void *object
)
1656 struct community_list
*list
;
1657 struct community
*merge
;
1658 struct community
*new;
1659 struct community
*old
;
1660 struct bgp_info
*binfo
;
1662 if (type
== RMAP_BGP
)
1668 list
= community_list_lookup (bgp_clist
, rule
, COMMUNITY_LIST_MASTER
);
1669 old
= binfo
->attr
->community
;
1673 merge
= community_list_match_delete (community_dup (old
), list
);
1674 new = community_uniq_sort (merge
);
1675 community_free (merge
);
1677 /* HACK: if the old community is not intern'd,
1678 * we should free it here, or all reference to it may be lost.
1679 * Really need to cleanup attribute caching sometime.
1681 if (old
->refcnt
== 0)
1682 community_free (old
);
1686 binfo
->attr
->community
= NULL
;
1687 binfo
->attr
->flag
&= ~ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
);
1688 community_free (new);
1692 binfo
->attr
->community
= new;
1693 binfo
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
);
1701 /* Compile function for set community. */
1703 route_set_community_delete_compile (const char *arg
)
1709 p
= strchr (arg
, ' ');
1713 str
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, len
+ 1);
1714 memcpy (str
, arg
, len
);
1722 /* Free function for set community. */
1724 route_set_community_delete_free (void *rule
)
1726 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1729 /* Set community rule structure. */
1730 struct route_map_rule_cmd route_set_community_delete_cmd
=
1733 route_set_community_delete
,
1734 route_set_community_delete_compile
,
1735 route_set_community_delete_free
,
1738 /* `set extcommunity rt COMMUNITY' */
1740 /* For community set mechanism. Used by _rt and _soo. */
1741 static route_map_result_t
1742 route_set_ecommunity (void *rule
, struct prefix
*prefix
,
1743 route_map_object_t type
, void *object
)
1745 struct ecommunity
*ecom
;
1746 struct ecommunity
*new_ecom
;
1747 struct ecommunity
*old_ecom
;
1748 struct bgp_info
*bgp_info
;
1750 if (type
== RMAP_BGP
)
1758 /* We assume additive for Extended Community. */
1759 old_ecom
= (bgp_attr_extra_get (bgp_info
->attr
))->ecommunity
;
1763 new_ecom
= ecommunity_merge (ecommunity_dup (old_ecom
), ecom
);
1765 /* old_ecom->refcnt = 1 => owned elsewhere, e.g. bgp_update_receive()
1766 * ->refcnt = 0 => set by a previous route-map statement */
1767 if (!old_ecom
->refcnt
)
1768 ecommunity_free (&old_ecom
);
1771 new_ecom
= ecommunity_dup (ecom
);
1773 /* will be intern()'d or attr_flush()'d by bgp_update_main() */
1774 bgp_info
->attr
->extra
->ecommunity
= new_ecom
;
1776 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES
);
1781 /* Compile function for set community. */
1783 route_set_ecommunity_rt_compile (const char *arg
)
1785 struct ecommunity
*ecom
;
1787 ecom
= ecommunity_str2com (arg
, ECOMMUNITY_ROUTE_TARGET
, 0);
1790 return ecommunity_intern (ecom
);
1793 /* Free function for set community. Used by _rt and _soo */
1795 route_set_ecommunity_free (void *rule
)
1797 struct ecommunity
*ecom
= rule
;
1798 ecommunity_unintern (&ecom
);
1801 /* Set community rule structure. */
1802 struct route_map_rule_cmd route_set_ecommunity_rt_cmd
=
1805 route_set_ecommunity
,
1806 route_set_ecommunity_rt_compile
,
1807 route_set_ecommunity_free
,
1810 /* `set extcommunity soo COMMUNITY' */
1812 /* Compile function for set community. */
1814 route_set_ecommunity_soo_compile (const char *arg
)
1816 struct ecommunity
*ecom
;
1818 ecom
= ecommunity_str2com (arg
, ECOMMUNITY_SITE_ORIGIN
, 0);
1822 return ecommunity_intern (ecom
);
1825 /* Set community rule structure. */
1826 struct route_map_rule_cmd route_set_ecommunity_soo_cmd
=
1829 route_set_ecommunity
,
1830 route_set_ecommunity_soo_compile
,
1831 route_set_ecommunity_free
,
1834 /* `set origin ORIGIN' */
1836 /* For origin set. */
1837 static route_map_result_t
1838 route_set_origin (void *rule
, struct prefix
*prefix
, route_map_object_t type
, void *object
)
1841 struct bgp_info
*bgp_info
;
1843 if (type
== RMAP_BGP
)
1848 bgp_info
->attr
->origin
= *origin
;
1854 /* Compile function for origin set. */
1856 route_set_origin_compile (const char *arg
)
1860 origin
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_char
));
1862 if (strcmp (arg
, "igp") == 0)
1864 else if (strcmp (arg
, "egp") == 0)
1872 /* Compile function for origin set. */
1874 route_set_origin_free (void *rule
)
1876 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1879 /* Set origin rule structure. */
1880 struct route_map_rule_cmd route_set_origin_cmd
=
1884 route_set_origin_compile
,
1885 route_set_origin_free
,
1888 /* `set atomic-aggregate' */
1890 /* For atomic aggregate set. */
1891 static route_map_result_t
1892 route_set_atomic_aggregate (void *rule
, struct prefix
*prefix
,
1893 route_map_object_t type
, void *object
)
1895 struct bgp_info
*bgp_info
;
1897 if (type
== RMAP_BGP
)
1900 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
1906 /* Compile function for atomic aggregate. */
1908 route_set_atomic_aggregate_compile (const char *arg
)
1913 /* Compile function for atomic aggregate. */
1915 route_set_atomic_aggregate_free (void *rule
)
1920 /* Set atomic aggregate rule structure. */
1921 struct route_map_rule_cmd route_set_atomic_aggregate_cmd
=
1924 route_set_atomic_aggregate
,
1925 route_set_atomic_aggregate_compile
,
1926 route_set_atomic_aggregate_free
,
1929 /* `set aggregator as AS A.B.C.D' */
1933 struct in_addr address
;
1936 static route_map_result_t
1937 route_set_aggregator_as (void *rule
, struct prefix
*prefix
,
1938 route_map_object_t type
, void *object
)
1940 struct bgp_info
*bgp_info
;
1941 struct aggregator
*aggregator
;
1942 struct attr_extra
*ae
;
1944 if (type
== RMAP_BGP
)
1948 ae
= bgp_attr_extra_get (bgp_info
->attr
);
1950 ae
->aggregator_as
= aggregator
->as
;
1951 ae
->aggregator_addr
= aggregator
->address
;
1952 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
);
1959 route_set_aggregator_as_compile (const char *arg
)
1961 struct aggregator
*aggregator
;
1965 aggregator
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct aggregator
));
1966 sscanf (arg
, "%s %s", as
, address
);
1968 aggregator
->as
= strtoul (as
, NULL
, 10);
1969 inet_aton (address
, &aggregator
->address
);
1975 route_set_aggregator_as_free (void *rule
)
1977 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1980 struct route_map_rule_cmd route_set_aggregator_as_cmd
=
1983 route_set_aggregator_as
,
1984 route_set_aggregator_as_compile
,
1985 route_set_aggregator_as_free
,
1988 /* Set tag to object. object must be pointer to struct bgp_info */
1989 static route_map_result_t
1990 route_set_tag (void *rule
, struct prefix
*prefix
,
1991 route_map_object_t type
, void *object
)
1994 struct bgp_info
*bgp_info
;
1995 struct attr_extra
*ae
;
1997 if (type
== RMAP_BGP
)
2001 ae
= bgp_attr_extra_get (bgp_info
->attr
);
2011 /* Route map `tag' compile function. Given string is converted to u_short. */
2013 route_set_tag_compile (const char *arg
)
2018 /* tag value shoud be integer. */
2019 if (! all_digit (arg
))
2027 tag
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_short
));
2037 /* Free route map's tag value. */
2039 route_set_tag_free (void *rule
)
2041 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2045 /* Route map commands for tag set. */
2046 struct route_map_rule_cmd route_set_tag_cmd
=
2050 route_set_tag_compile
,
2056 /* `match ipv6 address IP_ACCESS_LIST' */
2058 static route_map_result_t
2059 route_match_ipv6_address (void *rule
, struct prefix
*prefix
,
2060 route_map_object_t type
, void *object
)
2062 struct access_list
*alist
;
2064 if (type
== RMAP_BGP
)
2066 alist
= access_list_lookup (AFI_IP6
, (char *) rule
);
2068 return RMAP_NOMATCH
;
2070 return (access_list_apply (alist
, prefix
) == FILTER_DENY
?
2071 RMAP_NOMATCH
: RMAP_MATCH
);
2073 return RMAP_NOMATCH
;
2077 route_match_ipv6_address_compile (const char *arg
)
2079 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
2083 route_match_ipv6_address_free (void *rule
)
2085 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2088 /* Route map commands for ip address matching. */
2089 struct route_map_rule_cmd route_match_ipv6_address_cmd
=
2092 route_match_ipv6_address
,
2093 route_match_ipv6_address_compile
,
2094 route_match_ipv6_address_free
2097 /* `match ipv6 next-hop IP_ADDRESS' */
2099 static route_map_result_t
2100 route_match_ipv6_next_hop (void *rule
, struct prefix
*prefix
,
2101 route_map_object_t type
, void *object
)
2103 struct bgp_info
*bgp_info
;
2105 if (type
== RMAP_BGP
)
2109 if (!bgp_info
->attr
->extra
)
2110 return RMAP_NOMATCH
;
2112 if (IPV6_ADDR_SAME (&bgp_info
->attr
->extra
->mp_nexthop_global
, rule
))
2115 if (bgp_info
->attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
&&
2116 IPV6_ADDR_SAME (&bgp_info
->attr
->extra
->mp_nexthop_local
, rule
))
2119 return RMAP_NOMATCH
;
2122 return RMAP_NOMATCH
;
2126 route_match_ipv6_next_hop_compile (const char *arg
)
2128 struct in6_addr
*address
;
2131 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in6_addr
));
2133 ret
= inet_pton (AF_INET6
, arg
, address
);
2136 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
2144 route_match_ipv6_next_hop_free (void *rule
)
2146 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2149 struct route_map_rule_cmd route_match_ipv6_next_hop_cmd
=
2152 route_match_ipv6_next_hop
,
2153 route_match_ipv6_next_hop_compile
,
2154 route_match_ipv6_next_hop_free
2157 /* `match ipv6 address prefix-list PREFIX_LIST' */
2159 static route_map_result_t
2160 route_match_ipv6_address_prefix_list (void *rule
, struct prefix
*prefix
,
2161 route_map_object_t type
, void *object
)
2163 struct prefix_list
*plist
;
2165 if (type
== RMAP_BGP
)
2167 plist
= prefix_list_lookup (AFI_IP6
, (char *) rule
);
2169 return RMAP_NOMATCH
;
2171 return (prefix_list_apply (plist
, prefix
) == PREFIX_DENY
?
2172 RMAP_NOMATCH
: RMAP_MATCH
);
2174 return RMAP_NOMATCH
;
2178 route_match_ipv6_address_prefix_list_compile (const char *arg
)
2180 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
2184 route_match_ipv6_address_prefix_list_free (void *rule
)
2186 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2189 struct route_map_rule_cmd route_match_ipv6_address_prefix_list_cmd
=
2191 "ipv6 address prefix-list",
2192 route_match_ipv6_address_prefix_list
,
2193 route_match_ipv6_address_prefix_list_compile
,
2194 route_match_ipv6_address_prefix_list_free
2197 /* `set ipv6 nexthop global IP_ADDRESS' */
2199 /* Set nexthop to object. ojbect must be pointer to struct attr. */
2200 static route_map_result_t
2201 route_set_ipv6_nexthop_global (void *rule
, struct prefix
*prefix
,
2202 route_map_object_t type
, void *object
)
2204 struct in6_addr
*address
;
2205 struct bgp_info
*bgp_info
;
2207 if (type
== RMAP_BGP
)
2209 /* Fetch routemap's rule information. */
2213 /* Set next hop value. */
2214 (bgp_attr_extra_get (bgp_info
->attr
))->mp_nexthop_global
= *address
;
2216 /* Set nexthop length. */
2217 if (bgp_info
->attr
->extra
->mp_nexthop_len
== 0)
2218 bgp_info
->attr
->extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL
;
2220 SET_FLAG(bgp_info
->attr
->rmap_change_flags
,
2221 BATTR_RMAP_IPV6_GLOBAL_NHOP_CHANGED
);
2227 /* Route map `ip next-hop' compile function. Given string is converted
2228 to struct in_addr structure. */
2230 route_set_ipv6_nexthop_global_compile (const char *arg
)
2233 struct in6_addr
*address
;
2235 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in6_addr
));
2237 ret
= inet_pton (AF_INET6
, arg
, address
);
2241 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
2248 /* Free route map's compiled `ip next-hop' value. */
2250 route_set_ipv6_nexthop_global_free (void *rule
)
2252 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2255 /* Route map commands for ip nexthop set. */
2256 struct route_map_rule_cmd route_set_ipv6_nexthop_global_cmd
=
2258 "ipv6 next-hop global",
2259 route_set_ipv6_nexthop_global
,
2260 route_set_ipv6_nexthop_global_compile
,
2261 route_set_ipv6_nexthop_global_free
2264 /* `set ipv6 nexthop local IP_ADDRESS' */
2266 /* Set nexthop to object. ojbect must be pointer to struct attr. */
2267 static route_map_result_t
2268 route_set_ipv6_nexthop_local (void *rule
, struct prefix
*prefix
,
2269 route_map_object_t type
, void *object
)
2271 struct in6_addr
*address
;
2272 struct bgp_info
*bgp_info
;
2274 if (type
== RMAP_BGP
)
2276 /* Fetch routemap's rule information. */
2280 /* Set next hop value. */
2281 (bgp_attr_extra_get (bgp_info
->attr
))->mp_nexthop_local
= *address
;
2283 /* Set nexthop length. */
2284 if (bgp_info
->attr
->extra
->mp_nexthop_len
!= BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
2285 bgp_info
->attr
->extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
;
2287 SET_FLAG(bgp_info
->attr
->rmap_change_flags
,
2288 BATTR_RMAP_IPV6_LL_NHOP_CHANGED
);
2294 /* Route map `ip nexthop' compile function. Given string is converted
2295 to struct in_addr structure. */
2297 route_set_ipv6_nexthop_local_compile (const char *arg
)
2300 struct in6_addr
*address
;
2302 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in6_addr
));
2304 ret
= inet_pton (AF_INET6
, arg
, address
);
2308 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
2315 /* Free route map's compiled `ip nexthop' value. */
2317 route_set_ipv6_nexthop_local_free (void *rule
)
2319 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2322 /* Route map commands for ip nexthop set. */
2323 struct route_map_rule_cmd route_set_ipv6_nexthop_local_cmd
=
2325 "ipv6 next-hop local",
2326 route_set_ipv6_nexthop_local
,
2327 route_set_ipv6_nexthop_local_compile
,
2328 route_set_ipv6_nexthop_local_free
2331 /* `set ipv6 nexthop peer-address' */
2333 /* Set nexthop to object. ojbect must be pointer to struct attr. */
2334 static route_map_result_t
2335 route_set_ipv6_nexthop_peer (void *rule
, struct prefix
*prefix
,
2336 route_map_object_t type
, void *object
)
2338 struct in6_addr peer_address
;
2339 struct bgp_info
*bgp_info
;
2341 char peer_addr_buf
[INET6_ADDRSTRLEN
];
2343 if (type
== RMAP_BGP
)
2345 /* Fetch routemap's rule information. */
2347 peer
= bgp_info
->peer
;
2349 if ((CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IN
) ||
2350 CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IMPORT
))
2352 && sockunion_family (peer
->su_remote
) == AF_INET6
)
2354 inet_pton (AF_INET6
, sockunion2str (peer
->su_remote
,
2358 /* Set next hop value and length in attribute. */
2359 if (IN6_IS_ADDR_LINKLOCAL(&peer_address
))
2361 (bgp_attr_extra_get (bgp_info
->attr
))->mp_nexthop_local
= peer_address
;
2362 if (bgp_info
->attr
->extra
->mp_nexthop_len
!= 32)
2363 bgp_info
->attr
->extra
->mp_nexthop_len
= 32;
2367 (bgp_attr_extra_get (bgp_info
->attr
))->mp_nexthop_global
= peer_address
;
2368 if (bgp_info
->attr
->extra
->mp_nexthop_len
== 0)
2369 bgp_info
->attr
->extra
->mp_nexthop_len
= 16;
2373 else if (CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
))
2375 /* The next hop value will be set as part of packet rewrite.
2376 * Set the flags here to indicate that rewrite needs to be done.
2377 * Also, clear the value - we clear both global and link-local
2378 * nexthops, whether we send one or both is determined elsewhere.
2380 SET_FLAG(bgp_info
->attr
->rmap_change_flags
,
2381 BATTR_RMAP_NEXTHOP_PEER_ADDRESS
);
2382 /* clear next hop value. */
2383 memset (&((bgp_attr_extra_get (bgp_info
->attr
))->mp_nexthop_global
),
2384 0, sizeof (struct in6_addr
));
2385 memset (&((bgp_attr_extra_get (bgp_info
->attr
))->mp_nexthop_local
),
2386 0, sizeof (struct in6_addr
));
2393 /* Route map `ip next-hop' compile function. Given string is converted
2394 to struct in_addr structure. */
2396 route_set_ipv6_nexthop_peer_compile (const char *arg
)
2400 rins
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (int));
2406 /* Free route map's compiled `ip next-hop' value. */
2408 route_set_ipv6_nexthop_peer_free (void *rule
)
2410 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2413 /* Route map commands for ip nexthop set. */
2414 struct route_map_rule_cmd route_set_ipv6_nexthop_peer_cmd
=
2416 "ipv6 next-hop peer-address",
2417 route_set_ipv6_nexthop_peer
,
2418 route_set_ipv6_nexthop_peer_compile
,
2419 route_set_ipv6_nexthop_peer_free
2422 #endif /* HAVE_IPV6 */
2424 /* `set vpnv4 nexthop A.B.C.D' */
2426 static route_map_result_t
2427 route_set_vpnv4_nexthop (void *rule
, struct prefix
*prefix
,
2428 route_map_object_t type
, void *object
)
2430 struct in_addr
*address
;
2431 struct bgp_info
*bgp_info
;
2433 if (type
== RMAP_BGP
)
2435 /* Fetch routemap's rule information. */
2439 /* Set next hop value. */
2440 (bgp_attr_extra_get (bgp_info
->attr
))->mp_nexthop_global_in
= *address
;
2447 route_set_vpnv4_nexthop_compile (const char *arg
)
2450 struct in_addr
*address
;
2452 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in_addr
));
2454 ret
= inet_aton (arg
, address
);
2458 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
2466 route_set_vpnv4_nexthop_free (void *rule
)
2468 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2471 /* Route map commands for ip nexthop set. */
2472 struct route_map_rule_cmd route_set_vpnv4_nexthop_cmd
=
2475 route_set_vpnv4_nexthop
,
2476 route_set_vpnv4_nexthop_compile
,
2477 route_set_vpnv4_nexthop_free
2480 /* `set originator-id' */
2482 /* For origin set. */
2483 static route_map_result_t
2484 route_set_originator_id (void *rule
, struct prefix
*prefix
, route_map_object_t type
, void *object
)
2486 struct in_addr
*address
;
2487 struct bgp_info
*bgp_info
;
2489 if (type
== RMAP_BGP
)
2494 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
);
2495 (bgp_attr_extra_get (bgp_info
->attr
))->originator_id
= *address
;
2501 /* Compile function for originator-id set. */
2503 route_set_originator_id_compile (const char *arg
)
2506 struct in_addr
*address
;
2508 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in_addr
));
2510 ret
= inet_aton (arg
, address
);
2514 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
2521 /* Compile function for originator_id set. */
2523 route_set_originator_id_free (void *rule
)
2525 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2528 /* Set originator-id rule structure. */
2529 struct route_map_rule_cmd route_set_originator_id_cmd
=
2532 route_set_originator_id
,
2533 route_set_originator_id_compile
,
2534 route_set_originator_id_free
,
2537 /* Add bgp route map rule. */
2539 bgp_route_match_add (struct vty
*vty
, struct route_map_index
*index
,
2540 const char *command
, const char *arg
,
2541 route_map_event_t type
)
2545 ret
= route_map_add_match (index
, command
, arg
);
2550 case RMAP_RULE_MISSING
:
2551 vty_out (vty
, "%% BGP Can't find rule.%s", VTY_NEWLINE
);
2553 case RMAP_COMPILE_ERROR
:
2554 vty_out (vty
, "%% BGP Argument is malformed.%s", VTY_NEWLINE
);
2559 if (type
!= RMAP_EVENT_MATCH_ADDED
)
2561 route_map_upd8_dependency (type
, arg
, index
->map
->name
);
2567 /* Delete bgp route map rule. */
2569 bgp_route_match_delete (struct vty
*vty
, struct route_map_index
*index
,
2570 const char *command
, const char *arg
,
2571 route_map_event_t type
)
2574 char *dep_name
= NULL
;
2576 char *rmap_name
= NULL
;
2578 if (type
!= RMAP_EVENT_MATCH_DELETED
)
2580 /* ignore the mundane, the types without any dependency */
2583 if ((tmpstr
= route_map_get_match_arg(index
, command
)) != NULL
)
2584 dep_name
= XSTRDUP(MTYPE_ROUTE_MAP_RULE
, tmpstr
);
2588 dep_name
= XSTRDUP(MTYPE_ROUTE_MAP_RULE
, arg
);
2590 rmap_name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, index
->map
->name
);
2593 ret
= route_map_delete_match (index
, command
, dep_name
);
2598 case RMAP_RULE_MISSING
:
2599 vty_out (vty
, "%% BGP Can't find rule.%s", VTY_NEWLINE
);
2601 case RMAP_COMPILE_ERROR
:
2602 vty_out (vty
, "%% BGP Argument is malformed.%s", VTY_NEWLINE
);
2606 XFREE(MTYPE_ROUTE_MAP_RULE
, dep_name
);
2608 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap_name
);
2612 if (type
!= RMAP_EVENT_MATCH_DELETED
&& dep_name
)
2613 route_map_upd8_dependency(type
, dep_name
, rmap_name
);
2616 XFREE(MTYPE_ROUTE_MAP_RULE
, dep_name
);
2618 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap_name
);
2623 /* Add bgp route map rule. */
2625 bgp_route_set_add (struct vty
*vty
, struct route_map_index
*index
,
2626 const char *command
, const char *arg
)
2630 ret
= route_map_add_set (index
, command
, arg
);
2635 case RMAP_RULE_MISSING
:
2636 vty_out (vty
, "%% BGP Can't find rule.%s", VTY_NEWLINE
);
2638 case RMAP_COMPILE_ERROR
:
2639 vty_out (vty
, "%% BGP Argument is malformed.%s", VTY_NEWLINE
);
2646 /* Delete bgp route map rule. */
2648 bgp_route_set_delete (struct vty
*vty
, struct route_map_index
*index
,
2649 const char *command
, const char *arg
)
2653 ret
= route_map_delete_set (index
, command
, arg
);
2658 case RMAP_RULE_MISSING
:
2659 vty_out (vty
, "%% BGP Can't find rule.%s", VTY_NEWLINE
);
2661 case RMAP_COMPILE_ERROR
:
2662 vty_out (vty
, "%% BGP Argument is malformed.%s", VTY_NEWLINE
);
2670 * This is the workhorse routine for processing in/out routemap
2674 bgp_route_map_process_peer (const char *rmap_name
, struct route_map
*map
,
2675 struct peer
*peer
, int afi
, int safi
,
2680 struct bgp_filter
*filter
;
2682 if (!peer
|| !rmap_name
)
2685 filter
= &peer
->filter
[afi
][safi
];
2687 * in is for non-route-server clients,
2688 * out is for all peers
2690 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_RSERVER_CLIENT
))
2692 if (filter
->map
[RMAP_IN
].name
&&
2693 (strcmp(rmap_name
, filter
->map
[RMAP_IN
].name
) == 0))
2695 filter
->map
[RMAP_IN
].map
= map
;
2697 if (route_update
&& peer
->status
== Established
)
2699 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
],
2700 PEER_FLAG_SOFT_RECONFIG
))
2702 if (bgp_debug_update(peer
, NULL
, NULL
, 1))
2703 zlog_debug("Processing route_map %s update on "
2704 "peer %s (inbound, soft-reconfig)",
2705 rmap_name
, peer
->host
);
2707 bgp_soft_reconfig_in (peer
, afi
, safi
);
2709 else if (CHECK_FLAG (peer
->cap
, PEER_CAP_REFRESH_OLD_RCV
)
2710 || CHECK_FLAG (peer
->cap
, PEER_CAP_REFRESH_NEW_RCV
))
2713 if (bgp_debug_update(peer
, NULL
, NULL
, 1))
2714 zlog_debug("Processing route_map %s update on "
2715 "peer %s (inbound, route-refresh)",
2716 rmap_name
, peer
->host
);
2717 bgp_route_refresh_send (peer
, afi
, safi
, 0, 0, 0);
2723 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_RSERVER_CLIENT
))
2727 if (update
&& route_update
&& peer
->status
== Established
)
2729 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
],
2730 PEER_FLAG_SOFT_RECONFIG
))
2732 if (bgp_debug_update(peer
, NULL
, NULL
, 1))
2733 zlog_debug("Processing route_map %s update on "
2734 "peer %s (import, soft-reconfig)",
2735 rmap_name
, peer
->host
);
2737 bgp_soft_reconfig_in (peer
, afi
, safi
);
2739 else if (CHECK_FLAG (peer
->cap
, PEER_CAP_REFRESH_OLD_RCV
)
2740 || CHECK_FLAG (peer
->cap
, PEER_CAP_REFRESH_NEW_RCV
))
2742 if (bgp_debug_update(peer
, NULL
, NULL
, 1))
2743 zlog_debug("Processing route_map %s update on "
2744 "peer %s (import, route-refresh)",
2745 rmap_name
, peer
->host
);
2746 bgp_route_refresh_send (peer
, afi
, safi
, 0, 0, 0);
2748 /* DD: Else, what else do we do ? Reset peer ? */
2753 * For outbound, unsuppress and default-originate map change (content or
2754 * map created), merely update the "config" here, the actual route
2755 * announcement happens at the group level.
2757 if (filter
->map
[RMAP_OUT
].name
&&
2758 (strcmp(rmap_name
, filter
->map
[RMAP_OUT
].name
) == 0))
2759 filter
->map
[RMAP_OUT
].map
= map
;
2761 if (filter
->usmap
.name
&&
2762 (strcmp(rmap_name
, filter
->usmap
.name
) == 0))
2763 filter
->usmap
.map
= map
;
2765 if (peer
->default_rmap
[afi
][safi
].name
&&
2766 (strcmp (rmap_name
, peer
->default_rmap
[afi
][safi
].name
) == 0))
2767 peer
->default_rmap
[afi
][safi
].map
= map
;
2771 bgp_route_map_update_peer_group(const char *rmap_name
, struct route_map
*map
,
2774 struct peer_group
*group
;
2775 struct listnode
*node
, *nnode
;
2776 struct bgp_filter
*filter
;
2783 /* All the peers have been updated correctly already. This is
2784 * just updating the placeholder data. No real update required.
2786 for (ALL_LIST_ELEMENTS (bgp
->group
, node
, nnode
, group
))
2787 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2788 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2790 filter
= &group
->conf
->filter
[afi
][safi
];
2792 for (direct
= RMAP_IN
; direct
< RMAP_MAX
; direct
++)
2794 if ((filter
->map
[direct
].name
) &&
2795 (strcmp(rmap_name
, filter
->map
[direct
].name
) == 0))
2796 filter
->map
[direct
].map
= map
;
2799 if (filter
->usmap
.name
&&
2800 (strcmp(rmap_name
, filter
->usmap
.name
) == 0))
2801 filter
->usmap
.map
= map
;
2806 * Note that if an extreme number (tens of thousands) of route-maps are in use
2807 * and if bgp has an extreme number of peers, network statements, etc then this
2808 * function can consume a lot of cycles. This is due to this function being
2809 * called for each route-map and within this function we walk the list of peers,
2810 * network statements, etc looking to see if they use this route-map.
2813 bgp_route_map_process_update (struct bgp
*bgp
, const char *rmap_name
, int route_update
)
2819 struct bgp_node
*bn
;
2820 struct bgp_static
*bgp_static
;
2821 struct listnode
*node
, *nnode
;
2822 struct route_map
*map
;
2823 char buf
[INET6_ADDRSTRLEN
];
2825 map
= route_map_lookup_by_name (rmap_name
);
2827 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
2830 /* Ignore dummy peer-group structure */
2831 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
))
2834 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2835 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2837 /* Ignore inactive AFI/SAFI */
2838 if (! peer
->afc
[afi
][safi
])
2841 /* process in/out/import/export/default-orig route-maps */
2842 bgp_route_map_process_peer(rmap_name
, map
, peer
, afi
, safi
, route_update
);
2846 /* for outbound/default-orig route-maps, process for groups */
2847 update_group_policy_update(bgp
, BGP_POLICY_ROUTE_MAP
, rmap_name
,
2850 /* update peer-group config (template) */
2851 bgp_route_map_update_peer_group(rmap_name
, map
, bgp
);
2853 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2854 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2856 /* For table route-map updates. */
2857 if (bgp
->table_map
[afi
][safi
].name
&&
2858 (strcmp(rmap_name
, bgp
->table_map
[afi
][safi
].name
) == 0))
2860 bgp
->table_map
[afi
][safi
].map
= map
;
2862 if (BGP_DEBUG (zebra
, ZEBRA
))
2863 zlog_debug("Processing route_map %s update on "
2864 "table map", rmap_name
);
2866 bgp_zebra_announce_table(bgp
, afi
, safi
);
2869 /* For network route-map updates. */
2870 for (bn
= bgp_table_top (bgp
->route
[afi
][safi
]); bn
; bn
= bgp_route_next (bn
))
2871 if ((bgp_static
= bn
->info
) != NULL
)
2873 if (bgp_static
->rmap
.name
&&
2874 (strcmp(rmap_name
, bgp_static
->rmap
.name
) == 0))
2876 bgp_static
->rmap
.map
= map
;
2879 if (!bgp_static
->backdoor
)
2881 if (bgp_debug_zebra(&bn
->p
))
2882 zlog_debug("Processing route_map %s update on "
2883 "static route %s", rmap_name
,
2884 inet_ntop (bn
->p
.family
, &bn
->p
.u
.prefix
,
2885 buf
, INET6_ADDRSTRLEN
));
2886 bgp_static_update (bgp
, &bn
->p
, bgp_static
, afi
, safi
);
2892 /* For redistribute route-map updates. */
2893 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2894 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++)
2896 struct list
*red_list
;
2897 struct listnode
*node
;
2898 struct bgp_redist
*red
;
2900 red_list
= bgp
->redist
[afi
][i
];
2904 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
))
2906 if (red
->rmap
.name
&&
2907 (strcmp(rmap_name
, red
->rmap
.name
) == 0))
2909 red
->rmap
.map
= map
;
2913 if (BGP_DEBUG (zebra
, ZEBRA
))
2914 zlog_debug("Processing route_map %s update on "
2915 "redistributed routes", rmap_name
);
2917 bgp_redistribute_resend (bgp
, afi
, i
, red
->instance
);
2925 bgp_route_map_process_update_cb (char *rmap_name
)
2927 struct listnode
*node
, *nnode
;
2930 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
2931 bgp_route_map_process_update(bgp
, rmap_name
, 1);
2937 bgp_route_map_update_timer(struct thread
*thread
)
2939 bm
->t_rmap_update
= NULL
;
2941 route_map_walk_update_list(bgp_route_map_process_update_cb
);
2947 bgp_route_map_mark_update (const char *rmap_name
)
2949 if (bm
->t_rmap_update
== NULL
)
2951 struct listnode
*node
, *nnode
;
2954 /* rmap_update_timer of 0 means don't do route updates */
2955 if (bm
->rmap_update_timer
)
2958 thread_add_timer(bm
->master
, bgp_route_map_update_timer
, NULL
,
2959 bm
->rmap_update_timer
);
2961 /* Signal the groups that a route-map update event has started */
2962 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
2963 update_group_policy_update(bgp
, BGP_POLICY_ROUTE_MAP
, rmap_name
, 1, 1);
2967 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
2968 bgp_route_map_process_update(bgp
, rmap_name
, 0);
2974 bgp_route_map_add (const char *rmap_name
)
2976 if (route_map_mark_updated(rmap_name
, 0) == 0)
2977 bgp_route_map_mark_update(rmap_name
);
2979 route_map_notify_dependencies(rmap_name
, RMAP_EVENT_MATCH_ADDED
);
2983 bgp_route_map_delete (const char *rmap_name
)
2985 if (route_map_mark_updated(rmap_name
, 1) == 0)
2986 bgp_route_map_mark_update(rmap_name
);
2988 route_map_notify_dependencies(rmap_name
, RMAP_EVENT_MATCH_DELETED
);
2992 bgp_route_map_event (route_map_event_t event
, const char *rmap_name
)
2994 if (route_map_mark_updated(rmap_name
, 0) == 0)
2995 bgp_route_map_mark_update(rmap_name
);
2997 route_map_notify_dependencies(rmap_name
, RMAP_EVENT_MATCH_ADDED
);
3003 "match peer (A.B.C.D|X:X::X:X)",
3005 "Match peer address\n"
3006 "IPv6 address of peer\n"
3007 "IP address of peer\n")
3009 return bgp_route_match_add (vty
, vty
->index
, "peer", argv
[0],
3010 RMAP_EVENT_MATCH_ADDED
);
3013 DEFUN (match_peer_local
,
3014 match_peer_local_cmd
,
3017 "Match peer address\n"
3018 "Static or Redistributed routes\n")
3020 return bgp_route_match_add (vty
, vty
->index
, "peer", "local",
3021 RMAP_EVENT_MATCH_DELETED
);
3024 DEFUN (no_match_peer
,
3029 "Match peer address\n")
3032 return bgp_route_match_delete (vty
, vty
->index
, "peer", NULL
,
3033 RMAP_EVENT_MATCH_DELETED
);
3035 return bgp_route_match_delete (vty
, vty
->index
, "peer", argv
[0],
3036 RMAP_EVENT_MATCH_DELETED
);
3039 ALIAS (no_match_peer
,
3040 no_match_peer_val_cmd
,
3041 "no match peer (A.B.C.D|X:X::X:X)",
3044 "Match peer address\n"
3045 "IPv6 address of peer\n"
3046 "IP address of peer\n")
3048 ALIAS (no_match_peer
,
3049 no_match_peer_local_cmd
,
3050 "no match peer local",
3053 "Match peer address\n"
3054 "Static or Redistributed routes\n")
3056 DEFUN (match_ip_address
,
3057 match_ip_address_cmd
,
3058 "match ip address (<1-199>|<1300-2699>|WORD)",
3061 "Match address of route\n"
3062 "IP access-list number\n"
3063 "IP access-list number (expanded range)\n"
3064 "IP Access-list name\n")
3066 return bgp_route_match_add (vty
, vty
->index
, "ip address", argv
[0],
3067 RMAP_EVENT_FILTER_ADDED
);
3070 DEFUN (no_match_ip_address
,
3071 no_match_ip_address_cmd
,
3072 "no match ip address",
3076 "Match address of route\n")
3079 return bgp_route_match_delete (vty
, vty
->index
, "ip address", NULL
,
3080 RMAP_EVENT_FILTER_DELETED
);
3082 return bgp_route_match_delete (vty
, vty
->index
, "ip address", argv
[0],
3083 RMAP_EVENT_FILTER_DELETED
);
3086 ALIAS (no_match_ip_address
,
3087 no_match_ip_address_val_cmd
,
3088 "no match ip address (<1-199>|<1300-2699>|WORD)",
3092 "Match address of route\n"
3093 "IP access-list number\n"
3094 "IP access-list number (expanded range)\n"
3095 "IP Access-list name\n")
3097 DEFUN (match_ip_next_hop
,
3098 match_ip_next_hop_cmd
,
3099 "match ip next-hop (<1-199>|<1300-2699>|WORD)",
3102 "Match next-hop address of route\n"
3103 "IP access-list number\n"
3104 "IP access-list number (expanded range)\n"
3105 "IP Access-list name\n")
3107 return bgp_route_match_add (vty
, vty
->index
, "ip next-hop", argv
[0],
3108 RMAP_EVENT_FILTER_ADDED
);
3111 DEFUN (no_match_ip_next_hop
,
3112 no_match_ip_next_hop_cmd
,
3113 "no match ip next-hop",
3117 "Match next-hop address of route\n")
3120 return bgp_route_match_delete (vty
, vty
->index
, "ip next-hop", NULL
,
3121 RMAP_EVENT_FILTER_DELETED
);
3123 return bgp_route_match_delete (vty
, vty
->index
, "ip next-hop", argv
[0],
3124 RMAP_EVENT_FILTER_DELETED
);
3127 ALIAS (no_match_ip_next_hop
,
3128 no_match_ip_next_hop_val_cmd
,
3129 "no match ip next-hop (<1-199>|<1300-2699>|WORD)",
3133 "Match next-hop address of route\n"
3134 "IP access-list number\n"
3135 "IP access-list number (expanded range)\n"
3136 "IP Access-list name\n")
3138 /* match probability { */
3140 DEFUN (match_probability
,
3141 match_probability_cmd
,
3142 "match probability <0-100>",
3144 "Match portion of routes defined by percentage value\n"
3145 "Percentage of routes\n")
3147 return bgp_route_match_add (vty
, vty
->index
, "probability", argv
[0],
3148 RMAP_EVENT_MATCH_ADDED
);
3151 DEFUN (no_match_probability
,
3152 no_match_probability_cmd
,
3153 "no match probability",
3156 "Match portion of routes defined by percentage value\n")
3158 return bgp_route_match_delete (vty
, vty
->index
, "probability", argc
? argv
[0] : NULL
,
3159 RMAP_EVENT_MATCH_DELETED
);
3162 ALIAS (no_match_probability
,
3163 no_match_probability_val_cmd
,
3164 "no match probability <1-99>",
3167 "Match portion of routes defined by percentage value\n"
3168 "Percentage of routes\n")
3172 DEFUN (match_ip_route_source
,
3173 match_ip_route_source_cmd
,
3174 "match ip route-source (<1-199>|<1300-2699>|WORD)",
3177 "Match advertising source address of route\n"
3178 "IP access-list number\n"
3179 "IP access-list number (expanded range)\n"
3180 "IP standard access-list name\n")
3182 return bgp_route_match_add (vty
, vty
->index
, "ip route-source", argv
[0],
3183 RMAP_EVENT_FILTER_ADDED
);
3186 DEFUN (no_match_ip_route_source
,
3187 no_match_ip_route_source_cmd
,
3188 "no match ip route-source",
3192 "Match advertising source address of route\n")
3195 return bgp_route_match_delete (vty
, vty
->index
, "ip route-source", NULL
,
3196 RMAP_EVENT_FILTER_DELETED
);
3198 return bgp_route_match_delete (vty
, vty
->index
, "ip route-source",
3199 argv
[0], RMAP_EVENT_FILTER_DELETED
);
3202 ALIAS (no_match_ip_route_source
,
3203 no_match_ip_route_source_val_cmd
,
3204 "no match ip route-source (<1-199>|<1300-2699>|WORD)",
3208 "Match advertising source address of route\n"
3209 "IP access-list number\n"
3210 "IP access-list number (expanded range)\n"
3211 "IP standard access-list name\n")
3213 DEFUN (match_ip_address_prefix_list
,
3214 match_ip_address_prefix_list_cmd
,
3215 "match ip address prefix-list WORD",
3218 "Match address of route\n"
3219 "Match entries of prefix-lists\n"
3220 "IP prefix-list name\n")
3222 return bgp_route_match_add (vty
, vty
->index
, "ip address prefix-list",
3223 argv
[0], RMAP_EVENT_PLIST_ADDED
);
3226 DEFUN (no_match_ip_address_prefix_list
,
3227 no_match_ip_address_prefix_list_cmd
,
3228 "no match ip address prefix-list",
3232 "Match address of route\n"
3233 "Match entries of prefix-lists\n")
3235 return bgp_route_match_delete (vty
, vty
->index
, "ip address prefix-list",
3236 argc
== 0 ? NULL
: argv
[0],
3237 RMAP_EVENT_PLIST_DELETED
);
3240 ALIAS (no_match_ip_address_prefix_list
,
3241 no_match_ip_address_prefix_list_val_cmd
,
3242 "no match ip address prefix-list WORD",
3246 "Match address of route\n"
3247 "Match entries of prefix-lists\n"
3248 "IP prefix-list name\n")
3250 DEFUN (match_ip_next_hop_prefix_list
,
3251 match_ip_next_hop_prefix_list_cmd
,
3252 "match ip next-hop prefix-list WORD",
3255 "Match next-hop address of route\n"
3256 "Match entries of prefix-lists\n"
3257 "IP prefix-list name\n")
3259 return bgp_route_match_add (vty
, vty
->index
, "ip next-hop prefix-list",
3260 argv
[0], RMAP_EVENT_PLIST_ADDED
);
3263 DEFUN (no_match_ip_next_hop_prefix_list
,
3264 no_match_ip_next_hop_prefix_list_cmd
,
3265 "no match ip next-hop prefix-list",
3269 "Match next-hop address of route\n"
3270 "Match entries of prefix-lists\n")
3272 return bgp_route_match_delete (vty
, vty
->index
, "ip next-hop prefix-list",
3273 argc
== 0 ? NULL
: argv
[0],
3274 RMAP_EVENT_PLIST_DELETED
);
3277 ALIAS (no_match_ip_next_hop_prefix_list
,
3278 no_match_ip_next_hop_prefix_list_val_cmd
,
3279 "no match ip next-hop prefix-list WORD",
3283 "Match next-hop address of route\n"
3284 "Match entries of prefix-lists\n"
3285 "IP prefix-list name\n")
3287 DEFUN (match_ip_route_source_prefix_list
,
3288 match_ip_route_source_prefix_list_cmd
,
3289 "match ip route-source prefix-list WORD",
3292 "Match advertising source address of route\n"
3293 "Match entries of prefix-lists\n"
3294 "IP prefix-list name\n")
3296 return bgp_route_match_add (vty
, vty
->index
, "ip route-source prefix-list",
3297 argv
[0], RMAP_EVENT_PLIST_ADDED
);
3300 DEFUN (no_match_ip_route_source_prefix_list
,
3301 no_match_ip_route_source_prefix_list_cmd
,
3302 "no match ip route-source prefix-list",
3306 "Match advertising source address of route\n"
3307 "Match entries of prefix-lists\n")
3309 return bgp_route_match_delete (vty
, vty
->index
, "ip route-source prefix-list",
3310 argc
== 0 ? NULL
: argv
[0],
3311 RMAP_EVENT_PLIST_DELETED
);
3314 ALIAS (no_match_ip_route_source_prefix_list
,
3315 no_match_ip_route_source_prefix_list_val_cmd
,
3316 "no match ip route-source prefix-list WORD",
3320 "Match advertising source address of route\n"
3321 "Match entries of prefix-lists\n"
3322 "IP prefix-list name\n")
3324 DEFUN (match_metric
,
3326 "match metric <0-4294967295>",
3328 "Match metric of route\n"
3331 return bgp_route_match_add (vty
, vty
->index
, "metric", argv
[0],
3332 RMAP_EVENT_MATCH_ADDED
);
3335 DEFUN (no_match_metric
,
3336 no_match_metric_cmd
,
3340 "Match metric of route\n")
3342 return bgp_route_match_delete (vty
, vty
->index
, "metric",
3343 argc
== 0 ? NULL
: argv
[0],
3344 RMAP_EVENT_MATCH_DELETED
);
3347 ALIAS (no_match_metric
,
3348 no_match_metric_val_cmd
,
3349 "no match metric <0-4294967295>",
3352 "Match metric of route\n"
3355 DEFUN (match_local_pref
,
3356 match_local_pref_cmd
,
3357 "match local-preference <0-4294967295>",
3359 "Match local-preference of route\n"
3362 return bgp_route_match_add (vty
, vty
->index
, "local-preference", argv
[0],
3363 RMAP_EVENT_MATCH_ADDED
);
3366 DEFUN (no_match_local_pref
,
3367 no_match_local_pref_cmd
,
3368 "no match local-preference",
3371 "Match local preference of route\n")
3373 return bgp_route_match_delete (vty
, vty
->index
, "local-preference",
3374 argc
== 0 ? NULL
: argv
[0],
3375 RMAP_EVENT_MATCH_DELETED
);
3377 return bgp_route_match_delete (vty
, vty
->index
, "local-preference", argv
[0],
3378 RMAP_EVENT_MATCH_DELETED
);
3381 ALIAS (no_match_local_pref
,
3382 no_match_local_pref_val_cmd
,
3383 "no match local-preference <0-4294967295>",
3386 "Match local preference of route\n"
3387 "Local preference value\n")
3389 DEFUN (match_community
,
3390 match_community_cmd
,
3391 "match community (<1-99>|<100-500>|WORD)",
3393 "Match BGP community list\n"
3394 "Community-list number (standard)\n"
3395 "Community-list number (expanded)\n"
3396 "Community-list name\n")
3398 return bgp_route_match_add (vty
, vty
->index
, "community", argv
[0],
3399 RMAP_EVENT_CLIST_ADDED
);
3402 DEFUN (match_community_exact
,
3403 match_community_exact_cmd
,
3404 "match community (<1-99>|<100-500>|WORD) exact-match",
3406 "Match BGP community list\n"
3407 "Community-list number (standard)\n"
3408 "Community-list number (expanded)\n"
3409 "Community-list name\n"
3410 "Do exact matching of communities\n")
3415 argstr
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
,
3416 strlen (argv
[0]) + strlen ("exact-match") + 2);
3418 sprintf (argstr
, "%s exact-match", argv
[0]);
3420 ret
= bgp_route_match_add (vty
, vty
->index
, "community", argstr
,
3421 RMAP_EVENT_CLIST_ADDED
);
3423 XFREE (MTYPE_ROUTE_MAP_COMPILED
, argstr
);
3428 DEFUN (no_match_community
,
3429 no_match_community_cmd
,
3430 "no match community",
3433 "Match BGP community list\n")
3435 return bgp_route_match_delete (vty
, vty
->index
, "community", NULL
,
3436 RMAP_EVENT_CLIST_DELETED
);
3439 ALIAS (no_match_community
,
3440 no_match_community_val_cmd
,
3441 "no match community (<1-99>|<100-500>|WORD)",
3444 "Match BGP community list\n"
3445 "Community-list number (standard)\n"
3446 "Community-list number (expanded)\n"
3447 "Community-list name\n")
3449 ALIAS (no_match_community
,
3450 no_match_community_exact_cmd
,
3451 "no match community (<1-99>|<100-500>|WORD) exact-match",
3454 "Match BGP community list\n"
3455 "Community-list number (standard)\n"
3456 "Community-list number (expanded)\n"
3457 "Community-list name\n"
3458 "Do exact matching of communities\n")
3460 DEFUN (match_ecommunity
,
3461 match_ecommunity_cmd
,
3462 "match extcommunity (<1-99>|<100-500>|WORD)",
3464 "Match BGP/VPN extended community list\n"
3465 "Extended community-list number (standard)\n"
3466 "Extended community-list number (expanded)\n"
3467 "Extended community-list name\n")
3469 return bgp_route_match_add (vty
, vty
->index
, "extcommunity", argv
[0],
3470 RMAP_EVENT_ECLIST_ADDED
);
3473 DEFUN (no_match_ecommunity
,
3474 no_match_ecommunity_cmd
,
3475 "no match extcommunity",
3478 "Match BGP/VPN extended community list\n")
3480 return bgp_route_match_delete (vty
, vty
->index
, "extcommunity", NULL
,
3481 RMAP_EVENT_ECLIST_DELETED
);
3484 ALIAS (no_match_ecommunity
,
3485 no_match_ecommunity_val_cmd
,
3486 "no match extcommunity (<1-99>|<100-500>|WORD)",
3489 "Match BGP/VPN extended community list\n"
3490 "Extended community-list number (standard)\n"
3491 "Extended community-list number (expanded)\n"
3492 "Extended community-list name\n")
3494 DEFUN (match_aspath
,
3496 "match as-path WORD",
3498 "Match BGP AS path list\n"
3499 "AS path access-list name\n")
3501 return bgp_route_match_add (vty
, vty
->index
, "as-path", argv
[0],
3502 RMAP_EVENT_ASLIST_ADDED
);
3505 DEFUN (no_match_aspath
,
3506 no_match_aspath_cmd
,
3510 "Match BGP AS path list\n")
3512 return bgp_route_match_delete (vty
, vty
->index
, "as-path", NULL
,
3513 RMAP_EVENT_ASLIST_DELETED
);
3516 ALIAS (no_match_aspath
,
3517 no_match_aspath_val_cmd
,
3518 "no match as-path WORD",
3521 "Match BGP AS path list\n"
3522 "AS path access-list name\n")
3524 DEFUN (match_origin
,
3526 "match origin (egp|igp|incomplete)",
3531 "unknown heritage\n")
3533 if (strncmp (argv
[0], "igp", 2) == 0)
3534 return bgp_route_match_add (vty
, vty
->index
, "origin", "igp",
3535 RMAP_EVENT_MATCH_ADDED
);
3536 if (strncmp (argv
[0], "egp", 1) == 0)
3537 return bgp_route_match_add (vty
, vty
->index
, "origin", "egp",
3538 RMAP_EVENT_MATCH_ADDED
);
3539 if (strncmp (argv
[0], "incomplete", 2) == 0)
3540 return bgp_route_match_add (vty
, vty
->index
, "origin", "incomplete",
3541 RMAP_EVENT_MATCH_ADDED
);
3546 DEFUN (no_match_origin
,
3547 no_match_origin_cmd
,
3551 "BGP origin code\n")
3553 return bgp_route_match_delete (vty
, vty
->index
, "origin", NULL
,
3554 RMAP_EVENT_MATCH_DELETED
);
3557 ALIAS (no_match_origin
,
3558 no_match_origin_val_cmd
,
3559 "no match origin (egp|igp|incomplete)",
3565 "unknown heritage\n")
3567 DEFUN (match_interface
,
3568 match_interface_cmd
,
3569 "match interface WORD",
3571 "Match first hop interface of route\n"
3574 return bgp_route_match_add (vty
, vty
->index
, "interface", argv
[0],
3575 RMAP_EVENT_MATCH_ADDED
);
3578 DEFUN (no_match_interface
,
3579 no_match_interface_cmd
,
3580 "no match interface",
3583 "Match first hop interface of route\n")
3586 return bgp_route_match_delete (vty
, vty
->index
, "interface", NULL
,
3587 RMAP_EVENT_MATCH_DELETED
);
3589 return bgp_route_match_delete (vty
, vty
->index
, "interface", argv
[0],
3590 RMAP_EVENT_MATCH_DELETED
);
3593 ALIAS (no_match_interface
,
3594 no_match_interface_val_cmd
,
3595 "no match interface WORD",
3598 "Match first hop interface of route\n"
3603 "match tag <1-65535>",
3605 "Match tag of route\n"
3608 return bgp_route_match_add (vty
, vty
->index
, "tag", argv
[0],
3609 RMAP_EVENT_MATCH_ADDED
);
3612 DEFUN (no_match_tag
,
3617 "Match tag of route\n")
3620 return bgp_route_match_delete (vty
, vty
->index
, "tag", NULL
,
3621 RMAP_EVENT_MATCH_DELETED
);
3623 return bgp_route_match_delete (vty
, vty
->index
, "tag", argv
[0],
3624 RMAP_EVENT_MATCH_DELETED
);
3627 ALIAS (no_match_tag
,
3628 no_match_tag_val_cmd
,
3629 "no match tag <1-65535>",
3632 "Match tag of route\n"
3636 DEFUN (set_ip_nexthop
,
3638 "set ip next-hop A.B.C.D",
3641 "Next hop address\n"
3642 "IP address of next hop\n")
3647 ret
= str2sockunion (argv
[0], &su
);
3650 vty_out (vty
, "%% Malformed nexthop address%s", VTY_NEWLINE
);
3653 if (su
.sin
.sin_addr
.s_addr
== 0 ||
3654 IPV4_CLASS_DE(su
.sin
.sin_addr
.s_addr
))
3656 vty_out (vty
, "%% nexthop address cannot be 0.0.0.0, multicast "
3657 "or reserved%s", VTY_NEWLINE
);
3661 return bgp_route_set_add (vty
, vty
->index
, "ip next-hop", argv
[0]);
3664 DEFUN (set_ip_nexthop_peer
,
3665 set_ip_nexthop_peer_cmd
,
3666 "set ip next-hop peer-address",
3669 "Next hop address\n"
3670 "Use peer address (for BGP only)\n")
3672 return bgp_route_set_add (vty
, vty
->index
, "ip next-hop", "peer-address");
3675 DEFUN (set_ip_nexthop_unchanged
,
3676 set_ip_nexthop_unchanged_cmd
,
3677 "set ip next-hop unchanged",
3680 "Next hop address\n"
3681 "Don't modify existing Next hop address\n")
3683 return bgp_route_set_add (vty
, vty
->index
, "ip next-hop", "unchanged");
3686 DEFUN (no_set_ip_nexthop
,
3687 no_set_ip_nexthop_cmd
,
3688 "no set ip next-hop",
3691 "Next hop address\n")
3694 return bgp_route_set_delete (vty
, vty
->index
, "ip next-hop", NULL
);
3696 return bgp_route_set_delete (vty
, vty
->index
, "ip next-hop", argv
[0]);
3699 ALIAS (no_set_ip_nexthop
,
3700 no_set_ip_nexthop_val_cmd
,
3701 "no set ip next-hop A.B.C.D",
3705 "Next hop address\n"
3706 "IP address of next hop\n")
3708 ALIAS (no_set_ip_nexthop
,
3709 no_set_ip_nexthop_peer_cmd
,
3710 "no set ip next-hop peer-address",
3714 "Next hop address\n"
3715 "Use peer address (for BGP only)\n")
3719 "set metric <0-4294967295>",
3721 "Metric value for destination routing protocol\n"
3724 return bgp_route_set_add (vty
, vty
->index
, "metric", argv
[0]);
3728 set_metric_addsub_cmd
,
3729 "set metric <+/-metric>",
3731 "Metric value for destination routing protocol\n"
3732 "Add or subtract metric\n")
3734 DEFUN (no_set_metric
,
3739 "Metric value for destination routing protocol\n")
3742 return bgp_route_set_delete (vty
, vty
->index
, "metric", NULL
);
3744 return bgp_route_set_delete (vty
, vty
->index
, "metric", argv
[0]);
3747 ALIAS (no_set_metric
,
3748 no_set_metric_val_cmd
,
3749 "no set metric <0-4294967295>",
3752 "Metric value for destination routing protocol\n"
3755 DEFUN (set_local_pref
,
3757 "set local-preference <0-4294967295>",
3759 "BGP local preference path attribute\n"
3760 "Preference value\n")
3762 return bgp_route_set_add (vty
, vty
->index
, "local-preference", argv
[0]);
3765 DEFUN (no_set_local_pref
,
3766 no_set_local_pref_cmd
,
3767 "no set local-preference",
3770 "BGP local preference path attribute\n")
3773 return bgp_route_set_delete (vty
, vty
->index
, "local-preference", NULL
);
3775 return bgp_route_set_delete (vty
, vty
->index
, "local-preference", argv
[0]);
3778 ALIAS (no_set_local_pref
,
3779 no_set_local_pref_val_cmd
,
3780 "no set local-preference <0-4294967295>",
3783 "BGP local preference path attribute\n"
3784 "Preference value\n")
3788 "set weight <0-4294967295>",
3790 "BGP weight for routing table\n"
3793 return bgp_route_set_add (vty
, vty
->index
, "weight", argv
[0]);
3796 DEFUN (no_set_weight
,
3801 "BGP weight for routing table\n")
3804 return bgp_route_set_delete (vty
, vty
->index
, "weight", NULL
);
3806 return bgp_route_set_delete (vty
, vty
->index
, "weight", argv
[0]);
3809 ALIAS (no_set_weight
,
3810 no_set_weight_val_cmd
,
3811 "no set weight <0-4294967295>",
3814 "BGP weight for routing table\n"
3817 DEFUN (set_aspath_prepend
,
3818 set_aspath_prepend_cmd
,
3819 "set as-path prepend ." CMD_AS_RANGE
,
3821 "Transform BGP AS_PATH attribute\n"
3822 "Prepend to the as-path\n"
3828 str
= argv_concat (argv
, argc
, 0);
3829 ret
= bgp_route_set_add (vty
, vty
->index
, "as-path prepend", str
);
3830 XFREE (MTYPE_TMP
, str
);
3835 ALIAS (set_aspath_prepend
,
3836 set_aspath_prepend_lastas_cmd
,
3837 "set as-path prepend (last-as) <1-10>",
3839 "Transform BGP AS_PATH attribute\n"
3840 "Prepend to the as-path\n"
3841 "Use the peer's AS-number\n"
3842 "Number of times to insert");
3844 DEFUN (no_set_aspath_prepend
,
3845 no_set_aspath_prepend_cmd
,
3846 "no set as-path prepend",
3849 "Transform BGP AS_PATH attribute\n"
3850 "Prepend to the as-path\n")
3856 return bgp_route_set_delete (vty
, vty
->index
, "as-path prepend", NULL
);
3858 str
= argv_concat (argv
, argc
, 0);
3859 ret
= bgp_route_set_delete (vty
, vty
->index
, "as-path prepend", str
);
3860 XFREE (MTYPE_TMP
, str
);
3864 ALIAS (no_set_aspath_prepend
,
3865 no_set_aspath_prepend_val_cmd
,
3866 "no set as-path prepend ." CMD_AS_RANGE
,
3869 "Transform BGP AS_PATH attribute\n"
3870 "Prepend to the as-path\n"
3873 DEFUN (set_aspath_exclude
,
3874 set_aspath_exclude_cmd
,
3875 "set as-path exclude ." CMD_AS_RANGE
,
3877 "Transform BGP AS-path attribute\n"
3878 "Exclude from the as-path\n"
3884 str
= argv_concat (argv
, argc
, 0);
3885 ret
= bgp_route_set_add (vty
, vty
->index
, "as-path exclude", str
);
3886 XFREE (MTYPE_TMP
, str
);
3890 DEFUN (no_set_aspath_exclude
,
3891 no_set_aspath_exclude_cmd
,
3892 "no set as-path exclude",
3895 "Transform BGP AS_PATH attribute\n"
3896 "Exclude from the as-path\n")
3902 return bgp_route_set_delete (vty
, vty
->index
, "as-path exclude", NULL
);
3904 str
= argv_concat (argv
, argc
, 0);
3905 ret
= bgp_route_set_delete (vty
, vty
->index
, "as-path exclude", str
);
3906 XFREE (MTYPE_TMP
, str
);
3910 ALIAS (no_set_aspath_exclude
,
3911 no_set_aspath_exclude_val_cmd
,
3912 "no set as-path exclude ." CMD_AS_RANGE
,
3915 "Transform BGP AS_PATH attribute\n"
3916 "Exclude from the as-path\n"
3919 DEFUN (set_community
,
3921 "set community .AA:NN",
3923 "BGP community attribute\n"
3930 struct community
*com
= NULL
;
3935 b
= buffer_new (1024);
3937 for (i
= 0; i
< argc
; i
++)
3939 if (strncmp (argv
[i
], "additive", strlen (argv
[i
])) == 0)
3946 buffer_putc (b
, ' ');
3950 if (strncmp (argv
[i
], "internet", strlen (argv
[i
])) == 0)
3952 buffer_putstr (b
, "internet");
3955 if (strncmp (argv
[i
], "local-AS", strlen (argv
[i
])) == 0)
3957 buffer_putstr (b
, "local-AS");
3960 if (strncmp (argv
[i
], "no-a", strlen ("no-a")) == 0
3961 && strncmp (argv
[i
], "no-advertise", strlen (argv
[i
])) == 0)
3963 buffer_putstr (b
, "no-advertise");
3966 if (strncmp (argv
[i
], "no-e", strlen ("no-e"))== 0
3967 && strncmp (argv
[i
], "no-export", strlen (argv
[i
])) == 0)
3969 buffer_putstr (b
, "no-export");
3972 buffer_putstr (b
, argv
[i
]);
3974 buffer_putc (b
, '\0');
3976 /* Fetch result string then compile it to communities attribute. */
3977 str
= buffer_getstr (b
);
3982 com
= community_str2com (str
);
3983 XFREE (MTYPE_TMP
, str
);
3986 /* Can't compile user input into communities attribute. */
3989 vty_out (vty
, "%% Malformed communities attribute%s", VTY_NEWLINE
);
3993 /* Set communites attribute string. */
3994 str
= community_str (com
);
3998 argstr
= XCALLOC (MTYPE_TMP
, strlen (str
) + strlen (" additive") + 1);
3999 strcpy (argstr
, str
);
4000 strcpy (argstr
+ strlen (str
), " additive");
4001 ret
= bgp_route_set_add (vty
, vty
->index
, "community", argstr
);
4002 XFREE (MTYPE_TMP
, argstr
);
4005 ret
= bgp_route_set_add (vty
, vty
->index
, "community", str
);
4007 community_free (com
);
4012 DEFUN (set_community_none
,
4013 set_community_none_cmd
,
4014 "set community none",
4016 "BGP community attribute\n"
4017 "No community attribute\n")
4019 return bgp_route_set_add (vty
, vty
->index
, "community", "none");
4022 DEFUN (no_set_community
,
4023 no_set_community_cmd
,
4027 "BGP community attribute\n")
4029 return bgp_route_set_delete (vty
, vty
->index
, "community", NULL
);
4032 ALIAS (no_set_community
,
4033 no_set_community_val_cmd
,
4034 "no set community .AA:NN",
4037 "BGP community attribute\n"
4040 ALIAS (no_set_community
,
4041 no_set_community_none_cmd
,
4042 "no set community none",
4045 "BGP community attribute\n"
4046 "No community attribute\n")
4048 DEFUN (set_community_delete
,
4049 set_community_delete_cmd
,
4050 "set comm-list (<1-99>|<100-500>|WORD) delete",
4052 "set BGP community list (for deletion)\n"
4053 "Community-list number (standard)\n"
4054 "Community-list number (expanded)\n"
4055 "Community-list name\n"
4056 "Delete matching communities\n")
4060 str
= XCALLOC (MTYPE_TMP
, strlen (argv
[0]) + strlen (" delete") + 1);
4061 strcpy (str
, argv
[0]);
4062 strcpy (str
+ strlen (argv
[0]), " delete");
4064 bgp_route_set_add (vty
, vty
->index
, "comm-list", str
);
4066 XFREE (MTYPE_TMP
, str
);
4070 DEFUN (no_set_community_delete
,
4071 no_set_community_delete_cmd
,
4075 "set BGP community list (for deletion)\n")
4077 return bgp_route_set_delete (vty
, vty
->index
, "comm-list", NULL
);
4080 ALIAS (no_set_community_delete
,
4081 no_set_community_delete_val_cmd
,
4082 "no set comm-list (<1-99>|<100-500>|WORD) delete",
4085 "set BGP community list (for deletion)\n"
4086 "Community-list number (standard)\n"
4087 "Community-list number (expanded)\n"
4088 "Community-list name\n"
4089 "Delete matching communities\n")
4091 DEFUN (set_ecommunity_rt
,
4092 set_ecommunity_rt_cmd
,
4093 "set extcommunity rt .ASN:nn_or_IP-address:nn",
4095 "BGP extended community attribute\n"
4096 "Route Target extended community\n"
4097 "VPN extended community\n")
4102 str
= argv_concat (argv
, argc
, 0);
4103 ret
= bgp_route_set_add (vty
, vty
->index
, "extcommunity rt", str
);
4104 XFREE (MTYPE_TMP
, str
);
4109 DEFUN (no_set_ecommunity_rt
,
4110 no_set_ecommunity_rt_cmd
,
4111 "no set extcommunity rt",
4114 "BGP extended community attribute\n"
4115 "Route Target extended community\n")
4117 return bgp_route_set_delete (vty
, vty
->index
, "extcommunity rt", NULL
);
4120 ALIAS (no_set_ecommunity_rt
,
4121 no_set_ecommunity_rt_val_cmd
,
4122 "no set extcommunity rt .ASN:nn_or_IP-address:nn",
4125 "BGP extended community attribute\n"
4126 "Route Target extended community\n"
4127 "VPN extended community\n")
4129 DEFUN (set_ecommunity_soo
,
4130 set_ecommunity_soo_cmd
,
4131 "set extcommunity soo .ASN:nn_or_IP-address:nn",
4133 "BGP extended community attribute\n"
4134 "Site-of-Origin extended community\n"
4135 "VPN extended community\n")
4140 str
= argv_concat (argv
, argc
, 0);
4141 ret
= bgp_route_set_add (vty
, vty
->index
, "extcommunity soo", str
);
4142 XFREE (MTYPE_TMP
, str
);
4146 DEFUN (no_set_ecommunity_soo
,
4147 no_set_ecommunity_soo_cmd
,
4148 "no set extcommunity soo",
4151 "BGP extended community attribute\n"
4152 "Site-of-Origin extended community\n")
4154 return bgp_route_set_delete (vty
, vty
->index
, "extcommunity soo", NULL
);
4157 ALIAS (no_set_ecommunity_soo
,
4158 no_set_ecommunity_soo_val_cmd
,
4159 "no set extcommunity soo .ASN:nn_or_IP-address:nn",
4162 "BGP extended community attribute\n"
4163 "Site-of-Origin extended community\n"
4164 "VPN extended community\n")
4168 "set origin (egp|igp|incomplete)",
4173 "unknown heritage\n")
4175 if (strncmp (argv
[0], "igp", 2) == 0)
4176 return bgp_route_set_add (vty
, vty
->index
, "origin", "igp");
4177 if (strncmp (argv
[0], "egp", 1) == 0)
4178 return bgp_route_set_add (vty
, vty
->index
, "origin", "egp");
4179 if (strncmp (argv
[0], "incomplete", 2) == 0)
4180 return bgp_route_set_add (vty
, vty
->index
, "origin", "incomplete");
4185 DEFUN (no_set_origin
,
4190 "BGP origin code\n")
4192 return bgp_route_set_delete (vty
, vty
->index
, "origin", NULL
);
4195 ALIAS (no_set_origin
,
4196 no_set_origin_val_cmd
,
4197 "no set origin (egp|igp|incomplete)",
4203 "unknown heritage\n")
4205 DEFUN (set_atomic_aggregate
,
4206 set_atomic_aggregate_cmd
,
4207 "set atomic-aggregate",
4209 "BGP atomic aggregate attribute\n" )
4211 return bgp_route_set_add (vty
, vty
->index
, "atomic-aggregate", NULL
);
4214 DEFUN (no_set_atomic_aggregate
,
4215 no_set_atomic_aggregate_cmd
,
4216 "no set atomic-aggregate",
4219 "BGP atomic aggregate attribute\n" )
4221 return bgp_route_set_delete (vty
, vty
->index
, "atomic-aggregate", NULL
);
4224 DEFUN (set_aggregator_as
,
4225 set_aggregator_as_cmd
,
4226 "set aggregator as " CMD_AS_RANGE
" A.B.C.D",
4228 "BGP aggregator attribute\n"
4229 "AS number of aggregator\n"
4231 "IP address of aggregator\n")
4234 struct in_addr address
;
4237 ret
= inet_aton (argv
[1], &address
);
4240 vty_out (vty
, "Aggregator IP address is invalid%s", VTY_NEWLINE
);
4244 argstr
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
,
4245 strlen (argv
[0]) + strlen (argv
[1]) + 2);
4247 sprintf (argstr
, "%s %s", argv
[0], argv
[1]);
4249 ret
= bgp_route_set_add (vty
, vty
->index
, "aggregator as", argstr
);
4251 XFREE (MTYPE_ROUTE_MAP_COMPILED
, argstr
);
4256 DEFUN (no_set_aggregator_as
,
4257 no_set_aggregator_as_cmd
,
4258 "no set aggregator as",
4261 "BGP aggregator attribute\n"
4262 "AS number of aggregator\n")
4265 struct in_addr address
;
4269 return bgp_route_set_delete (vty
, vty
->index
, "aggregator as", NULL
);
4271 ret
= inet_aton (argv
[1], &address
);
4274 vty_out (vty
, "Aggregator IP address is invalid%s", VTY_NEWLINE
);
4278 argstr
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
,
4279 strlen (argv
[0]) + strlen (argv
[1]) + 2);
4281 sprintf (argstr
, "%s %s", argv
[0], argv
[1]);
4283 ret
= bgp_route_set_delete (vty
, vty
->index
, "aggregator as", argstr
);
4285 XFREE (MTYPE_ROUTE_MAP_COMPILED
, argstr
);
4290 ALIAS (no_set_aggregator_as
,
4291 no_set_aggregator_as_val_cmd
,
4292 "no set aggregator as " CMD_AS_RANGE
" A.B.C.D",
4295 "BGP aggregator attribute\n"
4296 "AS number of aggregator\n"
4298 "IP address of aggregator\n")
4302 "set tag <1-65535>",
4304 "Tag value for routing protocol\n"
4307 return bgp_route_set_add (vty
, vty
->index
, "tag", argv
[0]);
4315 "Tag value for routing protocol\n")
4318 bgp_route_set_delete(vty
, vty
->index
, "tag", NULL
);
4320 return bgp_route_set_delete (vty
, vty
->index
, "tag", argv
[0]);
4325 "no set tag <1-65535>",
4328 "Tag value for routing protocol\n"
4333 DEFUN (match_ipv6_address
,
4334 match_ipv6_address_cmd
,
4335 "match ipv6 address WORD",
4338 "Match IPv6 address of route\n"
4339 "IPv6 access-list name\n")
4341 return bgp_route_match_add (vty
, vty
->index
, "ipv6 address", argv
[0],
4342 RMAP_EVENT_FILTER_ADDED
);
4345 DEFUN (no_match_ipv6_address
,
4346 no_match_ipv6_address_cmd
,
4347 "no match ipv6 address WORD",
4351 "Match IPv6 address of route\n"
4352 "IPv6 access-list name\n")
4354 return bgp_route_match_delete (vty
, vty
->index
, "ipv6 address", argv
[0],
4355 RMAP_EVENT_FILTER_DELETED
);
4358 DEFUN (match_ipv6_next_hop
,
4359 match_ipv6_next_hop_cmd
,
4360 "match ipv6 next-hop X:X::X:X",
4363 "Match IPv6 next-hop address of route\n"
4364 "IPv6 address of next hop\n")
4366 return bgp_route_match_add (vty
, vty
->index
, "ipv6 next-hop", argv
[0],
4367 RMAP_EVENT_MATCH_ADDED
);
4370 DEFUN (no_match_ipv6_next_hop
,
4371 no_match_ipv6_next_hop_cmd
,
4372 "no match ipv6 next-hop X:X::X:X",
4376 "Match IPv6 next-hop address of route\n"
4377 "IPv6 address of next hop\n")
4379 return bgp_route_match_delete (vty
, vty
->index
, "ipv6 next-hop", argv
[0],
4380 RMAP_EVENT_MATCH_DELETED
);
4383 DEFUN (match_ipv6_address_prefix_list
,
4384 match_ipv6_address_prefix_list_cmd
,
4385 "match ipv6 address prefix-list WORD",
4388 "Match address of route\n"
4389 "Match entries of prefix-lists\n"
4390 "IP prefix-list name\n")
4392 return bgp_route_match_add (vty
, vty
->index
, "ipv6 address prefix-list",
4393 argv
[0], RMAP_EVENT_PLIST_ADDED
);
4396 DEFUN (no_match_ipv6_address_prefix_list
,
4397 no_match_ipv6_address_prefix_list_cmd
,
4398 "no match ipv6 address prefix-list WORD",
4402 "Match address of route\n"
4403 "Match entries of prefix-lists\n"
4404 "IP prefix-list name\n")
4406 return bgp_route_match_delete (vty
, vty
->index
, "ipv6 address prefix-list",
4407 argv
[0], RMAP_EVENT_PLIST_DELETED
);
4410 DEFUN (set_ipv6_nexthop_peer
,
4411 set_ipv6_nexthop_peer_cmd
,
4412 "set ipv6 next-hop peer-address",
4415 "Next hop address\n"
4416 "Use peer address (for BGP only)\n")
4418 return bgp_route_set_add (vty
, vty
->index
, "ipv6 next-hop peer-address", NULL
);
4421 DEFUN (no_set_ipv6_nexthop_peer
,
4422 no_set_ipv6_nexthop_peer_cmd
,
4423 "no set ipv6 next-hop peer-address",
4427 "IPv6 next-hop address\n"
4430 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop peer-address", NULL
);
4433 DEFUN (set_ipv6_nexthop_global
,
4434 set_ipv6_nexthop_global_cmd
,
4435 "set ipv6 next-hop global X:X::X:X",
4438 "IPv6 next-hop address\n"
4439 "IPv6 global address\n"
4440 "IPv6 address of next hop\n")
4442 struct in6_addr addr
;
4445 ret
= inet_pton (AF_INET6
, argv
[0], &addr
);
4448 vty_out (vty
, "%% Malformed nexthop address%s", VTY_NEWLINE
);
4451 if (IN6_IS_ADDR_UNSPECIFIED(&addr
) ||
4452 IN6_IS_ADDR_LOOPBACK(&addr
) ||
4453 IN6_IS_ADDR_MULTICAST(&addr
) ||
4454 IN6_IS_ADDR_LINKLOCAL(&addr
))
4456 vty_out (vty
, "%% Invalid global nexthop address%s", VTY_NEWLINE
);
4460 return bgp_route_set_add (vty
, vty
->index
, "ipv6 next-hop global", argv
[0]);
4463 DEFUN (no_set_ipv6_nexthop_global
,
4464 no_set_ipv6_nexthop_global_cmd
,
4465 "no set ipv6 next-hop global",
4469 "IPv6 next-hop address\n"
4470 "IPv6 global address\n")
4473 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop global", NULL
);
4475 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop global", argv
[0]);
4478 ALIAS (no_set_ipv6_nexthop_global
,
4479 no_set_ipv6_nexthop_global_val_cmd
,
4480 "no set ipv6 next-hop global X:X::X:X",
4484 "IPv6 next-hop address\n"
4485 "IPv6 global address\n"
4486 "IPv6 address of next hop\n")
4488 DEFUN (set_ipv6_nexthop_local
,
4489 set_ipv6_nexthop_local_cmd
,
4490 "set ipv6 next-hop local X:X::X:X",
4493 "IPv6 next-hop address\n"
4494 "IPv6 local address\n"
4495 "IPv6 address of next hop\n")
4497 struct in6_addr addr
;
4500 ret
= inet_pton (AF_INET6
, argv
[0], &addr
);
4503 vty_out (vty
, "%% Malformed nexthop address%s", VTY_NEWLINE
);
4506 if (!IN6_IS_ADDR_LINKLOCAL(&addr
))
4508 vty_out (vty
, "%% Invalid link-local nexthop address%s", VTY_NEWLINE
);
4512 return bgp_route_set_add (vty
, vty
->index
, "ipv6 next-hop local", argv
[0]);
4515 DEFUN (no_set_ipv6_nexthop_local
,
4516 no_set_ipv6_nexthop_local_cmd
,
4517 "no set ipv6 next-hop local",
4521 "IPv6 next-hop address\n"
4522 "IPv6 local address\n")
4525 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop local", NULL
);
4527 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop local", argv
[0]);
4530 ALIAS (no_set_ipv6_nexthop_local
,
4531 no_set_ipv6_nexthop_local_val_cmd
,
4532 "no set ipv6 next-hop local X:X::X:X",
4536 "IPv6 next-hop address\n"
4537 "IPv6 local address\n"
4538 "IPv6 address of next hop\n")
4539 #endif /* HAVE_IPV6 */
4541 DEFUN (set_vpnv4_nexthop
,
4542 set_vpnv4_nexthop_cmd
,
4543 "set vpnv4 next-hop A.B.C.D",
4545 "VPNv4 information\n"
4546 "VPNv4 next-hop address\n"
4547 "IP address of next hop\n")
4549 return bgp_route_set_add (vty
, vty
->index
, "vpnv4 next-hop", argv
[0]);
4552 DEFUN (no_set_vpnv4_nexthop
,
4553 no_set_vpnv4_nexthop_cmd
,
4554 "no set vpnv4 next-hop",
4557 "VPNv4 information\n"
4558 "VPNv4 next-hop address\n")
4561 return bgp_route_set_delete (vty
, vty
->index
, "vpnv4 next-hop", NULL
);
4563 return bgp_route_set_delete (vty
, vty
->index
, "vpnv4 next-hop", argv
[0]);
4566 ALIAS (no_set_vpnv4_nexthop
,
4567 no_set_vpnv4_nexthop_val_cmd
,
4568 "no set vpnv4 next-hop A.B.C.D",
4571 "VPNv4 information\n"
4572 "VPNv4 next-hop address\n"
4573 "IP address of next hop\n")
4575 DEFUN (set_originator_id
,
4576 set_originator_id_cmd
,
4577 "set originator-id A.B.C.D",
4579 "BGP originator ID attribute\n"
4580 "IP address of originator\n")
4582 return bgp_route_set_add (vty
, vty
->index
, "originator-id", argv
[0]);
4585 DEFUN (no_set_originator_id
,
4586 no_set_originator_id_cmd
,
4587 "no set originator-id",
4590 "BGP originator ID attribute\n")
4593 return bgp_route_set_delete (vty
, vty
->index
, "originator-id", NULL
);
4595 return bgp_route_set_delete (vty
, vty
->index
, "originator-id", argv
[0]);
4598 ALIAS (no_set_originator_id
,
4599 no_set_originator_id_val_cmd
,
4600 "no set originator-id A.B.C.D",
4603 "BGP originator ID attribute\n"
4604 "IP address of originator\n")
4606 /* Initialization of route map. */
4608 bgp_route_map_init (void)
4611 route_map_init_vty ();
4612 route_map_add_hook (bgp_route_map_add
);
4613 route_map_delete_hook (bgp_route_map_delete
);
4614 route_map_event_hook (bgp_route_map_event
);
4616 route_map_install_match (&route_match_peer_cmd
);
4617 route_map_install_match (&route_match_local_pref_cmd
);
4618 route_map_install_match (&route_match_ip_address_cmd
);
4619 route_map_install_match (&route_match_ip_next_hop_cmd
);
4620 route_map_install_match (&route_match_ip_route_source_cmd
);
4621 route_map_install_match (&route_match_ip_address_prefix_list_cmd
);
4622 route_map_install_match (&route_match_ip_next_hop_prefix_list_cmd
);
4623 route_map_install_match (&route_match_ip_route_source_prefix_list_cmd
);
4624 route_map_install_match (&route_match_aspath_cmd
);
4625 route_map_install_match (&route_match_community_cmd
);
4626 route_map_install_match (&route_match_ecommunity_cmd
);
4627 route_map_install_match (&route_match_local_pref_cmd
);
4628 route_map_install_match (&route_match_metric_cmd
);
4629 route_map_install_match (&route_match_origin_cmd
);
4630 route_map_install_match (&route_match_probability_cmd
);
4631 route_map_install_match (&route_match_interface_cmd
);
4632 route_map_install_match (&route_match_tag_cmd
);
4634 route_map_install_set (&route_set_ip_nexthop_cmd
);
4635 route_map_install_set (&route_set_local_pref_cmd
);
4636 route_map_install_set (&route_set_weight_cmd
);
4637 route_map_install_set (&route_set_metric_cmd
);
4638 route_map_install_set (&route_set_aspath_prepend_cmd
);
4639 route_map_install_set (&route_set_aspath_exclude_cmd
);
4640 route_map_install_set (&route_set_origin_cmd
);
4641 route_map_install_set (&route_set_atomic_aggregate_cmd
);
4642 route_map_install_set (&route_set_aggregator_as_cmd
);
4643 route_map_install_set (&route_set_community_cmd
);
4644 route_map_install_set (&route_set_community_delete_cmd
);
4645 route_map_install_set (&route_set_vpnv4_nexthop_cmd
);
4646 route_map_install_set (&route_set_originator_id_cmd
);
4647 route_map_install_set (&route_set_ecommunity_rt_cmd
);
4648 route_map_install_set (&route_set_ecommunity_soo_cmd
);
4649 route_map_install_set (&route_set_tag_cmd
);
4651 install_element (RMAP_NODE
, &match_peer_cmd
);
4652 install_element (RMAP_NODE
, &match_peer_local_cmd
);
4653 install_element (RMAP_NODE
, &no_match_peer_cmd
);
4654 install_element (RMAP_NODE
, &no_match_peer_val_cmd
);
4655 install_element (RMAP_NODE
, &no_match_peer_local_cmd
);
4656 install_element (RMAP_NODE
, &match_ip_address_cmd
);
4657 install_element (RMAP_NODE
, &no_match_ip_address_cmd
);
4658 install_element (RMAP_NODE
, &no_match_ip_address_val_cmd
);
4659 install_element (RMAP_NODE
, &match_ip_next_hop_cmd
);
4660 install_element (RMAP_NODE
, &no_match_ip_next_hop_cmd
);
4661 install_element (RMAP_NODE
, &no_match_ip_next_hop_val_cmd
);
4662 install_element (RMAP_NODE
, &match_ip_route_source_cmd
);
4663 install_element (RMAP_NODE
, &no_match_ip_route_source_cmd
);
4664 install_element (RMAP_NODE
, &no_match_ip_route_source_val_cmd
);
4665 install_element (RMAP_NODE
, &match_ip_address_prefix_list_cmd
);
4666 install_element (RMAP_NODE
, &no_match_ip_address_prefix_list_cmd
);
4667 install_element (RMAP_NODE
, &no_match_ip_address_prefix_list_val_cmd
);
4668 install_element (RMAP_NODE
, &match_ip_next_hop_prefix_list_cmd
);
4669 install_element (RMAP_NODE
, &no_match_ip_next_hop_prefix_list_cmd
);
4670 install_element (RMAP_NODE
, &no_match_ip_next_hop_prefix_list_val_cmd
);
4671 install_element (RMAP_NODE
, &match_ip_route_source_prefix_list_cmd
);
4672 install_element (RMAP_NODE
, &no_match_ip_route_source_prefix_list_cmd
);
4673 install_element (RMAP_NODE
, &no_match_ip_route_source_prefix_list_val_cmd
);
4675 install_element (RMAP_NODE
, &match_aspath_cmd
);
4676 install_element (RMAP_NODE
, &no_match_aspath_cmd
);
4677 install_element (RMAP_NODE
, &no_match_aspath_val_cmd
);
4678 install_element (RMAP_NODE
, &match_metric_cmd
);
4679 install_element (RMAP_NODE
, &no_match_metric_cmd
);
4680 install_element (RMAP_NODE
, &no_match_metric_val_cmd
);
4681 install_element (RMAP_NODE
, &match_local_pref_cmd
);
4682 install_element (RMAP_NODE
, &no_match_local_pref_cmd
);
4683 install_element (RMAP_NODE
, &no_match_local_pref_val_cmd
);
4684 install_element (RMAP_NODE
, &match_community_cmd
);
4685 install_element (RMAP_NODE
, &match_community_exact_cmd
);
4686 install_element (RMAP_NODE
, &no_match_community_cmd
);
4687 install_element (RMAP_NODE
, &no_match_community_val_cmd
);
4688 install_element (RMAP_NODE
, &no_match_community_exact_cmd
);
4689 install_element (RMAP_NODE
, &match_ecommunity_cmd
);
4690 install_element (RMAP_NODE
, &no_match_ecommunity_cmd
);
4691 install_element (RMAP_NODE
, &no_match_ecommunity_val_cmd
);
4692 install_element (RMAP_NODE
, &match_origin_cmd
);
4693 install_element (RMAP_NODE
, &no_match_origin_cmd
);
4694 install_element (RMAP_NODE
, &no_match_origin_val_cmd
);
4695 install_element (RMAP_NODE
, &match_probability_cmd
);
4696 install_element (RMAP_NODE
, &no_match_probability_cmd
);
4697 install_element (RMAP_NODE
, &no_match_probability_val_cmd
);
4698 install_element (RMAP_NODE
, &match_interface_cmd
);
4699 install_element (RMAP_NODE
, &no_match_interface_cmd
);
4700 install_element (RMAP_NODE
, &no_match_interface_val_cmd
);
4701 install_element (RMAP_NODE
, &match_tag_cmd
);
4702 install_element (RMAP_NODE
, &no_match_tag_cmd
);
4703 install_element (RMAP_NODE
, &no_match_tag_val_cmd
);
4705 install_element (RMAP_NODE
, &set_ip_nexthop_cmd
);
4706 install_element (RMAP_NODE
, &set_ip_nexthop_peer_cmd
);
4707 install_element (RMAP_NODE
, &set_ip_nexthop_unchanged_cmd
);
4708 install_element (RMAP_NODE
, &no_set_ip_nexthop_cmd
);
4709 install_element (RMAP_NODE
, &no_set_ip_nexthop_val_cmd
);
4710 install_element (RMAP_NODE
, &no_set_ip_nexthop_peer_cmd
);
4711 install_element (RMAP_NODE
, &set_local_pref_cmd
);
4712 install_element (RMAP_NODE
, &no_set_local_pref_cmd
);
4713 install_element (RMAP_NODE
, &no_set_local_pref_val_cmd
);
4714 install_element (RMAP_NODE
, &set_weight_cmd
);
4715 install_element (RMAP_NODE
, &no_set_weight_cmd
);
4716 install_element (RMAP_NODE
, &no_set_weight_val_cmd
);
4717 install_element (RMAP_NODE
, &set_metric_cmd
);
4718 install_element (RMAP_NODE
, &set_metric_addsub_cmd
);
4719 install_element (RMAP_NODE
, &no_set_metric_cmd
);
4720 install_element (RMAP_NODE
, &no_set_metric_val_cmd
);
4721 install_element (RMAP_NODE
, &set_aspath_prepend_cmd
);
4722 install_element (RMAP_NODE
, &set_aspath_prepend_lastas_cmd
);
4723 install_element (RMAP_NODE
, &set_aspath_exclude_cmd
);
4724 install_element (RMAP_NODE
, &no_set_aspath_prepend_cmd
);
4725 install_element (RMAP_NODE
, &no_set_aspath_prepend_val_cmd
);
4726 install_element (RMAP_NODE
, &no_set_aspath_exclude_cmd
);
4727 install_element (RMAP_NODE
, &no_set_aspath_exclude_val_cmd
);
4728 install_element (RMAP_NODE
, &set_origin_cmd
);
4729 install_element (RMAP_NODE
, &no_set_origin_cmd
);
4730 install_element (RMAP_NODE
, &no_set_origin_val_cmd
);
4731 install_element (RMAP_NODE
, &set_atomic_aggregate_cmd
);
4732 install_element (RMAP_NODE
, &no_set_atomic_aggregate_cmd
);
4733 install_element (RMAP_NODE
, &set_aggregator_as_cmd
);
4734 install_element (RMAP_NODE
, &no_set_aggregator_as_cmd
);
4735 install_element (RMAP_NODE
, &no_set_aggregator_as_val_cmd
);
4736 install_element (RMAP_NODE
, &set_community_cmd
);
4737 install_element (RMAP_NODE
, &set_community_none_cmd
);
4738 install_element (RMAP_NODE
, &no_set_community_cmd
);
4739 install_element (RMAP_NODE
, &no_set_community_val_cmd
);
4740 install_element (RMAP_NODE
, &no_set_community_none_cmd
);
4741 install_element (RMAP_NODE
, &set_community_delete_cmd
);
4742 install_element (RMAP_NODE
, &no_set_community_delete_cmd
);
4743 install_element (RMAP_NODE
, &no_set_community_delete_val_cmd
);
4744 install_element (RMAP_NODE
, &set_ecommunity_rt_cmd
);
4745 install_element (RMAP_NODE
, &no_set_ecommunity_rt_cmd
);
4746 install_element (RMAP_NODE
, &no_set_ecommunity_rt_val_cmd
);
4747 install_element (RMAP_NODE
, &set_ecommunity_soo_cmd
);
4748 install_element (RMAP_NODE
, &no_set_ecommunity_soo_cmd
);
4749 install_element (RMAP_NODE
, &no_set_ecommunity_soo_val_cmd
);
4750 install_element (RMAP_NODE
, &set_vpnv4_nexthop_cmd
);
4751 install_element (RMAP_NODE
, &no_set_vpnv4_nexthop_cmd
);
4752 install_element (RMAP_NODE
, &no_set_vpnv4_nexthop_val_cmd
);
4753 install_element (RMAP_NODE
, &set_originator_id_cmd
);
4754 install_element (RMAP_NODE
, &no_set_originator_id_cmd
);
4755 install_element (RMAP_NODE
, &no_set_originator_id_val_cmd
);
4756 install_element (RMAP_NODE
, &set_tag_cmd
);
4757 install_element (RMAP_NODE
, &no_set_tag_cmd
);
4758 install_element (RMAP_NODE
, &no_set_tag_val_cmd
);
4761 route_map_install_match (&route_match_ipv6_address_cmd
);
4762 route_map_install_match (&route_match_ipv6_next_hop_cmd
);
4763 route_map_install_match (&route_match_ipv6_address_prefix_list_cmd
);
4764 route_map_install_set (&route_set_ipv6_nexthop_global_cmd
);
4765 route_map_install_set (&route_set_ipv6_nexthop_local_cmd
);
4766 route_map_install_set (&route_set_ipv6_nexthop_peer_cmd
);
4768 install_element (RMAP_NODE
, &match_ipv6_address_cmd
);
4769 install_element (RMAP_NODE
, &no_match_ipv6_address_cmd
);
4770 install_element (RMAP_NODE
, &match_ipv6_next_hop_cmd
);
4771 install_element (RMAP_NODE
, &no_match_ipv6_next_hop_cmd
);
4772 install_element (RMAP_NODE
, &match_ipv6_address_prefix_list_cmd
);
4773 install_element (RMAP_NODE
, &no_match_ipv6_address_prefix_list_cmd
);
4774 install_element (RMAP_NODE
, &set_ipv6_nexthop_global_cmd
);
4775 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_global_cmd
);
4776 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_global_val_cmd
);
4777 install_element (RMAP_NODE
, &set_ipv6_nexthop_local_cmd
);
4778 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_local_cmd
);
4779 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_local_val_cmd
);
4780 install_element (RMAP_NODE
, &set_ipv6_nexthop_peer_cmd
);
4781 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_peer_cmd
);
4782 #endif /* HAVE_IPV6 */
4786 bgp_route_map_terminate (void)
4788 /* ToDo: Cleanup all the used memory */
4790 route_map_add_hook (NULL
);
4791 route_map_delete_hook (NULL
);
4792 route_map_event_hook (NULL
);