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>
35 #endif /* HAVE_LIBPCREPOSIX */
37 #include "sockunion.h"
41 #include "bgpd/bgpd.h"
42 #include "bgpd/bgp_table.h"
43 #include "bgpd/bgp_attr.h"
44 #include "bgpd/bgp_aspath.h"
45 #include "bgpd/bgp_packet.h"
46 #include "bgpd/bgp_route.h"
47 #include "bgpd/bgp_zebra.h"
48 #include "bgpd/bgp_regex.h"
49 #include "bgpd/bgp_community.h"
50 #include "bgpd/bgp_clist.h"
51 #include "bgpd/bgp_filter.h"
52 #include "bgpd/bgp_mplsvpn.h"
53 #include "bgpd/bgp_ecommunity.h"
54 #include "bgpd/bgp_vty.h"
55 #include "bgpd/bgp_debug.h"
58 # include "bgpd/rfapi/bgp_rfapi_cfg.h"
61 /* Memo of route-map commands.
70 ip route-source : Done
74 ipv6 route-source: (This will not be implemented by bgpd)
75 ipv6 prefix-list : Done
76 length : (This will not be implemented by bgpd)
78 route-type : (This will not be implemented by bgpd)
80 local-preference : Done
82 set as-path prepend : Done
84 automatic-tag : (This will not be implemented by bgpd)
88 default : (This will not be implemented by bgpd)
89 interface : (This will not be implemented by bgpd)
90 ip default : (This will not be implemented by bgpd)
92 ip precedence : (This will not be implemented by bgpd)
93 ip tos : (This will not be implemented by bgpd)
94 level : (This will not be implemented by bgpd)
95 local-preference : Done
104 set ipv6 next-hop global: Done
105 set ipv6 next-hop prefer-global: Done
106 set ipv6 next-hop local : Done
107 set as-path exclude : Done
111 /* generic value manipulation to be shared in multiple rules */
113 #define RMAP_VALUE_SET 0
114 #define RMAP_VALUE_ADD 1
115 #define RMAP_VALUE_SUB 2
125 route_value_match (struct rmap_value
*rv
, u_int32_t value
)
127 if (rv
->variable
== 0 && value
== rv
->value
)
134 route_value_adjust (struct rmap_value
*rv
, u_int32_t current
, struct peer
*peer
)
138 switch (rv
->variable
)
151 if (current
> UINT32_MAX
-value
)
153 return current
+ value
;
155 if (current
<= value
)
157 return current
- value
;
164 route_value_compile (const char *arg
)
166 u_int8_t action
= RMAP_VALUE_SET
, var
= 0;
167 unsigned long larg
= 0;
169 struct rmap_value
*rv
;
173 action
= RMAP_VALUE_ADD
;
176 else if (arg
[0] == '-')
178 action
= RMAP_VALUE_SUB
;
185 larg
= strtoul (arg
, &endptr
, 10);
186 if (*arg
== 0 || *endptr
!= 0 || errno
|| larg
> UINT32_MAX
)
191 if (strcmp(arg
, "rtt") == 0)
197 rv
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof(struct rmap_value
));
208 route_value_free (void *rule
)
210 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
213 /* generic as path object to be shared in multiple rules */
216 route_aspath_compile (const char *arg
)
218 struct aspath
*aspath
;
220 aspath
= aspath_str2aspath (arg
);
227 route_aspath_free (void *rule
)
229 struct aspath
*aspath
= rule
;
230 aspath_free (aspath
);
233 /* 'match peer (A.B.C.D|X:X::X:X)' */
235 /* Compares the peer specified in the 'match peer' clause with the peer
236 received in bgp_info->peer. If it is the same, or if the peer structure
237 received is a peer_group containing it, returns RMAP_MATCH. */
238 static route_map_result_t
239 route_match_peer (void *rule
, struct prefix
*prefix
, route_map_object_t type
,
243 union sockunion su_def
= { .sin
= { .sin_family
= AF_INET
,
244 .sin_addr
.s_addr
= INADDR_ANY
} };
245 struct peer_group
*group
;
247 struct listnode
*node
, *nnode
;
249 if (type
== RMAP_BGP
)
252 peer
= ((struct bgp_info
*) object
)->peer
;
254 if ( ! CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IMPORT
) &&
255 ! CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_EXPORT
) )
258 /* If su='0.0.0.0' (command 'match peer local'), and it's a NETWORK,
259 REDISTRIBUTE or DEFAULT_GENERATED route => return RMAP_MATCH */
260 if (sockunion_same (su
, &su_def
))
263 if ( CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_NETWORK
) ||
264 CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
) ||
265 CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_DEFAULT
))
272 if (! CHECK_FLAG (peer
->sflags
, PEER_STATUS_GROUP
))
274 if (sockunion_same (su
, &peer
->su
))
282 for (ALL_LIST_ELEMENTS (group
->peer
, node
, nnode
, peer
))
284 if (sockunion_same (su
, &peer
->su
))
294 route_match_peer_compile (const char *arg
)
299 su
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (union sockunion
));
301 ret
= str2sockunion (strcmp(arg
, "local") ? arg
: "0.0.0.0", su
);
303 XFREE (MTYPE_ROUTE_MAP_COMPILED
, su
);
310 /* Free route map's compiled `ip address' value. */
312 route_match_peer_free (void *rule
)
314 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
317 /* Route map commands for ip address matching. */
318 struct route_map_rule_cmd route_match_peer_cmd
=
322 route_match_peer_compile
,
323 route_match_peer_free
326 /* `match ip address IP_ACCESS_LIST' */
328 /* Match function should return 1 if match is success else return
330 static route_map_result_t
331 route_match_ip_address (void *rule
, struct prefix
*prefix
,
332 route_map_object_t type
, void *object
)
334 struct access_list
*alist
;
335 /* struct prefix_ipv4 match; */
337 if (type
== RMAP_BGP
)
339 alist
= access_list_lookup (AFI_IP
, (char *) rule
);
343 return (access_list_apply (alist
, prefix
) == FILTER_DENY
?
344 RMAP_NOMATCH
: RMAP_MATCH
);
349 /* Route map `ip address' match statement. `arg' should be
352 route_match_ip_address_compile (const char *arg
)
354 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
357 /* Free route map's compiled `ip address' value. */
359 route_match_ip_address_free (void *rule
)
361 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
364 /* Route map commands for ip address matching. */
365 struct route_map_rule_cmd route_match_ip_address_cmd
=
368 route_match_ip_address
,
369 route_match_ip_address_compile
,
370 route_match_ip_address_free
373 /* `match ip next-hop IP_ADDRESS' */
375 /* Match function return 1 if match is success else return zero. */
376 static route_map_result_t
377 route_match_ip_next_hop (void *rule
, struct prefix
*prefix
,
378 route_map_object_t type
, void *object
)
380 struct access_list
*alist
;
381 struct bgp_info
*bgp_info
;
382 struct prefix_ipv4 p
;
384 if (type
== RMAP_BGP
)
388 p
.prefix
= bgp_info
->attr
->nexthop
;
389 p
.prefixlen
= IPV4_MAX_BITLEN
;
391 alist
= access_list_lookup (AFI_IP
, (char *) rule
);
395 return (access_list_apply (alist
, &p
) == FILTER_DENY
?
396 RMAP_NOMATCH
: RMAP_MATCH
);
401 /* Route map `ip next-hop' match statement. `arg' is
404 route_match_ip_next_hop_compile (const char *arg
)
406 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
409 /* Free route map's compiled `ip address' value. */
411 route_match_ip_next_hop_free (void *rule
)
413 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
416 /* Route map commands for ip next-hop matching. */
417 struct route_map_rule_cmd route_match_ip_next_hop_cmd
=
420 route_match_ip_next_hop
,
421 route_match_ip_next_hop_compile
,
422 route_match_ip_next_hop_free
425 /* `match ip route-source ACCESS-LIST' */
427 /* Match function return 1 if match is success else return zero. */
428 static route_map_result_t
429 route_match_ip_route_source (void *rule
, struct prefix
*prefix
,
430 route_map_object_t type
, void *object
)
432 struct access_list
*alist
;
433 struct bgp_info
*bgp_info
;
435 struct prefix_ipv4 p
;
437 if (type
== RMAP_BGP
)
440 peer
= bgp_info
->peer
;
442 if (! peer
|| sockunion_family (&peer
->su
) != AF_INET
)
446 p
.prefix
= peer
->su
.sin
.sin_addr
;
447 p
.prefixlen
= IPV4_MAX_BITLEN
;
449 alist
= access_list_lookup (AFI_IP
, (char *) rule
);
453 return (access_list_apply (alist
, &p
) == FILTER_DENY
?
454 RMAP_NOMATCH
: RMAP_MATCH
);
459 /* Route map `ip route-source' match statement. `arg' is
462 route_match_ip_route_source_compile (const char *arg
)
464 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
467 /* Free route map's compiled `ip address' value. */
469 route_match_ip_route_source_free (void *rule
)
471 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
474 /* Route map commands for ip route-source matching. */
475 struct route_map_rule_cmd route_match_ip_route_source_cmd
=
478 route_match_ip_route_source
,
479 route_match_ip_route_source_compile
,
480 route_match_ip_route_source_free
483 /* `match ip address prefix-list PREFIX_LIST' */
485 static route_map_result_t
486 route_match_ip_address_prefix_list (void *rule
, struct prefix
*prefix
,
487 route_map_object_t type
, void *object
)
489 struct prefix_list
*plist
;
491 if (type
== RMAP_BGP
)
493 plist
= prefix_list_lookup (AFI_IP
, (char *) rule
);
497 return (prefix_list_apply (plist
, prefix
) == PREFIX_DENY
?
498 RMAP_NOMATCH
: RMAP_MATCH
);
504 route_match_ip_address_prefix_list_compile (const char *arg
)
506 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
510 route_match_ip_address_prefix_list_free (void *rule
)
512 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
515 struct route_map_rule_cmd route_match_ip_address_prefix_list_cmd
=
517 "ip address prefix-list",
518 route_match_ip_address_prefix_list
,
519 route_match_ip_address_prefix_list_compile
,
520 route_match_ip_address_prefix_list_free
523 /* `match ip next-hop prefix-list PREFIX_LIST' */
525 static route_map_result_t
526 route_match_ip_next_hop_prefix_list (void *rule
, struct prefix
*prefix
,
527 route_map_object_t type
, void *object
)
529 struct prefix_list
*plist
;
530 struct bgp_info
*bgp_info
;
531 struct prefix_ipv4 p
;
533 if (type
== RMAP_BGP
)
537 p
.prefix
= bgp_info
->attr
->nexthop
;
538 p
.prefixlen
= IPV4_MAX_BITLEN
;
540 plist
= prefix_list_lookup (AFI_IP
, (char *) rule
);
544 return (prefix_list_apply (plist
, &p
) == PREFIX_DENY
?
545 RMAP_NOMATCH
: RMAP_MATCH
);
551 route_match_ip_next_hop_prefix_list_compile (const char *arg
)
553 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
557 route_match_ip_next_hop_prefix_list_free (void *rule
)
559 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
562 struct route_map_rule_cmd route_match_ip_next_hop_prefix_list_cmd
=
564 "ip next-hop prefix-list",
565 route_match_ip_next_hop_prefix_list
,
566 route_match_ip_next_hop_prefix_list_compile
,
567 route_match_ip_next_hop_prefix_list_free
570 /* `match ip route-source prefix-list PREFIX_LIST' */
572 static route_map_result_t
573 route_match_ip_route_source_prefix_list (void *rule
, struct prefix
*prefix
,
574 route_map_object_t type
, void *object
)
576 struct prefix_list
*plist
;
577 struct bgp_info
*bgp_info
;
579 struct prefix_ipv4 p
;
581 if (type
== RMAP_BGP
)
584 peer
= bgp_info
->peer
;
586 if (! peer
|| sockunion_family (&peer
->su
) != AF_INET
)
590 p
.prefix
= peer
->su
.sin
.sin_addr
;
591 p
.prefixlen
= IPV4_MAX_BITLEN
;
593 plist
= prefix_list_lookup (AFI_IP
, (char *) rule
);
597 return (prefix_list_apply (plist
, &p
) == PREFIX_DENY
?
598 RMAP_NOMATCH
: RMAP_MATCH
);
604 route_match_ip_route_source_prefix_list_compile (const char *arg
)
606 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
610 route_match_ip_route_source_prefix_list_free (void *rule
)
612 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
615 struct route_map_rule_cmd route_match_ip_route_source_prefix_list_cmd
=
617 "ip route-source prefix-list",
618 route_match_ip_route_source_prefix_list
,
619 route_match_ip_route_source_prefix_list_compile
,
620 route_match_ip_route_source_prefix_list_free
623 /* `match local-preference LOCAL-PREF' */
625 /* Match function return 1 if match is success else return zero. */
626 static route_map_result_t
627 route_match_local_pref (void *rule
, struct prefix
*prefix
,
628 route_map_object_t type
, void *object
)
630 u_int32_t
*local_pref
;
631 struct bgp_info
*bgp_info
;
633 if (type
== RMAP_BGP
)
638 if (bgp_info
->attr
->local_pref
== *local_pref
)
646 /* Route map `match local-preference' match statement.
647 `arg' is local-pref value */
649 route_match_local_pref_compile (const char *arg
)
651 u_int32_t
*local_pref
;
653 unsigned long tmpval
;
655 /* Locpref value shoud be integer. */
656 if (! all_digit (arg
))
660 tmpval
= strtoul (arg
, &endptr
, 10);
661 if (*endptr
!= '\0' || errno
|| tmpval
> UINT32_MAX
)
664 local_pref
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_int32_t
));
669 *local_pref
= tmpval
;
673 /* Free route map's compiled `match local-preference' value. */
675 route_match_local_pref_free (void *rule
)
677 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
680 /* Route map commands for metric matching. */
681 struct route_map_rule_cmd route_match_local_pref_cmd
=
684 route_match_local_pref
,
685 route_match_local_pref_compile
,
686 route_match_local_pref_free
689 /* `match metric METRIC' */
691 /* Match function return 1 if match is success else return zero. */
692 static route_map_result_t
693 route_match_metric (void *rule
, struct prefix
*prefix
,
694 route_map_object_t type
, void *object
)
696 struct rmap_value
*rv
;
697 struct bgp_info
*bgp_info
;
699 if (type
== RMAP_BGP
)
703 return route_value_match(rv
, bgp_info
->attr
->med
);
708 /* Route map commands for metric matching. */
709 struct route_map_rule_cmd route_match_metric_cmd
=
717 /* `match as-path ASPATH' */
719 /* Match function for as-path match. I assume given object is */
720 static route_map_result_t
721 route_match_aspath (void *rule
, struct prefix
*prefix
,
722 route_map_object_t type
, void *object
)
725 struct as_list
*as_list
;
726 struct bgp_info
*bgp_info
;
728 if (type
== RMAP_BGP
)
730 as_list
= as_list_lookup ((char *) rule
);
737 return ((as_list_apply (as_list
, bgp_info
->attr
->aspath
) == AS_FILTER_DENY
) ? RMAP_NOMATCH
: RMAP_MATCH
);
742 /* Compile function for as-path match. */
744 route_match_aspath_compile (const char *arg
)
746 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
749 /* Compile function for as-path match. */
751 route_match_aspath_free (void *rule
)
753 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
756 /* Route map commands for aspath matching. */
757 struct route_map_rule_cmd route_match_aspath_cmd
=
761 route_match_aspath_compile
,
762 route_match_aspath_free
765 /* `match community COMMUNIY' */
766 struct rmap_community
772 /* Match function for community match. */
773 static route_map_result_t
774 route_match_community (void *rule
, struct prefix
*prefix
,
775 route_map_object_t type
, void *object
)
777 struct community_list
*list
;
778 struct bgp_info
*bgp_info
;
779 struct rmap_community
*rcom
;
781 if (type
== RMAP_BGP
)
786 list
= community_list_lookup (bgp_clist
, rcom
->name
, COMMUNITY_LIST_MASTER
);
792 if (community_list_exact_match (bgp_info
->attr
->community
, list
))
797 if (community_list_match (bgp_info
->attr
->community
, list
))
804 /* Compile function for community match. */
806 route_match_community_compile (const char *arg
)
808 struct rmap_community
*rcom
;
812 rcom
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct rmap_community
));
814 p
= strchr (arg
, ' ');
818 rcom
->name
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, len
+ 1);
819 memcpy (rcom
->name
, arg
, len
);
824 rcom
->name
= XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
830 /* Compile function for community match. */
832 route_match_community_free (void *rule
)
834 struct rmap_community
*rcom
= rule
;
836 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rcom
->name
);
837 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rcom
);
840 /* Route map commands for community matching. */
841 struct route_map_rule_cmd route_match_community_cmd
=
844 route_match_community
,
845 route_match_community_compile
,
846 route_match_community_free
849 /* Match function for extcommunity match. */
850 static route_map_result_t
851 route_match_ecommunity (void *rule
, struct prefix
*prefix
,
852 route_map_object_t type
, void *object
)
854 struct community_list
*list
;
855 struct bgp_info
*bgp_info
;
857 if (type
== RMAP_BGP
)
861 if (!bgp_info
->attr
->extra
)
864 list
= community_list_lookup (bgp_clist
, (char *) rule
,
865 EXTCOMMUNITY_LIST_MASTER
);
869 if (ecommunity_list_match (bgp_info
->attr
->extra
->ecommunity
, list
))
875 /* Compile function for extcommunity match. */
877 route_match_ecommunity_compile (const char *arg
)
879 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
882 /* Compile function for extcommunity match. */
884 route_match_ecommunity_free (void *rule
)
886 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
889 /* Route map commands for community matching. */
890 struct route_map_rule_cmd route_match_ecommunity_cmd
=
893 route_match_ecommunity
,
894 route_match_ecommunity_compile
,
895 route_match_ecommunity_free
898 /* `match nlri` and `set nlri` are replaced by `address-family ipv4`
899 and `address-family vpnv4'. */
902 static route_map_result_t
903 route_match_origin (void *rule
, struct prefix
*prefix
,
904 route_map_object_t type
, void *object
)
907 struct bgp_info
*bgp_info
;
909 if (type
== RMAP_BGP
)
914 if (bgp_info
->attr
->origin
== *origin
)
922 route_match_origin_compile (const char *arg
)
926 origin
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_char
));
928 if (strcmp (arg
, "igp") == 0)
930 else if (strcmp (arg
, "egp") == 0)
938 /* Free route map's compiled `ip address' value. */
940 route_match_origin_free (void *rule
)
942 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
945 /* Route map commands for origin matching. */
946 struct route_map_rule_cmd route_match_origin_cmd
=
950 route_match_origin_compile
,
951 route_match_origin_free
954 /* match probability { */
956 static route_map_result_t
957 route_match_probability (void *rule
, struct prefix
*prefix
,
958 route_map_object_t type
, void *object
)
962 switch (*(long *) rule
)
965 case RAND_MAX
: return RMAP_MATCH
;
967 if (r
< *(long *) rule
)
977 route_match_probability_compile (const char *arg
)
983 lobule
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (long));
987 case 0: *lobule
= 0; break;
988 case 100: *lobule
= RAND_MAX
; break;
989 default: *lobule
= RAND_MAX
/ 100 * perc
;
996 route_match_probability_free (void *rule
)
998 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1001 struct route_map_rule_cmd route_match_probability_cmd
=
1004 route_match_probability
,
1005 route_match_probability_compile
,
1006 route_match_probability_free
1009 /* `match interface IFNAME' */
1010 /* Match function should return 1 if match is success else return
1012 static route_map_result_t
1013 route_match_interface (void *rule
, struct prefix
*prefix
,
1014 route_map_object_t type
, void *object
)
1016 struct interface
*ifp
;
1017 struct bgp_info
*info
;
1019 if (type
== RMAP_BGP
)
1023 if (!info
|| !info
->attr
)
1024 return RMAP_NOMATCH
;
1026 ifp
= if_lookup_by_name_all_vrf ((char *)rule
);
1028 if (ifp
== NULL
|| ifp
->ifindex
!= info
->attr
->nh_ifindex
)
1029 return RMAP_NOMATCH
;
1033 return RMAP_NOMATCH
;
1036 /* Route map `interface' match statement. `arg' should be
1039 route_match_interface_compile (const char *arg
)
1041 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
1044 /* Free route map's compiled `interface' value. */
1046 route_match_interface_free (void *rule
)
1048 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1051 /* Route map commands for ip address matching. */
1052 struct route_map_rule_cmd route_match_interface_cmd
=
1055 route_match_interface
,
1056 route_match_interface_compile
,
1057 route_match_interface_free
1062 /* `set ip next-hop IP_ADDRESS' */
1064 /* Match function return 1 if match is success else return zero. */
1065 static route_map_result_t
1066 route_match_tag (void *rule
, struct prefix
*prefix
,
1067 route_map_object_t type
, void *object
)
1070 struct bgp_info
*bgp_info
;
1072 if (type
== RMAP_BGP
)
1077 if (!bgp_info
->attr
->extra
)
1078 return RMAP_NOMATCH
;
1080 return ((bgp_info
->attr
->extra
->tag
== *tag
)? RMAP_MATCH
: RMAP_NOMATCH
);
1083 return RMAP_NOMATCH
;
1087 /* Route map commands for tag matching. */
1088 static struct route_map_rule_cmd route_match_tag_cmd
=
1092 route_map_rule_tag_compile
,
1093 route_map_rule_tag_free
,
1097 /* Set nexthop to object. ojbect must be pointer to struct attr. */
1098 struct rmap_ip_nexthop_set
1100 struct in_addr
*address
;
1105 static route_map_result_t
1106 route_set_ip_nexthop (void *rule
, struct prefix
*prefix
,
1107 route_map_object_t type
, void *object
)
1109 struct rmap_ip_nexthop_set
*rins
= rule
;
1110 struct bgp_info
*bgp_info
;
1113 if (type
== RMAP_BGP
)
1116 peer
= bgp_info
->peer
;
1118 if (rins
->unchanged
)
1120 SET_FLAG(bgp_info
->attr
->rmap_change_flags
,
1121 BATTR_RMAP_NEXTHOP_UNCHANGED
);
1123 else if (rins
->peer_address
)
1125 if ((CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IN
) ||
1126 CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IMPORT
))
1128 && sockunion_family (peer
->su_remote
) == AF_INET
)
1130 bgp_info
->attr
->nexthop
.s_addr
= sockunion2ip (peer
->su_remote
);
1131 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
);
1133 else if (CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
))
1135 /* The next hop value will be set as part of packet rewrite.
1136 * Set the flags here to indicate that rewrite needs to be done.
1137 * Also, clear the value.
1139 SET_FLAG(bgp_info
->attr
->rmap_change_flags
,
1140 BATTR_RMAP_NEXTHOP_PEER_ADDRESS
);
1141 bgp_info
->attr
->nexthop
.s_addr
= 0;
1146 /* Set next hop value. */
1147 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
);
1148 bgp_info
->attr
->nexthop
= *rins
->address
;
1149 SET_FLAG(bgp_info
->attr
->rmap_change_flags
,
1150 BATTR_RMAP_IPV4_NHOP_CHANGED
);
1157 /* Route map `ip nexthop' compile function. Given string is converted
1158 to struct in_addr structure. */
1160 route_set_ip_nexthop_compile (const char *arg
)
1162 struct rmap_ip_nexthop_set
*rins
;
1163 struct in_addr
*address
= NULL
;
1164 int peer_address
= 0;
1168 if (strcmp (arg
, "peer-address") == 0)
1170 else if (strcmp (arg
, "unchanged") == 0)
1174 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in_addr
));
1175 ret
= inet_aton (arg
, address
);
1179 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
1184 rins
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct rmap_ip_nexthop_set
));
1186 rins
->address
= address
;
1187 rins
->peer_address
= peer_address
;
1188 rins
->unchanged
= unchanged
;
1193 /* Free route map's compiled `ip nexthop' value. */
1195 route_set_ip_nexthop_free (void *rule
)
1197 struct rmap_ip_nexthop_set
*rins
= rule
;
1200 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rins
->address
);
1202 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rins
);
1205 /* Route map commands for ip nexthop set. */
1206 struct route_map_rule_cmd route_set_ip_nexthop_cmd
=
1209 route_set_ip_nexthop
,
1210 route_set_ip_nexthop_compile
,
1211 route_set_ip_nexthop_free
1214 /* `set local-preference LOCAL_PREF' */
1216 /* Set local preference. */
1217 static route_map_result_t
1218 route_set_local_pref (void *rule
, struct prefix
*prefix
,
1219 route_map_object_t type
, void *object
)
1221 struct rmap_value
*rv
;
1222 struct bgp_info
*bgp_info
;
1223 u_int32_t locpref
= 0;
1225 if (type
== RMAP_BGP
)
1227 /* Fetch routemap's rule information. */
1231 /* Set local preference value. */
1232 if (bgp_info
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
1233 locpref
= bgp_info
->attr
->local_pref
;
1235 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
);
1236 bgp_info
->attr
->local_pref
= route_value_adjust(rv
, locpref
, bgp_info
->peer
);
1242 /* Set local preference rule structure. */
1243 struct route_map_rule_cmd route_set_local_pref_cmd
=
1246 route_set_local_pref
,
1247 route_value_compile
,
1251 /* `set weight WEIGHT' */
1254 static route_map_result_t
1255 route_set_weight (void *rule
, struct prefix
*prefix
, route_map_object_t type
,
1258 struct rmap_value
*rv
;
1259 struct bgp_info
*bgp_info
;
1262 if (type
== RMAP_BGP
)
1264 /* Fetch routemap's rule information. */
1268 /* Set weight value. */
1269 weight
= route_value_adjust(rv
, 0, bgp_info
->peer
);
1271 (bgp_attr_extra_get (bgp_info
->attr
))->weight
= weight
;
1272 else if (bgp_info
->attr
->extra
)
1273 bgp_info
->attr
->extra
->weight
= 0;
1279 /* Set local preference rule structure. */
1280 struct route_map_rule_cmd route_set_weight_cmd
=
1284 route_value_compile
,
1288 /* `set metric METRIC' */
1290 /* Set metric to attribute. */
1291 static route_map_result_t
1292 route_set_metric (void *rule
, struct prefix
*prefix
,
1293 route_map_object_t type
, void *object
)
1295 struct rmap_value
*rv
;
1296 struct bgp_info
*bgp_info
;
1299 if (type
== RMAP_BGP
)
1301 /* Fetch routemap's rule information. */
1305 if (bgp_info
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
1306 med
= bgp_info
->attr
->med
;
1308 bgp_info
->attr
->med
= route_value_adjust(rv
, med
, bgp_info
->peer
);
1309 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
1314 /* Set metric rule structure. */
1315 struct route_map_rule_cmd route_set_metric_cmd
=
1319 route_value_compile
,
1323 /* `set as-path prepend ASPATH' */
1325 /* For AS path prepend mechanism. */
1326 static route_map_result_t
1327 route_set_aspath_prepend (void *rule
, struct prefix
*prefix
, route_map_object_t type
, void *object
)
1329 struct aspath
*aspath
;
1331 struct bgp_info
*binfo
;
1333 if (type
== RMAP_BGP
)
1337 if (binfo
->attr
->aspath
->refcnt
)
1338 new = aspath_dup (binfo
->attr
->aspath
);
1340 new = binfo
->attr
->aspath
;
1342 if ((uintptr_t)rule
> 10)
1345 aspath_prepend (aspath
, new);
1349 as_t as
= aspath_leftmost(new);
1350 if (!as
) as
= binfo
->peer
->as
;
1351 new = aspath_add_seq_n (new, as
, (uintptr_t) rule
);
1354 binfo
->attr
->aspath
= new;
1361 route_set_aspath_prepend_compile (const char *arg
)
1365 if (sscanf(arg
, "last-as %u", &num
) == 1 && num
> 0 && num
<= 10)
1366 return (void*)(uintptr_t)num
;
1368 return route_aspath_compile(arg
);
1372 route_set_aspath_prepend_free (void *rule
)
1374 if ((uintptr_t)rule
> 10)
1375 route_aspath_free(rule
);
1379 /* Set as-path prepend rule structure. */
1380 struct route_map_rule_cmd route_set_aspath_prepend_cmd
=
1383 route_set_aspath_prepend
,
1384 route_set_aspath_prepend_compile
,
1385 route_set_aspath_prepend_free
,
1388 /* `set as-path exclude ASn' */
1390 /* For ASN exclude mechanism.
1391 * Iterate over ASns requested and filter them from the given AS_PATH one by one.
1392 * Make a deep copy of existing AS_PATH, but for the first ASn only.
1394 static route_map_result_t
1395 route_set_aspath_exclude (void *rule
, struct prefix
*dummy
, route_map_object_t type
, void *object
)
1397 struct aspath
* new_path
, * exclude_path
;
1398 struct bgp_info
*binfo
;
1400 if (type
== RMAP_BGP
)
1402 exclude_path
= rule
;
1404 if (binfo
->attr
->aspath
->refcnt
)
1405 new_path
= aspath_dup (binfo
->attr
->aspath
);
1407 new_path
= binfo
->attr
->aspath
;
1408 binfo
->attr
->aspath
= aspath_filter_exclude (new_path
, exclude_path
);
1413 /* Set ASn exlude rule structure. */
1414 struct route_map_rule_cmd route_set_aspath_exclude_cmd
=
1417 route_set_aspath_exclude
,
1418 route_aspath_compile
,
1422 /* `set community COMMUNITY' */
1425 struct community
*com
;
1430 /* For community set mechanism. */
1431 static route_map_result_t
1432 route_set_community (void *rule
, struct prefix
*prefix
,
1433 route_map_object_t type
, void *object
)
1435 struct rmap_com_set
*rcs
;
1436 struct bgp_info
*binfo
;
1438 struct community
*new = NULL
;
1439 struct community
*old
;
1440 struct community
*merge
;
1442 if (type
== RMAP_BGP
)
1447 old
= attr
->community
;
1452 attr
->flag
&= ~(ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
));
1453 attr
->community
= NULL
;
1454 /* See the longer comment down below. */
1455 if (old
&& old
->refcnt
== 0)
1456 community_free(old
);
1460 /* "additive" case. */
1461 if (rcs
->additive
&& old
)
1463 merge
= community_merge (community_dup (old
), rcs
->com
);
1465 /* HACK: if the old community is not intern'd,
1466 * we should free it here, or all reference to it may be lost.
1467 * Really need to cleanup attribute caching sometime.
1469 if (old
->refcnt
== 0)
1470 community_free (old
);
1471 new = community_uniq_sort (merge
);
1472 community_free (merge
);
1475 new = community_dup (rcs
->com
);
1477 /* will be interned by caller if required */
1478 attr
->community
= new;
1480 attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
);
1486 /* Compile function for set community. */
1488 route_set_community_compile (const char *arg
)
1490 struct rmap_com_set
*rcs
;
1491 struct community
*com
= NULL
;
1496 if (strcmp (arg
, "none") == 0)
1500 sp
= strstr (arg
, "additive");
1504 /* "additive" keyworkd is included. */
1509 com
= community_str2com (arg
);
1518 rcs
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct rmap_com_set
));
1520 rcs
->additive
= additive
;
1526 /* Free function for set community. */
1528 route_set_community_free (void *rule
)
1530 struct rmap_com_set
*rcs
= rule
;
1533 community_free (rcs
->com
);
1534 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rcs
);
1537 /* Set community rule structure. */
1538 struct route_map_rule_cmd route_set_community_cmd
=
1541 route_set_community
,
1542 route_set_community_compile
,
1543 route_set_community_free
,
1546 /* `set comm-list (<1-99>|<100-500>|WORD) delete' */
1548 /* For community set mechanism. */
1549 static route_map_result_t
1550 route_set_community_delete (void *rule
, struct prefix
*prefix
,
1551 route_map_object_t type
, void *object
)
1553 struct community_list
*list
;
1554 struct community
*merge
;
1555 struct community
*new;
1556 struct community
*old
;
1557 struct bgp_info
*binfo
;
1559 if (type
== RMAP_BGP
)
1565 list
= community_list_lookup (bgp_clist
, rule
, COMMUNITY_LIST_MASTER
);
1566 old
= binfo
->attr
->community
;
1570 merge
= community_list_match_delete (community_dup (old
), list
);
1571 new = community_uniq_sort (merge
);
1572 community_free (merge
);
1574 /* HACK: if the old community is not intern'd,
1575 * we should free it here, or all reference to it may be lost.
1576 * Really need to cleanup attribute caching sometime.
1578 if (old
->refcnt
== 0)
1579 community_free (old
);
1583 binfo
->attr
->community
= NULL
;
1584 binfo
->attr
->flag
&= ~ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
);
1585 community_free (new);
1589 binfo
->attr
->community
= new;
1590 binfo
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES
);
1598 /* Compile function for set community. */
1600 route_set_community_delete_compile (const char *arg
)
1606 p
= strchr (arg
, ' ');
1610 str
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, len
+ 1);
1611 memcpy (str
, arg
, len
);
1619 /* Free function for set community. */
1621 route_set_community_delete_free (void *rule
)
1623 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1626 /* Set community rule structure. */
1627 struct route_map_rule_cmd route_set_community_delete_cmd
=
1630 route_set_community_delete
,
1631 route_set_community_delete_compile
,
1632 route_set_community_delete_free
,
1635 /* `set extcommunity rt COMMUNITY' */
1637 /* For community set mechanism. Used by _rt and _soo. */
1638 static route_map_result_t
1639 route_set_ecommunity (void *rule
, struct prefix
*prefix
,
1640 route_map_object_t type
, void *object
)
1642 struct ecommunity
*ecom
;
1643 struct ecommunity
*new_ecom
;
1644 struct ecommunity
*old_ecom
;
1645 struct bgp_info
*bgp_info
;
1647 if (type
== RMAP_BGP
)
1655 /* We assume additive for Extended Community. */
1656 old_ecom
= (bgp_attr_extra_get (bgp_info
->attr
))->ecommunity
;
1660 new_ecom
= ecommunity_merge (ecommunity_dup (old_ecom
), ecom
);
1662 /* old_ecom->refcnt = 1 => owned elsewhere, e.g. bgp_update_receive()
1663 * ->refcnt = 0 => set by a previous route-map statement */
1664 if (!old_ecom
->refcnt
)
1665 ecommunity_free (&old_ecom
);
1668 new_ecom
= ecommunity_dup (ecom
);
1670 /* will be intern()'d or attr_flush()'d by bgp_update_main() */
1671 bgp_info
->attr
->extra
->ecommunity
= new_ecom
;
1673 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES
);
1678 /* Compile function for set community. */
1680 route_set_ecommunity_rt_compile (const char *arg
)
1682 struct ecommunity
*ecom
;
1684 ecom
= ecommunity_str2com (arg
, ECOMMUNITY_ROUTE_TARGET
, 0);
1687 return ecommunity_intern (ecom
);
1690 /* Free function for set community. Used by _rt and _soo */
1692 route_set_ecommunity_free (void *rule
)
1694 struct ecommunity
*ecom
= rule
;
1695 ecommunity_unintern (&ecom
);
1698 /* Set community rule structure. */
1699 struct route_map_rule_cmd route_set_ecommunity_rt_cmd
=
1702 route_set_ecommunity
,
1703 route_set_ecommunity_rt_compile
,
1704 route_set_ecommunity_free
,
1707 /* `set extcommunity soo COMMUNITY' */
1709 /* Compile function for set community. */
1711 route_set_ecommunity_soo_compile (const char *arg
)
1713 struct ecommunity
*ecom
;
1715 ecom
= ecommunity_str2com (arg
, ECOMMUNITY_SITE_ORIGIN
, 0);
1719 return ecommunity_intern (ecom
);
1722 /* Set community rule structure. */
1723 struct route_map_rule_cmd route_set_ecommunity_soo_cmd
=
1726 route_set_ecommunity
,
1727 route_set_ecommunity_soo_compile
,
1728 route_set_ecommunity_free
,
1731 /* `set origin ORIGIN' */
1733 /* For origin set. */
1734 static route_map_result_t
1735 route_set_origin (void *rule
, struct prefix
*prefix
, route_map_object_t type
, void *object
)
1738 struct bgp_info
*bgp_info
;
1740 if (type
== RMAP_BGP
)
1745 bgp_info
->attr
->origin
= *origin
;
1751 /* Compile function for origin set. */
1753 route_set_origin_compile (const char *arg
)
1757 origin
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (u_char
));
1759 if (strcmp (arg
, "igp") == 0)
1761 else if (strcmp (arg
, "egp") == 0)
1769 /* Compile function for origin set. */
1771 route_set_origin_free (void *rule
)
1773 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1776 /* Set origin rule structure. */
1777 struct route_map_rule_cmd route_set_origin_cmd
=
1781 route_set_origin_compile
,
1782 route_set_origin_free
,
1785 /* `set atomic-aggregate' */
1787 /* For atomic aggregate set. */
1788 static route_map_result_t
1789 route_set_atomic_aggregate (void *rule
, struct prefix
*prefix
,
1790 route_map_object_t type
, void *object
)
1792 struct bgp_info
*bgp_info
;
1794 if (type
== RMAP_BGP
)
1797 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
1803 /* Compile function for atomic aggregate. */
1805 route_set_atomic_aggregate_compile (const char *arg
)
1810 /* Compile function for atomic aggregate. */
1812 route_set_atomic_aggregate_free (void *rule
)
1817 /* Set atomic aggregate rule structure. */
1818 struct route_map_rule_cmd route_set_atomic_aggregate_cmd
=
1821 route_set_atomic_aggregate
,
1822 route_set_atomic_aggregate_compile
,
1823 route_set_atomic_aggregate_free
,
1826 /* `set aggregator as AS A.B.C.D' */
1830 struct in_addr address
;
1833 static route_map_result_t
1834 route_set_aggregator_as (void *rule
, struct prefix
*prefix
,
1835 route_map_object_t type
, void *object
)
1837 struct bgp_info
*bgp_info
;
1838 struct aggregator
*aggregator
;
1839 struct attr_extra
*ae
;
1841 if (type
== RMAP_BGP
)
1845 ae
= bgp_attr_extra_get (bgp_info
->attr
);
1847 ae
->aggregator_as
= aggregator
->as
;
1848 ae
->aggregator_addr
= aggregator
->address
;
1849 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
);
1856 route_set_aggregator_as_compile (const char *arg
)
1858 struct aggregator
*aggregator
;
1862 aggregator
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct aggregator
));
1863 sscanf (arg
, "%s %s", as
, address
);
1865 aggregator
->as
= strtoul (as
, NULL
, 10);
1866 inet_aton (address
, &aggregator
->address
);
1872 route_set_aggregator_as_free (void *rule
)
1874 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1877 struct route_map_rule_cmd route_set_aggregator_as_cmd
=
1880 route_set_aggregator_as
,
1881 route_set_aggregator_as_compile
,
1882 route_set_aggregator_as_free
,
1885 /* Set tag to object. object must be pointer to struct bgp_info */
1886 static route_map_result_t
1887 route_set_tag (void *rule
, struct prefix
*prefix
,
1888 route_map_object_t type
, void *object
)
1891 struct bgp_info
*bgp_info
;
1892 struct attr_extra
*ae
;
1894 if (type
== RMAP_BGP
)
1898 ae
= bgp_attr_extra_get (bgp_info
->attr
);
1908 /* Route map commands for tag set. */
1909 static struct route_map_rule_cmd route_set_tag_cmd
=
1913 route_map_rule_tag_compile
,
1914 route_map_rule_tag_free
,
1919 /* `match ipv6 address IP_ACCESS_LIST' */
1921 static route_map_result_t
1922 route_match_ipv6_address (void *rule
, struct prefix
*prefix
,
1923 route_map_object_t type
, void *object
)
1925 struct access_list
*alist
;
1927 if (type
== RMAP_BGP
)
1929 alist
= access_list_lookup (AFI_IP6
, (char *) rule
);
1931 return RMAP_NOMATCH
;
1933 return (access_list_apply (alist
, prefix
) == FILTER_DENY
?
1934 RMAP_NOMATCH
: RMAP_MATCH
);
1936 return RMAP_NOMATCH
;
1940 route_match_ipv6_address_compile (const char *arg
)
1942 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
1946 route_match_ipv6_address_free (void *rule
)
1948 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
1951 /* Route map commands for ip address matching. */
1952 struct route_map_rule_cmd route_match_ipv6_address_cmd
=
1955 route_match_ipv6_address
,
1956 route_match_ipv6_address_compile
,
1957 route_match_ipv6_address_free
1960 /* `match ipv6 next-hop IP_ADDRESS' */
1962 static route_map_result_t
1963 route_match_ipv6_next_hop (void *rule
, struct prefix
*prefix
,
1964 route_map_object_t type
, void *object
)
1966 struct in6_addr
*addr
= rule
;
1967 struct bgp_info
*bgp_info
;
1969 if (type
== RMAP_BGP
)
1973 if (!bgp_info
->attr
->extra
)
1974 return RMAP_NOMATCH
;
1976 if (IPV6_ADDR_SAME (&bgp_info
->attr
->extra
->mp_nexthop_global
, addr
))
1979 if (bgp_info
->attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
&&
1980 IPV6_ADDR_SAME (&bgp_info
->attr
->extra
->mp_nexthop_local
, rule
))
1983 return RMAP_NOMATCH
;
1986 return RMAP_NOMATCH
;
1990 route_match_ipv6_next_hop_compile (const char *arg
)
1992 struct in6_addr
*address
;
1995 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in6_addr
));
1997 ret
= inet_pton (AF_INET6
, arg
, address
);
2000 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
2008 route_match_ipv6_next_hop_free (void *rule
)
2010 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2013 struct route_map_rule_cmd route_match_ipv6_next_hop_cmd
=
2016 route_match_ipv6_next_hop
,
2017 route_match_ipv6_next_hop_compile
,
2018 route_match_ipv6_next_hop_free
2021 /* `match ipv6 address prefix-list PREFIX_LIST' */
2023 static route_map_result_t
2024 route_match_ipv6_address_prefix_list (void *rule
, struct prefix
*prefix
,
2025 route_map_object_t type
, void *object
)
2027 struct prefix_list
*plist
;
2029 if (type
== RMAP_BGP
)
2031 plist
= prefix_list_lookup (AFI_IP6
, (char *) rule
);
2033 return RMAP_NOMATCH
;
2035 return (prefix_list_apply (plist
, prefix
) == PREFIX_DENY
?
2036 RMAP_NOMATCH
: RMAP_MATCH
);
2038 return RMAP_NOMATCH
;
2042 route_match_ipv6_address_prefix_list_compile (const char *arg
)
2044 return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED
, arg
);
2048 route_match_ipv6_address_prefix_list_free (void *rule
)
2050 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2053 struct route_map_rule_cmd route_match_ipv6_address_prefix_list_cmd
=
2055 "ipv6 address prefix-list",
2056 route_match_ipv6_address_prefix_list
,
2057 route_match_ipv6_address_prefix_list_compile
,
2058 route_match_ipv6_address_prefix_list_free
2061 /* `set ipv6 nexthop global IP_ADDRESS' */
2063 /* Set nexthop to object. ojbect must be pointer to struct attr. */
2064 static route_map_result_t
2065 route_set_ipv6_nexthop_global (void *rule
, struct prefix
*prefix
,
2066 route_map_object_t type
, void *object
)
2068 struct in6_addr
*address
;
2069 struct bgp_info
*bgp_info
;
2071 if (type
== RMAP_BGP
)
2073 /* Fetch routemap's rule information. */
2077 /* Set next hop value. */
2078 (bgp_attr_extra_get (bgp_info
->attr
))->mp_nexthop_global
= *address
;
2080 /* Set nexthop length. */
2081 if (bgp_info
->attr
->extra
->mp_nexthop_len
== 0)
2082 bgp_info
->attr
->extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL
;
2084 SET_FLAG(bgp_info
->attr
->rmap_change_flags
,
2085 BATTR_RMAP_IPV6_GLOBAL_NHOP_CHANGED
);
2091 /* Route map `ip next-hop' compile function. Given string is converted
2092 to struct in_addr structure. */
2094 route_set_ipv6_nexthop_global_compile (const char *arg
)
2097 struct in6_addr
*address
;
2099 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in6_addr
));
2101 ret
= inet_pton (AF_INET6
, arg
, address
);
2105 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
2112 /* Free route map's compiled `ip next-hop' value. */
2114 route_set_ipv6_nexthop_global_free (void *rule
)
2116 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2119 /* Route map commands for ip nexthop set. */
2120 struct route_map_rule_cmd route_set_ipv6_nexthop_global_cmd
=
2122 "ipv6 next-hop global",
2123 route_set_ipv6_nexthop_global
,
2124 route_set_ipv6_nexthop_global_compile
,
2125 route_set_ipv6_nexthop_global_free
2128 /* Set next-hop preference value. */
2129 static route_map_result_t
2130 route_set_ipv6_nexthop_prefer_global (void *rule
, struct prefix
*prefix
,
2131 route_map_object_t type
, void *object
)
2133 struct bgp_info
*bgp_info
;
2136 if (type
== RMAP_BGP
)
2138 /* Fetch routemap's rule information. */
2140 peer
= bgp_info
->peer
;
2142 if ((CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IN
) ||
2143 CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IMPORT
))
2145 && sockunion_family (peer
->su_remote
) == AF_INET6
)
2147 /* Set next hop preference to global */
2148 bgp_info
->attr
->extra
->mp_nexthop_prefer_global
= TRUE
;
2149 SET_FLAG(bgp_info
->attr
->rmap_change_flags
,
2150 BATTR_RMAP_IPV6_PREFER_GLOBAL_CHANGED
);
2154 bgp_info
->attr
->extra
->mp_nexthop_prefer_global
= FALSE
;
2155 SET_FLAG(bgp_info
->attr
->rmap_change_flags
,
2156 BATTR_RMAP_IPV6_PREFER_GLOBAL_CHANGED
);
2163 route_set_ipv6_nexthop_prefer_global_compile (const char *arg
)
2167 rins
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (int));
2173 /* Free route map's compiled `ip next-hop' value. */
2175 route_set_ipv6_nexthop_prefer_global_free (void *rule
)
2177 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2180 /* Route map commands for ip nexthop set preferred. */
2181 struct route_map_rule_cmd route_set_ipv6_nexthop_prefer_global_cmd
=
2183 "ipv6 next-hop prefer-global",
2184 route_set_ipv6_nexthop_prefer_global
,
2185 route_set_ipv6_nexthop_prefer_global_compile
,
2186 route_set_ipv6_nexthop_prefer_global_free
2189 /* `set ipv6 nexthop local IP_ADDRESS' */
2191 /* Set nexthop to object. ojbect must be pointer to struct attr. */
2192 static route_map_result_t
2193 route_set_ipv6_nexthop_local (void *rule
, struct prefix
*prefix
,
2194 route_map_object_t type
, void *object
)
2196 struct in6_addr
*address
;
2197 struct bgp_info
*bgp_info
;
2199 if (type
== RMAP_BGP
)
2201 /* Fetch routemap's rule information. */
2205 /* Set next hop value. */
2206 (bgp_attr_extra_get (bgp_info
->attr
))->mp_nexthop_local
= *address
;
2208 /* Set nexthop length. */
2209 if (bgp_info
->attr
->extra
->mp_nexthop_len
!= BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
2210 bgp_info
->attr
->extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
;
2212 SET_FLAG(bgp_info
->attr
->rmap_change_flags
,
2213 BATTR_RMAP_IPV6_LL_NHOP_CHANGED
);
2219 /* Route map `ip nexthop' compile function. Given string is converted
2220 to struct in_addr structure. */
2222 route_set_ipv6_nexthop_local_compile (const char *arg
)
2225 struct in6_addr
*address
;
2227 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in6_addr
));
2229 ret
= inet_pton (AF_INET6
, arg
, address
);
2233 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
2240 /* Free route map's compiled `ip nexthop' value. */
2242 route_set_ipv6_nexthop_local_free (void *rule
)
2244 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2247 /* Route map commands for ip nexthop set. */
2248 struct route_map_rule_cmd route_set_ipv6_nexthop_local_cmd
=
2250 "ipv6 next-hop local",
2251 route_set_ipv6_nexthop_local
,
2252 route_set_ipv6_nexthop_local_compile
,
2253 route_set_ipv6_nexthop_local_free
2256 /* `set ipv6 nexthop peer-address' */
2258 /* Set nexthop to object. ojbect must be pointer to struct attr. */
2259 static route_map_result_t
2260 route_set_ipv6_nexthop_peer (void *rule
, struct prefix
*prefix
,
2261 route_map_object_t type
, void *object
)
2263 struct in6_addr peer_address
;
2264 struct bgp_info
*bgp_info
;
2267 if (type
== RMAP_BGP
)
2269 /* Fetch routemap's rule information. */
2271 peer
= bgp_info
->peer
;
2273 if ((CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IN
) ||
2274 CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IMPORT
))
2276 && sockunion_family (peer
->su_remote
) == AF_INET6
)
2278 peer_address
= peer
->su_remote
->sin6
.sin6_addr
;
2279 /* Set next hop value and length in attribute. */
2280 if (IN6_IS_ADDR_LINKLOCAL(&peer_address
))
2282 (bgp_attr_extra_get (bgp_info
->attr
))->mp_nexthop_local
= peer_address
;
2283 if (bgp_info
->attr
->extra
->mp_nexthop_len
!= 32)
2284 bgp_info
->attr
->extra
->mp_nexthop_len
= 32;
2288 (bgp_attr_extra_get (bgp_info
->attr
))->mp_nexthop_global
= peer_address
;
2289 if (bgp_info
->attr
->extra
->mp_nexthop_len
== 0)
2290 bgp_info
->attr
->extra
->mp_nexthop_len
= 16;
2294 else if (CHECK_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
))
2296 /* The next hop value will be set as part of packet rewrite.
2297 * Set the flags here to indicate that rewrite needs to be done.
2298 * Also, clear the value - we clear both global and link-local
2299 * nexthops, whether we send one or both is determined elsewhere.
2301 SET_FLAG(bgp_info
->attr
->rmap_change_flags
,
2302 BATTR_RMAP_NEXTHOP_PEER_ADDRESS
);
2303 /* clear next hop value. */
2304 memset (&((bgp_attr_extra_get (bgp_info
->attr
))->mp_nexthop_global
),
2305 0, sizeof (struct in6_addr
));
2306 memset (&((bgp_attr_extra_get (bgp_info
->attr
))->mp_nexthop_local
),
2307 0, sizeof (struct in6_addr
));
2314 /* Route map `ip next-hop' compile function. Given string is converted
2315 to struct in_addr structure. */
2317 route_set_ipv6_nexthop_peer_compile (const char *arg
)
2321 rins
= XCALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (int));
2327 /* Free route map's compiled `ip next-hop' value. */
2329 route_set_ipv6_nexthop_peer_free (void *rule
)
2331 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2334 /* Route map commands for ip nexthop set. */
2335 struct route_map_rule_cmd route_set_ipv6_nexthop_peer_cmd
=
2337 "ipv6 next-hop peer-address",
2338 route_set_ipv6_nexthop_peer
,
2339 route_set_ipv6_nexthop_peer_compile
,
2340 route_set_ipv6_nexthop_peer_free
2343 #endif /* HAVE_IPV6 */
2345 /* `set originator-id' */
2347 /* For origin set. */
2348 static route_map_result_t
2349 route_set_originator_id (void *rule
, struct prefix
*prefix
, route_map_object_t type
, void *object
)
2351 struct in_addr
*address
;
2352 struct bgp_info
*bgp_info
;
2354 if (type
== RMAP_BGP
)
2359 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
);
2360 (bgp_attr_extra_get (bgp_info
->attr
))->originator_id
= *address
;
2366 /* Compile function for originator-id set. */
2368 route_set_originator_id_compile (const char *arg
)
2371 struct in_addr
*address
;
2373 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in_addr
));
2375 ret
= inet_aton (arg
, address
);
2379 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
2386 /* Compile function for originator_id set. */
2388 route_set_originator_id_free (void *rule
)
2390 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2393 /* Set originator-id rule structure. */
2394 struct route_map_rule_cmd route_set_originator_id_cmd
=
2397 route_set_originator_id
,
2398 route_set_originator_id_compile
,
2399 route_set_originator_id_free
,
2402 /* Add bgp route map rule. */
2404 bgp_route_match_add (struct vty
*vty
, struct route_map_index
*index
,
2405 const char *command
, const char *arg
,
2406 route_map_event_t type
)
2410 ret
= route_map_add_match (index
, command
, arg
);
2415 case RMAP_RULE_MISSING
:
2416 vty_out (vty
, "%% BGP Can't find rule.%s", VTY_NEWLINE
);
2418 case RMAP_COMPILE_ERROR
:
2419 vty_out (vty
, "%% BGP Argument is malformed.%s", VTY_NEWLINE
);
2424 if (type
!= RMAP_EVENT_MATCH_ADDED
)
2426 route_map_upd8_dependency (type
, arg
, index
->map
->name
);
2432 /* Delete bgp route map rule. */
2434 bgp_route_match_delete (struct vty
*vty
, struct route_map_index
*index
,
2435 const char *command
, const char *arg
,
2436 route_map_event_t type
)
2439 char *dep_name
= NULL
;
2441 char *rmap_name
= NULL
;
2443 if (type
!= RMAP_EVENT_MATCH_DELETED
)
2445 /* ignore the mundane, the types without any dependency */
2448 if ((tmpstr
= route_map_get_match_arg(index
, command
)) != NULL
)
2449 dep_name
= XSTRDUP(MTYPE_ROUTE_MAP_RULE
, tmpstr
);
2453 dep_name
= XSTRDUP(MTYPE_ROUTE_MAP_RULE
, arg
);
2455 rmap_name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, index
->map
->name
);
2458 ret
= route_map_delete_match (index
, command
, dep_name
);
2463 case RMAP_RULE_MISSING
:
2464 vty_out (vty
, "%% BGP Can't find rule.%s", VTY_NEWLINE
);
2466 case RMAP_COMPILE_ERROR
:
2467 vty_out (vty
, "%% BGP Argument is malformed.%s", VTY_NEWLINE
);
2471 XFREE(MTYPE_ROUTE_MAP_RULE
, dep_name
);
2473 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap_name
);
2477 if (type
!= RMAP_EVENT_MATCH_DELETED
&& dep_name
)
2478 route_map_upd8_dependency(type
, dep_name
, rmap_name
);
2481 XFREE(MTYPE_ROUTE_MAP_RULE
, dep_name
);
2483 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap_name
);
2488 /* Add bgp route map rule. */
2490 bgp_route_set_add (struct vty
*vty
, struct route_map_index
*index
,
2491 const char *command
, const char *arg
)
2495 ret
= route_map_add_set (index
, command
, arg
);
2500 case RMAP_RULE_MISSING
:
2501 vty_out (vty
, "%% BGP Can't find rule.%s", VTY_NEWLINE
);
2503 case RMAP_COMPILE_ERROR
:
2504 vty_out (vty
, "%% BGP Argument is malformed.%s", VTY_NEWLINE
);
2511 /* Delete bgp route map rule. */
2513 bgp_route_set_delete (struct vty
*vty
, struct route_map_index
*index
,
2514 const char *command
, const char *arg
)
2518 ret
= route_map_delete_set (index
, command
, arg
);
2523 case RMAP_RULE_MISSING
:
2524 vty_out (vty
, "%% BGP Can't find rule.%s", VTY_NEWLINE
);
2526 case RMAP_COMPILE_ERROR
:
2527 vty_out (vty
, "%% BGP Argument is malformed.%s", VTY_NEWLINE
);
2535 * This is the workhorse routine for processing in/out routemap
2539 bgp_route_map_process_peer (const char *rmap_name
, struct route_map
*map
,
2540 struct peer
*peer
, int afi
, int safi
,
2545 struct bgp_filter
*filter
;
2547 if (!peer
|| !rmap_name
)
2550 filter
= &peer
->filter
[afi
][safi
];
2552 * in is for non-route-server clients,
2553 * out is for all peers
2555 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_RSERVER_CLIENT
))
2557 if (filter
->map
[RMAP_IN
].name
&&
2558 (strcmp(rmap_name
, filter
->map
[RMAP_IN
].name
) == 0))
2560 filter
->map
[RMAP_IN
].map
= map
;
2562 if (route_update
&& peer
->status
== Established
)
2564 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
],
2565 PEER_FLAG_SOFT_RECONFIG
))
2567 if (bgp_debug_update(peer
, NULL
, NULL
, 1))
2568 zlog_debug("Processing route_map %s update on "
2569 "peer %s (inbound, soft-reconfig)",
2570 rmap_name
, peer
->host
);
2572 bgp_soft_reconfig_in (peer
, afi
, safi
);
2574 else if (CHECK_FLAG (peer
->cap
, PEER_CAP_REFRESH_OLD_RCV
)
2575 || CHECK_FLAG (peer
->cap
, PEER_CAP_REFRESH_NEW_RCV
))
2578 if (bgp_debug_update(peer
, NULL
, NULL
, 1))
2579 zlog_debug("Processing route_map %s update on "
2580 "peer %s (inbound, route-refresh)",
2581 rmap_name
, peer
->host
);
2582 bgp_route_refresh_send (peer
, afi
, safi
, 0, 0, 0);
2588 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_RSERVER_CLIENT
))
2592 if (update
&& route_update
&& peer
->status
== Established
)
2594 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
],
2595 PEER_FLAG_SOFT_RECONFIG
))
2597 if (bgp_debug_update(peer
, NULL
, NULL
, 1))
2598 zlog_debug("Processing route_map %s update on "
2599 "peer %s (import, soft-reconfig)",
2600 rmap_name
, peer
->host
);
2602 bgp_soft_reconfig_in (peer
, afi
, safi
);
2604 else if (CHECK_FLAG (peer
->cap
, PEER_CAP_REFRESH_OLD_RCV
)
2605 || CHECK_FLAG (peer
->cap
, PEER_CAP_REFRESH_NEW_RCV
))
2607 if (bgp_debug_update(peer
, NULL
, NULL
, 1))
2608 zlog_debug("Processing route_map %s update on "
2609 "peer %s (import, route-refresh)",
2610 rmap_name
, peer
->host
);
2611 bgp_route_refresh_send (peer
, afi
, safi
, 0, 0, 0);
2613 /* DD: Else, what else do we do ? Reset peer ? */
2618 * For outbound, unsuppress and default-originate map change (content or
2619 * map created), merely update the "config" here, the actual route
2620 * announcement happens at the group level.
2622 if (filter
->map
[RMAP_OUT
].name
&&
2623 (strcmp(rmap_name
, filter
->map
[RMAP_OUT
].name
) == 0))
2624 filter
->map
[RMAP_OUT
].map
= map
;
2626 if (filter
->usmap
.name
&&
2627 (strcmp(rmap_name
, filter
->usmap
.name
) == 0))
2628 filter
->usmap
.map
= map
;
2630 if (peer
->default_rmap
[afi
][safi
].name
&&
2631 (strcmp (rmap_name
, peer
->default_rmap
[afi
][safi
].name
) == 0))
2632 peer
->default_rmap
[afi
][safi
].map
= map
;
2636 bgp_route_map_update_peer_group(const char *rmap_name
, struct route_map
*map
,
2639 struct peer_group
*group
;
2640 struct listnode
*node
, *nnode
;
2641 struct bgp_filter
*filter
;
2648 /* All the peers have been updated correctly already. This is
2649 * just updating the placeholder data. No real update required.
2651 for (ALL_LIST_ELEMENTS (bgp
->group
, node
, nnode
, group
))
2652 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2653 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2655 filter
= &group
->conf
->filter
[afi
][safi
];
2657 for (direct
= RMAP_IN
; direct
< RMAP_MAX
; direct
++)
2659 if ((filter
->map
[direct
].name
) &&
2660 (strcmp(rmap_name
, filter
->map
[direct
].name
) == 0))
2661 filter
->map
[direct
].map
= map
;
2664 if (filter
->usmap
.name
&&
2665 (strcmp(rmap_name
, filter
->usmap
.name
) == 0))
2666 filter
->usmap
.map
= map
;
2671 * Note that if an extreme number (tens of thousands) of route-maps are in use
2672 * and if bgp has an extreme number of peers, network statements, etc then this
2673 * function can consume a lot of cycles. This is due to this function being
2674 * called for each route-map and within this function we walk the list of peers,
2675 * network statements, etc looking to see if they use this route-map.
2678 bgp_route_map_process_update (struct bgp
*bgp
, const char *rmap_name
, int route_update
)
2684 struct bgp_node
*bn
;
2685 struct bgp_static
*bgp_static
;
2686 struct listnode
*node
, *nnode
;
2687 struct route_map
*map
;
2688 char buf
[INET6_ADDRSTRLEN
];
2690 map
= route_map_lookup_by_name (rmap_name
);
2692 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
2695 /* Ignore dummy peer-group structure */
2696 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
))
2699 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2700 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2702 /* Ignore inactive AFI/SAFI */
2703 if (! peer
->afc
[afi
][safi
])
2706 /* process in/out/import/export/default-orig route-maps */
2707 bgp_route_map_process_peer(rmap_name
, map
, peer
, afi
, safi
, route_update
);
2711 /* for outbound/default-orig route-maps, process for groups */
2712 update_group_policy_update(bgp
, BGP_POLICY_ROUTE_MAP
, rmap_name
,
2715 /* update peer-group config (template) */
2716 bgp_route_map_update_peer_group(rmap_name
, map
, bgp
);
2718 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2719 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2721 /* For table route-map updates. */
2722 if (bgp
->table_map
[afi
][safi
].name
&&
2723 (strcmp(rmap_name
, bgp
->table_map
[afi
][safi
].name
) == 0))
2725 bgp
->table_map
[afi
][safi
].map
= map
;
2727 if (BGP_DEBUG (zebra
, ZEBRA
))
2728 zlog_debug("Processing route_map %s update on "
2729 "table map", rmap_name
);
2731 bgp_zebra_announce_table(bgp
, afi
, safi
);
2734 /* For network route-map updates. */
2735 for (bn
= bgp_table_top (bgp
->route
[afi
][safi
]); bn
; bn
= bgp_route_next (bn
))
2736 if ((bgp_static
= bn
->info
) != NULL
)
2738 if (bgp_static
->rmap
.name
&&
2739 (strcmp(rmap_name
, bgp_static
->rmap
.name
) == 0))
2741 bgp_static
->rmap
.map
= map
;
2744 if (!bgp_static
->backdoor
)
2746 if (bgp_debug_zebra(&bn
->p
))
2747 zlog_debug("Processing route_map %s update on "
2748 "static route %s", rmap_name
,
2749 inet_ntop (bn
->p
.family
, &bn
->p
.u
.prefix
,
2750 buf
, INET6_ADDRSTRLEN
));
2751 bgp_static_update (bgp
, &bn
->p
, bgp_static
, afi
, safi
);
2757 /* For redistribute route-map updates. */
2758 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2759 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++)
2761 struct list
*red_list
;
2762 struct listnode
*node
;
2763 struct bgp_redist
*red
;
2765 red_list
= bgp
->redist
[afi
][i
];
2769 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
))
2771 if (red
->rmap
.name
&&
2772 (strcmp(rmap_name
, red
->rmap
.name
) == 0))
2774 red
->rmap
.map
= map
;
2778 if (BGP_DEBUG (zebra
, ZEBRA
))
2779 zlog_debug("Processing route_map %s update on "
2780 "redistributed routes", rmap_name
);
2782 bgp_redistribute_resend (bgp
, afi
, i
, red
->instance
);
2790 bgp_route_map_process_update_cb (char *rmap_name
)
2792 struct listnode
*node
, *nnode
;
2795 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
2796 bgp_route_map_process_update(bgp
, rmap_name
, 1);
2799 zlog_debug("%s: calling vnc_routemap_update", __func__
);
2800 vnc_routemap_update(bgp
, __func__
);
2806 bgp_route_map_update_timer(struct thread
*thread
)
2808 bm
->t_rmap_update
= NULL
;
2810 route_map_walk_update_list(bgp_route_map_process_update_cb
);
2816 bgp_route_map_mark_update (const char *rmap_name
)
2818 if (bm
->t_rmap_update
== NULL
)
2820 struct listnode
*node
, *nnode
;
2823 /* rmap_update_timer of 0 means don't do route updates */
2824 if (bm
->rmap_update_timer
)
2827 thread_add_timer(bm
->master
, bgp_route_map_update_timer
, NULL
,
2828 bm
->rmap_update_timer
);
2830 /* Signal the groups that a route-map update event has started */
2831 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
2832 update_group_policy_update(bgp
, BGP_POLICY_ROUTE_MAP
, rmap_name
, 1, 1);
2836 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
2837 bgp_route_map_process_update(bgp
, rmap_name
, 0);
2839 zlog_debug("%s: calling vnc_routemap_update", __func__
);
2840 vnc_routemap_update(bgp
, __func__
);
2847 bgp_route_map_add (const char *rmap_name
)
2849 if (route_map_mark_updated(rmap_name
, 0) == 0)
2850 bgp_route_map_mark_update(rmap_name
);
2852 route_map_notify_dependencies(rmap_name
, RMAP_EVENT_MATCH_ADDED
);
2856 bgp_route_map_delete (const char *rmap_name
)
2858 if (route_map_mark_updated(rmap_name
, 1) == 0)
2859 bgp_route_map_mark_update(rmap_name
);
2861 route_map_notify_dependencies(rmap_name
, RMAP_EVENT_MATCH_DELETED
);
2865 bgp_route_map_event (route_map_event_t event
, const char *rmap_name
)
2867 if (route_map_mark_updated(rmap_name
, 0) == 0)
2868 bgp_route_map_mark_update(rmap_name
);
2870 route_map_notify_dependencies(rmap_name
, RMAP_EVENT_MATCH_ADDED
);
2876 "match peer (A.B.C.D|X:X::X:X)",
2878 "Match peer address\n"
2879 "IP address of peer\n"
2880 "IPv6 address of peer\n")
2882 return bgp_route_match_add (vty
, vty
->index
, "peer", argv
[0],
2883 RMAP_EVENT_MATCH_ADDED
);
2886 DEFUN (match_peer_local
,
2887 match_peer_local_cmd
,
2890 "Match peer address\n"
2891 "Static or Redistributed routes\n")
2893 return bgp_route_match_add (vty
, vty
->index
, "peer", "local",
2894 RMAP_EVENT_MATCH_DELETED
);
2897 DEFUN (no_match_peer
,
2902 "Match peer address\n")
2905 return bgp_route_match_delete (vty
, vty
->index
, "peer", NULL
,
2906 RMAP_EVENT_MATCH_DELETED
);
2908 return bgp_route_match_delete (vty
, vty
->index
, "peer", argv
[0],
2909 RMAP_EVENT_MATCH_DELETED
);
2912 ALIAS (no_match_peer
,
2913 no_match_peer_val_cmd
,
2914 "no match peer (A.B.C.D|X:X::X:X)",
2917 "Match peer address\n"
2918 "IP address of peer\n"
2919 "IPv6 address of peer\n")
2921 ALIAS (no_match_peer
,
2922 no_match_peer_local_cmd
,
2923 "no match peer local",
2926 "Match peer address\n"
2927 "Static or Redistributed routes\n")
2929 DEFUN (match_ip_address
,
2930 match_ip_address_cmd
,
2931 "match ip address (<1-199>|<1300-2699>|WORD)",
2934 "Match address of route\n"
2935 "IP access-list number\n"
2936 "IP access-list number (expanded range)\n"
2937 "IP Access-list name\n")
2939 return bgp_route_match_add (vty
, vty
->index
, "ip address", argv
[0],
2940 RMAP_EVENT_FILTER_ADDED
);
2943 DEFUN (no_match_ip_address
,
2944 no_match_ip_address_cmd
,
2945 "no match ip address",
2949 "Match address of route\n")
2952 return bgp_route_match_delete (vty
, vty
->index
, "ip address", NULL
,
2953 RMAP_EVENT_FILTER_DELETED
);
2955 return bgp_route_match_delete (vty
, vty
->index
, "ip address", argv
[0],
2956 RMAP_EVENT_FILTER_DELETED
);
2959 ALIAS (no_match_ip_address
,
2960 no_match_ip_address_val_cmd
,
2961 "no match ip address (<1-199>|<1300-2699>|WORD)",
2965 "Match address of route\n"
2966 "IP access-list number\n"
2967 "IP access-list number (expanded range)\n"
2968 "IP Access-list name\n")
2970 DEFUN (match_ip_next_hop
,
2971 match_ip_next_hop_cmd
,
2972 "match ip next-hop (<1-199>|<1300-2699>|WORD)",
2975 "Match next-hop address of route\n"
2976 "IP access-list number\n"
2977 "IP access-list number (expanded range)\n"
2978 "IP Access-list name\n")
2980 return bgp_route_match_add (vty
, vty
->index
, "ip next-hop", argv
[0],
2981 RMAP_EVENT_FILTER_ADDED
);
2984 DEFUN (no_match_ip_next_hop
,
2985 no_match_ip_next_hop_cmd
,
2986 "no match ip next-hop",
2990 "Match next-hop address of route\n")
2993 return bgp_route_match_delete (vty
, vty
->index
, "ip next-hop", NULL
,
2994 RMAP_EVENT_FILTER_DELETED
);
2996 return bgp_route_match_delete (vty
, vty
->index
, "ip next-hop", argv
[0],
2997 RMAP_EVENT_FILTER_DELETED
);
3000 ALIAS (no_match_ip_next_hop
,
3001 no_match_ip_next_hop_val_cmd
,
3002 "no match ip next-hop (<1-199>|<1300-2699>|WORD)",
3006 "Match next-hop address of route\n"
3007 "IP access-list number\n"
3008 "IP access-list number (expanded range)\n"
3009 "IP Access-list name\n")
3011 /* match probability { */
3013 DEFUN (match_probability
,
3014 match_probability_cmd
,
3015 "match probability <0-100>",
3017 "Match portion of routes defined by percentage value\n"
3018 "Percentage of routes\n")
3020 return bgp_route_match_add (vty
, vty
->index
, "probability", argv
[0],
3021 RMAP_EVENT_MATCH_ADDED
);
3024 DEFUN (no_match_probability
,
3025 no_match_probability_cmd
,
3026 "no match probability",
3029 "Match portion of routes defined by percentage value\n")
3031 return bgp_route_match_delete (vty
, vty
->index
, "probability", argc
? argv
[0] : NULL
,
3032 RMAP_EVENT_MATCH_DELETED
);
3035 ALIAS (no_match_probability
,
3036 no_match_probability_val_cmd
,
3037 "no match probability <1-99>",
3040 "Match portion of routes defined by percentage value\n"
3041 "Percentage of routes\n")
3045 DEFUN (match_ip_route_source
,
3046 match_ip_route_source_cmd
,
3047 "match ip route-source (<1-199>|<1300-2699>|WORD)",
3050 "Match advertising source address of route\n"
3051 "IP access-list number\n"
3052 "IP access-list number (expanded range)\n"
3053 "IP standard access-list name\n")
3055 return bgp_route_match_add (vty
, vty
->index
, "ip route-source", argv
[0],
3056 RMAP_EVENT_FILTER_ADDED
);
3059 DEFUN (no_match_ip_route_source
,
3060 no_match_ip_route_source_cmd
,
3061 "no match ip route-source",
3065 "Match advertising source address of route\n")
3068 return bgp_route_match_delete (vty
, vty
->index
, "ip route-source", NULL
,
3069 RMAP_EVENT_FILTER_DELETED
);
3071 return bgp_route_match_delete (vty
, vty
->index
, "ip route-source",
3072 argv
[0], RMAP_EVENT_FILTER_DELETED
);
3075 ALIAS (no_match_ip_route_source
,
3076 no_match_ip_route_source_val_cmd
,
3077 "no match ip route-source (<1-199>|<1300-2699>|WORD)",
3081 "Match advertising source address of route\n"
3082 "IP access-list number\n"
3083 "IP access-list number (expanded range)\n"
3084 "IP standard access-list name\n")
3086 DEFUN (match_ip_address_prefix_list
,
3087 match_ip_address_prefix_list_cmd
,
3088 "match ip address prefix-list WORD",
3091 "Match address of route\n"
3092 "Match entries of prefix-lists\n"
3093 "IP prefix-list name\n")
3095 return bgp_route_match_add (vty
, vty
->index
, "ip address prefix-list",
3096 argv
[0], RMAP_EVENT_PLIST_ADDED
);
3099 DEFUN (no_match_ip_address_prefix_list
,
3100 no_match_ip_address_prefix_list_cmd
,
3101 "no match ip address prefix-list",
3105 "Match address of route\n"
3106 "Match entries of prefix-lists\n")
3108 return bgp_route_match_delete (vty
, vty
->index
, "ip address prefix-list",
3109 argc
== 0 ? NULL
: argv
[0],
3110 RMAP_EVENT_PLIST_DELETED
);
3113 ALIAS (no_match_ip_address_prefix_list
,
3114 no_match_ip_address_prefix_list_val_cmd
,
3115 "no match ip address prefix-list WORD",
3119 "Match address of route\n"
3120 "Match entries of prefix-lists\n"
3121 "IP prefix-list name\n")
3123 DEFUN (match_ip_next_hop_prefix_list
,
3124 match_ip_next_hop_prefix_list_cmd
,
3125 "match ip next-hop prefix-list WORD",
3128 "Match next-hop address of route\n"
3129 "Match entries of prefix-lists\n"
3130 "IP prefix-list name\n")
3132 return bgp_route_match_add (vty
, vty
->index
, "ip next-hop prefix-list",
3133 argv
[0], RMAP_EVENT_PLIST_ADDED
);
3136 DEFUN (no_match_ip_next_hop_prefix_list
,
3137 no_match_ip_next_hop_prefix_list_cmd
,
3138 "no match ip next-hop prefix-list",
3142 "Match next-hop address of route\n"
3143 "Match entries of prefix-lists\n")
3145 return bgp_route_match_delete (vty
, vty
->index
, "ip next-hop prefix-list",
3146 argc
== 0 ? NULL
: argv
[0],
3147 RMAP_EVENT_PLIST_DELETED
);
3150 ALIAS (no_match_ip_next_hop_prefix_list
,
3151 no_match_ip_next_hop_prefix_list_val_cmd
,
3152 "no match ip next-hop prefix-list WORD",
3156 "Match next-hop address of route\n"
3157 "Match entries of prefix-lists\n"
3158 "IP prefix-list name\n")
3160 DEFUN (match_ip_route_source_prefix_list
,
3161 match_ip_route_source_prefix_list_cmd
,
3162 "match ip route-source prefix-list WORD",
3165 "Match advertising source address of route\n"
3166 "Match entries of prefix-lists\n"
3167 "IP prefix-list name\n")
3169 return bgp_route_match_add (vty
, vty
->index
, "ip route-source prefix-list",
3170 argv
[0], RMAP_EVENT_PLIST_ADDED
);
3173 DEFUN (no_match_ip_route_source_prefix_list
,
3174 no_match_ip_route_source_prefix_list_cmd
,
3175 "no match ip route-source prefix-list",
3179 "Match advertising source address of route\n"
3180 "Match entries of prefix-lists\n")
3182 return bgp_route_match_delete (vty
, vty
->index
, "ip route-source prefix-list",
3183 argc
== 0 ? NULL
: argv
[0],
3184 RMAP_EVENT_PLIST_DELETED
);
3187 ALIAS (no_match_ip_route_source_prefix_list
,
3188 no_match_ip_route_source_prefix_list_val_cmd
,
3189 "no match ip route-source prefix-list WORD",
3193 "Match advertising source address of route\n"
3194 "Match entries of prefix-lists\n"
3195 "IP prefix-list name\n")
3197 DEFUN (match_metric
,
3199 "match metric <0-4294967295>",
3201 "Match metric of route\n"
3204 return bgp_route_match_add (vty
, vty
->index
, "metric", argv
[0],
3205 RMAP_EVENT_MATCH_ADDED
);
3208 DEFUN (no_match_metric
,
3209 no_match_metric_cmd
,
3213 "Match metric of route\n")
3215 return bgp_route_match_delete (vty
, vty
->index
, "metric",
3216 argc
== 0 ? NULL
: argv
[0],
3217 RMAP_EVENT_MATCH_DELETED
);
3220 ALIAS (no_match_metric
,
3221 no_match_metric_val_cmd
,
3222 "no match metric <0-4294967295>",
3225 "Match metric of route\n"
3228 DEFUN (match_local_pref
,
3229 match_local_pref_cmd
,
3230 "match local-preference <0-4294967295>",
3232 "Match local-preference of route\n"
3235 return bgp_route_match_add (vty
, vty
->index
, "local-preference", argv
[0],
3236 RMAP_EVENT_MATCH_ADDED
);
3239 DEFUN (no_match_local_pref
,
3240 no_match_local_pref_cmd
,
3241 "no match local-preference",
3244 "Match local preference of route\n")
3246 return bgp_route_match_delete (vty
, vty
->index
, "local-preference",
3247 argc
== 0 ? NULL
: argv
[0],
3248 RMAP_EVENT_MATCH_DELETED
);
3250 return bgp_route_match_delete (vty
, vty
->index
, "local-preference", argv
[0],
3251 RMAP_EVENT_MATCH_DELETED
);
3254 ALIAS (no_match_local_pref
,
3255 no_match_local_pref_val_cmd
,
3256 "no match local-preference <0-4294967295>",
3259 "Match local preference of route\n"
3260 "Local preference value\n")
3262 DEFUN (match_community
,
3263 match_community_cmd
,
3264 "match community (<1-99>|<100-500>|WORD)",
3266 "Match BGP community list\n"
3267 "Community-list number (standard)\n"
3268 "Community-list number (expanded)\n"
3269 "Community-list name\n")
3271 return bgp_route_match_add (vty
, vty
->index
, "community", argv
[0],
3272 RMAP_EVENT_CLIST_ADDED
);
3275 DEFUN (match_community_exact
,
3276 match_community_exact_cmd
,
3277 "match community (<1-99>|<100-500>|WORD) exact-match",
3279 "Match BGP community list\n"
3280 "Community-list number (standard)\n"
3281 "Community-list number (expanded)\n"
3282 "Community-list name\n"
3283 "Do exact matching of communities\n")
3288 argstr
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
,
3289 strlen (argv
[0]) + strlen ("exact-match") + 2);
3291 sprintf (argstr
, "%s exact-match", argv
[0]);
3293 ret
= bgp_route_match_add (vty
, vty
->index
, "community", argstr
,
3294 RMAP_EVENT_CLIST_ADDED
);
3296 XFREE (MTYPE_ROUTE_MAP_COMPILED
, argstr
);
3301 DEFUN (no_match_community
,
3302 no_match_community_cmd
,
3303 "no match community",
3306 "Match BGP community list\n")
3308 return bgp_route_match_delete (vty
, vty
->index
, "community", NULL
,
3309 RMAP_EVENT_CLIST_DELETED
);
3312 ALIAS (no_match_community
,
3313 no_match_community_val_cmd
,
3314 "no match community (<1-99>|<100-500>|WORD)",
3317 "Match BGP community list\n"
3318 "Community-list number (standard)\n"
3319 "Community-list number (expanded)\n"
3320 "Community-list name\n")
3322 ALIAS (no_match_community
,
3323 no_match_community_exact_cmd
,
3324 "no match community (<1-99>|<100-500>|WORD) exact-match",
3327 "Match BGP community list\n"
3328 "Community-list number (standard)\n"
3329 "Community-list number (expanded)\n"
3330 "Community-list name\n"
3331 "Do exact matching of communities\n")
3333 DEFUN (match_ecommunity
,
3334 match_ecommunity_cmd
,
3335 "match extcommunity (<1-99>|<100-500>|WORD)",
3337 "Match BGP/VPN extended community list\n"
3338 "Extended community-list number (standard)\n"
3339 "Extended community-list number (expanded)\n"
3340 "Extended community-list name\n")
3342 return bgp_route_match_add (vty
, vty
->index
, "extcommunity", argv
[0],
3343 RMAP_EVENT_ECLIST_ADDED
);
3346 DEFUN (no_match_ecommunity
,
3347 no_match_ecommunity_cmd
,
3348 "no match extcommunity",
3351 "Match BGP/VPN extended community list\n")
3353 return bgp_route_match_delete (vty
, vty
->index
, "extcommunity", NULL
,
3354 RMAP_EVENT_ECLIST_DELETED
);
3357 ALIAS (no_match_ecommunity
,
3358 no_match_ecommunity_val_cmd
,
3359 "no match extcommunity (<1-99>|<100-500>|WORD)",
3362 "Match BGP/VPN extended community list\n"
3363 "Extended community-list number (standard)\n"
3364 "Extended community-list number (expanded)\n"
3365 "Extended community-list name\n")
3367 DEFUN (match_aspath
,
3369 "match as-path WORD",
3371 "Match BGP AS path list\n"
3372 "AS path access-list name\n")
3374 return bgp_route_match_add (vty
, vty
->index
, "as-path", argv
[0],
3375 RMAP_EVENT_ASLIST_ADDED
);
3378 DEFUN (no_match_aspath
,
3379 no_match_aspath_cmd
,
3383 "Match BGP AS path list\n")
3385 return bgp_route_match_delete (vty
, vty
->index
, "as-path", NULL
,
3386 RMAP_EVENT_ASLIST_DELETED
);
3389 ALIAS (no_match_aspath
,
3390 no_match_aspath_val_cmd
,
3391 "no match as-path WORD",
3394 "Match BGP AS path list\n"
3395 "AS path access-list name\n")
3397 DEFUN (match_origin
,
3399 "match origin (egp|igp|incomplete)",
3404 "unknown heritage\n")
3406 if (strncmp (argv
[0], "igp", 2) == 0)
3407 return bgp_route_match_add (vty
, vty
->index
, "origin", "igp",
3408 RMAP_EVENT_MATCH_ADDED
);
3409 if (strncmp (argv
[0], "egp", 1) == 0)
3410 return bgp_route_match_add (vty
, vty
->index
, "origin", "egp",
3411 RMAP_EVENT_MATCH_ADDED
);
3412 if (strncmp (argv
[0], "incomplete", 2) == 0)
3413 return bgp_route_match_add (vty
, vty
->index
, "origin", "incomplete",
3414 RMAP_EVENT_MATCH_ADDED
);
3419 DEFUN (no_match_origin
,
3420 no_match_origin_cmd
,
3424 "BGP origin code\n")
3426 return bgp_route_match_delete (vty
, vty
->index
, "origin", NULL
,
3427 RMAP_EVENT_MATCH_DELETED
);
3430 ALIAS (no_match_origin
,
3431 no_match_origin_val_cmd
,
3432 "no match origin (egp|igp|incomplete)",
3438 "unknown heritage\n")
3440 DEFUN (match_interface
,
3441 match_interface_cmd
,
3442 "match interface WORD",
3444 "Match first hop interface of route\n"
3447 return bgp_route_match_add (vty
, vty
->index
, "interface", argv
[0],
3448 RMAP_EVENT_MATCH_ADDED
);
3451 DEFUN (no_match_interface
,
3452 no_match_interface_cmd
,
3453 "no match interface",
3456 "Match first hop interface of route\n")
3459 return bgp_route_match_delete (vty
, vty
->index
, "interface", NULL
,
3460 RMAP_EVENT_MATCH_DELETED
);
3462 return bgp_route_match_delete (vty
, vty
->index
, "interface", argv
[0],
3463 RMAP_EVENT_MATCH_DELETED
);
3466 ALIAS (no_match_interface
,
3467 no_match_interface_val_cmd
,
3468 "no match interface WORD",
3471 "Match first hop interface of route\n"
3476 "match tag <1-4294967295>",
3478 "Match tag of route\n"
3481 return bgp_route_match_add (vty
, vty
->index
, "tag", argv
[0],
3482 RMAP_EVENT_MATCH_ADDED
);
3485 DEFUN (no_match_tag
,
3490 "Match tag of route\n")
3493 return bgp_route_match_delete (vty
, vty
->index
, "tag", NULL
,
3494 RMAP_EVENT_MATCH_DELETED
);
3496 return bgp_route_match_delete (vty
, vty
->index
, "tag", argv
[0],
3497 RMAP_EVENT_MATCH_DELETED
);
3500 ALIAS (no_match_tag
,
3501 no_match_tag_val_cmd
,
3502 "no match tag <1-4294967295>",
3505 "Match tag of route\n"
3509 DEFUN (set_ip_nexthop
,
3511 "set ip next-hop A.B.C.D",
3514 "Next hop address\n"
3515 "IP address of next hop\n")
3520 ret
= str2sockunion (argv
[0], &su
);
3523 vty_out (vty
, "%% Malformed nexthop address%s", VTY_NEWLINE
);
3526 if (su
.sin
.sin_addr
.s_addr
== 0 ||
3527 IPV4_CLASS_DE(su
.sin
.sin_addr
.s_addr
))
3529 vty_out (vty
, "%% nexthop address cannot be 0.0.0.0, multicast "
3530 "or reserved%s", VTY_NEWLINE
);
3534 return bgp_route_set_add (vty
, vty
->index
, "ip next-hop", argv
[0]);
3537 DEFUN (set_ip_nexthop_peer
,
3538 set_ip_nexthop_peer_cmd
,
3539 "set ip next-hop peer-address",
3542 "Next hop address\n"
3543 "Use peer address (for BGP only)\n")
3545 return bgp_route_set_add (vty
, vty
->index
, "ip next-hop", "peer-address");
3548 DEFUN (set_ip_nexthop_unchanged
,
3549 set_ip_nexthop_unchanged_cmd
,
3550 "set ip next-hop unchanged",
3553 "Next hop address\n"
3554 "Don't modify existing Next hop address\n")
3556 return bgp_route_set_add (vty
, vty
->index
, "ip next-hop", "unchanged");
3559 DEFUN (no_set_ip_nexthop
,
3560 no_set_ip_nexthop_cmd
,
3561 "no set ip next-hop",
3564 "Next hop address\n")
3567 return bgp_route_set_delete (vty
, vty
->index
, "ip next-hop", NULL
);
3569 return bgp_route_set_delete (vty
, vty
->index
, "ip next-hop", argv
[0]);
3572 ALIAS (no_set_ip_nexthop
,
3573 no_set_ip_nexthop_val_cmd
,
3574 "no set ip next-hop A.B.C.D",
3578 "Next hop address\n"
3579 "IP address of next hop\n")
3581 ALIAS (no_set_ip_nexthop
,
3582 no_set_ip_nexthop_peer_cmd
,
3583 "no set ip next-hop peer-address",
3587 "Next hop address\n"
3588 "Use peer address (for BGP only)\n")
3592 "set metric <0-4294967295>",
3594 "Metric value for destination routing protocol\n"
3597 return bgp_route_set_add (vty
, vty
->index
, "metric", argv
[0]);
3601 set_metric_addsub_cmd
,
3602 "set metric <+/-metric>",
3604 "Metric value for destination routing protocol\n"
3605 "Add or subtract metric\n")
3609 "set metric (rtt|+rtt|-rtt)",
3611 "Metric value for destination routing protocol\n"
3612 "Assign round trip time\n"
3613 "Add round trip time\n"
3614 "Subtract round trip time\n")
3616 DEFUN (no_set_metric
,
3621 "Metric value for destination routing protocol\n")
3624 return bgp_route_set_delete (vty
, vty
->index
, "metric", NULL
);
3626 return bgp_route_set_delete (vty
, vty
->index
, "metric", argv
[0]);
3629 ALIAS (no_set_metric
,
3630 no_set_metric_val_cmd
,
3631 "no set metric <0-4294967295>",
3634 "Metric value for destination routing protocol\n"
3637 DEFUN (set_local_pref
,
3639 "set local-preference <0-4294967295>",
3641 "BGP local preference path attribute\n"
3642 "Preference value\n")
3644 return bgp_route_set_add (vty
, vty
->index
, "local-preference", argv
[0]);
3647 DEFUN (no_set_local_pref
,
3648 no_set_local_pref_cmd
,
3649 "no set local-preference",
3652 "BGP local preference path attribute\n")
3655 return bgp_route_set_delete (vty
, vty
->index
, "local-preference", NULL
);
3657 return bgp_route_set_delete (vty
, vty
->index
, "local-preference", argv
[0]);
3660 ALIAS (no_set_local_pref
,
3661 no_set_local_pref_val_cmd
,
3662 "no set local-preference <0-4294967295>",
3665 "BGP local preference path attribute\n"
3666 "Preference value\n")
3670 "set weight <0-4294967295>",
3672 "BGP weight for routing table\n"
3675 return bgp_route_set_add (vty
, vty
->index
, "weight", argv
[0]);
3678 DEFUN (no_set_weight
,
3683 "BGP weight for routing table\n")
3686 return bgp_route_set_delete (vty
, vty
->index
, "weight", NULL
);
3688 return bgp_route_set_delete (vty
, vty
->index
, "weight", argv
[0]);
3691 ALIAS (no_set_weight
,
3692 no_set_weight_val_cmd
,
3693 "no set weight <0-4294967295>",
3696 "BGP weight for routing table\n"
3699 DEFUN (set_aspath_prepend
,
3700 set_aspath_prepend_cmd
,
3701 "set as-path prepend ." CMD_AS_RANGE
,
3703 "Transform BGP AS_PATH attribute\n"
3704 "Prepend to the as-path\n"
3710 str
= argv_concat (argv
, argc
, 0);
3711 ret
= bgp_route_set_add (vty
, vty
->index
, "as-path prepend", str
);
3712 XFREE (MTYPE_TMP
, str
);
3717 ALIAS (set_aspath_prepend
,
3718 set_aspath_prepend_lastas_cmd
,
3719 "set as-path prepend (last-as) <1-10>",
3721 "Transform BGP AS_PATH attribute\n"
3722 "Prepend to the as-path\n"
3723 "Use the peer's AS-number\n"
3724 "Number of times to insert")
3726 DEFUN (no_set_aspath_prepend
,
3727 no_set_aspath_prepend_cmd
,
3728 "no set as-path prepend",
3731 "Transform BGP AS_PATH attribute\n"
3732 "Prepend to the as-path\n")
3738 return bgp_route_set_delete (vty
, vty
->index
, "as-path prepend", NULL
);
3740 str
= argv_concat (argv
, argc
, 0);
3741 ret
= bgp_route_set_delete (vty
, vty
->index
, "as-path prepend", str
);
3742 XFREE (MTYPE_TMP
, str
);
3746 ALIAS (no_set_aspath_prepend
,
3747 no_set_aspath_prepend_val_cmd
,
3748 "no set as-path prepend ." CMD_AS_RANGE
,
3751 "Transform BGP AS_PATH attribute\n"
3752 "Prepend to the as-path\n"
3755 DEFUN (set_aspath_exclude
,
3756 set_aspath_exclude_cmd
,
3757 "set as-path exclude ." CMD_AS_RANGE
,
3759 "Transform BGP AS-path attribute\n"
3760 "Exclude from the as-path\n"
3766 str
= argv_concat (argv
, argc
, 0);
3767 ret
= bgp_route_set_add (vty
, vty
->index
, "as-path exclude", str
);
3768 XFREE (MTYPE_TMP
, str
);
3772 DEFUN (no_set_aspath_exclude
,
3773 no_set_aspath_exclude_cmd
,
3774 "no set as-path exclude",
3777 "Transform BGP AS_PATH attribute\n"
3778 "Exclude from the as-path\n")
3784 return bgp_route_set_delete (vty
, vty
->index
, "as-path exclude", NULL
);
3786 str
= argv_concat (argv
, argc
, 0);
3787 ret
= bgp_route_set_delete (vty
, vty
->index
, "as-path exclude", str
);
3788 XFREE (MTYPE_TMP
, str
);
3792 ALIAS (no_set_aspath_exclude
,
3793 no_set_aspath_exclude_val_cmd
,
3794 "no set as-path exclude ." CMD_AS_RANGE
,
3797 "Transform BGP AS_PATH attribute\n"
3798 "Exclude from the as-path\n"
3801 DEFUN (set_community
,
3803 "set community .AA:NN",
3805 "BGP community attribute\n"
3812 struct community
*com
= NULL
;
3817 b
= buffer_new (1024);
3819 for (i
= 0; i
< argc
; i
++)
3821 if (strncmp (argv
[i
], "additive", strlen (argv
[i
])) == 0)
3828 buffer_putc (b
, ' ');
3832 if (strncmp (argv
[i
], "internet", strlen (argv
[i
])) == 0)
3834 buffer_putstr (b
, "internet");
3837 if (strncmp (argv
[i
], "local-AS", strlen (argv
[i
])) == 0)
3839 buffer_putstr (b
, "local-AS");
3842 if (strncmp (argv
[i
], "no-a", strlen ("no-a")) == 0
3843 && strncmp (argv
[i
], "no-advertise", strlen (argv
[i
])) == 0)
3845 buffer_putstr (b
, "no-advertise");
3848 if (strncmp (argv
[i
], "no-e", strlen ("no-e"))== 0
3849 && strncmp (argv
[i
], "no-export", strlen (argv
[i
])) == 0)
3851 buffer_putstr (b
, "no-export");
3854 buffer_putstr (b
, argv
[i
]);
3856 buffer_putc (b
, '\0');
3858 /* Fetch result string then compile it to communities attribute. */
3859 str
= buffer_getstr (b
);
3864 com
= community_str2com (str
);
3865 XFREE (MTYPE_TMP
, str
);
3868 /* Can't compile user input into communities attribute. */
3871 vty_out (vty
, "%% Malformed communities attribute%s", VTY_NEWLINE
);
3875 /* Set communites attribute string. */
3876 str
= community_str (com
);
3880 argstr
= XCALLOC (MTYPE_TMP
, strlen (str
) + strlen (" additive") + 1);
3881 strcpy (argstr
, str
);
3882 strcpy (argstr
+ strlen (str
), " additive");
3883 ret
= bgp_route_set_add (vty
, vty
->index
, "community", argstr
);
3884 XFREE (MTYPE_TMP
, argstr
);
3887 ret
= bgp_route_set_add (vty
, vty
->index
, "community", str
);
3889 community_free (com
);
3894 DEFUN (set_community_none
,
3895 set_community_none_cmd
,
3896 "set community none",
3898 "BGP community attribute\n"
3899 "No community attribute\n")
3901 return bgp_route_set_add (vty
, vty
->index
, "community", "none");
3904 DEFUN (no_set_community
,
3905 no_set_community_cmd
,
3909 "BGP community attribute\n")
3911 return bgp_route_set_delete (vty
, vty
->index
, "community", NULL
);
3914 ALIAS (no_set_community
,
3915 no_set_community_val_cmd
,
3916 "no set community .AA:NN",
3919 "BGP community attribute\n"
3922 ALIAS (no_set_community
,
3923 no_set_community_none_cmd
,
3924 "no set community none",
3927 "BGP community attribute\n"
3928 "No community attribute\n")
3930 DEFUN (set_community_delete
,
3931 set_community_delete_cmd
,
3932 "set comm-list (<1-99>|<100-500>|WORD) delete",
3934 "set BGP community list (for deletion)\n"
3935 "Community-list number (standard)\n"
3936 "Community-list number (expanded)\n"
3937 "Community-list name\n"
3938 "Delete matching communities\n")
3942 str
= XCALLOC (MTYPE_TMP
, strlen (argv
[0]) + strlen (" delete") + 1);
3943 strcpy (str
, argv
[0]);
3944 strcpy (str
+ strlen (argv
[0]), " delete");
3946 bgp_route_set_add (vty
, vty
->index
, "comm-list", str
);
3948 XFREE (MTYPE_TMP
, str
);
3952 DEFUN (no_set_community_delete
,
3953 no_set_community_delete_cmd
,
3957 "set BGP community list (for deletion)\n")
3959 return bgp_route_set_delete (vty
, vty
->index
, "comm-list", NULL
);
3962 ALIAS (no_set_community_delete
,
3963 no_set_community_delete_val_cmd
,
3964 "no set comm-list (<1-99>|<100-500>|WORD) delete",
3967 "set BGP community list (for deletion)\n"
3968 "Community-list number (standard)\n"
3969 "Community-list number (expanded)\n"
3970 "Community-list name\n"
3971 "Delete matching communities\n")
3973 DEFUN (set_ecommunity_rt
,
3974 set_ecommunity_rt_cmd
,
3975 "set extcommunity rt .ASN:nn_or_IP-address:nn",
3977 "BGP extended community attribute\n"
3978 "Route Target extended community\n"
3979 "VPN extended community\n")
3984 str
= argv_concat (argv
, argc
, 0);
3985 ret
= bgp_route_set_add (vty
, vty
->index
, "extcommunity rt", str
);
3986 XFREE (MTYPE_TMP
, str
);
3991 DEFUN (no_set_ecommunity_rt
,
3992 no_set_ecommunity_rt_cmd
,
3993 "no set extcommunity rt",
3996 "BGP extended community attribute\n"
3997 "Route Target extended community\n")
3999 return bgp_route_set_delete (vty
, vty
->index
, "extcommunity rt", NULL
);
4002 ALIAS (no_set_ecommunity_rt
,
4003 no_set_ecommunity_rt_val_cmd
,
4004 "no set extcommunity rt .ASN:nn_or_IP-address:nn",
4007 "BGP extended community attribute\n"
4008 "Route Target extended community\n"
4009 "VPN extended community\n")
4011 DEFUN (set_ecommunity_soo
,
4012 set_ecommunity_soo_cmd
,
4013 "set extcommunity soo .ASN:nn_or_IP-address:nn",
4015 "BGP extended community attribute\n"
4016 "Site-of-Origin extended community\n"
4017 "VPN extended community\n")
4022 str
= argv_concat (argv
, argc
, 0);
4023 ret
= bgp_route_set_add (vty
, vty
->index
, "extcommunity soo", str
);
4024 XFREE (MTYPE_TMP
, str
);
4028 DEFUN (no_set_ecommunity_soo
,
4029 no_set_ecommunity_soo_cmd
,
4030 "no set extcommunity soo",
4033 "BGP extended community attribute\n"
4034 "Site-of-Origin extended community\n")
4036 return bgp_route_set_delete (vty
, vty
->index
, "extcommunity soo", NULL
);
4039 ALIAS (no_set_ecommunity_soo
,
4040 no_set_ecommunity_soo_val_cmd
,
4041 "no set extcommunity soo .ASN:nn_or_IP-address:nn",
4044 "BGP extended community attribute\n"
4045 "Site-of-Origin extended community\n"
4046 "VPN extended community\n")
4050 "set origin (egp|igp|incomplete)",
4055 "unknown heritage\n")
4057 if (strncmp (argv
[0], "igp", 2) == 0)
4058 return bgp_route_set_add (vty
, vty
->index
, "origin", "igp");
4059 if (strncmp (argv
[0], "egp", 1) == 0)
4060 return bgp_route_set_add (vty
, vty
->index
, "origin", "egp");
4061 if (strncmp (argv
[0], "incomplete", 2) == 0)
4062 return bgp_route_set_add (vty
, vty
->index
, "origin", "incomplete");
4067 DEFUN (no_set_origin
,
4072 "BGP origin code\n")
4074 return bgp_route_set_delete (vty
, vty
->index
, "origin", NULL
);
4077 ALIAS (no_set_origin
,
4078 no_set_origin_val_cmd
,
4079 "no set origin (egp|igp|incomplete)",
4085 "unknown heritage\n")
4087 DEFUN (set_atomic_aggregate
,
4088 set_atomic_aggregate_cmd
,
4089 "set atomic-aggregate",
4091 "BGP atomic aggregate attribute\n" )
4093 return bgp_route_set_add (vty
, vty
->index
, "atomic-aggregate", NULL
);
4096 DEFUN (no_set_atomic_aggregate
,
4097 no_set_atomic_aggregate_cmd
,
4098 "no set atomic-aggregate",
4101 "BGP atomic aggregate attribute\n" )
4103 return bgp_route_set_delete (vty
, vty
->index
, "atomic-aggregate", NULL
);
4106 DEFUN (set_aggregator_as
,
4107 set_aggregator_as_cmd
,
4108 "set aggregator as " CMD_AS_RANGE
" A.B.C.D",
4110 "BGP aggregator attribute\n"
4111 "AS number of aggregator\n"
4113 "IP address of aggregator\n")
4116 struct in_addr address
;
4119 ret
= inet_aton (argv
[1], &address
);
4122 vty_out (vty
, "Aggregator IP address is invalid%s", VTY_NEWLINE
);
4126 argstr
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
,
4127 strlen (argv
[0]) + strlen (argv
[1]) + 2);
4129 sprintf (argstr
, "%s %s", argv
[0], argv
[1]);
4131 ret
= bgp_route_set_add (vty
, vty
->index
, "aggregator as", argstr
);
4133 XFREE (MTYPE_ROUTE_MAP_COMPILED
, argstr
);
4138 DEFUN (no_set_aggregator_as
,
4139 no_set_aggregator_as_cmd
,
4140 "no set aggregator as",
4143 "BGP aggregator attribute\n"
4144 "AS number of aggregator\n")
4147 struct in_addr address
;
4151 return bgp_route_set_delete (vty
, vty
->index
, "aggregator as", NULL
);
4153 ret
= inet_aton (argv
[1], &address
);
4156 vty_out (vty
, "Aggregator IP address is invalid%s", VTY_NEWLINE
);
4160 argstr
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
,
4161 strlen (argv
[0]) + strlen (argv
[1]) + 2);
4163 sprintf (argstr
, "%s %s", argv
[0], argv
[1]);
4165 ret
= bgp_route_set_delete (vty
, vty
->index
, "aggregator as", argstr
);
4167 XFREE (MTYPE_ROUTE_MAP_COMPILED
, argstr
);
4172 ALIAS (no_set_aggregator_as
,
4173 no_set_aggregator_as_val_cmd
,
4174 "no set aggregator as " CMD_AS_RANGE
" A.B.C.D",
4177 "BGP aggregator attribute\n"
4178 "AS number of aggregator\n"
4180 "IP address of aggregator\n")
4184 "set tag <1-4294967295>",
4186 "Tag value for routing protocol\n"
4189 return bgp_route_set_add (vty
, vty
->index
, "tag", argv
[0]);
4197 "Tag value for routing protocol\n")
4200 bgp_route_set_delete(vty
, vty
->index
, "tag", NULL
);
4202 return bgp_route_set_delete (vty
, vty
->index
, "tag", argv
[0]);
4207 "no set tag <1-4294967295>",
4210 "Tag value for routing protocol\n"
4215 DEFUN (match_ipv6_address
,
4216 match_ipv6_address_cmd
,
4217 "match ipv6 address WORD",
4220 "Match IPv6 address of route\n"
4221 "IPv6 access-list name\n")
4223 return bgp_route_match_add (vty
, vty
->index
, "ipv6 address", argv
[0],
4224 RMAP_EVENT_FILTER_ADDED
);
4227 DEFUN (no_match_ipv6_address
,
4228 no_match_ipv6_address_cmd
,
4229 "no match ipv6 address WORD",
4233 "Match IPv6 address of route\n"
4234 "IPv6 access-list name\n")
4236 return bgp_route_match_delete (vty
, vty
->index
, "ipv6 address", argv
[0],
4237 RMAP_EVENT_FILTER_DELETED
);
4240 DEFUN (match_ipv6_next_hop
,
4241 match_ipv6_next_hop_cmd
,
4242 "match ipv6 next-hop X:X::X:X",
4245 "Match IPv6 next-hop address of route\n"
4246 "IPv6 address of next hop\n")
4248 return bgp_route_match_add (vty
, vty
->index
, "ipv6 next-hop", argv
[0],
4249 RMAP_EVENT_MATCH_ADDED
);
4252 DEFUN (no_match_ipv6_next_hop
,
4253 no_match_ipv6_next_hop_cmd
,
4254 "no match ipv6 next-hop X:X::X:X",
4258 "Match IPv6 next-hop address of route\n"
4259 "IPv6 address of next hop\n")
4261 return bgp_route_match_delete (vty
, vty
->index
, "ipv6 next-hop", argv
[0],
4262 RMAP_EVENT_MATCH_DELETED
);
4265 DEFUN (match_ipv6_address_prefix_list
,
4266 match_ipv6_address_prefix_list_cmd
,
4267 "match ipv6 address prefix-list WORD",
4270 "Match address of route\n"
4271 "Match entries of prefix-lists\n"
4272 "IP prefix-list name\n")
4274 return bgp_route_match_add (vty
, vty
->index
, "ipv6 address prefix-list",
4275 argv
[0], RMAP_EVENT_PLIST_ADDED
);
4278 DEFUN (no_match_ipv6_address_prefix_list
,
4279 no_match_ipv6_address_prefix_list_cmd
,
4280 "no match ipv6 address prefix-list WORD",
4284 "Match address of route\n"
4285 "Match entries of prefix-lists\n"
4286 "IP prefix-list name\n")
4288 return bgp_route_match_delete (vty
, vty
->index
, "ipv6 address prefix-list",
4289 argv
[0], RMAP_EVENT_PLIST_DELETED
);
4292 DEFUN (set_ipv6_nexthop_peer
,
4293 set_ipv6_nexthop_peer_cmd
,
4294 "set ipv6 next-hop peer-address",
4297 "Next hop address\n"
4298 "Use peer address (for BGP only)\n")
4300 return bgp_route_set_add (vty
, vty
->index
, "ipv6 next-hop peer-address", NULL
);
4303 DEFUN (no_set_ipv6_nexthop_peer
,
4304 no_set_ipv6_nexthop_peer_cmd
,
4305 "no set ipv6 next-hop peer-address",
4309 "IPv6 next-hop address\n"
4310 "Use peer address (for BGP only)\n")
4312 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop peer-address", NULL
);
4315 DEFUN (set_ipv6_nexthop_prefer_global
,
4316 set_ipv6_nexthop_prefer_global_cmd
,
4317 "set ipv6 next-hop prefer-global",
4320 "IPv6 next-hop address\n"
4321 "Prefer global over link-local if both exist\n")
4323 return bgp_route_set_add (vty
, vty
->index
, "ipv6 next-hop prefer-global", NULL
);;
4326 DEFUN (no_set_ipv6_nexthop_prefer_global
,
4327 no_set_ipv6_nexthop_prefer_global_cmd
,
4328 "no set ipv6 next-hop prefer-global",
4332 "IPv6 next-hop address\n"
4333 "Prefer global over link-local if both exist\n")
4335 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop prefer-global", NULL
);
4338 DEFUN (set_ipv6_nexthop_global
,
4339 set_ipv6_nexthop_global_cmd
,
4340 "set ipv6 next-hop global X:X::X:X",
4343 "IPv6 next-hop address\n"
4344 "IPv6 global address\n"
4345 "IPv6 address of next hop\n")
4347 struct in6_addr addr
;
4350 ret
= inet_pton (AF_INET6
, argv
[0], &addr
);
4353 vty_out (vty
, "%% Malformed nexthop address%s", VTY_NEWLINE
);
4356 if (IN6_IS_ADDR_UNSPECIFIED(&addr
) ||
4357 IN6_IS_ADDR_LOOPBACK(&addr
) ||
4358 IN6_IS_ADDR_MULTICAST(&addr
) ||
4359 IN6_IS_ADDR_LINKLOCAL(&addr
))
4361 vty_out (vty
, "%% Invalid global nexthop address%s", VTY_NEWLINE
);
4365 return bgp_route_set_add (vty
, vty
->index
, "ipv6 next-hop global", argv
[0]);
4368 DEFUN (no_set_ipv6_nexthop_global
,
4369 no_set_ipv6_nexthop_global_cmd
,
4370 "no set ipv6 next-hop global",
4374 "IPv6 next-hop address\n"
4375 "IPv6 global address\n")
4378 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop global", NULL
);
4380 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop global", argv
[0]);
4383 ALIAS (no_set_ipv6_nexthop_global
,
4384 no_set_ipv6_nexthop_global_val_cmd
,
4385 "no set ipv6 next-hop global X:X::X:X",
4389 "IPv6 next-hop address\n"
4390 "IPv6 global address\n"
4391 "IPv6 address of next hop\n")
4393 DEFUN (set_ipv6_nexthop_local
,
4394 set_ipv6_nexthop_local_cmd
,
4395 "set ipv6 next-hop local X:X::X:X",
4398 "IPv6 next-hop address\n"
4399 "IPv6 local address\n"
4400 "IPv6 address of next hop\n")
4402 struct in6_addr addr
;
4405 ret
= inet_pton (AF_INET6
, argv
[0], &addr
);
4408 vty_out (vty
, "%% Malformed nexthop address%s", VTY_NEWLINE
);
4411 if (!IN6_IS_ADDR_LINKLOCAL(&addr
))
4413 vty_out (vty
, "%% Invalid link-local nexthop address%s", VTY_NEWLINE
);
4417 return bgp_route_set_add (vty
, vty
->index
, "ipv6 next-hop local", argv
[0]);
4420 DEFUN (no_set_ipv6_nexthop_local
,
4421 no_set_ipv6_nexthop_local_cmd
,
4422 "no set ipv6 next-hop local",
4426 "IPv6 next-hop address\n"
4427 "IPv6 local address\n")
4430 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop local", NULL
);
4432 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop local", argv
[0]);
4435 ALIAS (no_set_ipv6_nexthop_local
,
4436 no_set_ipv6_nexthop_local_val_cmd
,
4437 "no set ipv6 next-hop local X:X::X:X",
4441 "IPv6 next-hop address\n"
4442 "IPv6 local address\n"
4443 "IPv6 address of next hop\n")
4444 #endif /* HAVE_IPV6 */
4446 DEFUN (set_originator_id
,
4447 set_originator_id_cmd
,
4448 "set originator-id A.B.C.D",
4450 "BGP originator ID attribute\n"
4451 "IP address of originator\n")
4453 return bgp_route_set_add (vty
, vty
->index
, "originator-id", argv
[0]);
4456 DEFUN (no_set_originator_id
,
4457 no_set_originator_id_cmd
,
4458 "no set originator-id",
4461 "BGP originator ID attribute\n")
4464 return bgp_route_set_delete (vty
, vty
->index
, "originator-id", NULL
);
4466 return bgp_route_set_delete (vty
, vty
->index
, "originator-id", argv
[0]);
4469 ALIAS (no_set_originator_id
,
4470 no_set_originator_id_val_cmd
,
4471 "no set originator-id A.B.C.D",
4474 "BGP originator ID attribute\n"
4475 "IP address of originator\n")
4477 /* Initialization of route map. */
4479 bgp_route_map_init (void)
4483 route_map_add_hook (bgp_route_map_add
);
4484 route_map_delete_hook (bgp_route_map_delete
);
4485 route_map_event_hook (bgp_route_map_event
);
4487 route_map_install_match (&route_match_peer_cmd
);
4488 route_map_install_match (&route_match_local_pref_cmd
);
4489 route_map_install_match (&route_match_ip_address_cmd
);
4490 route_map_install_match (&route_match_ip_next_hop_cmd
);
4491 route_map_install_match (&route_match_ip_route_source_cmd
);
4492 route_map_install_match (&route_match_ip_address_prefix_list_cmd
);
4493 route_map_install_match (&route_match_ip_next_hop_prefix_list_cmd
);
4494 route_map_install_match (&route_match_ip_route_source_prefix_list_cmd
);
4495 route_map_install_match (&route_match_aspath_cmd
);
4496 route_map_install_match (&route_match_community_cmd
);
4497 route_map_install_match (&route_match_ecommunity_cmd
);
4498 route_map_install_match (&route_match_local_pref_cmd
);
4499 route_map_install_match (&route_match_metric_cmd
);
4500 route_map_install_match (&route_match_origin_cmd
);
4501 route_map_install_match (&route_match_probability_cmd
);
4502 route_map_install_match (&route_match_interface_cmd
);
4503 route_map_install_match (&route_match_tag_cmd
);
4505 route_map_install_set (&route_set_ip_nexthop_cmd
);
4506 route_map_install_set (&route_set_local_pref_cmd
);
4507 route_map_install_set (&route_set_weight_cmd
);
4508 route_map_install_set (&route_set_metric_cmd
);
4509 route_map_install_set (&route_set_aspath_prepend_cmd
);
4510 route_map_install_set (&route_set_aspath_exclude_cmd
);
4511 route_map_install_set (&route_set_origin_cmd
);
4512 route_map_install_set (&route_set_atomic_aggregate_cmd
);
4513 route_map_install_set (&route_set_aggregator_as_cmd
);
4514 route_map_install_set (&route_set_community_cmd
);
4515 route_map_install_set (&route_set_community_delete_cmd
);
4516 route_map_install_set (&route_set_originator_id_cmd
);
4517 route_map_install_set (&route_set_ecommunity_rt_cmd
);
4518 route_map_install_set (&route_set_ecommunity_soo_cmd
);
4519 route_map_install_set (&route_set_tag_cmd
);
4521 install_element (RMAP_NODE
, &match_peer_cmd
);
4522 install_element (RMAP_NODE
, &match_peer_local_cmd
);
4523 install_element (RMAP_NODE
, &no_match_peer_cmd
);
4524 install_element (RMAP_NODE
, &no_match_peer_val_cmd
);
4525 install_element (RMAP_NODE
, &no_match_peer_local_cmd
);
4526 install_element (RMAP_NODE
, &match_ip_address_cmd
);
4527 install_element (RMAP_NODE
, &no_match_ip_address_cmd
);
4528 install_element (RMAP_NODE
, &no_match_ip_address_val_cmd
);
4529 install_element (RMAP_NODE
, &match_ip_next_hop_cmd
);
4530 install_element (RMAP_NODE
, &no_match_ip_next_hop_cmd
);
4531 install_element (RMAP_NODE
, &no_match_ip_next_hop_val_cmd
);
4532 install_element (RMAP_NODE
, &match_ip_route_source_cmd
);
4533 install_element (RMAP_NODE
, &no_match_ip_route_source_cmd
);
4534 install_element (RMAP_NODE
, &no_match_ip_route_source_val_cmd
);
4535 install_element (RMAP_NODE
, &match_ip_address_prefix_list_cmd
);
4536 install_element (RMAP_NODE
, &no_match_ip_address_prefix_list_cmd
);
4537 install_element (RMAP_NODE
, &no_match_ip_address_prefix_list_val_cmd
);
4538 install_element (RMAP_NODE
, &match_ip_next_hop_prefix_list_cmd
);
4539 install_element (RMAP_NODE
, &no_match_ip_next_hop_prefix_list_cmd
);
4540 install_element (RMAP_NODE
, &no_match_ip_next_hop_prefix_list_val_cmd
);
4541 install_element (RMAP_NODE
, &match_ip_route_source_prefix_list_cmd
);
4542 install_element (RMAP_NODE
, &no_match_ip_route_source_prefix_list_cmd
);
4543 install_element (RMAP_NODE
, &no_match_ip_route_source_prefix_list_val_cmd
);
4545 install_element (RMAP_NODE
, &match_aspath_cmd
);
4546 install_element (RMAP_NODE
, &no_match_aspath_cmd
);
4547 install_element (RMAP_NODE
, &no_match_aspath_val_cmd
);
4548 install_element (RMAP_NODE
, &match_metric_cmd
);
4549 install_element (RMAP_NODE
, &no_match_metric_cmd
);
4550 install_element (RMAP_NODE
, &no_match_metric_val_cmd
);
4551 install_element (RMAP_NODE
, &match_local_pref_cmd
);
4552 install_element (RMAP_NODE
, &no_match_local_pref_cmd
);
4553 install_element (RMAP_NODE
, &no_match_local_pref_val_cmd
);
4554 install_element (RMAP_NODE
, &match_community_cmd
);
4555 install_element (RMAP_NODE
, &match_community_exact_cmd
);
4556 install_element (RMAP_NODE
, &no_match_community_cmd
);
4557 install_element (RMAP_NODE
, &no_match_community_val_cmd
);
4558 install_element (RMAP_NODE
, &no_match_community_exact_cmd
);
4559 install_element (RMAP_NODE
, &match_ecommunity_cmd
);
4560 install_element (RMAP_NODE
, &no_match_ecommunity_cmd
);
4561 install_element (RMAP_NODE
, &no_match_ecommunity_val_cmd
);
4562 install_element (RMAP_NODE
, &match_origin_cmd
);
4563 install_element (RMAP_NODE
, &no_match_origin_cmd
);
4564 install_element (RMAP_NODE
, &no_match_origin_val_cmd
);
4565 install_element (RMAP_NODE
, &match_probability_cmd
);
4566 install_element (RMAP_NODE
, &no_match_probability_cmd
);
4567 install_element (RMAP_NODE
, &no_match_probability_val_cmd
);
4568 install_element (RMAP_NODE
, &match_interface_cmd
);
4569 install_element (RMAP_NODE
, &no_match_interface_cmd
);
4570 install_element (RMAP_NODE
, &no_match_interface_val_cmd
);
4571 install_element (RMAP_NODE
, &match_tag_cmd
);
4572 install_element (RMAP_NODE
, &no_match_tag_cmd
);
4573 install_element (RMAP_NODE
, &no_match_tag_val_cmd
);
4575 install_element (RMAP_NODE
, &set_ip_nexthop_cmd
);
4576 install_element (RMAP_NODE
, &set_ip_nexthop_peer_cmd
);
4577 install_element (RMAP_NODE
, &set_ip_nexthop_unchanged_cmd
);
4578 install_element (RMAP_NODE
, &no_set_ip_nexthop_cmd
);
4579 install_element (RMAP_NODE
, &no_set_ip_nexthop_val_cmd
);
4580 install_element (RMAP_NODE
, &no_set_ip_nexthop_peer_cmd
);
4581 install_element (RMAP_NODE
, &set_local_pref_cmd
);
4582 install_element (RMAP_NODE
, &no_set_local_pref_cmd
);
4583 install_element (RMAP_NODE
, &no_set_local_pref_val_cmd
);
4584 install_element (RMAP_NODE
, &set_weight_cmd
);
4585 install_element (RMAP_NODE
, &no_set_weight_cmd
);
4586 install_element (RMAP_NODE
, &no_set_weight_val_cmd
);
4587 install_element (RMAP_NODE
, &set_metric_cmd
);
4588 install_element (RMAP_NODE
, &set_metric_addsub_cmd
);
4589 install_element (RMAP_NODE
, &set_metric_rtt_cmd
);
4590 install_element (RMAP_NODE
, &no_set_metric_cmd
);
4591 install_element (RMAP_NODE
, &no_set_metric_val_cmd
);
4592 install_element (RMAP_NODE
, &set_aspath_prepend_cmd
);
4593 install_element (RMAP_NODE
, &set_aspath_prepend_lastas_cmd
);
4594 install_element (RMAP_NODE
, &set_aspath_exclude_cmd
);
4595 install_element (RMAP_NODE
, &no_set_aspath_prepend_cmd
);
4596 install_element (RMAP_NODE
, &no_set_aspath_prepend_val_cmd
);
4597 install_element (RMAP_NODE
, &no_set_aspath_exclude_cmd
);
4598 install_element (RMAP_NODE
, &no_set_aspath_exclude_val_cmd
);
4599 install_element (RMAP_NODE
, &set_origin_cmd
);
4600 install_element (RMAP_NODE
, &no_set_origin_cmd
);
4601 install_element (RMAP_NODE
, &no_set_origin_val_cmd
);
4602 install_element (RMAP_NODE
, &set_atomic_aggregate_cmd
);
4603 install_element (RMAP_NODE
, &no_set_atomic_aggregate_cmd
);
4604 install_element (RMAP_NODE
, &set_aggregator_as_cmd
);
4605 install_element (RMAP_NODE
, &no_set_aggregator_as_cmd
);
4606 install_element (RMAP_NODE
, &no_set_aggregator_as_val_cmd
);
4607 install_element (RMAP_NODE
, &set_community_cmd
);
4608 install_element (RMAP_NODE
, &set_community_none_cmd
);
4609 install_element (RMAP_NODE
, &no_set_community_cmd
);
4610 install_element (RMAP_NODE
, &no_set_community_val_cmd
);
4611 install_element (RMAP_NODE
, &no_set_community_none_cmd
);
4612 install_element (RMAP_NODE
, &set_community_delete_cmd
);
4613 install_element (RMAP_NODE
, &no_set_community_delete_cmd
);
4614 install_element (RMAP_NODE
, &no_set_community_delete_val_cmd
);
4615 install_element (RMAP_NODE
, &set_ecommunity_rt_cmd
);
4616 install_element (RMAP_NODE
, &no_set_ecommunity_rt_cmd
);
4617 install_element (RMAP_NODE
, &no_set_ecommunity_rt_val_cmd
);
4618 install_element (RMAP_NODE
, &set_ecommunity_soo_cmd
);
4619 install_element (RMAP_NODE
, &no_set_ecommunity_soo_cmd
);
4620 install_element (RMAP_NODE
, &no_set_ecommunity_soo_val_cmd
);
4621 install_element (RMAP_NODE
, &set_originator_id_cmd
);
4622 install_element (RMAP_NODE
, &no_set_originator_id_cmd
);
4623 install_element (RMAP_NODE
, &no_set_originator_id_val_cmd
);
4624 install_element (RMAP_NODE
, &set_tag_cmd
);
4625 install_element (RMAP_NODE
, &no_set_tag_cmd
);
4626 install_element (RMAP_NODE
, &no_set_tag_val_cmd
);
4629 route_map_install_match (&route_match_ipv6_address_cmd
);
4630 route_map_install_match (&route_match_ipv6_next_hop_cmd
);
4631 route_map_install_match (&route_match_ipv6_address_prefix_list_cmd
);
4632 route_map_install_set (&route_set_ipv6_nexthop_global_cmd
);
4633 route_map_install_set (&route_set_ipv6_nexthop_prefer_global_cmd
);
4634 route_map_install_set (&route_set_ipv6_nexthop_local_cmd
);
4635 route_map_install_set (&route_set_ipv6_nexthop_peer_cmd
);
4637 install_element (RMAP_NODE
, &match_ipv6_address_cmd
);
4638 install_element (RMAP_NODE
, &no_match_ipv6_address_cmd
);
4639 install_element (RMAP_NODE
, &match_ipv6_next_hop_cmd
);
4640 install_element (RMAP_NODE
, &no_match_ipv6_next_hop_cmd
);
4641 install_element (RMAP_NODE
, &match_ipv6_address_prefix_list_cmd
);
4642 install_element (RMAP_NODE
, &no_match_ipv6_address_prefix_list_cmd
);
4643 install_element (RMAP_NODE
, &set_ipv6_nexthop_global_cmd
);
4644 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_global_cmd
);
4645 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_global_val_cmd
);
4646 install_element (RMAP_NODE
, &set_ipv6_nexthop_prefer_global_cmd
);
4647 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_prefer_global_cmd
);
4648 install_element (RMAP_NODE
, &set_ipv6_nexthop_local_cmd
);
4649 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_local_cmd
);
4650 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_local_val_cmd
);
4651 install_element (RMAP_NODE
, &set_ipv6_nexthop_peer_cmd
);
4652 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_peer_cmd
);
4653 #endif /* HAVE_IPV6 */
4657 bgp_route_map_terminate (void)
4659 /* ToDo: Cleanup all the used memory */
4661 route_map_add_hook (NULL
);
4662 route_map_delete_hook (NULL
);
4663 route_map_event_hook (NULL
);