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 vpnv4 nexthop A.B.C.D' */
2347 static route_map_result_t
2348 route_set_vpnv4_nexthop (void *rule
, struct prefix
*prefix
,
2349 route_map_object_t type
, void *object
)
2351 struct in_addr
*address
;
2352 struct bgp_info
*bgp_info
;
2354 if (type
== RMAP_BGP
)
2356 /* Fetch routemap's rule information. */
2360 /* Set next hop value. */
2361 (bgp_attr_extra_get (bgp_info
->attr
))->mp_nexthop_global_in
= *address
;
2362 (bgp_attr_extra_get (bgp_info
->attr
))->mp_nexthop_len
= 4;
2369 route_set_vpnv4_nexthop_compile (const char *arg
)
2372 struct in_addr
*address
;
2374 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in_addr
));
2376 ret
= inet_aton (arg
, address
);
2380 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
2388 route_set_vpnv4_nexthop_free (void *rule
)
2390 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2393 /* Route map commands for ip nexthop set. */
2394 struct route_map_rule_cmd route_set_vpnv4_nexthop_cmd
=
2397 route_set_vpnv4_nexthop
,
2398 route_set_vpnv4_nexthop_compile
,
2399 route_set_vpnv4_nexthop_free
2402 /* `set originator-id' */
2404 /* For origin set. */
2405 static route_map_result_t
2406 route_set_originator_id (void *rule
, struct prefix
*prefix
, route_map_object_t type
, void *object
)
2408 struct in_addr
*address
;
2409 struct bgp_info
*bgp_info
;
2411 if (type
== RMAP_BGP
)
2416 bgp_info
->attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
);
2417 (bgp_attr_extra_get (bgp_info
->attr
))->originator_id
= *address
;
2423 /* Compile function for originator-id set. */
2425 route_set_originator_id_compile (const char *arg
)
2428 struct in_addr
*address
;
2430 address
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
, sizeof (struct in_addr
));
2432 ret
= inet_aton (arg
, address
);
2436 XFREE (MTYPE_ROUTE_MAP_COMPILED
, address
);
2443 /* Compile function for originator_id set. */
2445 route_set_originator_id_free (void *rule
)
2447 XFREE (MTYPE_ROUTE_MAP_COMPILED
, rule
);
2450 /* Set originator-id rule structure. */
2451 struct route_map_rule_cmd route_set_originator_id_cmd
=
2454 route_set_originator_id
,
2455 route_set_originator_id_compile
,
2456 route_set_originator_id_free
,
2459 /* Add bgp route map rule. */
2461 bgp_route_match_add (struct vty
*vty
, struct route_map_index
*index
,
2462 const char *command
, const char *arg
,
2463 route_map_event_t type
)
2467 ret
= route_map_add_match (index
, command
, arg
);
2472 case RMAP_RULE_MISSING
:
2473 vty_out (vty
, "%% BGP Can't find rule.%s", VTY_NEWLINE
);
2475 case RMAP_COMPILE_ERROR
:
2476 vty_out (vty
, "%% BGP Argument is malformed.%s", VTY_NEWLINE
);
2481 if (type
!= RMAP_EVENT_MATCH_ADDED
)
2483 route_map_upd8_dependency (type
, arg
, index
->map
->name
);
2489 /* Delete bgp route map rule. */
2491 bgp_route_match_delete (struct vty
*vty
, struct route_map_index
*index
,
2492 const char *command
, const char *arg
,
2493 route_map_event_t type
)
2496 char *dep_name
= NULL
;
2498 char *rmap_name
= NULL
;
2500 if (type
!= RMAP_EVENT_MATCH_DELETED
)
2502 /* ignore the mundane, the types without any dependency */
2505 if ((tmpstr
= route_map_get_match_arg(index
, command
)) != NULL
)
2506 dep_name
= XSTRDUP(MTYPE_ROUTE_MAP_RULE
, tmpstr
);
2510 dep_name
= XSTRDUP(MTYPE_ROUTE_MAP_RULE
, arg
);
2512 rmap_name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, index
->map
->name
);
2515 ret
= route_map_delete_match (index
, command
, dep_name
);
2520 case RMAP_RULE_MISSING
:
2521 vty_out (vty
, "%% BGP Can't find rule.%s", VTY_NEWLINE
);
2523 case RMAP_COMPILE_ERROR
:
2524 vty_out (vty
, "%% BGP Argument is malformed.%s", VTY_NEWLINE
);
2528 XFREE(MTYPE_ROUTE_MAP_RULE
, dep_name
);
2530 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap_name
);
2534 if (type
!= RMAP_EVENT_MATCH_DELETED
&& dep_name
)
2535 route_map_upd8_dependency(type
, dep_name
, rmap_name
);
2538 XFREE(MTYPE_ROUTE_MAP_RULE
, dep_name
);
2540 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap_name
);
2545 /* Add bgp route map rule. */
2547 bgp_route_set_add (struct vty
*vty
, struct route_map_index
*index
,
2548 const char *command
, const char *arg
)
2552 ret
= route_map_add_set (index
, command
, arg
);
2557 case RMAP_RULE_MISSING
:
2558 vty_out (vty
, "%% BGP Can't find rule.%s", VTY_NEWLINE
);
2560 case RMAP_COMPILE_ERROR
:
2561 vty_out (vty
, "%% BGP Argument is malformed.%s", VTY_NEWLINE
);
2568 /* Delete bgp route map rule. */
2570 bgp_route_set_delete (struct vty
*vty
, struct route_map_index
*index
,
2571 const char *command
, const char *arg
)
2575 ret
= route_map_delete_set (index
, command
, arg
);
2580 case RMAP_RULE_MISSING
:
2581 vty_out (vty
, "%% BGP Can't find rule.%s", VTY_NEWLINE
);
2583 case RMAP_COMPILE_ERROR
:
2584 vty_out (vty
, "%% BGP Argument is malformed.%s", VTY_NEWLINE
);
2592 * This is the workhorse routine for processing in/out routemap
2596 bgp_route_map_process_peer (const char *rmap_name
, struct route_map
*map
,
2597 struct peer
*peer
, int afi
, int safi
,
2602 struct bgp_filter
*filter
;
2604 if (!peer
|| !rmap_name
)
2607 filter
= &peer
->filter
[afi
][safi
];
2609 * in is for non-route-server clients,
2610 * out is for all peers
2612 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_RSERVER_CLIENT
))
2614 if (filter
->map
[RMAP_IN
].name
&&
2615 (strcmp(rmap_name
, filter
->map
[RMAP_IN
].name
) == 0))
2617 filter
->map
[RMAP_IN
].map
= map
;
2619 if (route_update
&& peer
->status
== Established
)
2621 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
],
2622 PEER_FLAG_SOFT_RECONFIG
))
2624 if (bgp_debug_update(peer
, NULL
, NULL
, 1))
2625 zlog_debug("Processing route_map %s update on "
2626 "peer %s (inbound, soft-reconfig)",
2627 rmap_name
, peer
->host
);
2629 bgp_soft_reconfig_in (peer
, afi
, safi
);
2631 else if (CHECK_FLAG (peer
->cap
, PEER_CAP_REFRESH_OLD_RCV
)
2632 || CHECK_FLAG (peer
->cap
, PEER_CAP_REFRESH_NEW_RCV
))
2635 if (bgp_debug_update(peer
, NULL
, NULL
, 1))
2636 zlog_debug("Processing route_map %s update on "
2637 "peer %s (inbound, route-refresh)",
2638 rmap_name
, peer
->host
);
2639 bgp_route_refresh_send (peer
, afi
, safi
, 0, 0, 0);
2645 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_RSERVER_CLIENT
))
2649 if (update
&& route_update
&& peer
->status
== Established
)
2651 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
],
2652 PEER_FLAG_SOFT_RECONFIG
))
2654 if (bgp_debug_update(peer
, NULL
, NULL
, 1))
2655 zlog_debug("Processing route_map %s update on "
2656 "peer %s (import, soft-reconfig)",
2657 rmap_name
, peer
->host
);
2659 bgp_soft_reconfig_in (peer
, afi
, safi
);
2661 else if (CHECK_FLAG (peer
->cap
, PEER_CAP_REFRESH_OLD_RCV
)
2662 || CHECK_FLAG (peer
->cap
, PEER_CAP_REFRESH_NEW_RCV
))
2664 if (bgp_debug_update(peer
, NULL
, NULL
, 1))
2665 zlog_debug("Processing route_map %s update on "
2666 "peer %s (import, route-refresh)",
2667 rmap_name
, peer
->host
);
2668 bgp_route_refresh_send (peer
, afi
, safi
, 0, 0, 0);
2670 /* DD: Else, what else do we do ? Reset peer ? */
2675 * For outbound, unsuppress and default-originate map change (content or
2676 * map created), merely update the "config" here, the actual route
2677 * announcement happens at the group level.
2679 if (filter
->map
[RMAP_OUT
].name
&&
2680 (strcmp(rmap_name
, filter
->map
[RMAP_OUT
].name
) == 0))
2681 filter
->map
[RMAP_OUT
].map
= map
;
2683 if (filter
->usmap
.name
&&
2684 (strcmp(rmap_name
, filter
->usmap
.name
) == 0))
2685 filter
->usmap
.map
= map
;
2687 if (peer
->default_rmap
[afi
][safi
].name
&&
2688 (strcmp (rmap_name
, peer
->default_rmap
[afi
][safi
].name
) == 0))
2689 peer
->default_rmap
[afi
][safi
].map
= map
;
2693 bgp_route_map_update_peer_group(const char *rmap_name
, struct route_map
*map
,
2696 struct peer_group
*group
;
2697 struct listnode
*node
, *nnode
;
2698 struct bgp_filter
*filter
;
2705 /* All the peers have been updated correctly already. This is
2706 * just updating the placeholder data. No real update required.
2708 for (ALL_LIST_ELEMENTS (bgp
->group
, node
, nnode
, group
))
2709 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2710 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2712 filter
= &group
->conf
->filter
[afi
][safi
];
2714 for (direct
= RMAP_IN
; direct
< RMAP_MAX
; direct
++)
2716 if ((filter
->map
[direct
].name
) &&
2717 (strcmp(rmap_name
, filter
->map
[direct
].name
) == 0))
2718 filter
->map
[direct
].map
= map
;
2721 if (filter
->usmap
.name
&&
2722 (strcmp(rmap_name
, filter
->usmap
.name
) == 0))
2723 filter
->usmap
.map
= map
;
2728 * Note that if an extreme number (tens of thousands) of route-maps are in use
2729 * and if bgp has an extreme number of peers, network statements, etc then this
2730 * function can consume a lot of cycles. This is due to this function being
2731 * called for each route-map and within this function we walk the list of peers,
2732 * network statements, etc looking to see if they use this route-map.
2735 bgp_route_map_process_update (struct bgp
*bgp
, const char *rmap_name
, int route_update
)
2741 struct bgp_node
*bn
;
2742 struct bgp_static
*bgp_static
;
2743 struct listnode
*node
, *nnode
;
2744 struct route_map
*map
;
2745 char buf
[INET6_ADDRSTRLEN
];
2747 map
= route_map_lookup_by_name (rmap_name
);
2749 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
2752 /* Ignore dummy peer-group structure */
2753 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
))
2756 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2757 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2759 /* Ignore inactive AFI/SAFI */
2760 if (! peer
->afc
[afi
][safi
])
2763 /* process in/out/import/export/default-orig route-maps */
2764 bgp_route_map_process_peer(rmap_name
, map
, peer
, afi
, safi
, route_update
);
2768 /* for outbound/default-orig route-maps, process for groups */
2769 update_group_policy_update(bgp
, BGP_POLICY_ROUTE_MAP
, rmap_name
,
2772 /* update peer-group config (template) */
2773 bgp_route_map_update_peer_group(rmap_name
, map
, bgp
);
2775 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2776 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2778 /* For table route-map updates. */
2779 if (bgp
->table_map
[afi
][safi
].name
&&
2780 (strcmp(rmap_name
, bgp
->table_map
[afi
][safi
].name
) == 0))
2782 bgp
->table_map
[afi
][safi
].map
= map
;
2784 if (BGP_DEBUG (zebra
, ZEBRA
))
2785 zlog_debug("Processing route_map %s update on "
2786 "table map", rmap_name
);
2788 bgp_zebra_announce_table(bgp
, afi
, safi
);
2791 /* For network route-map updates. */
2792 for (bn
= bgp_table_top (bgp
->route
[afi
][safi
]); bn
; bn
= bgp_route_next (bn
))
2793 if ((bgp_static
= bn
->info
) != NULL
)
2795 if (bgp_static
->rmap
.name
&&
2796 (strcmp(rmap_name
, bgp_static
->rmap
.name
) == 0))
2798 bgp_static
->rmap
.map
= map
;
2801 if (!bgp_static
->backdoor
)
2803 if (bgp_debug_zebra(&bn
->p
))
2804 zlog_debug("Processing route_map %s update on "
2805 "static route %s", rmap_name
,
2806 inet_ntop (bn
->p
.family
, &bn
->p
.u
.prefix
,
2807 buf
, INET6_ADDRSTRLEN
));
2808 bgp_static_update (bgp
, &bn
->p
, bgp_static
, afi
, safi
);
2814 /* For redistribute route-map updates. */
2815 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2816 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++)
2818 struct list
*red_list
;
2819 struct listnode
*node
;
2820 struct bgp_redist
*red
;
2822 red_list
= bgp
->redist
[afi
][i
];
2826 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
))
2828 if (red
->rmap
.name
&&
2829 (strcmp(rmap_name
, red
->rmap
.name
) == 0))
2831 red
->rmap
.map
= map
;
2835 if (BGP_DEBUG (zebra
, ZEBRA
))
2836 zlog_debug("Processing route_map %s update on "
2837 "redistributed routes", rmap_name
);
2839 bgp_redistribute_resend (bgp
, afi
, i
, red
->instance
);
2847 bgp_route_map_process_update_cb (char *rmap_name
)
2849 struct listnode
*node
, *nnode
;
2852 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
2853 bgp_route_map_process_update(bgp
, rmap_name
, 1);
2856 zlog_debug("%s: calling vnc_routemap_update", __func__
);
2857 vnc_routemap_update(bgp
, __func__
);
2863 bgp_route_map_update_timer(struct thread
*thread
)
2865 bm
->t_rmap_update
= NULL
;
2867 route_map_walk_update_list(bgp_route_map_process_update_cb
);
2873 bgp_route_map_mark_update (const char *rmap_name
)
2875 if (bm
->t_rmap_update
== NULL
)
2877 struct listnode
*node
, *nnode
;
2880 /* rmap_update_timer of 0 means don't do route updates */
2881 if (bm
->rmap_update_timer
)
2884 thread_add_timer(bm
->master
, bgp_route_map_update_timer
, NULL
,
2885 bm
->rmap_update_timer
);
2887 /* Signal the groups that a route-map update event has started */
2888 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
2889 update_group_policy_update(bgp
, BGP_POLICY_ROUTE_MAP
, rmap_name
, 1, 1);
2893 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
2894 bgp_route_map_process_update(bgp
, rmap_name
, 0);
2896 zlog_debug("%s: calling vnc_routemap_update", __func__
);
2897 vnc_routemap_update(bgp
, __func__
);
2904 bgp_route_map_add (const char *rmap_name
)
2906 if (route_map_mark_updated(rmap_name
, 0) == 0)
2907 bgp_route_map_mark_update(rmap_name
);
2909 route_map_notify_dependencies(rmap_name
, RMAP_EVENT_MATCH_ADDED
);
2913 bgp_route_map_delete (const char *rmap_name
)
2915 if (route_map_mark_updated(rmap_name
, 1) == 0)
2916 bgp_route_map_mark_update(rmap_name
);
2918 route_map_notify_dependencies(rmap_name
, RMAP_EVENT_MATCH_DELETED
);
2922 bgp_route_map_event (route_map_event_t event
, const char *rmap_name
)
2924 if (route_map_mark_updated(rmap_name
, 0) == 0)
2925 bgp_route_map_mark_update(rmap_name
);
2927 route_map_notify_dependencies(rmap_name
, RMAP_EVENT_MATCH_ADDED
);
2933 "match peer (A.B.C.D|X:X::X:X)",
2935 "Match peer address\n"
2936 "IP address of peer\n"
2937 "IPv6 address of peer\n")
2939 return bgp_route_match_add (vty
, vty
->index
, "peer", argv
[0],
2940 RMAP_EVENT_MATCH_ADDED
);
2943 DEFUN (match_peer_local
,
2944 match_peer_local_cmd
,
2947 "Match peer address\n"
2948 "Static or Redistributed routes\n")
2950 return bgp_route_match_add (vty
, vty
->index
, "peer", "local",
2951 RMAP_EVENT_MATCH_DELETED
);
2954 DEFUN (no_match_peer
,
2959 "Match peer address\n")
2962 return bgp_route_match_delete (vty
, vty
->index
, "peer", NULL
,
2963 RMAP_EVENT_MATCH_DELETED
);
2965 return bgp_route_match_delete (vty
, vty
->index
, "peer", argv
[0],
2966 RMAP_EVENT_MATCH_DELETED
);
2969 ALIAS (no_match_peer
,
2970 no_match_peer_val_cmd
,
2971 "no match peer (A.B.C.D|X:X::X:X)",
2974 "Match peer address\n"
2975 "IP address of peer\n"
2976 "IPv6 address of peer\n")
2978 ALIAS (no_match_peer
,
2979 no_match_peer_local_cmd
,
2980 "no match peer local",
2983 "Match peer address\n"
2984 "Static or Redistributed routes\n")
2986 DEFUN (match_ip_address
,
2987 match_ip_address_cmd
,
2988 "match ip address (<1-199>|<1300-2699>|WORD)",
2991 "Match address of route\n"
2992 "IP access-list number\n"
2993 "IP access-list number (expanded range)\n"
2994 "IP Access-list name\n")
2996 return bgp_route_match_add (vty
, vty
->index
, "ip address", argv
[0],
2997 RMAP_EVENT_FILTER_ADDED
);
3000 DEFUN (no_match_ip_address
,
3001 no_match_ip_address_cmd
,
3002 "no match ip address",
3006 "Match address of route\n")
3009 return bgp_route_match_delete (vty
, vty
->index
, "ip address", NULL
,
3010 RMAP_EVENT_FILTER_DELETED
);
3012 return bgp_route_match_delete (vty
, vty
->index
, "ip address", argv
[0],
3013 RMAP_EVENT_FILTER_DELETED
);
3016 ALIAS (no_match_ip_address
,
3017 no_match_ip_address_val_cmd
,
3018 "no match ip address (<1-199>|<1300-2699>|WORD)",
3022 "Match address of route\n"
3023 "IP access-list number\n"
3024 "IP access-list number (expanded range)\n"
3025 "IP Access-list name\n")
3027 DEFUN (match_ip_next_hop
,
3028 match_ip_next_hop_cmd
,
3029 "match ip next-hop (<1-199>|<1300-2699>|WORD)",
3032 "Match next-hop address of route\n"
3033 "IP access-list number\n"
3034 "IP access-list number (expanded range)\n"
3035 "IP Access-list name\n")
3037 return bgp_route_match_add (vty
, vty
->index
, "ip next-hop", argv
[0],
3038 RMAP_EVENT_FILTER_ADDED
);
3041 DEFUN (no_match_ip_next_hop
,
3042 no_match_ip_next_hop_cmd
,
3043 "no match ip next-hop",
3047 "Match next-hop address of route\n")
3050 return bgp_route_match_delete (vty
, vty
->index
, "ip next-hop", NULL
,
3051 RMAP_EVENT_FILTER_DELETED
);
3053 return bgp_route_match_delete (vty
, vty
->index
, "ip next-hop", argv
[0],
3054 RMAP_EVENT_FILTER_DELETED
);
3057 ALIAS (no_match_ip_next_hop
,
3058 no_match_ip_next_hop_val_cmd
,
3059 "no match ip next-hop (<1-199>|<1300-2699>|WORD)",
3063 "Match next-hop address of route\n"
3064 "IP access-list number\n"
3065 "IP access-list number (expanded range)\n"
3066 "IP Access-list name\n")
3068 /* match probability { */
3070 DEFUN (match_probability
,
3071 match_probability_cmd
,
3072 "match probability <0-100>",
3074 "Match portion of routes defined by percentage value\n"
3075 "Percentage of routes\n")
3077 return bgp_route_match_add (vty
, vty
->index
, "probability", argv
[0],
3078 RMAP_EVENT_MATCH_ADDED
);
3081 DEFUN (no_match_probability
,
3082 no_match_probability_cmd
,
3083 "no match probability",
3086 "Match portion of routes defined by percentage value\n")
3088 return bgp_route_match_delete (vty
, vty
->index
, "probability", argc
? argv
[0] : NULL
,
3089 RMAP_EVENT_MATCH_DELETED
);
3092 ALIAS (no_match_probability
,
3093 no_match_probability_val_cmd
,
3094 "no match probability <1-99>",
3097 "Match portion of routes defined by percentage value\n"
3098 "Percentage of routes\n")
3102 DEFUN (match_ip_route_source
,
3103 match_ip_route_source_cmd
,
3104 "match ip route-source (<1-199>|<1300-2699>|WORD)",
3107 "Match advertising source address of route\n"
3108 "IP access-list number\n"
3109 "IP access-list number (expanded range)\n"
3110 "IP standard access-list name\n")
3112 return bgp_route_match_add (vty
, vty
->index
, "ip route-source", argv
[0],
3113 RMAP_EVENT_FILTER_ADDED
);
3116 DEFUN (no_match_ip_route_source
,
3117 no_match_ip_route_source_cmd
,
3118 "no match ip route-source",
3122 "Match advertising source address of route\n")
3125 return bgp_route_match_delete (vty
, vty
->index
, "ip route-source", NULL
,
3126 RMAP_EVENT_FILTER_DELETED
);
3128 return bgp_route_match_delete (vty
, vty
->index
, "ip route-source",
3129 argv
[0], RMAP_EVENT_FILTER_DELETED
);
3132 ALIAS (no_match_ip_route_source
,
3133 no_match_ip_route_source_val_cmd
,
3134 "no match ip route-source (<1-199>|<1300-2699>|WORD)",
3138 "Match advertising source address of route\n"
3139 "IP access-list number\n"
3140 "IP access-list number (expanded range)\n"
3141 "IP standard access-list name\n")
3143 DEFUN (match_ip_address_prefix_list
,
3144 match_ip_address_prefix_list_cmd
,
3145 "match ip address prefix-list WORD",
3148 "Match address of route\n"
3149 "Match entries of prefix-lists\n"
3150 "IP prefix-list name\n")
3152 return bgp_route_match_add (vty
, vty
->index
, "ip address prefix-list",
3153 argv
[0], RMAP_EVENT_PLIST_ADDED
);
3156 DEFUN (no_match_ip_address_prefix_list
,
3157 no_match_ip_address_prefix_list_cmd
,
3158 "no match ip address prefix-list",
3162 "Match address of route\n"
3163 "Match entries of prefix-lists\n")
3165 return bgp_route_match_delete (vty
, vty
->index
, "ip address prefix-list",
3166 argc
== 0 ? NULL
: argv
[0],
3167 RMAP_EVENT_PLIST_DELETED
);
3170 ALIAS (no_match_ip_address_prefix_list
,
3171 no_match_ip_address_prefix_list_val_cmd
,
3172 "no match ip address prefix-list WORD",
3176 "Match address of route\n"
3177 "Match entries of prefix-lists\n"
3178 "IP prefix-list name\n")
3180 DEFUN (match_ip_next_hop_prefix_list
,
3181 match_ip_next_hop_prefix_list_cmd
,
3182 "match ip next-hop prefix-list WORD",
3185 "Match next-hop address of route\n"
3186 "Match entries of prefix-lists\n"
3187 "IP prefix-list name\n")
3189 return bgp_route_match_add (vty
, vty
->index
, "ip next-hop prefix-list",
3190 argv
[0], RMAP_EVENT_PLIST_ADDED
);
3193 DEFUN (no_match_ip_next_hop_prefix_list
,
3194 no_match_ip_next_hop_prefix_list_cmd
,
3195 "no match ip next-hop prefix-list",
3199 "Match next-hop address of route\n"
3200 "Match entries of prefix-lists\n")
3202 return bgp_route_match_delete (vty
, vty
->index
, "ip next-hop prefix-list",
3203 argc
== 0 ? NULL
: argv
[0],
3204 RMAP_EVENT_PLIST_DELETED
);
3207 ALIAS (no_match_ip_next_hop_prefix_list
,
3208 no_match_ip_next_hop_prefix_list_val_cmd
,
3209 "no match ip next-hop prefix-list WORD",
3213 "Match next-hop address of route\n"
3214 "Match entries of prefix-lists\n"
3215 "IP prefix-list name\n")
3217 DEFUN (match_ip_route_source_prefix_list
,
3218 match_ip_route_source_prefix_list_cmd
,
3219 "match ip route-source prefix-list WORD",
3222 "Match advertising source address of route\n"
3223 "Match entries of prefix-lists\n"
3224 "IP prefix-list name\n")
3226 return bgp_route_match_add (vty
, vty
->index
, "ip route-source prefix-list",
3227 argv
[0], RMAP_EVENT_PLIST_ADDED
);
3230 DEFUN (no_match_ip_route_source_prefix_list
,
3231 no_match_ip_route_source_prefix_list_cmd
,
3232 "no match ip route-source prefix-list",
3236 "Match advertising source address of route\n"
3237 "Match entries of prefix-lists\n")
3239 return bgp_route_match_delete (vty
, vty
->index
, "ip route-source prefix-list",
3240 argc
== 0 ? NULL
: argv
[0],
3241 RMAP_EVENT_PLIST_DELETED
);
3244 ALIAS (no_match_ip_route_source_prefix_list
,
3245 no_match_ip_route_source_prefix_list_val_cmd
,
3246 "no match ip route-source prefix-list WORD",
3250 "Match advertising source address of route\n"
3251 "Match entries of prefix-lists\n"
3252 "IP prefix-list name\n")
3254 DEFUN (match_metric
,
3256 "match metric <0-4294967295>",
3258 "Match metric of route\n"
3261 return bgp_route_match_add (vty
, vty
->index
, "metric", argv
[0],
3262 RMAP_EVENT_MATCH_ADDED
);
3265 DEFUN (no_match_metric
,
3266 no_match_metric_cmd
,
3270 "Match metric of route\n")
3272 return bgp_route_match_delete (vty
, vty
->index
, "metric",
3273 argc
== 0 ? NULL
: argv
[0],
3274 RMAP_EVENT_MATCH_DELETED
);
3277 ALIAS (no_match_metric
,
3278 no_match_metric_val_cmd
,
3279 "no match metric <0-4294967295>",
3282 "Match metric of route\n"
3285 DEFUN (match_local_pref
,
3286 match_local_pref_cmd
,
3287 "match local-preference <0-4294967295>",
3289 "Match local-preference of route\n"
3292 return bgp_route_match_add (vty
, vty
->index
, "local-preference", argv
[0],
3293 RMAP_EVENT_MATCH_ADDED
);
3296 DEFUN (no_match_local_pref
,
3297 no_match_local_pref_cmd
,
3298 "no match local-preference",
3301 "Match local preference of route\n")
3303 return bgp_route_match_delete (vty
, vty
->index
, "local-preference",
3304 argc
== 0 ? NULL
: argv
[0],
3305 RMAP_EVENT_MATCH_DELETED
);
3307 return bgp_route_match_delete (vty
, vty
->index
, "local-preference", argv
[0],
3308 RMAP_EVENT_MATCH_DELETED
);
3311 ALIAS (no_match_local_pref
,
3312 no_match_local_pref_val_cmd
,
3313 "no match local-preference <0-4294967295>",
3316 "Match local preference of route\n"
3317 "Local preference value\n")
3319 DEFUN (match_community
,
3320 match_community_cmd
,
3321 "match community (<1-99>|<100-500>|WORD)",
3323 "Match BGP community list\n"
3324 "Community-list number (standard)\n"
3325 "Community-list number (expanded)\n"
3326 "Community-list name\n")
3328 return bgp_route_match_add (vty
, vty
->index
, "community", argv
[0],
3329 RMAP_EVENT_CLIST_ADDED
);
3332 DEFUN (match_community_exact
,
3333 match_community_exact_cmd
,
3334 "match community (<1-99>|<100-500>|WORD) exact-match",
3336 "Match BGP community list\n"
3337 "Community-list number (standard)\n"
3338 "Community-list number (expanded)\n"
3339 "Community-list name\n"
3340 "Do exact matching of communities\n")
3345 argstr
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
,
3346 strlen (argv
[0]) + strlen ("exact-match") + 2);
3348 sprintf (argstr
, "%s exact-match", argv
[0]);
3350 ret
= bgp_route_match_add (vty
, vty
->index
, "community", argstr
,
3351 RMAP_EVENT_CLIST_ADDED
);
3353 XFREE (MTYPE_ROUTE_MAP_COMPILED
, argstr
);
3358 DEFUN (no_match_community
,
3359 no_match_community_cmd
,
3360 "no match community",
3363 "Match BGP community list\n")
3365 return bgp_route_match_delete (vty
, vty
->index
, "community", NULL
,
3366 RMAP_EVENT_CLIST_DELETED
);
3369 ALIAS (no_match_community
,
3370 no_match_community_val_cmd
,
3371 "no match community (<1-99>|<100-500>|WORD)",
3374 "Match BGP community list\n"
3375 "Community-list number (standard)\n"
3376 "Community-list number (expanded)\n"
3377 "Community-list name\n")
3379 ALIAS (no_match_community
,
3380 no_match_community_exact_cmd
,
3381 "no match community (<1-99>|<100-500>|WORD) exact-match",
3384 "Match BGP community list\n"
3385 "Community-list number (standard)\n"
3386 "Community-list number (expanded)\n"
3387 "Community-list name\n"
3388 "Do exact matching of communities\n")
3390 DEFUN (match_ecommunity
,
3391 match_ecommunity_cmd
,
3392 "match extcommunity (<1-99>|<100-500>|WORD)",
3394 "Match BGP/VPN extended community list\n"
3395 "Extended community-list number (standard)\n"
3396 "Extended community-list number (expanded)\n"
3397 "Extended community-list name\n")
3399 return bgp_route_match_add (vty
, vty
->index
, "extcommunity", argv
[0],
3400 RMAP_EVENT_ECLIST_ADDED
);
3403 DEFUN (no_match_ecommunity
,
3404 no_match_ecommunity_cmd
,
3405 "no match extcommunity",
3408 "Match BGP/VPN extended community list\n")
3410 return bgp_route_match_delete (vty
, vty
->index
, "extcommunity", NULL
,
3411 RMAP_EVENT_ECLIST_DELETED
);
3414 ALIAS (no_match_ecommunity
,
3415 no_match_ecommunity_val_cmd
,
3416 "no match extcommunity (<1-99>|<100-500>|WORD)",
3419 "Match BGP/VPN extended community list\n"
3420 "Extended community-list number (standard)\n"
3421 "Extended community-list number (expanded)\n"
3422 "Extended community-list name\n")
3424 DEFUN (match_aspath
,
3426 "match as-path WORD",
3428 "Match BGP AS path list\n"
3429 "AS path access-list name\n")
3431 return bgp_route_match_add (vty
, vty
->index
, "as-path", argv
[0],
3432 RMAP_EVENT_ASLIST_ADDED
);
3435 DEFUN (no_match_aspath
,
3436 no_match_aspath_cmd
,
3440 "Match BGP AS path list\n")
3442 return bgp_route_match_delete (vty
, vty
->index
, "as-path", NULL
,
3443 RMAP_EVENT_ASLIST_DELETED
);
3446 ALIAS (no_match_aspath
,
3447 no_match_aspath_val_cmd
,
3448 "no match as-path WORD",
3451 "Match BGP AS path list\n"
3452 "AS path access-list name\n")
3454 DEFUN (match_origin
,
3456 "match origin (egp|igp|incomplete)",
3461 "unknown heritage\n")
3463 if (strncmp (argv
[0], "igp", 2) == 0)
3464 return bgp_route_match_add (vty
, vty
->index
, "origin", "igp",
3465 RMAP_EVENT_MATCH_ADDED
);
3466 if (strncmp (argv
[0], "egp", 1) == 0)
3467 return bgp_route_match_add (vty
, vty
->index
, "origin", "egp",
3468 RMAP_EVENT_MATCH_ADDED
);
3469 if (strncmp (argv
[0], "incomplete", 2) == 0)
3470 return bgp_route_match_add (vty
, vty
->index
, "origin", "incomplete",
3471 RMAP_EVENT_MATCH_ADDED
);
3476 DEFUN (no_match_origin
,
3477 no_match_origin_cmd
,
3481 "BGP origin code\n")
3483 return bgp_route_match_delete (vty
, vty
->index
, "origin", NULL
,
3484 RMAP_EVENT_MATCH_DELETED
);
3487 ALIAS (no_match_origin
,
3488 no_match_origin_val_cmd
,
3489 "no match origin (egp|igp|incomplete)",
3495 "unknown heritage\n")
3497 DEFUN (match_interface
,
3498 match_interface_cmd
,
3499 "match interface WORD",
3501 "Match first hop interface of route\n"
3504 return bgp_route_match_add (vty
, vty
->index
, "interface", argv
[0],
3505 RMAP_EVENT_MATCH_ADDED
);
3508 DEFUN (no_match_interface
,
3509 no_match_interface_cmd
,
3510 "no match interface",
3513 "Match first hop interface of route\n")
3516 return bgp_route_match_delete (vty
, vty
->index
, "interface", NULL
,
3517 RMAP_EVENT_MATCH_DELETED
);
3519 return bgp_route_match_delete (vty
, vty
->index
, "interface", argv
[0],
3520 RMAP_EVENT_MATCH_DELETED
);
3523 ALIAS (no_match_interface
,
3524 no_match_interface_val_cmd
,
3525 "no match interface WORD",
3528 "Match first hop interface of route\n"
3533 "match tag <1-4294967295>",
3535 "Match tag of route\n"
3538 return bgp_route_match_add (vty
, vty
->index
, "tag", argv
[0],
3539 RMAP_EVENT_MATCH_ADDED
);
3542 DEFUN (no_match_tag
,
3547 "Match tag of route\n")
3550 return bgp_route_match_delete (vty
, vty
->index
, "tag", NULL
,
3551 RMAP_EVENT_MATCH_DELETED
);
3553 return bgp_route_match_delete (vty
, vty
->index
, "tag", argv
[0],
3554 RMAP_EVENT_MATCH_DELETED
);
3557 ALIAS (no_match_tag
,
3558 no_match_tag_val_cmd
,
3559 "no match tag <1-4294967295>",
3562 "Match tag of route\n"
3566 DEFUN (set_ip_nexthop
,
3568 "set ip next-hop A.B.C.D",
3571 "Next hop address\n"
3572 "IP address of next hop\n")
3577 ret
= str2sockunion (argv
[0], &su
);
3580 vty_out (vty
, "%% Malformed nexthop address%s", VTY_NEWLINE
);
3583 if (su
.sin
.sin_addr
.s_addr
== 0 ||
3584 IPV4_CLASS_DE(su
.sin
.sin_addr
.s_addr
))
3586 vty_out (vty
, "%% nexthop address cannot be 0.0.0.0, multicast "
3587 "or reserved%s", VTY_NEWLINE
);
3591 return bgp_route_set_add (vty
, vty
->index
, "ip next-hop", argv
[0]);
3594 DEFUN (set_ip_nexthop_peer
,
3595 set_ip_nexthop_peer_cmd
,
3596 "set ip next-hop peer-address",
3599 "Next hop address\n"
3600 "Use peer address (for BGP only)\n")
3602 return bgp_route_set_add (vty
, vty
->index
, "ip next-hop", "peer-address");
3605 DEFUN (set_ip_nexthop_unchanged
,
3606 set_ip_nexthop_unchanged_cmd
,
3607 "set ip next-hop unchanged",
3610 "Next hop address\n"
3611 "Don't modify existing Next hop address\n")
3613 return bgp_route_set_add (vty
, vty
->index
, "ip next-hop", "unchanged");
3616 DEFUN (no_set_ip_nexthop
,
3617 no_set_ip_nexthop_cmd
,
3618 "no set ip next-hop",
3621 "Next hop address\n")
3624 return bgp_route_set_delete (vty
, vty
->index
, "ip next-hop", NULL
);
3626 return bgp_route_set_delete (vty
, vty
->index
, "ip next-hop", argv
[0]);
3629 ALIAS (no_set_ip_nexthop
,
3630 no_set_ip_nexthop_val_cmd
,
3631 "no set ip next-hop A.B.C.D",
3635 "Next hop address\n"
3636 "IP address of next hop\n")
3638 ALIAS (no_set_ip_nexthop
,
3639 no_set_ip_nexthop_peer_cmd
,
3640 "no set ip next-hop peer-address",
3644 "Next hop address\n"
3645 "Use peer address (for BGP only)\n")
3649 "set metric <0-4294967295>",
3651 "Metric value for destination routing protocol\n"
3654 return bgp_route_set_add (vty
, vty
->index
, "metric", argv
[0]);
3658 set_metric_addsub_cmd
,
3659 "set metric <+/-metric>",
3661 "Metric value for destination routing protocol\n"
3662 "Add or subtract metric\n")
3666 "set metric (rtt|+rtt|-rtt)",
3668 "Metric value for destination routing protocol\n"
3669 "Assign round trip time\n"
3670 "Add round trip time\n"
3671 "Subtract round trip time\n")
3673 DEFUN (no_set_metric
,
3678 "Metric value for destination routing protocol\n")
3681 return bgp_route_set_delete (vty
, vty
->index
, "metric", NULL
);
3683 return bgp_route_set_delete (vty
, vty
->index
, "metric", argv
[0]);
3686 ALIAS (no_set_metric
,
3687 no_set_metric_val_cmd
,
3688 "no set metric <0-4294967295>",
3691 "Metric value for destination routing protocol\n"
3694 DEFUN (set_local_pref
,
3696 "set local-preference <0-4294967295>",
3698 "BGP local preference path attribute\n"
3699 "Preference value\n")
3701 return bgp_route_set_add (vty
, vty
->index
, "local-preference", argv
[0]);
3704 DEFUN (no_set_local_pref
,
3705 no_set_local_pref_cmd
,
3706 "no set local-preference",
3709 "BGP local preference path attribute\n")
3712 return bgp_route_set_delete (vty
, vty
->index
, "local-preference", NULL
);
3714 return bgp_route_set_delete (vty
, vty
->index
, "local-preference", argv
[0]);
3717 ALIAS (no_set_local_pref
,
3718 no_set_local_pref_val_cmd
,
3719 "no set local-preference <0-4294967295>",
3722 "BGP local preference path attribute\n"
3723 "Preference value\n")
3727 "set weight <0-4294967295>",
3729 "BGP weight for routing table\n"
3732 return bgp_route_set_add (vty
, vty
->index
, "weight", argv
[0]);
3735 DEFUN (no_set_weight
,
3740 "BGP weight for routing table\n")
3743 return bgp_route_set_delete (vty
, vty
->index
, "weight", NULL
);
3745 return bgp_route_set_delete (vty
, vty
->index
, "weight", argv
[0]);
3748 ALIAS (no_set_weight
,
3749 no_set_weight_val_cmd
,
3750 "no set weight <0-4294967295>",
3753 "BGP weight for routing table\n"
3756 DEFUN (set_aspath_prepend
,
3757 set_aspath_prepend_cmd
,
3758 "set as-path prepend ." CMD_AS_RANGE
,
3760 "Transform BGP AS_PATH attribute\n"
3761 "Prepend to the as-path\n"
3767 str
= argv_concat (argv
, argc
, 0);
3768 ret
= bgp_route_set_add (vty
, vty
->index
, "as-path prepend", str
);
3769 XFREE (MTYPE_TMP
, str
);
3774 ALIAS (set_aspath_prepend
,
3775 set_aspath_prepend_lastas_cmd
,
3776 "set as-path prepend (last-as) <1-10>",
3778 "Transform BGP AS_PATH attribute\n"
3779 "Prepend to the as-path\n"
3780 "Use the peer's AS-number\n"
3781 "Number of times to insert")
3783 DEFUN (no_set_aspath_prepend
,
3784 no_set_aspath_prepend_cmd
,
3785 "no set as-path prepend",
3788 "Transform BGP AS_PATH attribute\n"
3789 "Prepend to the as-path\n")
3795 return bgp_route_set_delete (vty
, vty
->index
, "as-path prepend", NULL
);
3797 str
= argv_concat (argv
, argc
, 0);
3798 ret
= bgp_route_set_delete (vty
, vty
->index
, "as-path prepend", str
);
3799 XFREE (MTYPE_TMP
, str
);
3803 ALIAS (no_set_aspath_prepend
,
3804 no_set_aspath_prepend_val_cmd
,
3805 "no set as-path prepend ." CMD_AS_RANGE
,
3808 "Transform BGP AS_PATH attribute\n"
3809 "Prepend to the as-path\n"
3812 DEFUN (set_aspath_exclude
,
3813 set_aspath_exclude_cmd
,
3814 "set as-path exclude ." CMD_AS_RANGE
,
3816 "Transform BGP AS-path attribute\n"
3817 "Exclude from the as-path\n"
3823 str
= argv_concat (argv
, argc
, 0);
3824 ret
= bgp_route_set_add (vty
, vty
->index
, "as-path exclude", str
);
3825 XFREE (MTYPE_TMP
, str
);
3829 DEFUN (no_set_aspath_exclude
,
3830 no_set_aspath_exclude_cmd
,
3831 "no set as-path exclude",
3834 "Transform BGP AS_PATH attribute\n"
3835 "Exclude from the as-path\n")
3841 return bgp_route_set_delete (vty
, vty
->index
, "as-path exclude", NULL
);
3843 str
= argv_concat (argv
, argc
, 0);
3844 ret
= bgp_route_set_delete (vty
, vty
->index
, "as-path exclude", str
);
3845 XFREE (MTYPE_TMP
, str
);
3849 ALIAS (no_set_aspath_exclude
,
3850 no_set_aspath_exclude_val_cmd
,
3851 "no set as-path exclude ." CMD_AS_RANGE
,
3854 "Transform BGP AS_PATH attribute\n"
3855 "Exclude from the as-path\n"
3858 DEFUN (set_community
,
3860 "set community .AA:NN",
3862 "BGP community attribute\n"
3869 struct community
*com
= NULL
;
3874 b
= buffer_new (1024);
3876 for (i
= 0; i
< argc
; i
++)
3878 if (strncmp (argv
[i
], "additive", strlen (argv
[i
])) == 0)
3885 buffer_putc (b
, ' ');
3889 if (strncmp (argv
[i
], "internet", strlen (argv
[i
])) == 0)
3891 buffer_putstr (b
, "internet");
3894 if (strncmp (argv
[i
], "local-AS", strlen (argv
[i
])) == 0)
3896 buffer_putstr (b
, "local-AS");
3899 if (strncmp (argv
[i
], "no-a", strlen ("no-a")) == 0
3900 && strncmp (argv
[i
], "no-advertise", strlen (argv
[i
])) == 0)
3902 buffer_putstr (b
, "no-advertise");
3905 if (strncmp (argv
[i
], "no-e", strlen ("no-e"))== 0
3906 && strncmp (argv
[i
], "no-export", strlen (argv
[i
])) == 0)
3908 buffer_putstr (b
, "no-export");
3911 buffer_putstr (b
, argv
[i
]);
3913 buffer_putc (b
, '\0');
3915 /* Fetch result string then compile it to communities attribute. */
3916 str
= buffer_getstr (b
);
3921 com
= community_str2com (str
);
3922 XFREE (MTYPE_TMP
, str
);
3925 /* Can't compile user input into communities attribute. */
3928 vty_out (vty
, "%% Malformed communities attribute%s", VTY_NEWLINE
);
3932 /* Set communites attribute string. */
3933 str
= community_str (com
);
3937 argstr
= XCALLOC (MTYPE_TMP
, strlen (str
) + strlen (" additive") + 1);
3938 strcpy (argstr
, str
);
3939 strcpy (argstr
+ strlen (str
), " additive");
3940 ret
= bgp_route_set_add (vty
, vty
->index
, "community", argstr
);
3941 XFREE (MTYPE_TMP
, argstr
);
3944 ret
= bgp_route_set_add (vty
, vty
->index
, "community", str
);
3946 community_free (com
);
3951 DEFUN (set_community_none
,
3952 set_community_none_cmd
,
3953 "set community none",
3955 "BGP community attribute\n"
3956 "No community attribute\n")
3958 return bgp_route_set_add (vty
, vty
->index
, "community", "none");
3961 DEFUN (no_set_community
,
3962 no_set_community_cmd
,
3966 "BGP community attribute\n")
3968 return bgp_route_set_delete (vty
, vty
->index
, "community", NULL
);
3971 ALIAS (no_set_community
,
3972 no_set_community_val_cmd
,
3973 "no set community .AA:NN",
3976 "BGP community attribute\n"
3979 ALIAS (no_set_community
,
3980 no_set_community_none_cmd
,
3981 "no set community none",
3984 "BGP community attribute\n"
3985 "No community attribute\n")
3987 DEFUN (set_community_delete
,
3988 set_community_delete_cmd
,
3989 "set comm-list (<1-99>|<100-500>|WORD) delete",
3991 "set BGP community list (for deletion)\n"
3992 "Community-list number (standard)\n"
3993 "Community-list number (expanded)\n"
3994 "Community-list name\n"
3995 "Delete matching communities\n")
3999 str
= XCALLOC (MTYPE_TMP
, strlen (argv
[0]) + strlen (" delete") + 1);
4000 strcpy (str
, argv
[0]);
4001 strcpy (str
+ strlen (argv
[0]), " delete");
4003 bgp_route_set_add (vty
, vty
->index
, "comm-list", str
);
4005 XFREE (MTYPE_TMP
, str
);
4009 DEFUN (no_set_community_delete
,
4010 no_set_community_delete_cmd
,
4014 "set BGP community list (for deletion)\n")
4016 return bgp_route_set_delete (vty
, vty
->index
, "comm-list", NULL
);
4019 ALIAS (no_set_community_delete
,
4020 no_set_community_delete_val_cmd
,
4021 "no set comm-list (<1-99>|<100-500>|WORD) delete",
4024 "set BGP community list (for deletion)\n"
4025 "Community-list number (standard)\n"
4026 "Community-list number (expanded)\n"
4027 "Community-list name\n"
4028 "Delete matching communities\n")
4030 DEFUN (set_ecommunity_rt
,
4031 set_ecommunity_rt_cmd
,
4032 "set extcommunity rt .ASN:nn_or_IP-address:nn",
4034 "BGP extended community attribute\n"
4035 "Route Target extended community\n"
4036 "VPN extended community\n")
4041 str
= argv_concat (argv
, argc
, 0);
4042 ret
= bgp_route_set_add (vty
, vty
->index
, "extcommunity rt", str
);
4043 XFREE (MTYPE_TMP
, str
);
4048 DEFUN (no_set_ecommunity_rt
,
4049 no_set_ecommunity_rt_cmd
,
4050 "no set extcommunity rt",
4053 "BGP extended community attribute\n"
4054 "Route Target extended community\n")
4056 return bgp_route_set_delete (vty
, vty
->index
, "extcommunity rt", NULL
);
4059 ALIAS (no_set_ecommunity_rt
,
4060 no_set_ecommunity_rt_val_cmd
,
4061 "no set extcommunity rt .ASN:nn_or_IP-address:nn",
4064 "BGP extended community attribute\n"
4065 "Route Target extended community\n"
4066 "VPN extended community\n")
4068 DEFUN (set_ecommunity_soo
,
4069 set_ecommunity_soo_cmd
,
4070 "set extcommunity soo .ASN:nn_or_IP-address:nn",
4072 "BGP extended community attribute\n"
4073 "Site-of-Origin extended community\n"
4074 "VPN extended community\n")
4079 str
= argv_concat (argv
, argc
, 0);
4080 ret
= bgp_route_set_add (vty
, vty
->index
, "extcommunity soo", str
);
4081 XFREE (MTYPE_TMP
, str
);
4085 DEFUN (no_set_ecommunity_soo
,
4086 no_set_ecommunity_soo_cmd
,
4087 "no set extcommunity soo",
4090 "BGP extended community attribute\n"
4091 "Site-of-Origin extended community\n")
4093 return bgp_route_set_delete (vty
, vty
->index
, "extcommunity soo", NULL
);
4096 ALIAS (no_set_ecommunity_soo
,
4097 no_set_ecommunity_soo_val_cmd
,
4098 "no set extcommunity soo .ASN:nn_or_IP-address:nn",
4101 "BGP extended community attribute\n"
4102 "Site-of-Origin extended community\n"
4103 "VPN extended community\n")
4107 "set origin (egp|igp|incomplete)",
4112 "unknown heritage\n")
4114 if (strncmp (argv
[0], "igp", 2) == 0)
4115 return bgp_route_set_add (vty
, vty
->index
, "origin", "igp");
4116 if (strncmp (argv
[0], "egp", 1) == 0)
4117 return bgp_route_set_add (vty
, vty
->index
, "origin", "egp");
4118 if (strncmp (argv
[0], "incomplete", 2) == 0)
4119 return bgp_route_set_add (vty
, vty
->index
, "origin", "incomplete");
4124 DEFUN (no_set_origin
,
4129 "BGP origin code\n")
4131 return bgp_route_set_delete (vty
, vty
->index
, "origin", NULL
);
4134 ALIAS (no_set_origin
,
4135 no_set_origin_val_cmd
,
4136 "no set origin (egp|igp|incomplete)",
4142 "unknown heritage\n")
4144 DEFUN (set_atomic_aggregate
,
4145 set_atomic_aggregate_cmd
,
4146 "set atomic-aggregate",
4148 "BGP atomic aggregate attribute\n" )
4150 return bgp_route_set_add (vty
, vty
->index
, "atomic-aggregate", NULL
);
4153 DEFUN (no_set_atomic_aggregate
,
4154 no_set_atomic_aggregate_cmd
,
4155 "no set atomic-aggregate",
4158 "BGP atomic aggregate attribute\n" )
4160 return bgp_route_set_delete (vty
, vty
->index
, "atomic-aggregate", NULL
);
4163 DEFUN (set_aggregator_as
,
4164 set_aggregator_as_cmd
,
4165 "set aggregator as " CMD_AS_RANGE
" A.B.C.D",
4167 "BGP aggregator attribute\n"
4168 "AS number of aggregator\n"
4170 "IP address of aggregator\n")
4173 struct in_addr address
;
4176 ret
= inet_aton (argv
[1], &address
);
4179 vty_out (vty
, "Aggregator IP address is invalid%s", VTY_NEWLINE
);
4183 argstr
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
,
4184 strlen (argv
[0]) + strlen (argv
[1]) + 2);
4186 sprintf (argstr
, "%s %s", argv
[0], argv
[1]);
4188 ret
= bgp_route_set_add (vty
, vty
->index
, "aggregator as", argstr
);
4190 XFREE (MTYPE_ROUTE_MAP_COMPILED
, argstr
);
4195 DEFUN (no_set_aggregator_as
,
4196 no_set_aggregator_as_cmd
,
4197 "no set aggregator as",
4200 "BGP aggregator attribute\n"
4201 "AS number of aggregator\n")
4204 struct in_addr address
;
4208 return bgp_route_set_delete (vty
, vty
->index
, "aggregator as", NULL
);
4210 ret
= inet_aton (argv
[1], &address
);
4213 vty_out (vty
, "Aggregator IP address is invalid%s", VTY_NEWLINE
);
4217 argstr
= XMALLOC (MTYPE_ROUTE_MAP_COMPILED
,
4218 strlen (argv
[0]) + strlen (argv
[1]) + 2);
4220 sprintf (argstr
, "%s %s", argv
[0], argv
[1]);
4222 ret
= bgp_route_set_delete (vty
, vty
->index
, "aggregator as", argstr
);
4224 XFREE (MTYPE_ROUTE_MAP_COMPILED
, argstr
);
4229 ALIAS (no_set_aggregator_as
,
4230 no_set_aggregator_as_val_cmd
,
4231 "no set aggregator as " CMD_AS_RANGE
" A.B.C.D",
4234 "BGP aggregator attribute\n"
4235 "AS number of aggregator\n"
4237 "IP address of aggregator\n")
4241 "set tag <1-4294967295>",
4243 "Tag value for routing protocol\n"
4246 return bgp_route_set_add (vty
, vty
->index
, "tag", argv
[0]);
4254 "Tag value for routing protocol\n")
4257 bgp_route_set_delete(vty
, vty
->index
, "tag", NULL
);
4259 return bgp_route_set_delete (vty
, vty
->index
, "tag", argv
[0]);
4264 "no set tag <1-4294967295>",
4267 "Tag value for routing protocol\n"
4272 DEFUN (match_ipv6_address
,
4273 match_ipv6_address_cmd
,
4274 "match ipv6 address WORD",
4277 "Match IPv6 address of route\n"
4278 "IPv6 access-list name\n")
4280 return bgp_route_match_add (vty
, vty
->index
, "ipv6 address", argv
[0],
4281 RMAP_EVENT_FILTER_ADDED
);
4284 DEFUN (no_match_ipv6_address
,
4285 no_match_ipv6_address_cmd
,
4286 "no match ipv6 address WORD",
4290 "Match IPv6 address of route\n"
4291 "IPv6 access-list name\n")
4293 return bgp_route_match_delete (vty
, vty
->index
, "ipv6 address", argv
[0],
4294 RMAP_EVENT_FILTER_DELETED
);
4297 DEFUN (match_ipv6_next_hop
,
4298 match_ipv6_next_hop_cmd
,
4299 "match ipv6 next-hop X:X::X:X",
4302 "Match IPv6 next-hop address of route\n"
4303 "IPv6 address of next hop\n")
4305 return bgp_route_match_add (vty
, vty
->index
, "ipv6 next-hop", argv
[0],
4306 RMAP_EVENT_MATCH_ADDED
);
4309 DEFUN (no_match_ipv6_next_hop
,
4310 no_match_ipv6_next_hop_cmd
,
4311 "no match ipv6 next-hop X:X::X:X",
4315 "Match IPv6 next-hop address of route\n"
4316 "IPv6 address of next hop\n")
4318 return bgp_route_match_delete (vty
, vty
->index
, "ipv6 next-hop", argv
[0],
4319 RMAP_EVENT_MATCH_DELETED
);
4322 DEFUN (match_ipv6_address_prefix_list
,
4323 match_ipv6_address_prefix_list_cmd
,
4324 "match ipv6 address prefix-list WORD",
4327 "Match address of route\n"
4328 "Match entries of prefix-lists\n"
4329 "IP prefix-list name\n")
4331 return bgp_route_match_add (vty
, vty
->index
, "ipv6 address prefix-list",
4332 argv
[0], RMAP_EVENT_PLIST_ADDED
);
4335 DEFUN (no_match_ipv6_address_prefix_list
,
4336 no_match_ipv6_address_prefix_list_cmd
,
4337 "no match ipv6 address prefix-list WORD",
4341 "Match address of route\n"
4342 "Match entries of prefix-lists\n"
4343 "IP prefix-list name\n")
4345 return bgp_route_match_delete (vty
, vty
->index
, "ipv6 address prefix-list",
4346 argv
[0], RMAP_EVENT_PLIST_DELETED
);
4349 DEFUN (set_ipv6_nexthop_peer
,
4350 set_ipv6_nexthop_peer_cmd
,
4351 "set ipv6 next-hop peer-address",
4354 "Next hop address\n"
4355 "Use peer address (for BGP only)\n")
4357 return bgp_route_set_add (vty
, vty
->index
, "ipv6 next-hop peer-address", NULL
);
4360 DEFUN (no_set_ipv6_nexthop_peer
,
4361 no_set_ipv6_nexthop_peer_cmd
,
4362 "no set ipv6 next-hop peer-address",
4366 "IPv6 next-hop address\n"
4367 "Use peer address (for BGP only)\n")
4369 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop peer-address", NULL
);
4372 DEFUN (set_ipv6_nexthop_prefer_global
,
4373 set_ipv6_nexthop_prefer_global_cmd
,
4374 "set ipv6 next-hop prefer-global",
4377 "IPv6 next-hop address\n"
4378 "Prefer global over link-local if both exist\n")
4380 return bgp_route_set_add (vty
, vty
->index
, "ipv6 next-hop prefer-global", NULL
);;
4383 DEFUN (no_set_ipv6_nexthop_prefer_global
,
4384 no_set_ipv6_nexthop_prefer_global_cmd
,
4385 "no set ipv6 next-hop prefer-global",
4389 "IPv6 next-hop address\n"
4390 "Prefer global over link-local if both exist\n")
4392 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop prefer-global", NULL
);
4395 DEFUN (set_ipv6_nexthop_global
,
4396 set_ipv6_nexthop_global_cmd
,
4397 "set ipv6 next-hop global X:X::X:X",
4400 "IPv6 next-hop address\n"
4401 "IPv6 global address\n"
4402 "IPv6 address of next hop\n")
4404 struct in6_addr addr
;
4407 ret
= inet_pton (AF_INET6
, argv
[0], &addr
);
4410 vty_out (vty
, "%% Malformed nexthop address%s", VTY_NEWLINE
);
4413 if (IN6_IS_ADDR_UNSPECIFIED(&addr
) ||
4414 IN6_IS_ADDR_LOOPBACK(&addr
) ||
4415 IN6_IS_ADDR_MULTICAST(&addr
) ||
4416 IN6_IS_ADDR_LINKLOCAL(&addr
))
4418 vty_out (vty
, "%% Invalid global nexthop address%s", VTY_NEWLINE
);
4422 return bgp_route_set_add (vty
, vty
->index
, "ipv6 next-hop global", argv
[0]);
4425 DEFUN (no_set_ipv6_nexthop_global
,
4426 no_set_ipv6_nexthop_global_cmd
,
4427 "no set ipv6 next-hop global",
4431 "IPv6 next-hop address\n"
4432 "IPv6 global address\n")
4435 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop global", NULL
);
4437 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop global", argv
[0]);
4440 ALIAS (no_set_ipv6_nexthop_global
,
4441 no_set_ipv6_nexthop_global_val_cmd
,
4442 "no set ipv6 next-hop global X:X::X:X",
4446 "IPv6 next-hop address\n"
4447 "IPv6 global address\n"
4448 "IPv6 address of next hop\n")
4450 DEFUN (set_ipv6_nexthop_local
,
4451 set_ipv6_nexthop_local_cmd
,
4452 "set ipv6 next-hop local X:X::X:X",
4455 "IPv6 next-hop address\n"
4456 "IPv6 local address\n"
4457 "IPv6 address of next hop\n")
4459 struct in6_addr addr
;
4462 ret
= inet_pton (AF_INET6
, argv
[0], &addr
);
4465 vty_out (vty
, "%% Malformed nexthop address%s", VTY_NEWLINE
);
4468 if (!IN6_IS_ADDR_LINKLOCAL(&addr
))
4470 vty_out (vty
, "%% Invalid link-local nexthop address%s", VTY_NEWLINE
);
4474 return bgp_route_set_add (vty
, vty
->index
, "ipv6 next-hop local", argv
[0]);
4477 DEFUN (no_set_ipv6_nexthop_local
,
4478 no_set_ipv6_nexthop_local_cmd
,
4479 "no set ipv6 next-hop local",
4483 "IPv6 next-hop address\n"
4484 "IPv6 local address\n")
4487 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop local", NULL
);
4489 return bgp_route_set_delete (vty
, vty
->index
, "ipv6 next-hop local", argv
[0]);
4492 ALIAS (no_set_ipv6_nexthop_local
,
4493 no_set_ipv6_nexthop_local_val_cmd
,
4494 "no set ipv6 next-hop local X:X::X:X",
4498 "IPv6 next-hop address\n"
4499 "IPv6 local address\n"
4500 "IPv6 address of next hop\n")
4501 #endif /* HAVE_IPV6 */
4503 DEFUN (set_vpnv4_nexthop
,
4504 set_vpnv4_nexthop_cmd
,
4505 "set vpnv4 next-hop A.B.C.D",
4507 "VPNv4 information\n"
4508 "VPNv4 next-hop address\n"
4509 "IP address of next hop\n")
4511 return bgp_route_set_add (vty
, vty
->index
, "vpnv4 next-hop", argv
[0]);
4514 DEFUN (no_set_vpnv4_nexthop
,
4515 no_set_vpnv4_nexthop_cmd
,
4516 "no set vpnv4 next-hop",
4519 "VPNv4 information\n"
4520 "VPNv4 next-hop address\n")
4523 return bgp_route_set_delete (vty
, vty
->index
, "vpnv4 next-hop", NULL
);
4525 return bgp_route_set_delete (vty
, vty
->index
, "vpnv4 next-hop", argv
[0]);
4528 ALIAS (no_set_vpnv4_nexthop
,
4529 no_set_vpnv4_nexthop_val_cmd
,
4530 "no set vpnv4 next-hop A.B.C.D",
4533 "VPNv4 information\n"
4534 "VPNv4 next-hop address\n"
4535 "IP address of next hop\n")
4537 DEFUN (set_originator_id
,
4538 set_originator_id_cmd
,
4539 "set originator-id A.B.C.D",
4541 "BGP originator ID attribute\n"
4542 "IP address of originator\n")
4544 return bgp_route_set_add (vty
, vty
->index
, "originator-id", argv
[0]);
4547 DEFUN (no_set_originator_id
,
4548 no_set_originator_id_cmd
,
4549 "no set originator-id",
4552 "BGP originator ID attribute\n")
4555 return bgp_route_set_delete (vty
, vty
->index
, "originator-id", NULL
);
4557 return bgp_route_set_delete (vty
, vty
->index
, "originator-id", argv
[0]);
4560 ALIAS (no_set_originator_id
,
4561 no_set_originator_id_val_cmd
,
4562 "no set originator-id A.B.C.D",
4565 "BGP originator ID attribute\n"
4566 "IP address of originator\n")
4568 /* Initialization of route map. */
4570 bgp_route_map_init (void)
4574 route_map_add_hook (bgp_route_map_add
);
4575 route_map_delete_hook (bgp_route_map_delete
);
4576 route_map_event_hook (bgp_route_map_event
);
4578 route_map_install_match (&route_match_peer_cmd
);
4579 route_map_install_match (&route_match_local_pref_cmd
);
4580 route_map_install_match (&route_match_ip_address_cmd
);
4581 route_map_install_match (&route_match_ip_next_hop_cmd
);
4582 route_map_install_match (&route_match_ip_route_source_cmd
);
4583 route_map_install_match (&route_match_ip_address_prefix_list_cmd
);
4584 route_map_install_match (&route_match_ip_next_hop_prefix_list_cmd
);
4585 route_map_install_match (&route_match_ip_route_source_prefix_list_cmd
);
4586 route_map_install_match (&route_match_aspath_cmd
);
4587 route_map_install_match (&route_match_community_cmd
);
4588 route_map_install_match (&route_match_ecommunity_cmd
);
4589 route_map_install_match (&route_match_local_pref_cmd
);
4590 route_map_install_match (&route_match_metric_cmd
);
4591 route_map_install_match (&route_match_origin_cmd
);
4592 route_map_install_match (&route_match_probability_cmd
);
4593 route_map_install_match (&route_match_interface_cmd
);
4594 route_map_install_match (&route_match_tag_cmd
);
4596 route_map_install_set (&route_set_ip_nexthop_cmd
);
4597 route_map_install_set (&route_set_local_pref_cmd
);
4598 route_map_install_set (&route_set_weight_cmd
);
4599 route_map_install_set (&route_set_metric_cmd
);
4600 route_map_install_set (&route_set_aspath_prepend_cmd
);
4601 route_map_install_set (&route_set_aspath_exclude_cmd
);
4602 route_map_install_set (&route_set_origin_cmd
);
4603 route_map_install_set (&route_set_atomic_aggregate_cmd
);
4604 route_map_install_set (&route_set_aggregator_as_cmd
);
4605 route_map_install_set (&route_set_community_cmd
);
4606 route_map_install_set (&route_set_community_delete_cmd
);
4607 route_map_install_set (&route_set_vpnv4_nexthop_cmd
);
4608 route_map_install_set (&route_set_originator_id_cmd
);
4609 route_map_install_set (&route_set_ecommunity_rt_cmd
);
4610 route_map_install_set (&route_set_ecommunity_soo_cmd
);
4611 route_map_install_set (&route_set_tag_cmd
);
4613 install_element (RMAP_NODE
, &match_peer_cmd
);
4614 install_element (RMAP_NODE
, &match_peer_local_cmd
);
4615 install_element (RMAP_NODE
, &no_match_peer_cmd
);
4616 install_element (RMAP_NODE
, &no_match_peer_val_cmd
);
4617 install_element (RMAP_NODE
, &no_match_peer_local_cmd
);
4618 install_element (RMAP_NODE
, &match_ip_address_cmd
);
4619 install_element (RMAP_NODE
, &no_match_ip_address_cmd
);
4620 install_element (RMAP_NODE
, &no_match_ip_address_val_cmd
);
4621 install_element (RMAP_NODE
, &match_ip_next_hop_cmd
);
4622 install_element (RMAP_NODE
, &no_match_ip_next_hop_cmd
);
4623 install_element (RMAP_NODE
, &no_match_ip_next_hop_val_cmd
);
4624 install_element (RMAP_NODE
, &match_ip_route_source_cmd
);
4625 install_element (RMAP_NODE
, &no_match_ip_route_source_cmd
);
4626 install_element (RMAP_NODE
, &no_match_ip_route_source_val_cmd
);
4627 install_element (RMAP_NODE
, &match_ip_address_prefix_list_cmd
);
4628 install_element (RMAP_NODE
, &no_match_ip_address_prefix_list_cmd
);
4629 install_element (RMAP_NODE
, &no_match_ip_address_prefix_list_val_cmd
);
4630 install_element (RMAP_NODE
, &match_ip_next_hop_prefix_list_cmd
);
4631 install_element (RMAP_NODE
, &no_match_ip_next_hop_prefix_list_cmd
);
4632 install_element (RMAP_NODE
, &no_match_ip_next_hop_prefix_list_val_cmd
);
4633 install_element (RMAP_NODE
, &match_ip_route_source_prefix_list_cmd
);
4634 install_element (RMAP_NODE
, &no_match_ip_route_source_prefix_list_cmd
);
4635 install_element (RMAP_NODE
, &no_match_ip_route_source_prefix_list_val_cmd
);
4637 install_element (RMAP_NODE
, &match_aspath_cmd
);
4638 install_element (RMAP_NODE
, &no_match_aspath_cmd
);
4639 install_element (RMAP_NODE
, &no_match_aspath_val_cmd
);
4640 install_element (RMAP_NODE
, &match_metric_cmd
);
4641 install_element (RMAP_NODE
, &no_match_metric_cmd
);
4642 install_element (RMAP_NODE
, &no_match_metric_val_cmd
);
4643 install_element (RMAP_NODE
, &match_local_pref_cmd
);
4644 install_element (RMAP_NODE
, &no_match_local_pref_cmd
);
4645 install_element (RMAP_NODE
, &no_match_local_pref_val_cmd
);
4646 install_element (RMAP_NODE
, &match_community_cmd
);
4647 install_element (RMAP_NODE
, &match_community_exact_cmd
);
4648 install_element (RMAP_NODE
, &no_match_community_cmd
);
4649 install_element (RMAP_NODE
, &no_match_community_val_cmd
);
4650 install_element (RMAP_NODE
, &no_match_community_exact_cmd
);
4651 install_element (RMAP_NODE
, &match_ecommunity_cmd
);
4652 install_element (RMAP_NODE
, &no_match_ecommunity_cmd
);
4653 install_element (RMAP_NODE
, &no_match_ecommunity_val_cmd
);
4654 install_element (RMAP_NODE
, &match_origin_cmd
);
4655 install_element (RMAP_NODE
, &no_match_origin_cmd
);
4656 install_element (RMAP_NODE
, &no_match_origin_val_cmd
);
4657 install_element (RMAP_NODE
, &match_probability_cmd
);
4658 install_element (RMAP_NODE
, &no_match_probability_cmd
);
4659 install_element (RMAP_NODE
, &no_match_probability_val_cmd
);
4660 install_element (RMAP_NODE
, &match_interface_cmd
);
4661 install_element (RMAP_NODE
, &no_match_interface_cmd
);
4662 install_element (RMAP_NODE
, &no_match_interface_val_cmd
);
4663 install_element (RMAP_NODE
, &match_tag_cmd
);
4664 install_element (RMAP_NODE
, &no_match_tag_cmd
);
4665 install_element (RMAP_NODE
, &no_match_tag_val_cmd
);
4667 install_element (RMAP_NODE
, &set_ip_nexthop_cmd
);
4668 install_element (RMAP_NODE
, &set_ip_nexthop_peer_cmd
);
4669 install_element (RMAP_NODE
, &set_ip_nexthop_unchanged_cmd
);
4670 install_element (RMAP_NODE
, &no_set_ip_nexthop_cmd
);
4671 install_element (RMAP_NODE
, &no_set_ip_nexthop_val_cmd
);
4672 install_element (RMAP_NODE
, &no_set_ip_nexthop_peer_cmd
);
4673 install_element (RMAP_NODE
, &set_local_pref_cmd
);
4674 install_element (RMAP_NODE
, &no_set_local_pref_cmd
);
4675 install_element (RMAP_NODE
, &no_set_local_pref_val_cmd
);
4676 install_element (RMAP_NODE
, &set_weight_cmd
);
4677 install_element (RMAP_NODE
, &no_set_weight_cmd
);
4678 install_element (RMAP_NODE
, &no_set_weight_val_cmd
);
4679 install_element (RMAP_NODE
, &set_metric_cmd
);
4680 install_element (RMAP_NODE
, &set_metric_addsub_cmd
);
4681 install_element (RMAP_NODE
, &set_metric_rtt_cmd
);
4682 install_element (RMAP_NODE
, &no_set_metric_cmd
);
4683 install_element (RMAP_NODE
, &no_set_metric_val_cmd
);
4684 install_element (RMAP_NODE
, &set_aspath_prepend_cmd
);
4685 install_element (RMAP_NODE
, &set_aspath_prepend_lastas_cmd
);
4686 install_element (RMAP_NODE
, &set_aspath_exclude_cmd
);
4687 install_element (RMAP_NODE
, &no_set_aspath_prepend_cmd
);
4688 install_element (RMAP_NODE
, &no_set_aspath_prepend_val_cmd
);
4689 install_element (RMAP_NODE
, &no_set_aspath_exclude_cmd
);
4690 install_element (RMAP_NODE
, &no_set_aspath_exclude_val_cmd
);
4691 install_element (RMAP_NODE
, &set_origin_cmd
);
4692 install_element (RMAP_NODE
, &no_set_origin_cmd
);
4693 install_element (RMAP_NODE
, &no_set_origin_val_cmd
);
4694 install_element (RMAP_NODE
, &set_atomic_aggregate_cmd
);
4695 install_element (RMAP_NODE
, &no_set_atomic_aggregate_cmd
);
4696 install_element (RMAP_NODE
, &set_aggregator_as_cmd
);
4697 install_element (RMAP_NODE
, &no_set_aggregator_as_cmd
);
4698 install_element (RMAP_NODE
, &no_set_aggregator_as_val_cmd
);
4699 install_element (RMAP_NODE
, &set_community_cmd
);
4700 install_element (RMAP_NODE
, &set_community_none_cmd
);
4701 install_element (RMAP_NODE
, &no_set_community_cmd
);
4702 install_element (RMAP_NODE
, &no_set_community_val_cmd
);
4703 install_element (RMAP_NODE
, &no_set_community_none_cmd
);
4704 install_element (RMAP_NODE
, &set_community_delete_cmd
);
4705 install_element (RMAP_NODE
, &no_set_community_delete_cmd
);
4706 install_element (RMAP_NODE
, &no_set_community_delete_val_cmd
);
4707 install_element (RMAP_NODE
, &set_ecommunity_rt_cmd
);
4708 install_element (RMAP_NODE
, &no_set_ecommunity_rt_cmd
);
4709 install_element (RMAP_NODE
, &no_set_ecommunity_rt_val_cmd
);
4710 install_element (RMAP_NODE
, &set_ecommunity_soo_cmd
);
4711 install_element (RMAP_NODE
, &no_set_ecommunity_soo_cmd
);
4712 install_element (RMAP_NODE
, &no_set_ecommunity_soo_val_cmd
);
4713 install_element (RMAP_NODE
, &set_vpnv4_nexthop_cmd
);
4714 install_element (RMAP_NODE
, &no_set_vpnv4_nexthop_cmd
);
4715 install_element (RMAP_NODE
, &no_set_vpnv4_nexthop_val_cmd
);
4716 install_element (RMAP_NODE
, &set_originator_id_cmd
);
4717 install_element (RMAP_NODE
, &no_set_originator_id_cmd
);
4718 install_element (RMAP_NODE
, &no_set_originator_id_val_cmd
);
4719 install_element (RMAP_NODE
, &set_tag_cmd
);
4720 install_element (RMAP_NODE
, &no_set_tag_cmd
);
4721 install_element (RMAP_NODE
, &no_set_tag_val_cmd
);
4724 route_map_install_match (&route_match_ipv6_address_cmd
);
4725 route_map_install_match (&route_match_ipv6_next_hop_cmd
);
4726 route_map_install_match (&route_match_ipv6_address_prefix_list_cmd
);
4727 route_map_install_set (&route_set_ipv6_nexthop_global_cmd
);
4728 route_map_install_set (&route_set_ipv6_nexthop_prefer_global_cmd
);
4729 route_map_install_set (&route_set_ipv6_nexthop_local_cmd
);
4730 route_map_install_set (&route_set_ipv6_nexthop_peer_cmd
);
4732 install_element (RMAP_NODE
, &match_ipv6_address_cmd
);
4733 install_element (RMAP_NODE
, &no_match_ipv6_address_cmd
);
4734 install_element (RMAP_NODE
, &match_ipv6_next_hop_cmd
);
4735 install_element (RMAP_NODE
, &no_match_ipv6_next_hop_cmd
);
4736 install_element (RMAP_NODE
, &match_ipv6_address_prefix_list_cmd
);
4737 install_element (RMAP_NODE
, &no_match_ipv6_address_prefix_list_cmd
);
4738 install_element (RMAP_NODE
, &set_ipv6_nexthop_global_cmd
);
4739 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_global_cmd
);
4740 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_global_val_cmd
);
4741 install_element (RMAP_NODE
, &set_ipv6_nexthop_prefer_global_cmd
);
4742 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_prefer_global_cmd
);
4743 install_element (RMAP_NODE
, &set_ipv6_nexthop_local_cmd
);
4744 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_local_cmd
);
4745 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_local_val_cmd
);
4746 install_element (RMAP_NODE
, &set_ipv6_nexthop_peer_cmd
);
4747 install_element (RMAP_NODE
, &no_set_ipv6_nexthop_peer_cmd
);
4748 #endif /* HAVE_IPV6 */
4752 bgp_route_map_terminate (void)
4754 /* ToDo: Cleanup all the used memory */
4756 route_map_add_hook (NULL
);
4757 route_map_delete_hook (NULL
);
4758 route_map_event_hook (NULL
);