2002-12-13 21:15:29 +01:00
|
|
|
/* Route map function of bgpd.
|
|
|
|
Copyright (C) 1998, 1999 Kunihiro Ishiguro
|
|
|
|
|
|
|
|
This file is part of GNU Zebra.
|
|
|
|
|
|
|
|
GNU Zebra is free software; you can redistribute it and/or modify it
|
|
|
|
under the terms of the GNU General Public License as published by the
|
|
|
|
Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
later version.
|
|
|
|
|
|
|
|
GNU Zebra is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with GNU Zebra; see the file COPYING. If not, write to the Free
|
|
|
|
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
02111-1307, USA. */
|
|
|
|
|
|
|
|
#include <zebra.h>
|
|
|
|
|
|
|
|
#include "prefix.h"
|
|
|
|
#include "filter.h"
|
|
|
|
#include "routemap.h"
|
|
|
|
#include "command.h"
|
|
|
|
#include "linklist.h"
|
|
|
|
#include "plist.h"
|
|
|
|
#include "memory.h"
|
|
|
|
#include "log.h"
|
2009-01-12 22:06:12 +01:00
|
|
|
#ifdef HAVE_LIBPCREPOSIX
|
|
|
|
# include <pcreposix.h>
|
2002-12-13 21:15:29 +01:00
|
|
|
#else
|
2009-01-12 22:06:12 +01:00
|
|
|
# ifdef HAVE_GNU_REGEX
|
|
|
|
# include <regex.h>
|
|
|
|
# else
|
|
|
|
# include "regex-gnu.h"
|
|
|
|
# endif /* HAVE_GNU_REGEX */
|
|
|
|
#endif /* HAVE_LIBPCREPOSIX */
|
2002-12-13 21:15:29 +01:00
|
|
|
#include "buffer.h"
|
|
|
|
#include "sockunion.h"
|
2015-05-20 02:40:45 +02:00
|
|
|
#include "hash.h"
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
#include "bgpd/bgpd.h"
|
|
|
|
#include "bgpd/bgp_table.h"
|
|
|
|
#include "bgpd/bgp_attr.h"
|
|
|
|
#include "bgpd/bgp_aspath.h"
|
2015-05-20 02:40:45 +02:00
|
|
|
#include "bgpd/bgp_packet.h"
|
2002-12-13 21:15:29 +01:00
|
|
|
#include "bgpd/bgp_route.h"
|
bgpd: bgpd-table-map.patch
COMMAND:
table-map <route-map-name>
DESCRIPTION:
This feature is used to apply a route-map on route updates from BGP to Zebra.
All the applicable match operations are allowed, such as match on prefix,
next-hop, communities, etc. Set operations for this attach-point are limited
to metric and next-hop only. Any operation of this feature does not affect
BGPs internal RIB.
Supported for ipv4 and ipv6 address families. It works on multi-paths as well,
however, metric setting is based on the best-path only.
IMPLEMENTATION NOTES:
The route-map application at this point is not supposed to modify any of BGP
route's attributes (anything in bgp_info for that matter). To achieve that,
creating a copy of the bgp_attr was inevitable. Implementation tries to keep
the memory footprint low, code comments do point out the rationale behind a
few choices made.
bgp_zebra_announce() was already a big routine, adding this feature would
extend it further. Patch has created a few smaller routines/macros whereever
possible to keep the size of the routine in check without compromising on the
readability of the code/flow inside this routine.
For updating a partially filtered route (with its nexthops), BGP to Zebra
replacement semantic of the next-hops serves the purpose well. However, with
this patch there could be some redundant withdraws each time BGP announces a
route thats (all the nexthops) gets denied by the route-map application.
Handling of this case could be optimized by keeping state with the prefix and
the nexthops in BGP. The patch doesn't optimizing that case, as even with the
redundant withdraws the total number of updates to zebra are still be capped
by the total number of routes in the table.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com>
2015-05-20 02:40:34 +02:00
|
|
|
#include "bgpd/bgp_zebra.h"
|
2002-12-13 21:15:29 +01:00
|
|
|
#include "bgpd/bgp_regex.h"
|
|
|
|
#include "bgpd/bgp_community.h"
|
|
|
|
#include "bgpd/bgp_clist.h"
|
|
|
|
#include "bgpd/bgp_filter.h"
|
|
|
|
#include "bgpd/bgp_mplsvpn.h"
|
|
|
|
#include "bgpd/bgp_ecommunity.h"
|
2008-07-02 15:40:33 +02:00
|
|
|
#include "bgpd/bgp_vty.h"
|
bgpd: bgpd-table-map.patch
COMMAND:
table-map <route-map-name>
DESCRIPTION:
This feature is used to apply a route-map on route updates from BGP to Zebra.
All the applicable match operations are allowed, such as match on prefix,
next-hop, communities, etc. Set operations for this attach-point are limited
to metric and next-hop only. Any operation of this feature does not affect
BGPs internal RIB.
Supported for ipv4 and ipv6 address families. It works on multi-paths as well,
however, metric setting is based on the best-path only.
IMPLEMENTATION NOTES:
The route-map application at this point is not supposed to modify any of BGP
route's attributes (anything in bgp_info for that matter). To achieve that,
creating a copy of the bgp_attr was inevitable. Implementation tries to keep
the memory footprint low, code comments do point out the rationale behind a
few choices made.
bgp_zebra_announce() was already a big routine, adding this feature would
extend it further. Patch has created a few smaller routines/macros whereever
possible to keep the size of the routine in check without compromising on the
readability of the code/flow inside this routine.
For updating a partially filtered route (with its nexthops), BGP to Zebra
replacement semantic of the next-hops serves the purpose well. However, with
this patch there could be some redundant withdraws each time BGP announces a
route thats (all the nexthops) gets denied by the route-map application.
Handling of this case could be optimized by keeping state with the prefix and
the nexthops in BGP. The patch doesn't optimizing that case, as even with the
redundant withdraws the total number of updates to zebra are still be capped
by the total number of routes in the table.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com>
2015-05-20 02:40:34 +02:00
|
|
|
#include "bgpd/bgp_debug.h"
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Memo of route-map commands.
|
|
|
|
|
|
|
|
o Cisco route-map
|
|
|
|
|
|
|
|
match as-path : Done
|
|
|
|
community : Done
|
2015-05-20 02:40:47 +02:00
|
|
|
interface : Done
|
2002-12-13 21:15:29 +01:00
|
|
|
ip address : Done
|
|
|
|
ip next-hop : Done
|
2005-02-02 17:43:17 +01:00
|
|
|
ip route-source : Done
|
2002-12-13 21:15:29 +01:00
|
|
|
ip prefix-list : Done
|
|
|
|
ipv6 address : Done
|
|
|
|
ipv6 next-hop : Done
|
|
|
|
ipv6 route-source: (This will not be implemented by bgpd)
|
|
|
|
ipv6 prefix-list : Done
|
|
|
|
length : (This will not be implemented by bgpd)
|
|
|
|
metric : Done
|
|
|
|
route-type : (This will not be implemented by bgpd)
|
2015-05-20 02:46:33 +02:00
|
|
|
tag : Done
|
2015-05-20 02:40:40 +02:00
|
|
|
local-preference : Done
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
set as-path prepend : Done
|
|
|
|
as-path tag : Not yet
|
|
|
|
automatic-tag : (This will not be implemented by bgpd)
|
|
|
|
community : Done
|
|
|
|
comm-list : Not yet
|
|
|
|
dampning : Not yet
|
|
|
|
default : (This will not be implemented by bgpd)
|
|
|
|
interface : (This will not be implemented by bgpd)
|
|
|
|
ip default : (This will not be implemented by bgpd)
|
|
|
|
ip next-hop : Done
|
|
|
|
ip precedence : (This will not be implemented by bgpd)
|
|
|
|
ip tos : (This will not be implemented by bgpd)
|
|
|
|
level : (This will not be implemented by bgpd)
|
|
|
|
local-preference : Done
|
|
|
|
metric : Done
|
|
|
|
metric-type : Not yet
|
|
|
|
origin : Done
|
2015-05-20 02:46:33 +02:00
|
|
|
tag : Done
|
2002-12-13 21:15:29 +01:00
|
|
|
weight : Done
|
|
|
|
|
2014-05-20 07:57:26 +02:00
|
|
|
o Local extensions
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
set ipv6 next-hop global: Done
|
|
|
|
set ipv6 next-hop local : Done
|
2008-04-10 13:47:45 +02:00
|
|
|
set as-path exclude : Done
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
*/
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2014-05-20 08:04:49 +02:00
|
|
|
/* generic as path object to be shared in multiple rules */
|
|
|
|
|
|
|
|
static void *
|
|
|
|
route_aspath_compile (const char *arg)
|
|
|
|
{
|
|
|
|
struct aspath *aspath;
|
|
|
|
|
|
|
|
aspath = aspath_str2aspath (arg);
|
|
|
|
if (! aspath)
|
|
|
|
return NULL;
|
|
|
|
return aspath;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
route_aspath_free (void *rule)
|
|
|
|
{
|
|
|
|
struct aspath *aspath = rule;
|
|
|
|
aspath_free (aspath);
|
|
|
|
}
|
|
|
|
|
2004-09-13 Jose Luis Rubio <jrubio@dit.upm.es>
(at Technical University of Madrid as part of Euro6ix Project)
Enhanced Route Server functionality and Route-Maps:
* bgpd/bgpd.h: Modified 'struct peer' and 'struct bgp_filter' to
support rs-clients. A 'struct bgp_table *rib' has been added to the
first (to mantain a separated RIB for each rs-client) and two new
route-maps have been added to the last (for import/export policies).
Added the following #defines: RMAP_{IN|OUT|IMPORT|EXPORT|MAX},
PEER_RMAP_TYPE_{IMPORT|EXPORT} and BGP_CLEAR_SOFT_RSCLIENT.
* bgpd/bgpd.c: Modified the functions that create/delete/etc peers in
order to consider the new fields included in 'struct peer' for
supporting rs-clients, i.e. the import/export route-maps and the
'struct bgp_table'.
* bgpd/bgp_route.{ch}: Modified several functions related with
receiving/sending announces in order to support the new Route Server
capabilities.
Function 'bgp_process' has been reorganized, creating an auxiliar
function for best path selection ('bgp_best_selection').
Modified 'bgp_show' and 'bgp_show_route' for displaying information
about any RIB (and not only the main bgp RIB).
Added commands for displaying information about RS-clients RIBs:
'show bgp rsclient (A.B.C.D|X:X::X:X)', 'show bgp rsclient
(A.B.C.D|X:X::X:X) X:X::X:X/M', etc
* bgpd/bgp_table.{ch}: The structure 'struct bgp_table' now has two
new fields: type (which can take the values BGP_TABLE_{MAIN|RSCLIENT})
and 'void *owner' which points to 'struct bgp' or 'struct peer' which
owns the table.
When creating a new bgp_table by default 'type=BGP_TABLE_MAIN' is set.
* bgpd/bgp_vty.c: The commands 'neighbor ... route-server-client' and
'no neighbor ... route-server-client' now not only set/unset the flag
PEER_FLAG_RSERVER_CLIENT, but they create/destroy the 'struct
bgp_table' of the peer. Special actions are taken for peer_groups.
Command 'neighbor ... route-map WORD (in|out)' now also supports two
new kinds of route-map: 'import' and 'export'.
Added commands 'clear bgp * rsclient', etc. These commands allow a new
kind of soft_reconfig which affects only the RIB of the specified
RS-client.
Added commands 'show bgp rsclient summary', etc which display a
summary of the rs-clients configured for the corresponding address
family.
* bgpd/bgp_routemap.c: A new match statement is available,
'match peer (A.B.C.D|X:X::X:X)'. This statement can only be used in
import/export route-maps, and it matches when the peer who announces
(when used in an import route-map) or is going to receive (when used
in an export route-map) the route is the same than the one specified
in the statement.
For peer-groups the statement matches if the specified peer is member
of the peer-group.
A special version of the command, 'match peer local', matches with
routes originated by the Route Server (defined with 'network ...',
redistributed routes and default-originate).
* lib/routemap.{ch}: Added a new clause 'call NAME' for use in
route-maps. It jumps into the specified route-map and when it returns
the first route-map ends if the called RM returns DENY_MATCH, or
continues in other case.
2004-09-13 07:12:46 +02:00
|
|
|
/* 'match peer (A.B.C.D|X:X::X:X)' */
|
|
|
|
|
|
|
|
/* Compares the peer specified in the 'match peer' clause with the peer
|
|
|
|
received in bgp_info->peer. If it is the same, or if the peer structure
|
|
|
|
received is a peer_group containing it, returns RMAP_MATCH. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2004-09-13 Jose Luis Rubio <jrubio@dit.upm.es>
(at Technical University of Madrid as part of Euro6ix Project)
Enhanced Route Server functionality and Route-Maps:
* bgpd/bgpd.h: Modified 'struct peer' and 'struct bgp_filter' to
support rs-clients. A 'struct bgp_table *rib' has been added to the
first (to mantain a separated RIB for each rs-client) and two new
route-maps have been added to the last (for import/export policies).
Added the following #defines: RMAP_{IN|OUT|IMPORT|EXPORT|MAX},
PEER_RMAP_TYPE_{IMPORT|EXPORT} and BGP_CLEAR_SOFT_RSCLIENT.
* bgpd/bgpd.c: Modified the functions that create/delete/etc peers in
order to consider the new fields included in 'struct peer' for
supporting rs-clients, i.e. the import/export route-maps and the
'struct bgp_table'.
* bgpd/bgp_route.{ch}: Modified several functions related with
receiving/sending announces in order to support the new Route Server
capabilities.
Function 'bgp_process' has been reorganized, creating an auxiliar
function for best path selection ('bgp_best_selection').
Modified 'bgp_show' and 'bgp_show_route' for displaying information
about any RIB (and not only the main bgp RIB).
Added commands for displaying information about RS-clients RIBs:
'show bgp rsclient (A.B.C.D|X:X::X:X)', 'show bgp rsclient
(A.B.C.D|X:X::X:X) X:X::X:X/M', etc
* bgpd/bgp_table.{ch}: The structure 'struct bgp_table' now has two
new fields: type (which can take the values BGP_TABLE_{MAIN|RSCLIENT})
and 'void *owner' which points to 'struct bgp' or 'struct peer' which
owns the table.
When creating a new bgp_table by default 'type=BGP_TABLE_MAIN' is set.
* bgpd/bgp_vty.c: The commands 'neighbor ... route-server-client' and
'no neighbor ... route-server-client' now not only set/unset the flag
PEER_FLAG_RSERVER_CLIENT, but they create/destroy the 'struct
bgp_table' of the peer. Special actions are taken for peer_groups.
Command 'neighbor ... route-map WORD (in|out)' now also supports two
new kinds of route-map: 'import' and 'export'.
Added commands 'clear bgp * rsclient', etc. These commands allow a new
kind of soft_reconfig which affects only the RIB of the specified
RS-client.
Added commands 'show bgp rsclient summary', etc which display a
summary of the rs-clients configured for the corresponding address
family.
* bgpd/bgp_routemap.c: A new match statement is available,
'match peer (A.B.C.D|X:X::X:X)'. This statement can only be used in
import/export route-maps, and it matches when the peer who announces
(when used in an import route-map) or is going to receive (when used
in an export route-map) the route is the same than the one specified
in the statement.
For peer-groups the statement matches if the specified peer is member
of the peer-group.
A special version of the command, 'match peer local', matches with
routes originated by the Route Server (defined with 'network ...',
redistributed routes and default-originate).
* lib/routemap.{ch}: Added a new clause 'call NAME' for use in
route-maps. It jumps into the specified route-map and when it returns
the first route-map ends if the called RM returns DENY_MATCH, or
continues in other case.
2004-09-13 07:12:46 +02:00
|
|
|
route_match_peer (void *rule, struct prefix *prefix, route_map_object_t type,
|
|
|
|
void *object)
|
|
|
|
{
|
|
|
|
union sockunion *su;
|
2012-04-10 16:57:24 +02:00
|
|
|
union sockunion su_def = { .sa.sa_family = AF_INET,
|
|
|
|
.sin.sin_addr.s_addr = INADDR_ANY };
|
2004-09-13 Jose Luis Rubio <jrubio@dit.upm.es>
(at Technical University of Madrid as part of Euro6ix Project)
Enhanced Route Server functionality and Route-Maps:
* bgpd/bgpd.h: Modified 'struct peer' and 'struct bgp_filter' to
support rs-clients. A 'struct bgp_table *rib' has been added to the
first (to mantain a separated RIB for each rs-client) and two new
route-maps have been added to the last (for import/export policies).
Added the following #defines: RMAP_{IN|OUT|IMPORT|EXPORT|MAX},
PEER_RMAP_TYPE_{IMPORT|EXPORT} and BGP_CLEAR_SOFT_RSCLIENT.
* bgpd/bgpd.c: Modified the functions that create/delete/etc peers in
order to consider the new fields included in 'struct peer' for
supporting rs-clients, i.e. the import/export route-maps and the
'struct bgp_table'.
* bgpd/bgp_route.{ch}: Modified several functions related with
receiving/sending announces in order to support the new Route Server
capabilities.
Function 'bgp_process' has been reorganized, creating an auxiliar
function for best path selection ('bgp_best_selection').
Modified 'bgp_show' and 'bgp_show_route' for displaying information
about any RIB (and not only the main bgp RIB).
Added commands for displaying information about RS-clients RIBs:
'show bgp rsclient (A.B.C.D|X:X::X:X)', 'show bgp rsclient
(A.B.C.D|X:X::X:X) X:X::X:X/M', etc
* bgpd/bgp_table.{ch}: The structure 'struct bgp_table' now has two
new fields: type (which can take the values BGP_TABLE_{MAIN|RSCLIENT})
and 'void *owner' which points to 'struct bgp' or 'struct peer' which
owns the table.
When creating a new bgp_table by default 'type=BGP_TABLE_MAIN' is set.
* bgpd/bgp_vty.c: The commands 'neighbor ... route-server-client' and
'no neighbor ... route-server-client' now not only set/unset the flag
PEER_FLAG_RSERVER_CLIENT, but they create/destroy the 'struct
bgp_table' of the peer. Special actions are taken for peer_groups.
Command 'neighbor ... route-map WORD (in|out)' now also supports two
new kinds of route-map: 'import' and 'export'.
Added commands 'clear bgp * rsclient', etc. These commands allow a new
kind of soft_reconfig which affects only the RIB of the specified
RS-client.
Added commands 'show bgp rsclient summary', etc which display a
summary of the rs-clients configured for the corresponding address
family.
* bgpd/bgp_routemap.c: A new match statement is available,
'match peer (A.B.C.D|X:X::X:X)'. This statement can only be used in
import/export route-maps, and it matches when the peer who announces
(when used in an import route-map) or is going to receive (when used
in an export route-map) the route is the same than the one specified
in the statement.
For peer-groups the statement matches if the specified peer is member
of the peer-group.
A special version of the command, 'match peer local', matches with
routes originated by the Route Server (defined with 'network ...',
redistributed routes and default-originate).
* lib/routemap.{ch}: Added a new clause 'call NAME' for use in
route-maps. It jumps into the specified route-map and when it returns
the first route-map ends if the called RM returns DENY_MATCH, or
continues in other case.
2004-09-13 07:12:46 +02:00
|
|
|
struct peer_group *group;
|
|
|
|
struct peer *peer;
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
struct listnode *node, *nnode;
|
2004-09-13 Jose Luis Rubio <jrubio@dit.upm.es>
(at Technical University of Madrid as part of Euro6ix Project)
Enhanced Route Server functionality and Route-Maps:
* bgpd/bgpd.h: Modified 'struct peer' and 'struct bgp_filter' to
support rs-clients. A 'struct bgp_table *rib' has been added to the
first (to mantain a separated RIB for each rs-client) and two new
route-maps have been added to the last (for import/export policies).
Added the following #defines: RMAP_{IN|OUT|IMPORT|EXPORT|MAX},
PEER_RMAP_TYPE_{IMPORT|EXPORT} and BGP_CLEAR_SOFT_RSCLIENT.
* bgpd/bgpd.c: Modified the functions that create/delete/etc peers in
order to consider the new fields included in 'struct peer' for
supporting rs-clients, i.e. the import/export route-maps and the
'struct bgp_table'.
* bgpd/bgp_route.{ch}: Modified several functions related with
receiving/sending announces in order to support the new Route Server
capabilities.
Function 'bgp_process' has been reorganized, creating an auxiliar
function for best path selection ('bgp_best_selection').
Modified 'bgp_show' and 'bgp_show_route' for displaying information
about any RIB (and not only the main bgp RIB).
Added commands for displaying information about RS-clients RIBs:
'show bgp rsclient (A.B.C.D|X:X::X:X)', 'show bgp rsclient
(A.B.C.D|X:X::X:X) X:X::X:X/M', etc
* bgpd/bgp_table.{ch}: The structure 'struct bgp_table' now has two
new fields: type (which can take the values BGP_TABLE_{MAIN|RSCLIENT})
and 'void *owner' which points to 'struct bgp' or 'struct peer' which
owns the table.
When creating a new bgp_table by default 'type=BGP_TABLE_MAIN' is set.
* bgpd/bgp_vty.c: The commands 'neighbor ... route-server-client' and
'no neighbor ... route-server-client' now not only set/unset the flag
PEER_FLAG_RSERVER_CLIENT, but they create/destroy the 'struct
bgp_table' of the peer. Special actions are taken for peer_groups.
Command 'neighbor ... route-map WORD (in|out)' now also supports two
new kinds of route-map: 'import' and 'export'.
Added commands 'clear bgp * rsclient', etc. These commands allow a new
kind of soft_reconfig which affects only the RIB of the specified
RS-client.
Added commands 'show bgp rsclient summary', etc which display a
summary of the rs-clients configured for the corresponding address
family.
* bgpd/bgp_routemap.c: A new match statement is available,
'match peer (A.B.C.D|X:X::X:X)'. This statement can only be used in
import/export route-maps, and it matches when the peer who announces
(when used in an import route-map) or is going to receive (when used
in an export route-map) the route is the same than the one specified
in the statement.
For peer-groups the statement matches if the specified peer is member
of the peer-group.
A special version of the command, 'match peer local', matches with
routes originated by the Route Server (defined with 'network ...',
redistributed routes and default-originate).
* lib/routemap.{ch}: Added a new clause 'call NAME' for use in
route-maps. It jumps into the specified route-map and when it returns
the first route-map ends if the called RM returns DENY_MATCH, or
continues in other case.
2004-09-13 07:12:46 +02:00
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
su = rule;
|
|
|
|
peer = ((struct bgp_info *) object)->peer;
|
|
|
|
|
|
|
|
if ( ! CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT) &&
|
|
|
|
! CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_EXPORT) )
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
|
|
|
|
/* If su='0.0.0.0' (command 'match peer local'), and it's a NETWORK,
|
|
|
|
REDISTRIBUTE or DEFAULT_GENERATED route => return RMAP_MATCH */
|
2012-04-10 16:57:24 +02:00
|
|
|
if (sockunion_same (su, &su_def))
|
2004-09-13 Jose Luis Rubio <jrubio@dit.upm.es>
(at Technical University of Madrid as part of Euro6ix Project)
Enhanced Route Server functionality and Route-Maps:
* bgpd/bgpd.h: Modified 'struct peer' and 'struct bgp_filter' to
support rs-clients. A 'struct bgp_table *rib' has been added to the
first (to mantain a separated RIB for each rs-client) and two new
route-maps have been added to the last (for import/export policies).
Added the following #defines: RMAP_{IN|OUT|IMPORT|EXPORT|MAX},
PEER_RMAP_TYPE_{IMPORT|EXPORT} and BGP_CLEAR_SOFT_RSCLIENT.
* bgpd/bgpd.c: Modified the functions that create/delete/etc peers in
order to consider the new fields included in 'struct peer' for
supporting rs-clients, i.e. the import/export route-maps and the
'struct bgp_table'.
* bgpd/bgp_route.{ch}: Modified several functions related with
receiving/sending announces in order to support the new Route Server
capabilities.
Function 'bgp_process' has been reorganized, creating an auxiliar
function for best path selection ('bgp_best_selection').
Modified 'bgp_show' and 'bgp_show_route' for displaying information
about any RIB (and not only the main bgp RIB).
Added commands for displaying information about RS-clients RIBs:
'show bgp rsclient (A.B.C.D|X:X::X:X)', 'show bgp rsclient
(A.B.C.D|X:X::X:X) X:X::X:X/M', etc
* bgpd/bgp_table.{ch}: The structure 'struct bgp_table' now has two
new fields: type (which can take the values BGP_TABLE_{MAIN|RSCLIENT})
and 'void *owner' which points to 'struct bgp' or 'struct peer' which
owns the table.
When creating a new bgp_table by default 'type=BGP_TABLE_MAIN' is set.
* bgpd/bgp_vty.c: The commands 'neighbor ... route-server-client' and
'no neighbor ... route-server-client' now not only set/unset the flag
PEER_FLAG_RSERVER_CLIENT, but they create/destroy the 'struct
bgp_table' of the peer. Special actions are taken for peer_groups.
Command 'neighbor ... route-map WORD (in|out)' now also supports two
new kinds of route-map: 'import' and 'export'.
Added commands 'clear bgp * rsclient', etc. These commands allow a new
kind of soft_reconfig which affects only the RIB of the specified
RS-client.
Added commands 'show bgp rsclient summary', etc which display a
summary of the rs-clients configured for the corresponding address
family.
* bgpd/bgp_routemap.c: A new match statement is available,
'match peer (A.B.C.D|X:X::X:X)'. This statement can only be used in
import/export route-maps, and it matches when the peer who announces
(when used in an import route-map) or is going to receive (when used
in an export route-map) the route is the same than the one specified
in the statement.
For peer-groups the statement matches if the specified peer is member
of the peer-group.
A special version of the command, 'match peer local', matches with
routes originated by the Route Server (defined with 'network ...',
redistributed routes and default-originate).
* lib/routemap.{ch}: Added a new clause 'call NAME' for use in
route-maps. It jumps into the specified route-map and when it returns
the first route-map ends if the called RM returns DENY_MATCH, or
continues in other case.
2004-09-13 07:12:46 +02:00
|
|
|
{
|
2005-05-19 03:50:11 +02:00
|
|
|
int ret;
|
2004-09-13 Jose Luis Rubio <jrubio@dit.upm.es>
(at Technical University of Madrid as part of Euro6ix Project)
Enhanced Route Server functionality and Route-Maps:
* bgpd/bgpd.h: Modified 'struct peer' and 'struct bgp_filter' to
support rs-clients. A 'struct bgp_table *rib' has been added to the
first (to mantain a separated RIB for each rs-client) and two new
route-maps have been added to the last (for import/export policies).
Added the following #defines: RMAP_{IN|OUT|IMPORT|EXPORT|MAX},
PEER_RMAP_TYPE_{IMPORT|EXPORT} and BGP_CLEAR_SOFT_RSCLIENT.
* bgpd/bgpd.c: Modified the functions that create/delete/etc peers in
order to consider the new fields included in 'struct peer' for
supporting rs-clients, i.e. the import/export route-maps and the
'struct bgp_table'.
* bgpd/bgp_route.{ch}: Modified several functions related with
receiving/sending announces in order to support the new Route Server
capabilities.
Function 'bgp_process' has been reorganized, creating an auxiliar
function for best path selection ('bgp_best_selection').
Modified 'bgp_show' and 'bgp_show_route' for displaying information
about any RIB (and not only the main bgp RIB).
Added commands for displaying information about RS-clients RIBs:
'show bgp rsclient (A.B.C.D|X:X::X:X)', 'show bgp rsclient
(A.B.C.D|X:X::X:X) X:X::X:X/M', etc
* bgpd/bgp_table.{ch}: The structure 'struct bgp_table' now has two
new fields: type (which can take the values BGP_TABLE_{MAIN|RSCLIENT})
and 'void *owner' which points to 'struct bgp' or 'struct peer' which
owns the table.
When creating a new bgp_table by default 'type=BGP_TABLE_MAIN' is set.
* bgpd/bgp_vty.c: The commands 'neighbor ... route-server-client' and
'no neighbor ... route-server-client' now not only set/unset the flag
PEER_FLAG_RSERVER_CLIENT, but they create/destroy the 'struct
bgp_table' of the peer. Special actions are taken for peer_groups.
Command 'neighbor ... route-map WORD (in|out)' now also supports two
new kinds of route-map: 'import' and 'export'.
Added commands 'clear bgp * rsclient', etc. These commands allow a new
kind of soft_reconfig which affects only the RIB of the specified
RS-client.
Added commands 'show bgp rsclient summary', etc which display a
summary of the rs-clients configured for the corresponding address
family.
* bgpd/bgp_routemap.c: A new match statement is available,
'match peer (A.B.C.D|X:X::X:X)'. This statement can only be used in
import/export route-maps, and it matches when the peer who announces
(when used in an import route-map) or is going to receive (when used
in an export route-map) the route is the same than the one specified
in the statement.
For peer-groups the statement matches if the specified peer is member
of the peer-group.
A special version of the command, 'match peer local', matches with
routes originated by the Route Server (defined with 'network ...',
redistributed routes and default-originate).
* lib/routemap.{ch}: Added a new clause 'call NAME' for use in
route-maps. It jumps into the specified route-map and when it returns
the first route-map ends if the called RM returns DENY_MATCH, or
continues in other case.
2004-09-13 07:12:46 +02:00
|
|
|
if ( CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_NETWORK) ||
|
|
|
|
CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE) ||
|
|
|
|
CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_DEFAULT))
|
2005-05-19 03:50:11 +02:00
|
|
|
ret = RMAP_MATCH;
|
2004-09-13 Jose Luis Rubio <jrubio@dit.upm.es>
(at Technical University of Madrid as part of Euro6ix Project)
Enhanced Route Server functionality and Route-Maps:
* bgpd/bgpd.h: Modified 'struct peer' and 'struct bgp_filter' to
support rs-clients. A 'struct bgp_table *rib' has been added to the
first (to mantain a separated RIB for each rs-client) and two new
route-maps have been added to the last (for import/export policies).
Added the following #defines: RMAP_{IN|OUT|IMPORT|EXPORT|MAX},
PEER_RMAP_TYPE_{IMPORT|EXPORT} and BGP_CLEAR_SOFT_RSCLIENT.
* bgpd/bgpd.c: Modified the functions that create/delete/etc peers in
order to consider the new fields included in 'struct peer' for
supporting rs-clients, i.e. the import/export route-maps and the
'struct bgp_table'.
* bgpd/bgp_route.{ch}: Modified several functions related with
receiving/sending announces in order to support the new Route Server
capabilities.
Function 'bgp_process' has been reorganized, creating an auxiliar
function for best path selection ('bgp_best_selection').
Modified 'bgp_show' and 'bgp_show_route' for displaying information
about any RIB (and not only the main bgp RIB).
Added commands for displaying information about RS-clients RIBs:
'show bgp rsclient (A.B.C.D|X:X::X:X)', 'show bgp rsclient
(A.B.C.D|X:X::X:X) X:X::X:X/M', etc
* bgpd/bgp_table.{ch}: The structure 'struct bgp_table' now has two
new fields: type (which can take the values BGP_TABLE_{MAIN|RSCLIENT})
and 'void *owner' which points to 'struct bgp' or 'struct peer' which
owns the table.
When creating a new bgp_table by default 'type=BGP_TABLE_MAIN' is set.
* bgpd/bgp_vty.c: The commands 'neighbor ... route-server-client' and
'no neighbor ... route-server-client' now not only set/unset the flag
PEER_FLAG_RSERVER_CLIENT, but they create/destroy the 'struct
bgp_table' of the peer. Special actions are taken for peer_groups.
Command 'neighbor ... route-map WORD (in|out)' now also supports two
new kinds of route-map: 'import' and 'export'.
Added commands 'clear bgp * rsclient', etc. These commands allow a new
kind of soft_reconfig which affects only the RIB of the specified
RS-client.
Added commands 'show bgp rsclient summary', etc which display a
summary of the rs-clients configured for the corresponding address
family.
* bgpd/bgp_routemap.c: A new match statement is available,
'match peer (A.B.C.D|X:X::X:X)'. This statement can only be used in
import/export route-maps, and it matches when the peer who announces
(when used in an import route-map) or is going to receive (when used
in an export route-map) the route is the same than the one specified
in the statement.
For peer-groups the statement matches if the specified peer is member
of the peer-group.
A special version of the command, 'match peer local', matches with
routes originated by the Route Server (defined with 'network ...',
redistributed routes and default-originate).
* lib/routemap.{ch}: Added a new clause 'call NAME' for use in
route-maps. It jumps into the specified route-map and when it returns
the first route-map ends if the called RM returns DENY_MATCH, or
continues in other case.
2004-09-13 07:12:46 +02:00
|
|
|
else
|
2005-05-19 03:50:11 +02:00
|
|
|
ret = RMAP_NOMATCH;
|
|
|
|
return ret;
|
2004-09-13 Jose Luis Rubio <jrubio@dit.upm.es>
(at Technical University of Madrid as part of Euro6ix Project)
Enhanced Route Server functionality and Route-Maps:
* bgpd/bgpd.h: Modified 'struct peer' and 'struct bgp_filter' to
support rs-clients. A 'struct bgp_table *rib' has been added to the
first (to mantain a separated RIB for each rs-client) and two new
route-maps have been added to the last (for import/export policies).
Added the following #defines: RMAP_{IN|OUT|IMPORT|EXPORT|MAX},
PEER_RMAP_TYPE_{IMPORT|EXPORT} and BGP_CLEAR_SOFT_RSCLIENT.
* bgpd/bgpd.c: Modified the functions that create/delete/etc peers in
order to consider the new fields included in 'struct peer' for
supporting rs-clients, i.e. the import/export route-maps and the
'struct bgp_table'.
* bgpd/bgp_route.{ch}: Modified several functions related with
receiving/sending announces in order to support the new Route Server
capabilities.
Function 'bgp_process' has been reorganized, creating an auxiliar
function for best path selection ('bgp_best_selection').
Modified 'bgp_show' and 'bgp_show_route' for displaying information
about any RIB (and not only the main bgp RIB).
Added commands for displaying information about RS-clients RIBs:
'show bgp rsclient (A.B.C.D|X:X::X:X)', 'show bgp rsclient
(A.B.C.D|X:X::X:X) X:X::X:X/M', etc
* bgpd/bgp_table.{ch}: The structure 'struct bgp_table' now has two
new fields: type (which can take the values BGP_TABLE_{MAIN|RSCLIENT})
and 'void *owner' which points to 'struct bgp' or 'struct peer' which
owns the table.
When creating a new bgp_table by default 'type=BGP_TABLE_MAIN' is set.
* bgpd/bgp_vty.c: The commands 'neighbor ... route-server-client' and
'no neighbor ... route-server-client' now not only set/unset the flag
PEER_FLAG_RSERVER_CLIENT, but they create/destroy the 'struct
bgp_table' of the peer. Special actions are taken for peer_groups.
Command 'neighbor ... route-map WORD (in|out)' now also supports two
new kinds of route-map: 'import' and 'export'.
Added commands 'clear bgp * rsclient', etc. These commands allow a new
kind of soft_reconfig which affects only the RIB of the specified
RS-client.
Added commands 'show bgp rsclient summary', etc which display a
summary of the rs-clients configured for the corresponding address
family.
* bgpd/bgp_routemap.c: A new match statement is available,
'match peer (A.B.C.D|X:X::X:X)'. This statement can only be used in
import/export route-maps, and it matches when the peer who announces
(when used in an import route-map) or is going to receive (when used
in an export route-map) the route is the same than the one specified
in the statement.
For peer-groups the statement matches if the specified peer is member
of the peer-group.
A special version of the command, 'match peer local', matches with
routes originated by the Route Server (defined with 'network ...',
redistributed routes and default-originate).
* lib/routemap.{ch}: Added a new clause 'call NAME' for use in
route-maps. It jumps into the specified route-map and when it returns
the first route-map ends if the called RM returns DENY_MATCH, or
continues in other case.
2004-09-13 07:12:46 +02:00
|
|
|
}
|
2012-04-10 16:57:24 +02:00
|
|
|
|
2004-09-13 Jose Luis Rubio <jrubio@dit.upm.es>
(at Technical University of Madrid as part of Euro6ix Project)
Enhanced Route Server functionality and Route-Maps:
* bgpd/bgpd.h: Modified 'struct peer' and 'struct bgp_filter' to
support rs-clients. A 'struct bgp_table *rib' has been added to the
first (to mantain a separated RIB for each rs-client) and two new
route-maps have been added to the last (for import/export policies).
Added the following #defines: RMAP_{IN|OUT|IMPORT|EXPORT|MAX},
PEER_RMAP_TYPE_{IMPORT|EXPORT} and BGP_CLEAR_SOFT_RSCLIENT.
* bgpd/bgpd.c: Modified the functions that create/delete/etc peers in
order to consider the new fields included in 'struct peer' for
supporting rs-clients, i.e. the import/export route-maps and the
'struct bgp_table'.
* bgpd/bgp_route.{ch}: Modified several functions related with
receiving/sending announces in order to support the new Route Server
capabilities.
Function 'bgp_process' has been reorganized, creating an auxiliar
function for best path selection ('bgp_best_selection').
Modified 'bgp_show' and 'bgp_show_route' for displaying information
about any RIB (and not only the main bgp RIB).
Added commands for displaying information about RS-clients RIBs:
'show bgp rsclient (A.B.C.D|X:X::X:X)', 'show bgp rsclient
(A.B.C.D|X:X::X:X) X:X::X:X/M', etc
* bgpd/bgp_table.{ch}: The structure 'struct bgp_table' now has two
new fields: type (which can take the values BGP_TABLE_{MAIN|RSCLIENT})
and 'void *owner' which points to 'struct bgp' or 'struct peer' which
owns the table.
When creating a new bgp_table by default 'type=BGP_TABLE_MAIN' is set.
* bgpd/bgp_vty.c: The commands 'neighbor ... route-server-client' and
'no neighbor ... route-server-client' now not only set/unset the flag
PEER_FLAG_RSERVER_CLIENT, but they create/destroy the 'struct
bgp_table' of the peer. Special actions are taken for peer_groups.
Command 'neighbor ... route-map WORD (in|out)' now also supports two
new kinds of route-map: 'import' and 'export'.
Added commands 'clear bgp * rsclient', etc. These commands allow a new
kind of soft_reconfig which affects only the RIB of the specified
RS-client.
Added commands 'show bgp rsclient summary', etc which display a
summary of the rs-clients configured for the corresponding address
family.
* bgpd/bgp_routemap.c: A new match statement is available,
'match peer (A.B.C.D|X:X::X:X)'. This statement can only be used in
import/export route-maps, and it matches when the peer who announces
(when used in an import route-map) or is going to receive (when used
in an export route-map) the route is the same than the one specified
in the statement.
For peer-groups the statement matches if the specified peer is member
of the peer-group.
A special version of the command, 'match peer local', matches with
routes originated by the Route Server (defined with 'network ...',
redistributed routes and default-originate).
* lib/routemap.{ch}: Added a new clause 'call NAME' for use in
route-maps. It jumps into the specified route-map and when it returns
the first route-map ends if the called RM returns DENY_MATCH, or
continues in other case.
2004-09-13 07:12:46 +02:00
|
|
|
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
|
|
|
|
{
|
|
|
|
if (sockunion_same (su, &peer->su))
|
|
|
|
return RMAP_MATCH;
|
|
|
|
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
group = peer->group;
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
|
2004-09-13 Jose Luis Rubio <jrubio@dit.upm.es>
(at Technical University of Madrid as part of Euro6ix Project)
Enhanced Route Server functionality and Route-Maps:
* bgpd/bgpd.h: Modified 'struct peer' and 'struct bgp_filter' to
support rs-clients. A 'struct bgp_table *rib' has been added to the
first (to mantain a separated RIB for each rs-client) and two new
route-maps have been added to the last (for import/export policies).
Added the following #defines: RMAP_{IN|OUT|IMPORT|EXPORT|MAX},
PEER_RMAP_TYPE_{IMPORT|EXPORT} and BGP_CLEAR_SOFT_RSCLIENT.
* bgpd/bgpd.c: Modified the functions that create/delete/etc peers in
order to consider the new fields included in 'struct peer' for
supporting rs-clients, i.e. the import/export route-maps and the
'struct bgp_table'.
* bgpd/bgp_route.{ch}: Modified several functions related with
receiving/sending announces in order to support the new Route Server
capabilities.
Function 'bgp_process' has been reorganized, creating an auxiliar
function for best path selection ('bgp_best_selection').
Modified 'bgp_show' and 'bgp_show_route' for displaying information
about any RIB (and not only the main bgp RIB).
Added commands for displaying information about RS-clients RIBs:
'show bgp rsclient (A.B.C.D|X:X::X:X)', 'show bgp rsclient
(A.B.C.D|X:X::X:X) X:X::X:X/M', etc
* bgpd/bgp_table.{ch}: The structure 'struct bgp_table' now has two
new fields: type (which can take the values BGP_TABLE_{MAIN|RSCLIENT})
and 'void *owner' which points to 'struct bgp' or 'struct peer' which
owns the table.
When creating a new bgp_table by default 'type=BGP_TABLE_MAIN' is set.
* bgpd/bgp_vty.c: The commands 'neighbor ... route-server-client' and
'no neighbor ... route-server-client' now not only set/unset the flag
PEER_FLAG_RSERVER_CLIENT, but they create/destroy the 'struct
bgp_table' of the peer. Special actions are taken for peer_groups.
Command 'neighbor ... route-map WORD (in|out)' now also supports two
new kinds of route-map: 'import' and 'export'.
Added commands 'clear bgp * rsclient', etc. These commands allow a new
kind of soft_reconfig which affects only the RIB of the specified
RS-client.
Added commands 'show bgp rsclient summary', etc which display a
summary of the rs-clients configured for the corresponding address
family.
* bgpd/bgp_routemap.c: A new match statement is available,
'match peer (A.B.C.D|X:X::X:X)'. This statement can only be used in
import/export route-maps, and it matches when the peer who announces
(when used in an import route-map) or is going to receive (when used
in an export route-map) the route is the same than the one specified
in the statement.
For peer-groups the statement matches if the specified peer is member
of the peer-group.
A special version of the command, 'match peer local', matches with
routes originated by the Route Server (defined with 'network ...',
redistributed routes and default-originate).
* lib/routemap.{ch}: Added a new clause 'call NAME' for use in
route-maps. It jumps into the specified route-map and when it returns
the first route-map ends if the called RM returns DENY_MATCH, or
continues in other case.
2004-09-13 07:12:46 +02:00
|
|
|
{
|
|
|
|
if (sockunion_same (su, &peer->su))
|
|
|
|
return RMAP_MATCH;
|
|
|
|
}
|
2008-08-15 15:05:22 +02:00
|
|
|
return RMAP_NOMATCH;
|
2004-09-13 Jose Luis Rubio <jrubio@dit.upm.es>
(at Technical University of Madrid as part of Euro6ix Project)
Enhanced Route Server functionality and Route-Maps:
* bgpd/bgpd.h: Modified 'struct peer' and 'struct bgp_filter' to
support rs-clients. A 'struct bgp_table *rib' has been added to the
first (to mantain a separated RIB for each rs-client) and two new
route-maps have been added to the last (for import/export policies).
Added the following #defines: RMAP_{IN|OUT|IMPORT|EXPORT|MAX},
PEER_RMAP_TYPE_{IMPORT|EXPORT} and BGP_CLEAR_SOFT_RSCLIENT.
* bgpd/bgpd.c: Modified the functions that create/delete/etc peers in
order to consider the new fields included in 'struct peer' for
supporting rs-clients, i.e. the import/export route-maps and the
'struct bgp_table'.
* bgpd/bgp_route.{ch}: Modified several functions related with
receiving/sending announces in order to support the new Route Server
capabilities.
Function 'bgp_process' has been reorganized, creating an auxiliar
function for best path selection ('bgp_best_selection').
Modified 'bgp_show' and 'bgp_show_route' for displaying information
about any RIB (and not only the main bgp RIB).
Added commands for displaying information about RS-clients RIBs:
'show bgp rsclient (A.B.C.D|X:X::X:X)', 'show bgp rsclient
(A.B.C.D|X:X::X:X) X:X::X:X/M', etc
* bgpd/bgp_table.{ch}: The structure 'struct bgp_table' now has two
new fields: type (which can take the values BGP_TABLE_{MAIN|RSCLIENT})
and 'void *owner' which points to 'struct bgp' or 'struct peer' which
owns the table.
When creating a new bgp_table by default 'type=BGP_TABLE_MAIN' is set.
* bgpd/bgp_vty.c: The commands 'neighbor ... route-server-client' and
'no neighbor ... route-server-client' now not only set/unset the flag
PEER_FLAG_RSERVER_CLIENT, but they create/destroy the 'struct
bgp_table' of the peer. Special actions are taken for peer_groups.
Command 'neighbor ... route-map WORD (in|out)' now also supports two
new kinds of route-map: 'import' and 'export'.
Added commands 'clear bgp * rsclient', etc. These commands allow a new
kind of soft_reconfig which affects only the RIB of the specified
RS-client.
Added commands 'show bgp rsclient summary', etc which display a
summary of the rs-clients configured for the corresponding address
family.
* bgpd/bgp_routemap.c: A new match statement is available,
'match peer (A.B.C.D|X:X::X:X)'. This statement can only be used in
import/export route-maps, and it matches when the peer who announces
(when used in an import route-map) or is going to receive (when used
in an export route-map) the route is the same than the one specified
in the statement.
For peer-groups the statement matches if the specified peer is member
of the peer-group.
A special version of the command, 'match peer local', matches with
routes originated by the Route Server (defined with 'network ...',
redistributed routes and default-originate).
* lib/routemap.{ch}: Added a new clause 'call NAME' for use in
route-maps. It jumps into the specified route-map and when it returns
the first route-map ends if the called RM returns DENY_MATCH, or
continues in other case.
2004-09-13 07:12:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2004-10-13 07:06:08 +02:00
|
|
|
route_match_peer_compile (const char *arg)
|
2004-09-13 Jose Luis Rubio <jrubio@dit.upm.es>
(at Technical University of Madrid as part of Euro6ix Project)
Enhanced Route Server functionality and Route-Maps:
* bgpd/bgpd.h: Modified 'struct peer' and 'struct bgp_filter' to
support rs-clients. A 'struct bgp_table *rib' has been added to the
first (to mantain a separated RIB for each rs-client) and two new
route-maps have been added to the last (for import/export policies).
Added the following #defines: RMAP_{IN|OUT|IMPORT|EXPORT|MAX},
PEER_RMAP_TYPE_{IMPORT|EXPORT} and BGP_CLEAR_SOFT_RSCLIENT.
* bgpd/bgpd.c: Modified the functions that create/delete/etc peers in
order to consider the new fields included in 'struct peer' for
supporting rs-clients, i.e. the import/export route-maps and the
'struct bgp_table'.
* bgpd/bgp_route.{ch}: Modified several functions related with
receiving/sending announces in order to support the new Route Server
capabilities.
Function 'bgp_process' has been reorganized, creating an auxiliar
function for best path selection ('bgp_best_selection').
Modified 'bgp_show' and 'bgp_show_route' for displaying information
about any RIB (and not only the main bgp RIB).
Added commands for displaying information about RS-clients RIBs:
'show bgp rsclient (A.B.C.D|X:X::X:X)', 'show bgp rsclient
(A.B.C.D|X:X::X:X) X:X::X:X/M', etc
* bgpd/bgp_table.{ch}: The structure 'struct bgp_table' now has two
new fields: type (which can take the values BGP_TABLE_{MAIN|RSCLIENT})
and 'void *owner' which points to 'struct bgp' or 'struct peer' which
owns the table.
When creating a new bgp_table by default 'type=BGP_TABLE_MAIN' is set.
* bgpd/bgp_vty.c: The commands 'neighbor ... route-server-client' and
'no neighbor ... route-server-client' now not only set/unset the flag
PEER_FLAG_RSERVER_CLIENT, but they create/destroy the 'struct
bgp_table' of the peer. Special actions are taken for peer_groups.
Command 'neighbor ... route-map WORD (in|out)' now also supports two
new kinds of route-map: 'import' and 'export'.
Added commands 'clear bgp * rsclient', etc. These commands allow a new
kind of soft_reconfig which affects only the RIB of the specified
RS-client.
Added commands 'show bgp rsclient summary', etc which display a
summary of the rs-clients configured for the corresponding address
family.
* bgpd/bgp_routemap.c: A new match statement is available,
'match peer (A.B.C.D|X:X::X:X)'. This statement can only be used in
import/export route-maps, and it matches when the peer who announces
(when used in an import route-map) or is going to receive (when used
in an export route-map) the route is the same than the one specified
in the statement.
For peer-groups the statement matches if the specified peer is member
of the peer-group.
A special version of the command, 'match peer local', matches with
routes originated by the Route Server (defined with 'network ...',
redistributed routes and default-originate).
* lib/routemap.{ch}: Added a new clause 'call NAME' for use in
route-maps. It jumps into the specified route-map and when it returns
the first route-map ends if the called RM returns DENY_MATCH, or
continues in other case.
2004-09-13 07:12:46 +02:00
|
|
|
{
|
|
|
|
union sockunion *su;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
su = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (union sockunion));
|
|
|
|
|
2012-04-13 13:46:08 +02:00
|
|
|
ret = str2sockunion (strcmp(arg, "local") ? arg : "0.0.0.0", su);
|
2004-09-13 Jose Luis Rubio <jrubio@dit.upm.es>
(at Technical University of Madrid as part of Euro6ix Project)
Enhanced Route Server functionality and Route-Maps:
* bgpd/bgpd.h: Modified 'struct peer' and 'struct bgp_filter' to
support rs-clients. A 'struct bgp_table *rib' has been added to the
first (to mantain a separated RIB for each rs-client) and two new
route-maps have been added to the last (for import/export policies).
Added the following #defines: RMAP_{IN|OUT|IMPORT|EXPORT|MAX},
PEER_RMAP_TYPE_{IMPORT|EXPORT} and BGP_CLEAR_SOFT_RSCLIENT.
* bgpd/bgpd.c: Modified the functions that create/delete/etc peers in
order to consider the new fields included in 'struct peer' for
supporting rs-clients, i.e. the import/export route-maps and the
'struct bgp_table'.
* bgpd/bgp_route.{ch}: Modified several functions related with
receiving/sending announces in order to support the new Route Server
capabilities.
Function 'bgp_process' has been reorganized, creating an auxiliar
function for best path selection ('bgp_best_selection').
Modified 'bgp_show' and 'bgp_show_route' for displaying information
about any RIB (and not only the main bgp RIB).
Added commands for displaying information about RS-clients RIBs:
'show bgp rsclient (A.B.C.D|X:X::X:X)', 'show bgp rsclient
(A.B.C.D|X:X::X:X) X:X::X:X/M', etc
* bgpd/bgp_table.{ch}: The structure 'struct bgp_table' now has two
new fields: type (which can take the values BGP_TABLE_{MAIN|RSCLIENT})
and 'void *owner' which points to 'struct bgp' or 'struct peer' which
owns the table.
When creating a new bgp_table by default 'type=BGP_TABLE_MAIN' is set.
* bgpd/bgp_vty.c: The commands 'neighbor ... route-server-client' and
'no neighbor ... route-server-client' now not only set/unset the flag
PEER_FLAG_RSERVER_CLIENT, but they create/destroy the 'struct
bgp_table' of the peer. Special actions are taken for peer_groups.
Command 'neighbor ... route-map WORD (in|out)' now also supports two
new kinds of route-map: 'import' and 'export'.
Added commands 'clear bgp * rsclient', etc. These commands allow a new
kind of soft_reconfig which affects only the RIB of the specified
RS-client.
Added commands 'show bgp rsclient summary', etc which display a
summary of the rs-clients configured for the corresponding address
family.
* bgpd/bgp_routemap.c: A new match statement is available,
'match peer (A.B.C.D|X:X::X:X)'. This statement can only be used in
import/export route-maps, and it matches when the peer who announces
(when used in an import route-map) or is going to receive (when used
in an export route-map) the route is the same than the one specified
in the statement.
For peer-groups the statement matches if the specified peer is member
of the peer-group.
A special version of the command, 'match peer local', matches with
routes originated by the Route Server (defined with 'network ...',
redistributed routes and default-originate).
* lib/routemap.{ch}: Added a new clause 'call NAME' for use in
route-maps. It jumps into the specified route-map and when it returns
the first route-map ends if the called RM returns DENY_MATCH, or
continues in other case.
2004-09-13 07:12:46 +02:00
|
|
|
if (ret < 0) {
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, su);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return su;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free route map's compiled `ip address' value. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2004-09-13 Jose Luis Rubio <jrubio@dit.upm.es>
(at Technical University of Madrid as part of Euro6ix Project)
Enhanced Route Server functionality and Route-Maps:
* bgpd/bgpd.h: Modified 'struct peer' and 'struct bgp_filter' to
support rs-clients. A 'struct bgp_table *rib' has been added to the
first (to mantain a separated RIB for each rs-client) and two new
route-maps have been added to the last (for import/export policies).
Added the following #defines: RMAP_{IN|OUT|IMPORT|EXPORT|MAX},
PEER_RMAP_TYPE_{IMPORT|EXPORT} and BGP_CLEAR_SOFT_RSCLIENT.
* bgpd/bgpd.c: Modified the functions that create/delete/etc peers in
order to consider the new fields included in 'struct peer' for
supporting rs-clients, i.e. the import/export route-maps and the
'struct bgp_table'.
* bgpd/bgp_route.{ch}: Modified several functions related with
receiving/sending announces in order to support the new Route Server
capabilities.
Function 'bgp_process' has been reorganized, creating an auxiliar
function for best path selection ('bgp_best_selection').
Modified 'bgp_show' and 'bgp_show_route' for displaying information
about any RIB (and not only the main bgp RIB).
Added commands for displaying information about RS-clients RIBs:
'show bgp rsclient (A.B.C.D|X:X::X:X)', 'show bgp rsclient
(A.B.C.D|X:X::X:X) X:X::X:X/M', etc
* bgpd/bgp_table.{ch}: The structure 'struct bgp_table' now has two
new fields: type (which can take the values BGP_TABLE_{MAIN|RSCLIENT})
and 'void *owner' which points to 'struct bgp' or 'struct peer' which
owns the table.
When creating a new bgp_table by default 'type=BGP_TABLE_MAIN' is set.
* bgpd/bgp_vty.c: The commands 'neighbor ... route-server-client' and
'no neighbor ... route-server-client' now not only set/unset the flag
PEER_FLAG_RSERVER_CLIENT, but they create/destroy the 'struct
bgp_table' of the peer. Special actions are taken for peer_groups.
Command 'neighbor ... route-map WORD (in|out)' now also supports two
new kinds of route-map: 'import' and 'export'.
Added commands 'clear bgp * rsclient', etc. These commands allow a new
kind of soft_reconfig which affects only the RIB of the specified
RS-client.
Added commands 'show bgp rsclient summary', etc which display a
summary of the rs-clients configured for the corresponding address
family.
* bgpd/bgp_routemap.c: A new match statement is available,
'match peer (A.B.C.D|X:X::X:X)'. This statement can only be used in
import/export route-maps, and it matches when the peer who announces
(when used in an import route-map) or is going to receive (when used
in an export route-map) the route is the same than the one specified
in the statement.
For peer-groups the statement matches if the specified peer is member
of the peer-group.
A special version of the command, 'match peer local', matches with
routes originated by the Route Server (defined with 'network ...',
redistributed routes and default-originate).
* lib/routemap.{ch}: Added a new clause 'call NAME' for use in
route-maps. It jumps into the specified route-map and when it returns
the first route-map ends if the called RM returns DENY_MATCH, or
continues in other case.
2004-09-13 07:12:46 +02:00
|
|
|
route_match_peer_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map commands for ip address matching. */
|
|
|
|
struct route_map_rule_cmd route_match_peer_cmd =
|
|
|
|
{
|
|
|
|
"peer",
|
|
|
|
route_match_peer,
|
|
|
|
route_match_peer_compile,
|
|
|
|
route_match_peer_free
|
|
|
|
};
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* `match ip address IP_ACCESS_LIST' */
|
|
|
|
|
|
|
|
/* Match function should return 1 if match is success else return
|
|
|
|
zero. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2002-12-13 21:15:29 +01:00
|
|
|
route_match_ip_address (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
struct access_list *alist;
|
|
|
|
/* struct prefix_ipv4 match; */
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
alist = access_list_lookup (AFI_IP, (char *) rule);
|
|
|
|
if (alist == NULL)
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
|
|
|
|
return (access_list_apply (alist, prefix) == FILTER_DENY ?
|
|
|
|
RMAP_NOMATCH : RMAP_MATCH);
|
|
|
|
}
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map `ip address' match statement. `arg' should be
|
|
|
|
access-list name. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2004-10-13 07:06:08 +02:00
|
|
|
route_match_ip_address_compile (const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free route map's compiled `ip address' value. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
route_match_ip_address_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map commands for ip address matching. */
|
|
|
|
struct route_map_rule_cmd route_match_ip_address_cmd =
|
|
|
|
{
|
|
|
|
"ip address",
|
|
|
|
route_match_ip_address,
|
|
|
|
route_match_ip_address_compile,
|
|
|
|
route_match_ip_address_free
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* `match ip next-hop IP_ADDRESS' */
|
|
|
|
|
|
|
|
/* Match function return 1 if match is success else return zero. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2002-12-13 21:15:29 +01:00
|
|
|
route_match_ip_next_hop (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
struct access_list *alist;
|
|
|
|
struct bgp_info *bgp_info;
|
|
|
|
struct prefix_ipv4 p;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
bgp_info = object;
|
|
|
|
p.family = AF_INET;
|
|
|
|
p.prefix = bgp_info->attr->nexthop;
|
|
|
|
p.prefixlen = IPV4_MAX_BITLEN;
|
|
|
|
|
|
|
|
alist = access_list_lookup (AFI_IP, (char *) rule);
|
|
|
|
if (alist == NULL)
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
|
|
|
|
return (access_list_apply (alist, &p) == FILTER_DENY ?
|
|
|
|
RMAP_NOMATCH : RMAP_MATCH);
|
|
|
|
}
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map `ip next-hop' match statement. `arg' is
|
|
|
|
access-list name. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2004-10-13 07:06:08 +02:00
|
|
|
route_match_ip_next_hop_compile (const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free route map's compiled `ip address' value. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
route_match_ip_next_hop_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map commands for ip next-hop matching. */
|
|
|
|
struct route_map_rule_cmd route_match_ip_next_hop_cmd =
|
|
|
|
{
|
|
|
|
"ip next-hop",
|
|
|
|
route_match_ip_next_hop,
|
|
|
|
route_match_ip_next_hop_compile,
|
|
|
|
route_match_ip_next_hop_free
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2005-02-02 17:43:17 +01:00
|
|
|
/* `match ip route-source ACCESS-LIST' */
|
|
|
|
|
|
|
|
/* Match function return 1 if match is success else return zero. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2005-02-02 17:43:17 +01:00
|
|
|
route_match_ip_route_source (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
struct access_list *alist;
|
|
|
|
struct bgp_info *bgp_info;
|
|
|
|
struct peer *peer;
|
|
|
|
struct prefix_ipv4 p;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
bgp_info = object;
|
|
|
|
peer = bgp_info->peer;
|
|
|
|
|
|
|
|
if (! peer || sockunion_family (&peer->su) != AF_INET)
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
|
|
|
|
p.family = AF_INET;
|
|
|
|
p.prefix = peer->su.sin.sin_addr;
|
|
|
|
p.prefixlen = IPV4_MAX_BITLEN;
|
|
|
|
|
|
|
|
alist = access_list_lookup (AFI_IP, (char *) rule);
|
|
|
|
if (alist == NULL)
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
|
|
|
|
return (access_list_apply (alist, &p) == FILTER_DENY ?
|
|
|
|
RMAP_NOMATCH : RMAP_MATCH);
|
|
|
|
}
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map `ip route-source' match statement. `arg' is
|
|
|
|
access-list name. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2005-02-02 17:43:17 +01:00
|
|
|
route_match_ip_route_source_compile (const char *arg)
|
|
|
|
{
|
|
|
|
return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free route map's compiled `ip address' value. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2005-02-02 17:43:17 +01:00
|
|
|
route_match_ip_route_source_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map commands for ip route-source matching. */
|
|
|
|
struct route_map_rule_cmd route_match_ip_route_source_cmd =
|
|
|
|
{
|
|
|
|
"ip route-source",
|
|
|
|
route_match_ip_route_source,
|
|
|
|
route_match_ip_route_source_compile,
|
|
|
|
route_match_ip_route_source_free
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* `match ip address prefix-list PREFIX_LIST' */
|
|
|
|
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2002-12-13 21:15:29 +01:00
|
|
|
route_match_ip_address_prefix_list (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
struct prefix_list *plist;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
plist = prefix_list_lookup (AFI_IP, (char *) rule);
|
|
|
|
if (plist == NULL)
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
|
|
|
|
return (prefix_list_apply (plist, prefix) == PREFIX_DENY ?
|
|
|
|
RMAP_NOMATCH : RMAP_MATCH);
|
|
|
|
}
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2004-10-13 07:06:08 +02:00
|
|
|
route_match_ip_address_prefix_list_compile (const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
|
|
|
|
}
|
|
|
|
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
route_match_ip_address_prefix_list_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct route_map_rule_cmd route_match_ip_address_prefix_list_cmd =
|
|
|
|
{
|
|
|
|
"ip address prefix-list",
|
|
|
|
route_match_ip_address_prefix_list,
|
|
|
|
route_match_ip_address_prefix_list_compile,
|
|
|
|
route_match_ip_address_prefix_list_free
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* `match ip next-hop prefix-list PREFIX_LIST' */
|
|
|
|
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2002-12-13 21:15:29 +01:00
|
|
|
route_match_ip_next_hop_prefix_list (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
struct prefix_list *plist;
|
|
|
|
struct bgp_info *bgp_info;
|
|
|
|
struct prefix_ipv4 p;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
bgp_info = object;
|
|
|
|
p.family = AF_INET;
|
|
|
|
p.prefix = bgp_info->attr->nexthop;
|
|
|
|
p.prefixlen = IPV4_MAX_BITLEN;
|
|
|
|
|
|
|
|
plist = prefix_list_lookup (AFI_IP, (char *) rule);
|
|
|
|
if (plist == NULL)
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
|
|
|
|
return (prefix_list_apply (plist, &p) == PREFIX_DENY ?
|
|
|
|
RMAP_NOMATCH : RMAP_MATCH);
|
|
|
|
}
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2004-10-13 07:06:08 +02:00
|
|
|
route_match_ip_next_hop_prefix_list_compile (const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
|
|
|
|
}
|
|
|
|
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
route_match_ip_next_hop_prefix_list_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct route_map_rule_cmd route_match_ip_next_hop_prefix_list_cmd =
|
|
|
|
{
|
|
|
|
"ip next-hop prefix-list",
|
|
|
|
route_match_ip_next_hop_prefix_list,
|
|
|
|
route_match_ip_next_hop_prefix_list_compile,
|
|
|
|
route_match_ip_next_hop_prefix_list_free
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2005-02-02 17:43:17 +01:00
|
|
|
/* `match ip route-source prefix-list PREFIX_LIST' */
|
|
|
|
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2005-02-02 17:43:17 +01:00
|
|
|
route_match_ip_route_source_prefix_list (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
struct prefix_list *plist;
|
|
|
|
struct bgp_info *bgp_info;
|
|
|
|
struct peer *peer;
|
|
|
|
struct prefix_ipv4 p;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
bgp_info = object;
|
|
|
|
peer = bgp_info->peer;
|
|
|
|
|
|
|
|
if (! peer || sockunion_family (&peer->su) != AF_INET)
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
|
|
|
|
p.family = AF_INET;
|
|
|
|
p.prefix = peer->su.sin.sin_addr;
|
|
|
|
p.prefixlen = IPV4_MAX_BITLEN;
|
|
|
|
|
|
|
|
plist = prefix_list_lookup (AFI_IP, (char *) rule);
|
|
|
|
if (plist == NULL)
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
|
|
|
|
return (prefix_list_apply (plist, &p) == PREFIX_DENY ?
|
|
|
|
RMAP_NOMATCH : RMAP_MATCH);
|
|
|
|
}
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2005-02-02 17:43:17 +01:00
|
|
|
route_match_ip_route_source_prefix_list_compile (const char *arg)
|
|
|
|
{
|
|
|
|
return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
|
|
|
|
}
|
|
|
|
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2005-02-02 17:43:17 +01:00
|
|
|
route_match_ip_route_source_prefix_list_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct route_map_rule_cmd route_match_ip_route_source_prefix_list_cmd =
|
|
|
|
{
|
|
|
|
"ip route-source prefix-list",
|
|
|
|
route_match_ip_route_source_prefix_list,
|
|
|
|
route_match_ip_route_source_prefix_list_compile,
|
|
|
|
route_match_ip_route_source_prefix_list_free
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2015-05-20 02:40:40 +02:00
|
|
|
/* `match local-preference LOCAL-PREF' */
|
|
|
|
|
|
|
|
/* Match function return 1 if match is success else return zero. */
|
|
|
|
static route_map_result_t
|
|
|
|
route_match_local_pref (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
u_int32_t *local_pref;
|
|
|
|
struct bgp_info *bgp_info;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
local_pref = rule;
|
|
|
|
bgp_info = object;
|
|
|
|
|
|
|
|
if (bgp_info->attr->local_pref == *local_pref)
|
|
|
|
return RMAP_MATCH;
|
|
|
|
else
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map `match local-preference' match statement.
|
|
|
|
`arg' is local-pref value */
|
|
|
|
static void *
|
|
|
|
route_match_local_pref_compile (const char *arg)
|
|
|
|
{
|
|
|
|
u_int32_t *local_pref;
|
|
|
|
char *endptr = NULL;
|
|
|
|
unsigned long tmpval;
|
|
|
|
|
|
|
|
/* Locpref value shoud be integer. */
|
|
|
|
if (! all_digit (arg))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
tmpval = strtoul (arg, &endptr, 10);
|
|
|
|
if (*endptr != '\0' || errno || tmpval > UINT32_MAX)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
local_pref = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_int32_t));
|
|
|
|
|
|
|
|
if (!local_pref)
|
|
|
|
return local_pref;
|
|
|
|
|
|
|
|
*local_pref = tmpval;
|
|
|
|
return local_pref;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free route map's compiled `match local-preference' value. */
|
|
|
|
static void
|
|
|
|
route_match_local_pref_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map commands for metric matching. */
|
|
|
|
struct route_map_rule_cmd route_match_local_pref_cmd =
|
|
|
|
{
|
|
|
|
"local-preference",
|
|
|
|
route_match_local_pref,
|
|
|
|
route_match_local_pref_compile,
|
|
|
|
route_match_local_pref_free
|
|
|
|
};
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* `match metric METRIC' */
|
|
|
|
|
|
|
|
/* Match function return 1 if match is success else return zero. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2002-12-13 21:15:29 +01:00
|
|
|
route_match_metric (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
u_int32_t *med;
|
|
|
|
struct bgp_info *bgp_info;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
med = rule;
|
|
|
|
bgp_info = object;
|
|
|
|
|
|
|
|
if (bgp_info->attr->med == *med)
|
|
|
|
return RMAP_MATCH;
|
|
|
|
else
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map `match metric' match statement. `arg' is MED value */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2004-10-13 07:06:08 +02:00
|
|
|
route_match_metric_compile (const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
u_int32_t *med;
|
|
|
|
char *endptr = NULL;
|
2003-10-13 11:47:32 +02:00
|
|
|
unsigned long tmpval;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2011-12-20 23:24:11 +01:00
|
|
|
/* Metric value shoud be integer. */
|
|
|
|
if (! all_digit (arg))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
errno = 0;
|
2003-10-13 11:47:32 +02:00
|
|
|
tmpval = strtoul (arg, &endptr, 10);
|
2011-12-20 23:24:11 +01:00
|
|
|
if (*endptr != '\0' || errno || tmpval > UINT32_MAX)
|
2003-10-13 11:47:32 +02:00
|
|
|
return NULL;
|
2004-10-13 07:06:08 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
med = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_int32_t));
|
2004-10-13 07:06:08 +02:00
|
|
|
|
|
|
|
if (!med)
|
|
|
|
return med;
|
|
|
|
|
2003-10-13 11:47:32 +02:00
|
|
|
*med = tmpval;
|
2002-12-13 21:15:29 +01:00
|
|
|
return med;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free route map's compiled `match metric' value. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
route_match_metric_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map commands for metric matching. */
|
|
|
|
struct route_map_rule_cmd route_match_metric_cmd =
|
|
|
|
{
|
|
|
|
"metric",
|
|
|
|
route_match_metric,
|
|
|
|
route_match_metric_compile,
|
|
|
|
route_match_metric_free
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* `match as-path ASPATH' */
|
|
|
|
|
|
|
|
/* Match function for as-path match. I assume given object is */
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2002-12-13 21:15:29 +01:00
|
|
|
route_match_aspath (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
|
|
|
|
struct as_list *as_list;
|
|
|
|
struct bgp_info *bgp_info;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
as_list = as_list_lookup ((char *) rule);
|
|
|
|
if (as_list == NULL)
|
|
|
|
return RMAP_NOMATCH;
|
2015-05-20 02:40:45 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
bgp_info = object;
|
2015-05-20 02:40:45 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Perform match. */
|
|
|
|
return ((as_list_apply (as_list, bgp_info->attr->aspath) == AS_FILTER_DENY) ? RMAP_NOMATCH : RMAP_MATCH);
|
|
|
|
}
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compile function for as-path match. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2004-10-13 07:06:08 +02:00
|
|
|
route_match_aspath_compile (const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compile function for as-path match. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
route_match_aspath_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map commands for aspath matching. */
|
|
|
|
struct route_map_rule_cmd route_match_aspath_cmd =
|
|
|
|
{
|
|
|
|
"as-path",
|
|
|
|
route_match_aspath,
|
|
|
|
route_match_aspath_compile,
|
|
|
|
route_match_aspath_free
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* `match community COMMUNIY' */
|
|
|
|
struct rmap_community
|
|
|
|
{
|
|
|
|
char *name;
|
|
|
|
int exact;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Match function for community match. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2002-12-13 21:15:29 +01:00
|
|
|
route_match_community (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
struct community_list *list;
|
|
|
|
struct bgp_info *bgp_info;
|
|
|
|
struct rmap_community *rcom;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
bgp_info = object;
|
|
|
|
rcom = rule;
|
|
|
|
|
2005-02-02 17:29:31 +01:00
|
|
|
list = community_list_lookup (bgp_clist, rcom->name, COMMUNITY_LIST_MASTER);
|
2002-12-13 21:15:29 +01:00
|
|
|
if (! list)
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
|
|
|
|
if (rcom->exact)
|
|
|
|
{
|
|
|
|
if (community_list_exact_match (bgp_info->attr->community, list))
|
|
|
|
return RMAP_MATCH;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (community_list_match (bgp_info->attr->community, list))
|
|
|
|
return RMAP_MATCH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compile function for community match. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2004-10-13 07:06:08 +02:00
|
|
|
route_match_community_compile (const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct rmap_community *rcom;
|
|
|
|
int len;
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
rcom = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct rmap_community));
|
|
|
|
|
|
|
|
p = strchr (arg, ' ');
|
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
len = p - arg;
|
|
|
|
rcom->name = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, len + 1);
|
|
|
|
memcpy (rcom->name, arg, len);
|
|
|
|
rcom->exact = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rcom->name = XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
|
|
|
|
rcom->exact = 0;
|
|
|
|
}
|
|
|
|
return rcom;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compile function for community match. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
route_match_community_free (void *rule)
|
|
|
|
{
|
|
|
|
struct rmap_community *rcom = rule;
|
|
|
|
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rcom->name);
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rcom);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map commands for community matching. */
|
|
|
|
struct route_map_rule_cmd route_match_community_cmd =
|
|
|
|
{
|
|
|
|
"community",
|
|
|
|
route_match_community,
|
|
|
|
route_match_community_compile,
|
|
|
|
route_match_community_free
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2003-04-19 17:49:49 +02:00
|
|
|
/* Match function for extcommunity match. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2003-04-19 17:49:49 +02:00
|
|
|
route_match_ecommunity (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
struct community_list *list;
|
|
|
|
struct bgp_info *bgp_info;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
bgp_info = object;
|
2007-05-04 22:15:47 +02:00
|
|
|
|
|
|
|
if (!bgp_info->attr->extra)
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
|
2003-04-19 17:49:49 +02:00
|
|
|
list = community_list_lookup (bgp_clist, (char *) rule,
|
2005-02-02 17:29:31 +01:00
|
|
|
EXTCOMMUNITY_LIST_MASTER);
|
2003-04-19 17:49:49 +02:00
|
|
|
if (! list)
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
|
2007-05-04 22:15:47 +02:00
|
|
|
if (ecommunity_list_match (bgp_info->attr->extra->ecommunity, list))
|
2003-04-19 17:49:49 +02:00
|
|
|
return RMAP_MATCH;
|
|
|
|
}
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compile function for extcommunity match. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2004-10-13 07:06:08 +02:00
|
|
|
route_match_ecommunity_compile (const char *arg)
|
2003-04-19 17:49:49 +02:00
|
|
|
{
|
|
|
|
return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compile function for extcommunity match. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2003-04-19 17:49:49 +02:00
|
|
|
route_match_ecommunity_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map commands for community matching. */
|
|
|
|
struct route_map_rule_cmd route_match_ecommunity_cmd =
|
|
|
|
{
|
|
|
|
"extcommunity",
|
|
|
|
route_match_ecommunity,
|
|
|
|
route_match_ecommunity_compile,
|
|
|
|
route_match_ecommunity_free
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* `match nlri` and `set nlri` are replaced by `address-family ipv4`
|
|
|
|
and `address-family vpnv4'. */
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* `match origin' */
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2002-12-13 21:15:29 +01:00
|
|
|
route_match_origin (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
u_char *origin;
|
|
|
|
struct bgp_info *bgp_info;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
origin = rule;
|
|
|
|
bgp_info = object;
|
|
|
|
|
|
|
|
if (bgp_info->attr->origin == *origin)
|
|
|
|
return RMAP_MATCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2004-10-13 07:06:08 +02:00
|
|
|
route_match_origin_compile (const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
u_char *origin;
|
|
|
|
|
|
|
|
origin = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_char));
|
|
|
|
|
|
|
|
if (strcmp (arg, "igp") == 0)
|
|
|
|
*origin = 0;
|
|
|
|
else if (strcmp (arg, "egp") == 0)
|
|
|
|
*origin = 1;
|
|
|
|
else
|
|
|
|
*origin = 2;
|
|
|
|
|
|
|
|
return origin;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free route map's compiled `ip address' value. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
route_match_origin_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map commands for origin matching. */
|
|
|
|
struct route_map_rule_cmd route_match_origin_cmd =
|
|
|
|
{
|
|
|
|
"origin",
|
|
|
|
route_match_origin,
|
|
|
|
route_match_origin_compile,
|
|
|
|
route_match_origin_free
|
|
|
|
};
|
2011-11-22 17:15:10 +01:00
|
|
|
|
|
|
|
/* match probability { */
|
|
|
|
|
|
|
|
static route_map_result_t
|
|
|
|
route_match_probability (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
long r;
|
|
|
|
#if _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE >= 500
|
|
|
|
r = random();
|
|
|
|
#else
|
|
|
|
r = (long) rand();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
switch (*(unsigned *) rule)
|
|
|
|
{
|
|
|
|
case 0: break;
|
|
|
|
case RAND_MAX: return RMAP_MATCH;
|
|
|
|
default:
|
|
|
|
if (r < *(unsigned *) rule)
|
|
|
|
{
|
|
|
|
return RMAP_MATCH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
|
|
|
route_match_probability_compile (const char *arg)
|
|
|
|
{
|
|
|
|
unsigned *lobule;
|
|
|
|
unsigned perc;
|
|
|
|
|
|
|
|
#if _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE >= 500
|
|
|
|
srandom (time (NULL));
|
|
|
|
#else
|
|
|
|
srand (time (NULL));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
perc = atoi (arg);
|
|
|
|
lobule = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (unsigned));
|
|
|
|
|
|
|
|
switch (perc)
|
|
|
|
{
|
|
|
|
case 0: *lobule = 0; break;
|
|
|
|
case 100: *lobule = RAND_MAX; break;
|
|
|
|
default: *lobule = RAND_MAX / 100 * perc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return lobule;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
route_match_probability_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct route_map_rule_cmd route_match_probability_cmd =
|
|
|
|
{
|
|
|
|
"probability",
|
|
|
|
route_match_probability,
|
|
|
|
route_match_probability_compile,
|
|
|
|
route_match_probability_free
|
|
|
|
};
|
|
|
|
|
2015-05-20 02:40:47 +02:00
|
|
|
/* `match interface IFNAME' */
|
|
|
|
/* Match function should return 1 if match is success else return
|
|
|
|
zero. */
|
|
|
|
static route_map_result_t
|
|
|
|
route_match_interface (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
struct interface *ifp;
|
|
|
|
struct nexthop *nexthop;
|
|
|
|
struct bgp_info *info;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
info = object;
|
|
|
|
|
|
|
|
if (!info || !info->attr)
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
|
|
|
|
ifp = if_lookup_by_name ((char *)rule);
|
|
|
|
|
|
|
|
if (ifp == NULL || ifp->ifindex != info->attr->nh_ifindex)
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
|
|
|
|
return RMAP_MATCH;
|
|
|
|
}
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map `interface' match statement. `arg' should be
|
|
|
|
interface name. */
|
|
|
|
static void *
|
|
|
|
route_match_interface_compile (const char *arg)
|
|
|
|
{
|
|
|
|
return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free route map's compiled `interface' value. */
|
|
|
|
static void
|
|
|
|
route_match_interface_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map commands for ip address matching. */
|
|
|
|
struct route_map_rule_cmd route_match_interface_cmd =
|
|
|
|
{
|
|
|
|
"interface",
|
|
|
|
route_match_interface,
|
|
|
|
route_match_interface_compile,
|
|
|
|
route_match_interface_free
|
|
|
|
};
|
|
|
|
|
2011-11-22 17:15:10 +01:00
|
|
|
/* } */
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* `set ip next-hop IP_ADDRESS' */
|
|
|
|
|
2015-05-20 02:46:33 +02:00
|
|
|
/* Match function return 1 if match is success else return zero. */
|
|
|
|
static route_map_result_t
|
|
|
|
route_match_tag (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
u_short *tag;
|
|
|
|
struct bgp_info *bgp_info;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
tag = rule;
|
|
|
|
bgp_info = object;
|
|
|
|
|
|
|
|
if (!bgp_info->attr->extra)
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
|
|
|
|
return ((bgp_info->attr->extra->tag == *tag)? RMAP_MATCH : RMAP_NOMATCH);
|
|
|
|
}
|
|
|
|
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Route map `match tag' match statement. `arg' is TAG value */
|
|
|
|
static void *
|
|
|
|
route_match_tag_compile (const char *arg)
|
|
|
|
{
|
|
|
|
u_short *tag;
|
|
|
|
u_short tmp;
|
|
|
|
|
|
|
|
/* tag value shoud be integer. */
|
|
|
|
if (! all_digit (arg))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
tmp = atoi(arg);
|
|
|
|
if (tmp < 1)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
tag = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_short));
|
|
|
|
|
|
|
|
if (!tag)
|
|
|
|
return tag;
|
|
|
|
|
|
|
|
*tag = tmp;
|
|
|
|
|
|
|
|
return tag;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Free route map's compiled 'match tag' value. */
|
|
|
|
static void
|
|
|
|
route_match_tag_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map commands for tag matching. */
|
|
|
|
struct route_map_rule_cmd route_match_tag_cmd =
|
|
|
|
{
|
|
|
|
"tag",
|
|
|
|
route_match_tag,
|
|
|
|
route_match_tag_compile,
|
|
|
|
route_match_tag_free,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Set nexthop to object. ojbect must be pointer to struct attr. */
|
2003-08-12 07:32:27 +02:00
|
|
|
struct rmap_ip_nexthop_set
|
|
|
|
{
|
|
|
|
struct in_addr *address;
|
|
|
|
int peer_address;
|
|
|
|
};
|
|
|
|
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_ip_nexthop (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
2003-08-12 07:32:27 +02:00
|
|
|
struct rmap_ip_nexthop_set *rins = rule;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct bgp_info *bgp_info;
|
2003-08-12 07:32:27 +02:00
|
|
|
struct peer *peer;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
bgp_info = object;
|
2003-08-12 07:32:27 +02:00
|
|
|
peer = bgp_info->peer;
|
|
|
|
|
|
|
|
if (rins->peer_address)
|
|
|
|
{
|
2004-09-13 Jose Luis Rubio <jrubio@dit.upm.es>
(at Technical University of Madrid as part of Euro6ix Project)
Enhanced Route Server functionality and Route-Maps:
* bgpd/bgpd.h: Modified 'struct peer' and 'struct bgp_filter' to
support rs-clients. A 'struct bgp_table *rib' has been added to the
first (to mantain a separated RIB for each rs-client) and two new
route-maps have been added to the last (for import/export policies).
Added the following #defines: RMAP_{IN|OUT|IMPORT|EXPORT|MAX},
PEER_RMAP_TYPE_{IMPORT|EXPORT} and BGP_CLEAR_SOFT_RSCLIENT.
* bgpd/bgpd.c: Modified the functions that create/delete/etc peers in
order to consider the new fields included in 'struct peer' for
supporting rs-clients, i.e. the import/export route-maps and the
'struct bgp_table'.
* bgpd/bgp_route.{ch}: Modified several functions related with
receiving/sending announces in order to support the new Route Server
capabilities.
Function 'bgp_process' has been reorganized, creating an auxiliar
function for best path selection ('bgp_best_selection').
Modified 'bgp_show' and 'bgp_show_route' for displaying information
about any RIB (and not only the main bgp RIB).
Added commands for displaying information about RS-clients RIBs:
'show bgp rsclient (A.B.C.D|X:X::X:X)', 'show bgp rsclient
(A.B.C.D|X:X::X:X) X:X::X:X/M', etc
* bgpd/bgp_table.{ch}: The structure 'struct bgp_table' now has two
new fields: type (which can take the values BGP_TABLE_{MAIN|RSCLIENT})
and 'void *owner' which points to 'struct bgp' or 'struct peer' which
owns the table.
When creating a new bgp_table by default 'type=BGP_TABLE_MAIN' is set.
* bgpd/bgp_vty.c: The commands 'neighbor ... route-server-client' and
'no neighbor ... route-server-client' now not only set/unset the flag
PEER_FLAG_RSERVER_CLIENT, but they create/destroy the 'struct
bgp_table' of the peer. Special actions are taken for peer_groups.
Command 'neighbor ... route-map WORD (in|out)' now also supports two
new kinds of route-map: 'import' and 'export'.
Added commands 'clear bgp * rsclient', etc. These commands allow a new
kind of soft_reconfig which affects only the RIB of the specified
RS-client.
Added commands 'show bgp rsclient summary', etc which display a
summary of the rs-clients configured for the corresponding address
family.
* bgpd/bgp_routemap.c: A new match statement is available,
'match peer (A.B.C.D|X:X::X:X)'. This statement can only be used in
import/export route-maps, and it matches when the peer who announces
(when used in an import route-map) or is going to receive (when used
in an export route-map) the route is the same than the one specified
in the statement.
For peer-groups the statement matches if the specified peer is member
of the peer-group.
A special version of the command, 'match peer local', matches with
routes originated by the Route Server (defined with 'network ...',
redistributed routes and default-originate).
* lib/routemap.{ch}: Added a new clause 'call NAME' for use in
route-maps. It jumps into the specified route-map and when it returns
the first route-map ends if the called RM returns DENY_MATCH, or
continues in other case.
2004-09-13 07:12:46 +02:00
|
|
|
if ((CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN) ||
|
|
|
|
CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT))
|
2003-08-12 07:32:27 +02:00
|
|
|
&& peer->su_remote
|
|
|
|
&& sockunion_family (peer->su_remote) == AF_INET)
|
|
|
|
{
|
2012-04-10 16:57:22 +02:00
|
|
|
bgp_info->attr->nexthop.s_addr = sockunion2ip (peer->su_remote);
|
2003-08-12 07:32:27 +02:00
|
|
|
bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP);
|
|
|
|
}
|
|
|
|
else if (CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT)
|
|
|
|
&& peer->su_local
|
|
|
|
&& sockunion_family (peer->su_local) == AF_INET)
|
|
|
|
{
|
2012-04-10 16:57:22 +02:00
|
|
|
bgp_info->attr->nexthop.s_addr = sockunion2ip (peer->su_local);
|
2003-08-12 07:32:27 +02:00
|
|
|
bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Set next hop value. */
|
|
|
|
bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP);
|
|
|
|
bgp_info->attr->nexthop = *rins->address;
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return RMAP_OKAY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map `ip nexthop' compile function. Given string is converted
|
|
|
|
to struct in_addr structure. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2004-10-13 07:06:08 +02:00
|
|
|
route_set_ip_nexthop_compile (const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2003-08-12 07:32:27 +02:00
|
|
|
struct rmap_ip_nexthop_set *rins;
|
|
|
|
struct in_addr *address = NULL;
|
|
|
|
int peer_address = 0;
|
2002-12-13 21:15:29 +01:00
|
|
|
int ret;
|
|
|
|
|
2003-08-12 07:32:27 +02:00
|
|
|
if (strcmp (arg, "peer-address") == 0)
|
|
|
|
peer_address = 1;
|
|
|
|
else
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2003-08-12 07:32:27 +02:00
|
|
|
address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct in_addr));
|
|
|
|
ret = inet_aton (arg, address);
|
|
|
|
|
|
|
|
if (ret == 0)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, address);
|
|
|
|
return NULL;
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2008-08-18 23:13:29 +02:00
|
|
|
rins = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct rmap_ip_nexthop_set));
|
2003-08-12 07:32:27 +02:00
|
|
|
|
|
|
|
rins->address = address;
|
|
|
|
rins->peer_address = peer_address;
|
|
|
|
|
|
|
|
return rins;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Free route map's compiled `ip nexthop' value. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_ip_nexthop_free (void *rule)
|
|
|
|
{
|
2003-08-12 07:32:27 +02:00
|
|
|
struct rmap_ip_nexthop_set *rins = rule;
|
|
|
|
|
|
|
|
if (rins->address)
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rins->address);
|
|
|
|
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rins);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map commands for ip nexthop set. */
|
|
|
|
struct route_map_rule_cmd route_set_ip_nexthop_cmd =
|
|
|
|
{
|
|
|
|
"ip next-hop",
|
|
|
|
route_set_ip_nexthop,
|
|
|
|
route_set_ip_nexthop_compile,
|
|
|
|
route_set_ip_nexthop_free
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* `set local-preference LOCAL_PREF' */
|
|
|
|
|
|
|
|
/* Set local preference. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_local_pref (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
u_int32_t *local_pref;
|
|
|
|
struct bgp_info *bgp_info;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
/* Fetch routemap's rule information. */
|
|
|
|
local_pref = rule;
|
|
|
|
bgp_info = object;
|
|
|
|
|
|
|
|
/* Set local preference value. */
|
|
|
|
bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF);
|
|
|
|
bgp_info->attr->local_pref = *local_pref;
|
|
|
|
}
|
|
|
|
|
|
|
|
return RMAP_OKAY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set local preference compilation. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2004-10-13 07:06:08 +02:00
|
|
|
route_set_local_pref_compile (const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-10-13 07:06:08 +02:00
|
|
|
unsigned long tmp;
|
2002-12-13 21:15:29 +01:00
|
|
|
u_int32_t *local_pref;
|
|
|
|
char *endptr = NULL;
|
|
|
|
|
|
|
|
/* Local preference value shoud be integer. */
|
|
|
|
if (! all_digit (arg))
|
|
|
|
return NULL;
|
2004-10-13 07:06:08 +02:00
|
|
|
|
2011-12-20 23:24:11 +01:00
|
|
|
errno = 0;
|
2004-10-13 07:06:08 +02:00
|
|
|
tmp = strtoul (arg, &endptr, 10);
|
2011-12-20 23:24:11 +01:00
|
|
|
if (*endptr != '\0' || errno || tmp > UINT32_MAX)
|
2004-10-13 07:06:08 +02:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
local_pref = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_int32_t));
|
|
|
|
|
|
|
|
if (!local_pref)
|
|
|
|
return local_pref;
|
|
|
|
|
|
|
|
*local_pref = tmp;
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
return local_pref;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free route map's local preference value. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_local_pref_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set local preference rule structure. */
|
|
|
|
struct route_map_rule_cmd route_set_local_pref_cmd =
|
|
|
|
{
|
|
|
|
"local-preference",
|
|
|
|
route_set_local_pref,
|
|
|
|
route_set_local_pref_compile,
|
|
|
|
route_set_local_pref_free,
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* `set weight WEIGHT' */
|
|
|
|
|
|
|
|
/* Set weight. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_weight (void *rule, struct prefix *prefix, route_map_object_t type,
|
|
|
|
void *object)
|
|
|
|
{
|
|
|
|
u_int32_t *weight;
|
|
|
|
struct bgp_info *bgp_info;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
/* Fetch routemap's rule information. */
|
|
|
|
weight = rule;
|
|
|
|
bgp_info = object;
|
|
|
|
|
|
|
|
/* Set weight value. */
|
2007-05-04 22:15:47 +02:00
|
|
|
if (*weight)
|
|
|
|
(bgp_attr_extra_get (bgp_info->attr))->weight = *weight;
|
|
|
|
else if (bgp_info->attr->extra)
|
|
|
|
bgp_info->attr->extra->weight = 0;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return RMAP_OKAY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set local preference compilation. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2004-10-13 07:06:08 +02:00
|
|
|
route_set_weight_compile (const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-10-13 07:06:08 +02:00
|
|
|
unsigned long tmp;
|
2002-12-13 21:15:29 +01:00
|
|
|
u_int32_t *weight;
|
|
|
|
char *endptr = NULL;
|
|
|
|
|
|
|
|
/* Local preference value shoud be integer. */
|
|
|
|
if (! all_digit (arg))
|
|
|
|
return NULL;
|
|
|
|
|
2011-12-20 23:24:11 +01:00
|
|
|
errno = 0;
|
2004-10-13 07:06:08 +02:00
|
|
|
tmp = strtoul (arg, &endptr, 10);
|
2011-12-20 23:24:11 +01:00
|
|
|
if (*endptr != '\0' || errno || tmp > UINT32_MAX)
|
2004-10-13 07:06:08 +02:00
|
|
|
return NULL;
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
weight = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_int32_t));
|
2004-10-13 07:06:08 +02:00
|
|
|
|
|
|
|
if (weight == NULL)
|
|
|
|
return weight;
|
|
|
|
|
|
|
|
*weight = tmp;
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
return weight;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free route map's local preference value. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_weight_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set local preference rule structure. */
|
|
|
|
struct route_map_rule_cmd route_set_weight_cmd =
|
|
|
|
{
|
|
|
|
"weight",
|
|
|
|
route_set_weight,
|
|
|
|
route_set_weight_compile,
|
|
|
|
route_set_weight_free,
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* `set metric METRIC' */
|
|
|
|
|
|
|
|
/* Set metric to attribute. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_metric (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
char *metric;
|
|
|
|
u_int32_t metric_val;
|
|
|
|
struct bgp_info *bgp_info;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
/* Fetch routemap's rule information. */
|
|
|
|
metric = rule;
|
|
|
|
bgp_info = object;
|
|
|
|
|
|
|
|
if (! (bgp_info->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)))
|
|
|
|
bgp_info->attr->med = 0;
|
|
|
|
bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
|
|
|
|
|
|
|
|
if (all_digit (metric))
|
|
|
|
{
|
|
|
|
metric_val = strtoul (metric, (char **)NULL, 10);
|
|
|
|
bgp_info->attr->med = metric_val;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
metric_val = strtoul (metric+1, (char **)NULL, 10);
|
|
|
|
|
|
|
|
if (strncmp (metric, "+", 1) == 0)
|
|
|
|
{
|
2003-10-13 11:47:32 +02:00
|
|
|
if (bgp_info->attr->med/2 + metric_val/2 > BGP_MED_MAX/2)
|
|
|
|
bgp_info->attr->med = BGP_MED_MAX - 1;
|
2002-12-13 21:15:29 +01:00
|
|
|
else
|
2003-08-27 08:45:32 +02:00
|
|
|
bgp_info->attr->med += metric_val;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
else if (strncmp (metric, "-", 1) == 0)
|
|
|
|
{
|
2003-08-27 08:45:32 +02:00
|
|
|
if (bgp_info->attr->med <= metric_val)
|
|
|
|
bgp_info->attr->med = 0;
|
2002-12-13 21:15:29 +01:00
|
|
|
else
|
2003-08-27 08:45:32 +02:00
|
|
|
bgp_info->attr->med -= metric_val;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return RMAP_OKAY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set metric compilation. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2004-10-13 07:06:08 +02:00
|
|
|
route_set_metric_compile (const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
u_int32_t metric;
|
2005-06-28 14:44:16 +02:00
|
|
|
unsigned long larg;
|
2002-12-13 21:15:29 +01:00
|
|
|
char *endptr = NULL;
|
|
|
|
|
|
|
|
if (all_digit (arg))
|
|
|
|
{
|
|
|
|
/* set metric value check*/
|
2011-12-20 23:24:11 +01:00
|
|
|
errno = 0;
|
2005-06-28 14:44:16 +02:00
|
|
|
larg = strtoul (arg, &endptr, 10);
|
2011-12-20 23:24:11 +01:00
|
|
|
if (*endptr != '\0' || errno || larg > UINT32_MAX)
|
2002-12-13 21:15:29 +01:00
|
|
|
return NULL;
|
2005-06-28 14:44:16 +02:00
|
|
|
metric = larg;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-05-20 02:47:22 +02:00
|
|
|
/* set metric <+/-metric> check */
|
2002-12-13 21:15:29 +01:00
|
|
|
if ((strncmp (arg, "+", 1) != 0
|
|
|
|
&& strncmp (arg, "-", 1) != 0)
|
|
|
|
|| (! all_digit (arg+1)))
|
|
|
|
return NULL;
|
|
|
|
|
2011-12-20 23:24:11 +01:00
|
|
|
errno = 0;
|
2005-06-28 14:44:16 +02:00
|
|
|
larg = strtoul (arg+1, &endptr, 10);
|
2011-12-20 23:24:11 +01:00
|
|
|
if (*endptr != '\0' || errno || larg > UINT32_MAX)
|
2002-12-13 21:15:29 +01:00
|
|
|
return NULL;
|
2005-06-28 14:44:16 +02:00
|
|
|
metric = larg;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free route map's compiled `set metric' value. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_metric_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set metric rule structure. */
|
|
|
|
struct route_map_rule_cmd route_set_metric_cmd =
|
|
|
|
{
|
|
|
|
"metric",
|
|
|
|
route_set_metric,
|
|
|
|
route_set_metric_compile,
|
|
|
|
route_set_metric_free,
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* `set as-path prepend ASPATH' */
|
|
|
|
|
|
|
|
/* For AS path prepend mechanism. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_aspath_prepend (void *rule, struct prefix *prefix, route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
struct aspath *aspath;
|
|
|
|
struct aspath *new;
|
|
|
|
struct bgp_info *binfo;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
aspath = rule;
|
|
|
|
binfo = object;
|
|
|
|
|
|
|
|
if (binfo->attr->aspath->refcnt)
|
|
|
|
new = aspath_dup (binfo->attr->aspath);
|
|
|
|
else
|
|
|
|
new = binfo->attr->aspath;
|
|
|
|
|
|
|
|
aspath_prepend (aspath, new);
|
|
|
|
binfo->attr->aspath = new;
|
|
|
|
}
|
|
|
|
|
|
|
|
return RMAP_OKAY;
|
|
|
|
}
|
|
|
|
|
2014-05-20 07:57:26 +02:00
|
|
|
/* Set as-path prepend rule structure. */
|
2002-12-13 21:15:29 +01:00
|
|
|
struct route_map_rule_cmd route_set_aspath_prepend_cmd =
|
|
|
|
{
|
|
|
|
"as-path prepend",
|
|
|
|
route_set_aspath_prepend,
|
2014-05-20 08:04:49 +02:00
|
|
|
route_aspath_compile,
|
|
|
|
route_aspath_free,
|
2002-12-13 21:15:29 +01:00
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2008-04-10 13:47:45 +02:00
|
|
|
/* `set as-path exclude ASn' */
|
|
|
|
|
|
|
|
/* For ASN exclude mechanism.
|
|
|
|
* Iterate over ASns requested and filter them from the given AS_PATH one by one.
|
|
|
|
* Make a deep copy of existing AS_PATH, but for the first ASn only.
|
|
|
|
*/
|
|
|
|
static route_map_result_t
|
|
|
|
route_set_aspath_exclude (void *rule, struct prefix *dummy, route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
struct aspath * new_path, * exclude_path;
|
|
|
|
struct bgp_info *binfo;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
exclude_path = rule;
|
|
|
|
binfo = object;
|
|
|
|
if (binfo->attr->aspath->refcnt)
|
|
|
|
new_path = aspath_dup (binfo->attr->aspath);
|
|
|
|
else
|
|
|
|
new_path = binfo->attr->aspath;
|
|
|
|
binfo->attr->aspath = aspath_filter_exclude (new_path, exclude_path);
|
|
|
|
}
|
|
|
|
return RMAP_OKAY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set ASn exlude rule structure. */
|
|
|
|
struct route_map_rule_cmd route_set_aspath_exclude_cmd =
|
|
|
|
{
|
|
|
|
"as-path exclude",
|
|
|
|
route_set_aspath_exclude,
|
2014-05-20 08:04:49 +02:00
|
|
|
route_aspath_compile,
|
|
|
|
route_aspath_free,
|
2008-04-10 13:47:45 +02:00
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* `set community COMMUNITY' */
|
|
|
|
struct rmap_com_set
|
|
|
|
{
|
|
|
|
struct community *com;
|
|
|
|
int additive;
|
|
|
|
int none;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* For community set mechanism. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_community (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
struct rmap_com_set *rcs;
|
|
|
|
struct bgp_info *binfo;
|
|
|
|
struct attr *attr;
|
|
|
|
struct community *new = NULL;
|
|
|
|
struct community *old;
|
|
|
|
struct community *merge;
|
2006-02-18 11:49:04 +01:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
rcs = rule;
|
|
|
|
binfo = object;
|
|
|
|
attr = binfo->attr;
|
|
|
|
old = attr->community;
|
|
|
|
|
|
|
|
/* "none" case. */
|
|
|
|
if (rcs->none)
|
|
|
|
{
|
|
|
|
attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES));
|
|
|
|
attr->community = NULL;
|
2012-12-07 15:26:09 +01:00
|
|
|
/* See the longer comment down below. */
|
|
|
|
if (old && old->refcnt == 0)
|
|
|
|
community_free(old);
|
2002-12-13 21:15:29 +01:00
|
|
|
return RMAP_OKAY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* "additive" case. */
|
|
|
|
if (rcs->additive && old)
|
|
|
|
{
|
|
|
|
merge = community_merge (community_dup (old), rcs->com);
|
2006-02-18 11:49:04 +01:00
|
|
|
|
|
|
|
/* HACK: if the old community is not intern'd,
|
|
|
|
* we should free it here, or all reference to it may be lost.
|
|
|
|
* Really need to cleanup attribute caching sometime.
|
|
|
|
*/
|
|
|
|
if (old->refcnt == 0)
|
|
|
|
community_free (old);
|
2002-12-13 21:15:29 +01:00
|
|
|
new = community_uniq_sort (merge);
|
|
|
|
community_free (merge);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
new = community_dup (rcs->com);
|
2006-02-18 11:49:04 +01:00
|
|
|
|
|
|
|
/* will be interned by caller if required */
|
2011-04-01 16:58:27 +02:00
|
|
|
attr->community = new;
|
2005-05-27 05:26:57 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES);
|
|
|
|
}
|
|
|
|
|
|
|
|
return RMAP_OKAY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compile function for set community. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2004-10-13 07:06:08 +02:00
|
|
|
route_set_community_compile (const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct rmap_com_set *rcs;
|
|
|
|
struct community *com = NULL;
|
|
|
|
char *sp;
|
|
|
|
int additive = 0;
|
|
|
|
int none = 0;
|
|
|
|
|
|
|
|
if (strcmp (arg, "none") == 0)
|
|
|
|
none = 1;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sp = strstr (arg, "additive");
|
|
|
|
|
|
|
|
if (sp && sp > arg)
|
|
|
|
{
|
|
|
|
/* "additive" keyworkd is included. */
|
|
|
|
additive = 1;
|
|
|
|
*(sp - 1) = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
com = community_str2com (arg);
|
|
|
|
|
|
|
|
if (additive)
|
|
|
|
*(sp - 1) = ' ';
|
|
|
|
|
|
|
|
if (! com)
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-08-18 23:13:29 +02:00
|
|
|
rcs = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct rmap_com_set));
|
2011-04-01 16:58:27 +02:00
|
|
|
rcs->com = com;
|
2002-12-13 21:15:29 +01:00
|
|
|
rcs->additive = additive;
|
|
|
|
rcs->none = none;
|
|
|
|
|
|
|
|
return rcs;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free function for set community. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_community_free (void *rule)
|
|
|
|
{
|
|
|
|
struct rmap_com_set *rcs = rule;
|
|
|
|
|
|
|
|
if (rcs->com)
|
|
|
|
community_free (rcs->com);
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rcs);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set community rule structure. */
|
|
|
|
struct route_map_rule_cmd route_set_community_cmd =
|
|
|
|
{
|
|
|
|
"community",
|
|
|
|
route_set_community,
|
|
|
|
route_set_community_compile,
|
|
|
|
route_set_community_free,
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2005-02-02 17:29:31 +01:00
|
|
|
/* `set comm-list (<1-99>|<100-500>|WORD) delete' */
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
/* For community set mechanism. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_community_delete (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
struct community_list *list;
|
|
|
|
struct community *merge;
|
|
|
|
struct community *new;
|
|
|
|
struct community *old;
|
|
|
|
struct bgp_info *binfo;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
if (! rule)
|
|
|
|
return RMAP_OKAY;
|
|
|
|
|
|
|
|
binfo = object;
|
2005-02-02 17:29:31 +01:00
|
|
|
list = community_list_lookup (bgp_clist, rule, COMMUNITY_LIST_MASTER);
|
2002-12-13 21:15:29 +01:00
|
|
|
old = binfo->attr->community;
|
|
|
|
|
|
|
|
if (list && old)
|
|
|
|
{
|
|
|
|
merge = community_list_match_delete (community_dup (old), list);
|
|
|
|
new = community_uniq_sort (merge);
|
|
|
|
community_free (merge);
|
|
|
|
|
2010-09-13 17:48:11 +02:00
|
|
|
/* HACK: if the old community is not intern'd,
|
|
|
|
* we should free it here, or all reference to it may be lost.
|
|
|
|
* Really need to cleanup attribute caching sometime.
|
|
|
|
*/
|
|
|
|
if (old->refcnt == 0)
|
|
|
|
community_free (old);
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (new->size == 0)
|
|
|
|
{
|
|
|
|
binfo->attr->community = NULL;
|
|
|
|
binfo->attr->flag &= ~ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES);
|
|
|
|
community_free (new);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-04-01 16:58:27 +02:00
|
|
|
binfo->attr->community = new;
|
2002-12-13 21:15:29 +01:00
|
|
|
binfo->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return RMAP_OKAY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compile function for set community. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2004-10-13 07:06:08 +02:00
|
|
|
route_set_community_delete_compile (const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
char *p;
|
|
|
|
char *str;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
p = strchr (arg, ' ');
|
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
len = p - arg;
|
|
|
|
str = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, len + 1);
|
|
|
|
memcpy (str, arg, len);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
str = NULL;
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free function for set community. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_community_delete_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set community rule structure. */
|
|
|
|
struct route_map_rule_cmd route_set_community_delete_cmd =
|
|
|
|
{
|
|
|
|
"comm-list",
|
|
|
|
route_set_community_delete,
|
|
|
|
route_set_community_delete_compile,
|
|
|
|
route_set_community_delete_free,
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* `set extcommunity rt COMMUNITY' */
|
|
|
|
|
2014-06-04 00:58:47 +02:00
|
|
|
/* For community set mechanism. Used by _rt and _soo. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2014-06-04 00:58:47 +02:00
|
|
|
route_set_ecommunity (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct ecommunity *ecom;
|
|
|
|
struct ecommunity *new_ecom;
|
|
|
|
struct ecommunity *old_ecom;
|
|
|
|
struct bgp_info *bgp_info;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
ecom = rule;
|
|
|
|
bgp_info = object;
|
|
|
|
|
|
|
|
if (! ecom)
|
|
|
|
return RMAP_OKAY;
|
|
|
|
|
|
|
|
/* We assume additive for Extended Community. */
|
2007-05-04 22:15:47 +02:00
|
|
|
old_ecom = (bgp_attr_extra_get (bgp_info->attr))->ecommunity;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
if (old_ecom)
|
2014-06-04 00:59:01 +02:00
|
|
|
{
|
|
|
|
new_ecom = ecommunity_merge (ecommunity_dup (old_ecom), ecom);
|
|
|
|
|
|
|
|
/* old_ecom->refcnt = 1 => owned elsewhere, e.g. bgp_update_receive()
|
|
|
|
* ->refcnt = 0 => set by a previous route-map statement */
|
|
|
|
if (!old_ecom->refcnt)
|
|
|
|
ecommunity_free (&old_ecom);
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
else
|
|
|
|
new_ecom = ecommunity_dup (ecom);
|
|
|
|
|
2014-06-04 00:59:01 +02:00
|
|
|
/* will be intern()'d or attr_flush()'d by bgp_update_main() */
|
|
|
|
bgp_info->attr->extra->ecommunity = new_ecom;
|
2005-05-27 05:26:57 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES);
|
|
|
|
}
|
|
|
|
return RMAP_OKAY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compile function for set community. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2004-10-13 07:06:08 +02:00
|
|
|
route_set_ecommunity_rt_compile (const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct ecommunity *ecom;
|
|
|
|
|
|
|
|
ecom = ecommunity_str2com (arg, ECOMMUNITY_ROUTE_TARGET, 0);
|
|
|
|
if (! ecom)
|
|
|
|
return NULL;
|
bgpd: Try fix extcommunity resource allocation probs, particularly with 'set extcom..'
* Extended communities has some kind of resource allocation problem which
causes a double-free if the 'set extcommunity ...' command is used.
Try fix by properly interning extcommunities.
Also, more generally, make unintern functions take a double pointer
so they can NULL out callers references - a usefully defensive programming
pattern for functions which make refs invalid.
Sadly, this patch doesn't fix the problem entirely - crashes still
occur on session clear.
* bgp_ecommunity.h: (ecommunity_{free,unintern}) take double pointer
args.
* bgp_community.h: (community_unintern) ditto
* bgp_attr.h: (bgp_attr_intern) ditto
* bgp_aspath.h: (bgp_aspath.h) ditto
* (general) update all callers of above
* bgp_routemap.c: (route_set_ecommunity_{rt,soo}) intern the new extcom added
to the attr, and unintern any old one.
(route_set_ecommunity_{rt,soo}_compile) intern the extcom to be used
for the route-map set.
(route_set_ecommunity_*_free) unintern to match, instead of free
(route_set_ecommunity_soo) Do as _rt does and don't just leak
any pre-existing community, add to it (is additive right though?)
2010-11-23 22:28:03 +01:00
|
|
|
return ecommunity_intern (ecom);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2014-06-04 00:58:47 +02:00
|
|
|
/* Free function for set community. Used by _rt and _soo */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2014-06-04 00:58:47 +02:00
|
|
|
route_set_ecommunity_free (void *rule)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct ecommunity *ecom = rule;
|
bgpd: Try fix extcommunity resource allocation probs, particularly with 'set extcom..'
* Extended communities has some kind of resource allocation problem which
causes a double-free if the 'set extcommunity ...' command is used.
Try fix by properly interning extcommunities.
Also, more generally, make unintern functions take a double pointer
so they can NULL out callers references - a usefully defensive programming
pattern for functions which make refs invalid.
Sadly, this patch doesn't fix the problem entirely - crashes still
occur on session clear.
* bgp_ecommunity.h: (ecommunity_{free,unintern}) take double pointer
args.
* bgp_community.h: (community_unintern) ditto
* bgp_attr.h: (bgp_attr_intern) ditto
* bgp_aspath.h: (bgp_aspath.h) ditto
* (general) update all callers of above
* bgp_routemap.c: (route_set_ecommunity_{rt,soo}) intern the new extcom added
to the attr, and unintern any old one.
(route_set_ecommunity_{rt,soo}_compile) intern the extcom to be used
for the route-map set.
(route_set_ecommunity_*_free) unintern to match, instead of free
(route_set_ecommunity_soo) Do as _rt does and don't just leak
any pre-existing community, add to it (is additive right though?)
2010-11-23 22:28:03 +01:00
|
|
|
ecommunity_unintern (&ecom);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set community rule structure. */
|
|
|
|
struct route_map_rule_cmd route_set_ecommunity_rt_cmd =
|
|
|
|
{
|
|
|
|
"extcommunity rt",
|
2014-06-04 00:58:47 +02:00
|
|
|
route_set_ecommunity,
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_ecommunity_rt_compile,
|
2014-06-04 00:58:47 +02:00
|
|
|
route_set_ecommunity_free,
|
2002-12-13 21:15:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/* `set extcommunity soo COMMUNITY' */
|
|
|
|
|
|
|
|
/* Compile function for set community. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2004-10-13 07:06:08 +02:00
|
|
|
route_set_ecommunity_soo_compile (const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct ecommunity *ecom;
|
|
|
|
|
|
|
|
ecom = ecommunity_str2com (arg, ECOMMUNITY_SITE_ORIGIN, 0);
|
|
|
|
if (! ecom)
|
|
|
|
return NULL;
|
|
|
|
|
bgpd: Try fix extcommunity resource allocation probs, particularly with 'set extcom..'
* Extended communities has some kind of resource allocation problem which
causes a double-free if the 'set extcommunity ...' command is used.
Try fix by properly interning extcommunities.
Also, more generally, make unintern functions take a double pointer
so they can NULL out callers references - a usefully defensive programming
pattern for functions which make refs invalid.
Sadly, this patch doesn't fix the problem entirely - crashes still
occur on session clear.
* bgp_ecommunity.h: (ecommunity_{free,unintern}) take double pointer
args.
* bgp_community.h: (community_unintern) ditto
* bgp_attr.h: (bgp_attr_intern) ditto
* bgp_aspath.h: (bgp_aspath.h) ditto
* (general) update all callers of above
* bgp_routemap.c: (route_set_ecommunity_{rt,soo}) intern the new extcom added
to the attr, and unintern any old one.
(route_set_ecommunity_{rt,soo}_compile) intern the extcom to be used
for the route-map set.
(route_set_ecommunity_*_free) unintern to match, instead of free
(route_set_ecommunity_soo) Do as _rt does and don't just leak
any pre-existing community, add to it (is additive right though?)
2010-11-23 22:28:03 +01:00
|
|
|
return ecommunity_intern (ecom);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set community rule structure. */
|
|
|
|
struct route_map_rule_cmd route_set_ecommunity_soo_cmd =
|
|
|
|
{
|
|
|
|
"extcommunity soo",
|
2014-06-04 00:58:47 +02:00
|
|
|
route_set_ecommunity,
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_ecommunity_soo_compile,
|
2014-06-04 00:58:47 +02:00
|
|
|
route_set_ecommunity_free,
|
2002-12-13 21:15:29 +01:00
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* `set origin ORIGIN' */
|
|
|
|
|
|
|
|
/* For origin set. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_origin (void *rule, struct prefix *prefix, route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
u_char *origin;
|
|
|
|
struct bgp_info *bgp_info;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
origin = rule;
|
|
|
|
bgp_info = object;
|
|
|
|
|
|
|
|
bgp_info->attr->origin = *origin;
|
|
|
|
}
|
|
|
|
|
|
|
|
return RMAP_OKAY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compile function for origin set. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2004-10-13 07:06:08 +02:00
|
|
|
route_set_origin_compile (const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
u_char *origin;
|
|
|
|
|
|
|
|
origin = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_char));
|
|
|
|
|
|
|
|
if (strcmp (arg, "igp") == 0)
|
|
|
|
*origin = 0;
|
|
|
|
else if (strcmp (arg, "egp") == 0)
|
|
|
|
*origin = 1;
|
|
|
|
else
|
|
|
|
*origin = 2;
|
|
|
|
|
|
|
|
return origin;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compile function for origin set. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_origin_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
2014-05-20 07:57:26 +02:00
|
|
|
/* Set origin rule structure. */
|
2002-12-13 21:15:29 +01:00
|
|
|
struct route_map_rule_cmd route_set_origin_cmd =
|
|
|
|
{
|
|
|
|
"origin",
|
|
|
|
route_set_origin,
|
|
|
|
route_set_origin_compile,
|
|
|
|
route_set_origin_free,
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* `set atomic-aggregate' */
|
|
|
|
|
|
|
|
/* For atomic aggregate set. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_atomic_aggregate (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
struct bgp_info *bgp_info;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
bgp_info = object;
|
|
|
|
bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return RMAP_OKAY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compile function for atomic aggregate. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2004-10-13 07:06:08 +02:00
|
|
|
route_set_atomic_aggregate_compile (const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
return (void *)1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compile function for atomic aggregate. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_atomic_aggregate_free (void *rule)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set atomic aggregate rule structure. */
|
|
|
|
struct route_map_rule_cmd route_set_atomic_aggregate_cmd =
|
|
|
|
{
|
|
|
|
"atomic-aggregate",
|
|
|
|
route_set_atomic_aggregate,
|
|
|
|
route_set_atomic_aggregate_compile,
|
|
|
|
route_set_atomic_aggregate_free,
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* `set aggregator as AS A.B.C.D' */
|
|
|
|
struct aggregator
|
|
|
|
{
|
|
|
|
as_t as;
|
|
|
|
struct in_addr address;
|
|
|
|
};
|
|
|
|
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_aggregator_as (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
struct bgp_info *bgp_info;
|
|
|
|
struct aggregator *aggregator;
|
2007-05-04 22:15:47 +02:00
|
|
|
struct attr_extra *ae;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
bgp_info = object;
|
|
|
|
aggregator = rule;
|
2007-05-04 22:15:47 +02:00
|
|
|
ae = bgp_attr_extra_get (bgp_info->attr);
|
|
|
|
|
|
|
|
ae->aggregator_as = aggregator->as;
|
|
|
|
ae->aggregator_addr = aggregator->address;
|
2002-12-13 21:15:29 +01:00
|
|
|
bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR);
|
|
|
|
}
|
|
|
|
|
|
|
|
return RMAP_OKAY;
|
|
|
|
}
|
|
|
|
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2004-10-13 07:06:08 +02:00
|
|
|
route_set_aggregator_as_compile (const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct aggregator *aggregator;
|
|
|
|
char as[10];
|
|
|
|
char address[20];
|
|
|
|
|
2008-08-18 23:13:29 +02:00
|
|
|
aggregator = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct aggregator));
|
2002-12-13 21:15:29 +01:00
|
|
|
sscanf (arg, "%s %s", as, address);
|
|
|
|
|
|
|
|
aggregator->as = strtoul (as, NULL, 10);
|
|
|
|
inet_aton (address, &aggregator->address);
|
|
|
|
|
|
|
|
return aggregator;
|
|
|
|
}
|
|
|
|
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_aggregator_as_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct route_map_rule_cmd route_set_aggregator_as_cmd =
|
|
|
|
{
|
|
|
|
"aggregator as",
|
|
|
|
route_set_aggregator_as,
|
|
|
|
route_set_aggregator_as_compile,
|
|
|
|
route_set_aggregator_as_free,
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2015-05-20 02:46:33 +02:00
|
|
|
/* Set tag to object. object must be pointer to struct bgp_info */
|
|
|
|
static route_map_result_t
|
|
|
|
route_set_tag (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
u_short *tag;
|
|
|
|
struct bgp_info *bgp_info;
|
|
|
|
struct attr_extra *ae;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
tag = rule;
|
|
|
|
bgp_info = object;
|
|
|
|
ae = bgp_attr_extra_get (bgp_info->attr);
|
|
|
|
|
|
|
|
/* Set tag value */
|
|
|
|
ae->tag=*tag;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return RMAP_OKAY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map `tag' compile function. Given string is converted to u_short. */
|
|
|
|
static void *
|
|
|
|
route_set_tag_compile (const char *arg)
|
|
|
|
{
|
|
|
|
u_short *tag;
|
|
|
|
u_short tmp;
|
|
|
|
|
|
|
|
/* tag value shoud be integer. */
|
|
|
|
if (! all_digit (arg))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
tmp = atoi(arg);
|
|
|
|
|
|
|
|
if (tmp < 1)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
tag = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_short));
|
|
|
|
|
|
|
|
if (!tag)
|
|
|
|
return tag;
|
|
|
|
|
|
|
|
*tag = tmp;
|
|
|
|
|
|
|
|
return tag;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free route map's tag value. */
|
|
|
|
static void
|
|
|
|
route_set_tag_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Route map commands for tag set. */
|
|
|
|
struct route_map_rule_cmd route_set_tag_cmd =
|
|
|
|
{
|
|
|
|
"tag",
|
|
|
|
route_set_tag,
|
|
|
|
route_set_tag_compile,
|
|
|
|
route_set_tag_free,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
#ifdef HAVE_IPV6
|
|
|
|
/* `match ipv6 address IP_ACCESS_LIST' */
|
|
|
|
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2002-12-13 21:15:29 +01:00
|
|
|
route_match_ipv6_address (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
struct access_list *alist;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
alist = access_list_lookup (AFI_IP6, (char *) rule);
|
|
|
|
if (alist == NULL)
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
|
|
|
|
return (access_list_apply (alist, prefix) == FILTER_DENY ?
|
|
|
|
RMAP_NOMATCH : RMAP_MATCH);
|
|
|
|
}
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2004-10-13 07:06:08 +02:00
|
|
|
route_match_ipv6_address_compile (const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
|
|
|
|
}
|
|
|
|
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
route_match_ipv6_address_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map commands for ip address matching. */
|
|
|
|
struct route_map_rule_cmd route_match_ipv6_address_cmd =
|
|
|
|
{
|
|
|
|
"ipv6 address",
|
|
|
|
route_match_ipv6_address,
|
|
|
|
route_match_ipv6_address_compile,
|
|
|
|
route_match_ipv6_address_free
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* `match ipv6 next-hop IP_ADDRESS' */
|
|
|
|
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2002-12-13 21:15:29 +01:00
|
|
|
route_match_ipv6_next_hop (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
struct in6_addr *addr;
|
|
|
|
struct bgp_info *bgp_info;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
addr = rule;
|
|
|
|
bgp_info = object;
|
2007-05-04 22:15:47 +02:00
|
|
|
|
|
|
|
if (!bgp_info->attr->extra)
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
|
|
|
|
if (IPV6_ADDR_SAME (&bgp_info->attr->extra->mp_nexthop_global, rule))
|
2002-12-13 21:15:29 +01:00
|
|
|
return RMAP_MATCH;
|
|
|
|
|
2007-05-04 22:15:47 +02:00
|
|
|
if (bgp_info->attr->extra->mp_nexthop_len == 32 &&
|
|
|
|
IPV6_ADDR_SAME (&bgp_info->attr->extra->mp_nexthop_local, rule))
|
2002-12-13 21:15:29 +01:00
|
|
|
return RMAP_MATCH;
|
|
|
|
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2004-10-13 07:06:08 +02:00
|
|
|
route_match_ipv6_next_hop_compile (const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct in6_addr *address;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct in6_addr));
|
|
|
|
|
|
|
|
ret = inet_pton (AF_INET6, arg, address);
|
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, address);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return address;
|
|
|
|
}
|
|
|
|
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
route_match_ipv6_next_hop_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct route_map_rule_cmd route_match_ipv6_next_hop_cmd =
|
|
|
|
{
|
|
|
|
"ipv6 next-hop",
|
|
|
|
route_match_ipv6_next_hop,
|
|
|
|
route_match_ipv6_next_hop_compile,
|
|
|
|
route_match_ipv6_next_hop_free
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* `match ipv6 address prefix-list PREFIX_LIST' */
|
|
|
|
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2002-12-13 21:15:29 +01:00
|
|
|
route_match_ipv6_address_prefix_list (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
struct prefix_list *plist;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
plist = prefix_list_lookup (AFI_IP6, (char *) rule);
|
|
|
|
if (plist == NULL)
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
|
|
|
|
return (prefix_list_apply (plist, prefix) == PREFIX_DENY ?
|
|
|
|
RMAP_NOMATCH : RMAP_MATCH);
|
|
|
|
}
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2004-10-13 07:06:08 +02:00
|
|
|
route_match_ipv6_address_prefix_list_compile (const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
|
|
|
|
}
|
|
|
|
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
route_match_ipv6_address_prefix_list_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct route_map_rule_cmd route_match_ipv6_address_prefix_list_cmd =
|
|
|
|
{
|
|
|
|
"ipv6 address prefix-list",
|
|
|
|
route_match_ipv6_address_prefix_list,
|
|
|
|
route_match_ipv6_address_prefix_list_compile,
|
|
|
|
route_match_ipv6_address_prefix_list_free
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* `set ipv6 nexthop global IP_ADDRESS' */
|
|
|
|
|
|
|
|
/* Set nexthop to object. ojbect must be pointer to struct attr. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_ipv6_nexthop_global (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
struct in6_addr *address;
|
|
|
|
struct bgp_info *bgp_info;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
/* Fetch routemap's rule information. */
|
|
|
|
address = rule;
|
|
|
|
bgp_info = object;
|
|
|
|
|
|
|
|
/* Set next hop value. */
|
2007-05-04 22:15:47 +02:00
|
|
|
(bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_global = *address;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
/* Set nexthop length. */
|
2007-05-04 22:15:47 +02:00
|
|
|
if (bgp_info->attr->extra->mp_nexthop_len == 0)
|
|
|
|
bgp_info->attr->extra->mp_nexthop_len = 16;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return RMAP_OKAY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map `ip next-hop' compile function. Given string is converted
|
|
|
|
to struct in_addr structure. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2004-10-13 07:06:08 +02:00
|
|
|
route_set_ipv6_nexthop_global_compile (const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct in6_addr *address;
|
|
|
|
|
|
|
|
address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct in6_addr));
|
|
|
|
|
|
|
|
ret = inet_pton (AF_INET6, arg, address);
|
|
|
|
|
|
|
|
if (ret == 0)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, address);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return address;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free route map's compiled `ip next-hop' value. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_ipv6_nexthop_global_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map commands for ip nexthop set. */
|
|
|
|
struct route_map_rule_cmd route_set_ipv6_nexthop_global_cmd =
|
|
|
|
{
|
|
|
|
"ipv6 next-hop global",
|
|
|
|
route_set_ipv6_nexthop_global,
|
|
|
|
route_set_ipv6_nexthop_global_compile,
|
|
|
|
route_set_ipv6_nexthop_global_free
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* `set ipv6 nexthop local IP_ADDRESS' */
|
|
|
|
|
|
|
|
/* Set nexthop to object. ojbect must be pointer to struct attr. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_ipv6_nexthop_local (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
struct in6_addr *address;
|
|
|
|
struct bgp_info *bgp_info;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
/* Fetch routemap's rule information. */
|
|
|
|
address = rule;
|
|
|
|
bgp_info = object;
|
|
|
|
|
|
|
|
/* Set next hop value. */
|
2007-05-04 22:15:47 +02:00
|
|
|
(bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_local = *address;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
/* Set nexthop length. */
|
2007-05-04 22:15:47 +02:00
|
|
|
if (bgp_info->attr->extra->mp_nexthop_len != 32)
|
|
|
|
bgp_info->attr->extra->mp_nexthop_len = 32;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return RMAP_OKAY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map `ip nexthop' compile function. Given string is converted
|
|
|
|
to struct in_addr structure. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2004-10-13 07:06:08 +02:00
|
|
|
route_set_ipv6_nexthop_local_compile (const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct in6_addr *address;
|
|
|
|
|
|
|
|
address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct in6_addr));
|
|
|
|
|
|
|
|
ret = inet_pton (AF_INET6, arg, address);
|
|
|
|
|
|
|
|
if (ret == 0)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, address);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return address;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free route map's compiled `ip nexthop' value. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_ipv6_nexthop_local_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map commands for ip nexthop set. */
|
|
|
|
struct route_map_rule_cmd route_set_ipv6_nexthop_local_cmd =
|
|
|
|
{
|
|
|
|
"ipv6 next-hop local",
|
|
|
|
route_set_ipv6_nexthop_local,
|
|
|
|
route_set_ipv6_nexthop_local_compile,
|
|
|
|
route_set_ipv6_nexthop_local_free
|
|
|
|
};
|
2015-05-20 02:24:45 +02:00
|
|
|
|
|
|
|
/* `set ipv6 nexthop peer-address' */
|
|
|
|
|
|
|
|
/* Set nexthop to object. ojbect must be pointer to struct attr. */
|
|
|
|
static route_map_result_t
|
|
|
|
route_set_ipv6_nexthop_peer (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
int *use_peer_address;
|
|
|
|
struct in6_addr peer_address;
|
|
|
|
struct bgp_info *bgp_info;
|
|
|
|
struct peer *peer;
|
|
|
|
char peer_addr_buf[INET6_ADDRSTRLEN];
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
/* Fetch routemap's rule information. */
|
|
|
|
use_peer_address = rule;
|
|
|
|
bgp_info = object;
|
|
|
|
peer = bgp_info->peer;
|
|
|
|
|
|
|
|
if ((CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN) ||
|
|
|
|
CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT))
|
|
|
|
&& peer->su_remote
|
|
|
|
&& sockunion_family (peer->su_remote) == AF_INET6)
|
|
|
|
{
|
|
|
|
inet_pton (AF_INET6, sockunion2str (peer->su_remote,
|
|
|
|
peer_addr_buf,
|
|
|
|
INET6_ADDRSTRLEN),
|
|
|
|
&peer_address);
|
|
|
|
}
|
|
|
|
else if (CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT)
|
|
|
|
&& peer->su_local
|
|
|
|
&& sockunion_family (peer->su_local) == AF_INET6)
|
|
|
|
{
|
|
|
|
inet_pton (AF_INET, sockunion2str (peer->su_local,
|
|
|
|
peer_addr_buf,
|
|
|
|
INET6_ADDRSTRLEN),
|
|
|
|
&peer_address);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IN6_IS_ADDR_LINKLOCAL(&peer_address))
|
|
|
|
{
|
|
|
|
/* Set next hop value. */
|
|
|
|
(bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_local = peer_address;
|
|
|
|
|
|
|
|
/* Set nexthop length. */
|
|
|
|
if (bgp_info->attr->extra->mp_nexthop_len != 32)
|
|
|
|
bgp_info->attr->extra->mp_nexthop_len = 32;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Set next hop value. */
|
|
|
|
(bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_global = peer_address;
|
|
|
|
|
|
|
|
/* Set nexthop length. */
|
|
|
|
if (bgp_info->attr->extra->mp_nexthop_len == 0)
|
|
|
|
bgp_info->attr->extra->mp_nexthop_len = 16;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return RMAP_OKAY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map `ip next-hop' compile function. Given string is converted
|
|
|
|
to struct in_addr structure. */
|
|
|
|
static void *
|
|
|
|
route_set_ipv6_nexthop_peer_compile (const char *arg)
|
|
|
|
{
|
|
|
|
int *rins = NULL;
|
|
|
|
|
|
|
|
rins = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (int));
|
|
|
|
*rins = 1;
|
|
|
|
|
|
|
|
return rins;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free route map's compiled `ip next-hop' value. */
|
|
|
|
static void
|
|
|
|
route_set_ipv6_nexthop_peer_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map commands for ip nexthop set. */
|
|
|
|
struct route_map_rule_cmd route_set_ipv6_nexthop_peer_cmd =
|
|
|
|
{
|
|
|
|
"ipv6 next-hop peer-address",
|
|
|
|
route_set_ipv6_nexthop_peer,
|
|
|
|
route_set_ipv6_nexthop_peer_compile,
|
|
|
|
route_set_ipv6_nexthop_peer_free
|
|
|
|
};
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
#endif /* HAVE_IPV6 */
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* `set vpnv4 nexthop A.B.C.D' */
|
|
|
|
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_vpnv4_nexthop (void *rule, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
struct in_addr *address;
|
|
|
|
struct bgp_info *bgp_info;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
/* Fetch routemap's rule information. */
|
|
|
|
address = rule;
|
|
|
|
bgp_info = object;
|
|
|
|
|
|
|
|
/* Set next hop value. */
|
2007-05-04 22:15:47 +02:00
|
|
|
(bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_global_in = *address;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return RMAP_OKAY;
|
|
|
|
}
|
|
|
|
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2004-10-13 07:06:08 +02:00
|
|
|
route_set_vpnv4_nexthop_compile (const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct in_addr *address;
|
|
|
|
|
|
|
|
address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct in_addr));
|
|
|
|
|
|
|
|
ret = inet_aton (arg, address);
|
|
|
|
|
|
|
|
if (ret == 0)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, address);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return address;
|
|
|
|
}
|
|
|
|
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_vpnv4_nexthop_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map commands for ip nexthop set. */
|
|
|
|
struct route_map_rule_cmd route_set_vpnv4_nexthop_cmd =
|
|
|
|
{
|
|
|
|
"vpnv4 next-hop",
|
|
|
|
route_set_vpnv4_nexthop,
|
|
|
|
route_set_vpnv4_nexthop_compile,
|
|
|
|
route_set_vpnv4_nexthop_free
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* `set originator-id' */
|
|
|
|
|
|
|
|
/* For origin set. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static route_map_result_t
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_originator_id (void *rule, struct prefix *prefix, route_map_object_t type, void *object)
|
|
|
|
{
|
|
|
|
struct in_addr *address;
|
|
|
|
struct bgp_info *bgp_info;
|
|
|
|
|
|
|
|
if (type == RMAP_BGP)
|
|
|
|
{
|
|
|
|
address = rule;
|
|
|
|
bgp_info = object;
|
|
|
|
|
|
|
|
bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID);
|
2007-05-04 22:15:47 +02:00
|
|
|
(bgp_attr_extra_get (bgp_info->attr))->originator_id = *address;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return RMAP_OKAY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compile function for originator-id set. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void *
|
2004-10-13 07:06:08 +02:00
|
|
|
route_set_originator_id_compile (const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct in_addr *address;
|
|
|
|
|
|
|
|
address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct in_addr));
|
|
|
|
|
|
|
|
ret = inet_aton (arg, address);
|
|
|
|
|
|
|
|
if (ret == 0)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, address);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return address;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compile function for originator_id set. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
route_set_originator_id_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
2014-05-20 07:57:26 +02:00
|
|
|
/* Set originator-id rule structure. */
|
2002-12-13 21:15:29 +01:00
|
|
|
struct route_map_rule_cmd route_set_originator_id_cmd =
|
|
|
|
{
|
|
|
|
"originator-id",
|
|
|
|
route_set_originator_id,
|
|
|
|
route_set_originator_id_compile,
|
|
|
|
route_set_originator_id_free,
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Add bgp route map rule. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static int
|
2002-12-13 21:15:29 +01:00
|
|
|
bgp_route_match_add (struct vty *vty, struct route_map_index *index,
|
2015-05-20 02:40:45 +02:00
|
|
|
const char *command, const char *arg,
|
|
|
|
route_map_event_t type)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = route_map_add_match (index, command, arg);
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
switch (ret)
|
|
|
|
{
|
|
|
|
case RMAP_RULE_MISSING:
|
2015-05-20 02:47:22 +02:00
|
|
|
vty_out (vty, "%% BGP Can't find rule.%s", VTY_NEWLINE);
|
2002-12-13 21:15:29 +01:00
|
|
|
return CMD_WARNING;
|
|
|
|
case RMAP_COMPILE_ERROR:
|
2015-05-20 02:47:22 +02:00
|
|
|
vty_out (vty, "%% BGP Argument is malformed.%s", VTY_NEWLINE);
|
2002-12-13 21:15:29 +01:00
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
}
|
2015-05-20 02:40:45 +02:00
|
|
|
|
|
|
|
if (type != RMAP_EVENT_MATCH_ADDED)
|
|
|
|
{
|
|
|
|
route_map_upd8_dependency (type, arg, index->map->name);
|
|
|
|
}
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Delete bgp route map rule. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static int
|
2002-12-13 21:15:29 +01:00
|
|
|
bgp_route_match_delete (struct vty *vty, struct route_map_index *index,
|
2015-05-20 02:40:45 +02:00
|
|
|
const char *command, const char *arg,
|
|
|
|
route_map_event_t type)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
int ret;
|
2015-05-20 02:40:45 +02:00
|
|
|
char *dep_name = (char *)arg;
|
|
|
|
const char *tmpstr;
|
|
|
|
char *rmap_name = NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
if (type != RMAP_EVENT_MATCH_DELETED)
|
|
|
|
{
|
|
|
|
/* ignore the mundane, the types without any dependency */
|
|
|
|
if (arg == NULL)
|
|
|
|
{
|
|
|
|
if ((tmpstr = route_map_get_match_arg(index, command)) != NULL)
|
|
|
|
dep_name = XSTRDUP(MTYPE_ROUTE_MAP_RULE, tmpstr);
|
|
|
|
}
|
|
|
|
rmap_name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, index->map->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = route_map_delete_match (index, command, dep_name);
|
2002-12-13 21:15:29 +01:00
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
switch (ret)
|
|
|
|
{
|
|
|
|
case RMAP_RULE_MISSING:
|
2015-05-20 02:47:22 +02:00
|
|
|
vty_out (vty, "%% BGP Can't find rule.%s", VTY_NEWLINE);
|
2015-05-20 02:40:45 +02:00
|
|
|
break;
|
2002-12-13 21:15:29 +01:00
|
|
|
case RMAP_COMPILE_ERROR:
|
2015-05-20 02:47:22 +02:00
|
|
|
vty_out (vty, "%% BGP Argument is malformed.%s", VTY_NEWLINE);
|
2015-05-20 02:40:45 +02:00
|
|
|
break;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2015-05-20 02:40:45 +02:00
|
|
|
if (arg == NULL && dep_name)
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_RULE, dep_name);
|
|
|
|
if (rmap_name)
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_NAME, rmap_name);
|
|
|
|
return CMD_WARNING;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2015-05-20 02:40:45 +02:00
|
|
|
|
|
|
|
if (type != RMAP_EVENT_MATCH_DELETED && dep_name)
|
|
|
|
route_map_upd8_dependency(type, dep_name, rmap_name);
|
|
|
|
|
|
|
|
if (arg == NULL && dep_name)
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_RULE, dep_name);
|
|
|
|
if (rmap_name)
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_NAME, rmap_name);
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add bgp route map rule. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static int
|
2002-12-13 21:15:29 +01:00
|
|
|
bgp_route_set_add (struct vty *vty, struct route_map_index *index,
|
2004-10-13 07:06:08 +02:00
|
|
|
const char *command, const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = route_map_add_set (index, command, arg);
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
switch (ret)
|
|
|
|
{
|
|
|
|
case RMAP_RULE_MISSING:
|
2015-05-20 02:47:22 +02:00
|
|
|
vty_out (vty, "%% BGP Can't find rule.%s", VTY_NEWLINE);
|
2002-12-13 21:15:29 +01:00
|
|
|
return CMD_WARNING;
|
|
|
|
case RMAP_COMPILE_ERROR:
|
2015-05-20 02:47:22 +02:00
|
|
|
vty_out (vty, "%% BGP Argument is malformed.%s", VTY_NEWLINE);
|
2002-12-13 21:15:29 +01:00
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Delete bgp route map rule. */
|
2005-06-28 14:44:16 +02:00
|
|
|
static int
|
2002-12-13 21:15:29 +01:00
|
|
|
bgp_route_set_delete (struct vty *vty, struct route_map_index *index,
|
2004-10-13 07:06:08 +02:00
|
|
|
const char *command, const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = route_map_delete_set (index, command, arg);
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
switch (ret)
|
|
|
|
{
|
|
|
|
case RMAP_RULE_MISSING:
|
2015-05-20 02:47:22 +02:00
|
|
|
vty_out (vty, "%% BGP Can't find rule.%s", VTY_NEWLINE);
|
2002-12-13 21:15:29 +01:00
|
|
|
return CMD_WARNING;
|
|
|
|
case RMAP_COMPILE_ERROR:
|
2015-05-20 02:47:22 +02:00
|
|
|
vty_out (vty, "%% BGP Argument is malformed.%s", VTY_NEWLINE);
|
2002-12-13 21:15:29 +01:00
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
/*
|
|
|
|
* This is the workhorse routine for processing in/out/import/export routemap
|
|
|
|
* modifications.
|
|
|
|
*/
|
2005-06-28 14:44:16 +02:00
|
|
|
static void
|
2015-05-20 02:40:45 +02:00
|
|
|
bgp_route_map_process_peer (char *rmap_name, struct peer *peer,
|
|
|
|
int afi, int safi, int route_update)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
|
|
|
|
int update;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct bgp_filter *filter;
|
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
if (!peer || !rmap_name)
|
|
|
|
return;
|
|
|
|
|
|
|
|
filter = &peer->filter[afi][safi];
|
|
|
|
/*
|
|
|
|
* in is for non-route-server clients,
|
|
|
|
* import/export is for route-server clients,
|
|
|
|
* out is for all peers
|
|
|
|
*/
|
|
|
|
if (!CHECK_FLAG(peer->flags, PEER_FLAG_RSERVER_CLIENT))
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
if (filter->map[RMAP_IN].name &&
|
|
|
|
(strcmp(rmap_name, filter->map[RMAP_IN].name) == 0))
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
filter->map[RMAP_IN].map =
|
|
|
|
route_map_lookup_by_name (filter->map[RMAP_IN].name);
|
|
|
|
|
|
|
|
if (route_update)
|
|
|
|
{
|
|
|
|
if (CHECK_FLAG (peer->af_flags[afi][safi],
|
|
|
|
PEER_FLAG_SOFT_RECONFIG))
|
|
|
|
{
|
2015-05-20 02:58:12 +02:00
|
|
|
if (bgp_debug_update(peer, NULL, 1))
|
2015-05-20 02:40:45 +02:00
|
|
|
zlog_debug("Processing route_map %s update on "
|
|
|
|
"peer %s (inbound, soft-reconfig)",
|
|
|
|
rmap_name, peer->host);
|
|
|
|
|
|
|
|
bgp_soft_reconfig_in (peer, afi, safi);
|
|
|
|
}
|
|
|
|
else if (CHECK_FLAG (peer->cap, PEER_CAP_REFRESH_OLD_RCV)
|
|
|
|
|| CHECK_FLAG (peer->cap, PEER_CAP_REFRESH_NEW_RCV))
|
|
|
|
{
|
|
|
|
|
2015-05-20 02:58:12 +02:00
|
|
|
if (bgp_debug_update(peer, NULL, 1))
|
2015-05-20 02:40:45 +02:00
|
|
|
zlog_debug("Processing route_map %s update on "
|
|
|
|
"peer %s (inbound, route-refresh)",
|
|
|
|
rmap_name, peer->host);
|
|
|
|
bgp_route_refresh_send (peer, afi, safi, 0, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
if (CHECK_FLAG(peer->flags, PEER_FLAG_RSERVER_CLIENT))
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
update = 0;
|
|
|
|
|
|
|
|
if (filter->map[RMAP_IMPORT].name &&
|
|
|
|
(strcmp(rmap_name, filter->map[RMAP_IMPORT].name) == 0))
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
filter->map[RMAP_IMPORT].map =
|
|
|
|
route_map_lookup_by_name (filter->map[RMAP_IMPORT].name);
|
|
|
|
update = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (filter->map[RMAP_EXPORT].name &&
|
|
|
|
(strcmp(rmap_name, filter->map[RMAP_EXPORT].name) == 0))
|
|
|
|
{
|
|
|
|
filter->map[RMAP_EXPORT].map =
|
|
|
|
route_map_lookup_by_name (filter->map[RMAP_EXPORT].name);
|
|
|
|
|
|
|
|
update = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (update && route_update)
|
|
|
|
{
|
|
|
|
if (CHECK_FLAG (peer->af_flags[afi][safi],
|
|
|
|
PEER_FLAG_SOFT_RECONFIG))
|
|
|
|
{
|
2015-05-20 02:58:12 +02:00
|
|
|
if (bgp_debug_update(peer, NULL, 1))
|
2015-05-20 02:40:45 +02:00
|
|
|
zlog_debug("Processing route_map %s update on "
|
|
|
|
"peer %s (import, soft-reconfig)",
|
|
|
|
rmap_name, peer->host);
|
|
|
|
|
|
|
|
bgp_soft_reconfig_in (peer, afi, safi);
|
|
|
|
}
|
|
|
|
else if (CHECK_FLAG (peer->cap, PEER_CAP_REFRESH_OLD_RCV)
|
|
|
|
|| CHECK_FLAG (peer->cap, PEER_CAP_REFRESH_NEW_RCV))
|
|
|
|
{
|
2015-05-20 02:58:12 +02:00
|
|
|
if (bgp_debug_update(peer, NULL, 1))
|
2015-05-20 02:40:45 +02:00
|
|
|
zlog_debug("Processing route_map %s update on "
|
|
|
|
"peer %s (import, route-refresh)",
|
|
|
|
rmap_name, peer->host);
|
|
|
|
bgp_route_refresh_send (peer, afi, safi, 0, 0, 0);
|
|
|
|
}
|
|
|
|
/* DD: Else, what else do we do ? Reset peer ? */
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
if (filter->map[RMAP_OUT].name &&
|
|
|
|
(strcmp(rmap_name, filter->map[RMAP_OUT].name) == 0))
|
|
|
|
{
|
|
|
|
filter->map[RMAP_OUT].map =
|
|
|
|
route_map_lookup_by_name (filter->map[RMAP_OUT].name);
|
|
|
|
|
2015-05-20 02:58:12 +02:00
|
|
|
if (bgp_debug_update(peer, NULL, 0))
|
2015-05-20 02:40:45 +02:00
|
|
|
zlog_debug("Processing route_map %s update on peer %s (outbound)",
|
|
|
|
rmap_name, peer->host);
|
|
|
|
|
|
|
|
if (route_update)
|
|
|
|
bgp_announce_route_all(peer);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (filter->usmap.name &&
|
|
|
|
(strcmp(rmap_name, filter->usmap.name) == 0))
|
bgpd: bgpd-table-map.patch
COMMAND:
table-map <route-map-name>
DESCRIPTION:
This feature is used to apply a route-map on route updates from BGP to Zebra.
All the applicable match operations are allowed, such as match on prefix,
next-hop, communities, etc. Set operations for this attach-point are limited
to metric and next-hop only. Any operation of this feature does not affect
BGPs internal RIB.
Supported for ipv4 and ipv6 address families. It works on multi-paths as well,
however, metric setting is based on the best-path only.
IMPLEMENTATION NOTES:
The route-map application at this point is not supposed to modify any of BGP
route's attributes (anything in bgp_info for that matter). To achieve that,
creating a copy of the bgp_attr was inevitable. Implementation tries to keep
the memory footprint low, code comments do point out the rationale behind a
few choices made.
bgp_zebra_announce() was already a big routine, adding this feature would
extend it further. Patch has created a few smaller routines/macros whereever
possible to keep the size of the routine in check without compromising on the
readability of the code/flow inside this routine.
For updating a partially filtered route (with its nexthops), BGP to Zebra
replacement semantic of the next-hops serves the purpose well. However, with
this patch there could be some redundant withdraws each time BGP announces a
route thats (all the nexthops) gets denied by the route-map application.
Handling of this case could be optimized by keeping state with the prefix and
the nexthops in BGP. The patch doesn't optimizing that case, as even with the
redundant withdraws the total number of updates to zebra are still be capped
by the total number of routes in the table.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com>
2015-05-20 02:40:34 +02:00
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
filter->usmap.map = route_map_lookup_by_name (filter->usmap.name);
|
|
|
|
if (route_update)
|
|
|
|
bgp_announce_route_all(peer);
|
bgpd: bgpd-table-map.patch
COMMAND:
table-map <route-map-name>
DESCRIPTION:
This feature is used to apply a route-map on route updates from BGP to Zebra.
All the applicable match operations are allowed, such as match on prefix,
next-hop, communities, etc. Set operations for this attach-point are limited
to metric and next-hop only. Any operation of this feature does not affect
BGPs internal RIB.
Supported for ipv4 and ipv6 address families. It works on multi-paths as well,
however, metric setting is based on the best-path only.
IMPLEMENTATION NOTES:
The route-map application at this point is not supposed to modify any of BGP
route's attributes (anything in bgp_info for that matter). To achieve that,
creating a copy of the bgp_attr was inevitable. Implementation tries to keep
the memory footprint low, code comments do point out the rationale behind a
few choices made.
bgp_zebra_announce() was already a big routine, adding this feature would
extend it further. Patch has created a few smaller routines/macros whereever
possible to keep the size of the routine in check without compromising on the
readability of the code/flow inside this routine.
For updating a partially filtered route (with its nexthops), BGP to Zebra
replacement semantic of the next-hops serves the purpose well. However, with
this patch there could be some redundant withdraws each time BGP announces a
route thats (all the nexthops) gets denied by the route-map application.
Handling of this case could be optimized by keeping state with the prefix and
the nexthops in BGP. The patch doesn't optimizing that case, as even with the
redundant withdraws the total number of updates to zebra are still be capped
by the total number of routes in the table.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com>
2015-05-20 02:40:34 +02:00
|
|
|
}
|
2015-05-20 02:40:45 +02:00
|
|
|
}
|
bgpd: bgpd-table-map.patch
COMMAND:
table-map <route-map-name>
DESCRIPTION:
This feature is used to apply a route-map on route updates from BGP to Zebra.
All the applicable match operations are allowed, such as match on prefix,
next-hop, communities, etc. Set operations for this attach-point are limited
to metric and next-hop only. Any operation of this feature does not affect
BGPs internal RIB.
Supported for ipv4 and ipv6 address families. It works on multi-paths as well,
however, metric setting is based on the best-path only.
IMPLEMENTATION NOTES:
The route-map application at this point is not supposed to modify any of BGP
route's attributes (anything in bgp_info for that matter). To achieve that,
creating a copy of the bgp_attr was inevitable. Implementation tries to keep
the memory footprint low, code comments do point out the rationale behind a
few choices made.
bgp_zebra_announce() was already a big routine, adding this feature would
extend it further. Patch has created a few smaller routines/macros whereever
possible to keep the size of the routine in check without compromising on the
readability of the code/flow inside this routine.
For updating a partially filtered route (with its nexthops), BGP to Zebra
replacement semantic of the next-hops serves the purpose well. However, with
this patch there could be some redundant withdraws each time BGP announces a
route thats (all the nexthops) gets denied by the route-map application.
Handling of this case could be optimized by keeping state with the prefix and
the nexthops in BGP. The patch doesn't optimizing that case, as even with the
redundant withdraws the total number of updates to zebra are still be capped
by the total number of routes in the table.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com>
2015-05-20 02:40:34 +02:00
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
static void
|
|
|
|
bgp_route_map_update_peer_group(char *rmap_name, struct bgp *bgp)
|
|
|
|
{
|
|
|
|
struct peer_group *group;
|
|
|
|
struct listnode *node, *nnode;
|
|
|
|
struct bgp_filter *filter;
|
|
|
|
int afi, safi;
|
|
|
|
int direct;
|
|
|
|
|
|
|
|
if (!bgp)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* All the peers have been updated correctly already. This is
|
|
|
|
* just updating the placeholder data. No real update required.
|
|
|
|
*/
|
|
|
|
for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
|
|
|
|
for (afi = AFI_IP; afi < AFI_MAX; afi++)
|
|
|
|
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
|
|
|
|
{
|
|
|
|
filter = &group->conf->filter[afi][safi];
|
|
|
|
|
|
|
|
for (direct = RMAP_IN; direct < RMAP_MAX; direct++)
|
|
|
|
{
|
|
|
|
if ((filter->map[direct].name) &&
|
|
|
|
(strcmp(rmap_name, filter->map[direct].name) == 0))
|
|
|
|
filter->map[direct].map =
|
|
|
|
route_map_lookup_by_name (filter->map[direct].name);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (filter->usmap.name &&
|
|
|
|
(strcmp(rmap_name, filter->usmap.name) == 0))
|
|
|
|
filter->usmap.map = route_map_lookup_by_name (filter->usmap.name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
bgp_route_map_process_update (void *arg, char *rmap_name, int route_update)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
afi_t afi;
|
|
|
|
safi_t safi;
|
|
|
|
struct peer *peer;
|
|
|
|
struct bgp_node *bn;
|
|
|
|
struct bgp_static *bgp_static;
|
|
|
|
struct bgp *bgp = (struct bgp *)arg;
|
|
|
|
struct listnode *node, *nnode;
|
|
|
|
char buf[INET6_ADDRSTRLEN];
|
|
|
|
|
|
|
|
if (!bgp)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
|
|
|
|
/* Ignore dummy peer-group structure */
|
|
|
|
if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP))
|
|
|
|
continue;
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
for (afi = AFI_IP; afi < AFI_MAX; afi++)
|
|
|
|
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
|
2015-05-20 02:40:45 +02:00
|
|
|
{
|
|
|
|
/* Ignore inactive AFI/SAFI */
|
|
|
|
if (! peer->afc[afi][safi])
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* process in/out/import/export route-maps */
|
|
|
|
bgp_route_map_process_peer(rmap_name, peer, afi, safi, route_update);
|
|
|
|
|
|
|
|
/* process default-originate route-map */
|
|
|
|
if (peer->default_rmap[afi][safi].name &&
|
|
|
|
(strcmp (rmap_name, peer->default_rmap[afi][safi].name) == 0))
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
peer->default_rmap[afi][safi].map =
|
|
|
|
route_map_lookup_by_name (peer->default_rmap[afi][safi].name);
|
|
|
|
|
2015-05-20 02:58:12 +02:00
|
|
|
if (bgp_debug_update(peer, NULL, 0))
|
2015-05-20 02:40:45 +02:00
|
|
|
zlog_debug("Processing route_map %s update on "
|
|
|
|
"default-originate", rmap_name);
|
|
|
|
|
|
|
|
if (route_update)
|
|
|
|
bgp_default_originate (peer, afi, safi, 0);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2015-05-20 02:40:45 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
bgp_route_map_update_peer_group(rmap_name, bgp);
|
|
|
|
|
|
|
|
/* For table route-map updates. */
|
|
|
|
for (afi = AFI_IP; afi < AFI_MAX; afi++)
|
|
|
|
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
|
|
|
|
{
|
|
|
|
if (bgp->table_map[afi][safi].name &&
|
|
|
|
(strcmp(rmap_name, bgp->table_map[afi][safi].name) == 0))
|
|
|
|
{
|
|
|
|
bgp->table_map[afi][safi].map =
|
|
|
|
route_map_lookup_by_name (bgp->table_map[afi][safi].name);
|
2015-05-20 02:58:12 +02:00
|
|
|
if (BGP_DEBUG (zebra, ZEBRA))
|
2015-05-20 02:40:45 +02:00
|
|
|
zlog_debug("Processing route_map %s update on "
|
|
|
|
"table map", rmap_name);
|
|
|
|
if (route_update)
|
|
|
|
bgp_zebra_announce_table(bgp, afi, safi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* For network route-map updates. */
|
|
|
|
for (afi = AFI_IP; afi < AFI_MAX; afi++)
|
|
|
|
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
|
|
|
|
for (bn = bgp_table_top (bgp->route[afi][safi]); bn;
|
|
|
|
bn = bgp_route_next (bn))
|
|
|
|
if ((bgp_static = bn->info) != NULL)
|
|
|
|
{
|
|
|
|
if (bgp_static->rmap.name &&
|
|
|
|
(strcmp(rmap_name, bgp_static->rmap.name) == 0))
|
|
|
|
{
|
|
|
|
bgp_static->rmap.map =
|
|
|
|
route_map_lookup_by_name (bgp_static->rmap.name);
|
|
|
|
if (route_update)
|
|
|
|
if (!bgp_static->backdoor)
|
|
|
|
{
|
2015-05-20 02:58:12 +02:00
|
|
|
if (bgp_debug_zebra(&bn->p))
|
2015-05-20 02:40:45 +02:00
|
|
|
zlog_debug("Processing route_map %s update on "
|
|
|
|
"static route %s", rmap_name,
|
|
|
|
inet_ntop (bn->p.family, &bn->p.u.prefix,
|
|
|
|
buf, INET6_ADDRSTRLEN));
|
|
|
|
bgp_static_update (bgp, &bn->p, bgp_static, afi, safi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* For redistribute route-map updates. */
|
2015-05-20 02:40:45 +02:00
|
|
|
for (afi = AFI_IP; afi < AFI_MAX; afi++)
|
|
|
|
for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
|
|
|
|
{
|
|
|
|
if (bgp->rmap[afi][i].name &&
|
|
|
|
(strcmp(rmap_name, bgp->rmap[afi][i].name) == 0))
|
|
|
|
{
|
|
|
|
bgp->rmap[afi][i].map =
|
|
|
|
route_map_lookup_by_name (bgp->rmap[afi][i].name);
|
|
|
|
|
|
|
|
if (bgp->redist[afi][i] && route_update)
|
|
|
|
{
|
2015-05-20 02:58:12 +02:00
|
|
|
if (BGP_DEBUG (zebra, ZEBRA))
|
2015-05-20 02:40:45 +02:00
|
|
|
zlog_debug("Processing route_map %s update on "
|
|
|
|
"redistributed routes", rmap_name);
|
|
|
|
|
|
|
|
bgp_redistribute_resend (bgp, afi, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
bgp_route_map_process_update_cb (void *arg, char *rmap_name)
|
|
|
|
{
|
|
|
|
return bgp_route_map_process_update (arg, rmap_name, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
bgp_route_map_update_timer(struct thread *thread)
|
|
|
|
{
|
|
|
|
struct bgp *bgp = THREAD_ARG(thread);
|
|
|
|
|
|
|
|
bgp->t_rmap_update = NULL;
|
|
|
|
|
|
|
|
route_map_walk_update_list((void *)bgp, bgp_route_map_process_update_cb);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
bgp_route_map_mark_update (char *rmap_name)
|
|
|
|
{
|
|
|
|
struct listnode *node, *nnode;
|
|
|
|
struct bgp *bgp;
|
|
|
|
|
|
|
|
for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
if (bgp->t_rmap_update == NULL)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
/* rmap_update_timer of 0 means don't do route updates */
|
|
|
|
if (bgp->rmap_update_timer)
|
|
|
|
bgp->t_rmap_update =
|
|
|
|
thread_add_timer(master, bgp_route_map_update_timer, bgp,
|
|
|
|
bgp->rmap_update_timer);
|
|
|
|
else
|
|
|
|
bgp_route_map_process_update((void *)bgp, rmap_name, 0);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-06-04 06:53:35 +02:00
|
|
|
|
bgpd: bgpd-table-map.patch
COMMAND:
table-map <route-map-name>
DESCRIPTION:
This feature is used to apply a route-map on route updates from BGP to Zebra.
All the applicable match operations are allowed, such as match on prefix,
next-hop, communities, etc. Set operations for this attach-point are limited
to metric and next-hop only. Any operation of this feature does not affect
BGPs internal RIB.
Supported for ipv4 and ipv6 address families. It works on multi-paths as well,
however, metric setting is based on the best-path only.
IMPLEMENTATION NOTES:
The route-map application at this point is not supposed to modify any of BGP
route's attributes (anything in bgp_info for that matter). To achieve that,
creating a copy of the bgp_attr was inevitable. Implementation tries to keep
the memory footprint low, code comments do point out the rationale behind a
few choices made.
bgp_zebra_announce() was already a big routine, adding this feature would
extend it further. Patch has created a few smaller routines/macros whereever
possible to keep the size of the routine in check without compromising on the
readability of the code/flow inside this routine.
For updating a partially filtered route (with its nexthops), BGP to Zebra
replacement semantic of the next-hops serves the purpose well. However, with
this patch there could be some redundant withdraws each time BGP announces a
route thats (all the nexthops) gets denied by the route-map application.
Handling of this case could be optimized by keeping state with the prefix and
the nexthops in BGP. The patch doesn't optimizing that case, as even with the
redundant withdraws the total number of updates to zebra are still be capped
by the total number of routes in the table.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com>
2015-05-20 02:40:34 +02:00
|
|
|
static void
|
2015-05-20 02:40:45 +02:00
|
|
|
bgp_route_map_add (const char *rmap_name)
|
bgpd: bgpd-table-map.patch
COMMAND:
table-map <route-map-name>
DESCRIPTION:
This feature is used to apply a route-map on route updates from BGP to Zebra.
All the applicable match operations are allowed, such as match on prefix,
next-hop, communities, etc. Set operations for this attach-point are limited
to metric and next-hop only. Any operation of this feature does not affect
BGPs internal RIB.
Supported for ipv4 and ipv6 address families. It works on multi-paths as well,
however, metric setting is based on the best-path only.
IMPLEMENTATION NOTES:
The route-map application at this point is not supposed to modify any of BGP
route's attributes (anything in bgp_info for that matter). To achieve that,
creating a copy of the bgp_attr was inevitable. Implementation tries to keep
the memory footprint low, code comments do point out the rationale behind a
few choices made.
bgp_zebra_announce() was already a big routine, adding this feature would
extend it further. Patch has created a few smaller routines/macros whereever
possible to keep the size of the routine in check without compromising on the
readability of the code/flow inside this routine.
For updating a partially filtered route (with its nexthops), BGP to Zebra
replacement semantic of the next-hops serves the purpose well. However, with
this patch there could be some redundant withdraws each time BGP announces a
route thats (all the nexthops) gets denied by the route-map application.
Handling of this case could be optimized by keeping state with the prefix and
the nexthops in BGP. The patch doesn't optimizing that case, as even with the
redundant withdraws the total number of updates to zebra are still be capped
by the total number of routes in the table.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com>
2015-05-20 02:40:34 +02:00
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
if (route_map_mark_updated(rmap_name, 0) == 0)
|
|
|
|
bgp_route_map_mark_update(rmap_name);
|
bgpd: bgpd-table-map.patch
COMMAND:
table-map <route-map-name>
DESCRIPTION:
This feature is used to apply a route-map on route updates from BGP to Zebra.
All the applicable match operations are allowed, such as match on prefix,
next-hop, communities, etc. Set operations for this attach-point are limited
to metric and next-hop only. Any operation of this feature does not affect
BGPs internal RIB.
Supported for ipv4 and ipv6 address families. It works on multi-paths as well,
however, metric setting is based on the best-path only.
IMPLEMENTATION NOTES:
The route-map application at this point is not supposed to modify any of BGP
route's attributes (anything in bgp_info for that matter). To achieve that,
creating a copy of the bgp_attr was inevitable. Implementation tries to keep
the memory footprint low, code comments do point out the rationale behind a
few choices made.
bgp_zebra_announce() was already a big routine, adding this feature would
extend it further. Patch has created a few smaller routines/macros whereever
possible to keep the size of the routine in check without compromising on the
readability of the code/flow inside this routine.
For updating a partially filtered route (with its nexthops), BGP to Zebra
replacement semantic of the next-hops serves the purpose well. However, with
this patch there could be some redundant withdraws each time BGP announces a
route thats (all the nexthops) gets denied by the route-map application.
Handling of this case could be optimized by keeping state with the prefix and
the nexthops in BGP. The patch doesn't optimizing that case, as even with the
redundant withdraws the total number of updates to zebra are still be capped
by the total number of routes in the table.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com>
2015-05-20 02:40:34 +02:00
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_ADDED);
|
bgpd: bgpd-table-map.patch
COMMAND:
table-map <route-map-name>
DESCRIPTION:
This feature is used to apply a route-map on route updates from BGP to Zebra.
All the applicable match operations are allowed, such as match on prefix,
next-hop, communities, etc. Set operations for this attach-point are limited
to metric and next-hop only. Any operation of this feature does not affect
BGPs internal RIB.
Supported for ipv4 and ipv6 address families. It works on multi-paths as well,
however, metric setting is based on the best-path only.
IMPLEMENTATION NOTES:
The route-map application at this point is not supposed to modify any of BGP
route's attributes (anything in bgp_info for that matter). To achieve that,
creating a copy of the bgp_attr was inevitable. Implementation tries to keep
the memory footprint low, code comments do point out the rationale behind a
few choices made.
bgp_zebra_announce() was already a big routine, adding this feature would
extend it further. Patch has created a few smaller routines/macros whereever
possible to keep the size of the routine in check without compromising on the
readability of the code/flow inside this routine.
For updating a partially filtered route (with its nexthops), BGP to Zebra
replacement semantic of the next-hops serves the purpose well. However, with
this patch there could be some redundant withdraws each time BGP announces a
route thats (all the nexthops) gets denied by the route-map application.
Handling of this case could be optimized by keeping state with the prefix and
the nexthops in BGP. The patch doesn't optimizing that case, as even with the
redundant withdraws the total number of updates to zebra are still be capped
by the total number of routes in the table.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com>
2015-05-20 02:40:34 +02:00
|
|
|
}
|
2015-05-20 02:40:45 +02:00
|
|
|
|
bgpd: bgpd-table-map.patch
COMMAND:
table-map <route-map-name>
DESCRIPTION:
This feature is used to apply a route-map on route updates from BGP to Zebra.
All the applicable match operations are allowed, such as match on prefix,
next-hop, communities, etc. Set operations for this attach-point are limited
to metric and next-hop only. Any operation of this feature does not affect
BGPs internal RIB.
Supported for ipv4 and ipv6 address families. It works on multi-paths as well,
however, metric setting is based on the best-path only.
IMPLEMENTATION NOTES:
The route-map application at this point is not supposed to modify any of BGP
route's attributes (anything in bgp_info for that matter). To achieve that,
creating a copy of the bgp_attr was inevitable. Implementation tries to keep
the memory footprint low, code comments do point out the rationale behind a
few choices made.
bgp_zebra_announce() was already a big routine, adding this feature would
extend it further. Patch has created a few smaller routines/macros whereever
possible to keep the size of the routine in check without compromising on the
readability of the code/flow inside this routine.
For updating a partially filtered route (with its nexthops), BGP to Zebra
replacement semantic of the next-hops serves the purpose well. However, with
this patch there could be some redundant withdraws each time BGP announces a
route thats (all the nexthops) gets denied by the route-map application.
Handling of this case could be optimized by keeping state with the prefix and
the nexthops in BGP. The patch doesn't optimizing that case, as even with the
redundant withdraws the total number of updates to zebra are still be capped
by the total number of routes in the table.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com>
2015-05-20 02:40:34 +02:00
|
|
|
static void
|
2015-05-20 02:40:45 +02:00
|
|
|
bgp_route_map_delete (const char *rmap_name)
|
bgpd: bgpd-table-map.patch
COMMAND:
table-map <route-map-name>
DESCRIPTION:
This feature is used to apply a route-map on route updates from BGP to Zebra.
All the applicable match operations are allowed, such as match on prefix,
next-hop, communities, etc. Set operations for this attach-point are limited
to metric and next-hop only. Any operation of this feature does not affect
BGPs internal RIB.
Supported for ipv4 and ipv6 address families. It works on multi-paths as well,
however, metric setting is based on the best-path only.
IMPLEMENTATION NOTES:
The route-map application at this point is not supposed to modify any of BGP
route's attributes (anything in bgp_info for that matter). To achieve that,
creating a copy of the bgp_attr was inevitable. Implementation tries to keep
the memory footprint low, code comments do point out the rationale behind a
few choices made.
bgp_zebra_announce() was already a big routine, adding this feature would
extend it further. Patch has created a few smaller routines/macros whereever
possible to keep the size of the routine in check without compromising on the
readability of the code/flow inside this routine.
For updating a partially filtered route (with its nexthops), BGP to Zebra
replacement semantic of the next-hops serves the purpose well. However, with
this patch there could be some redundant withdraws each time BGP announces a
route thats (all the nexthops) gets denied by the route-map application.
Handling of this case could be optimized by keeping state with the prefix and
the nexthops in BGP. The patch doesn't optimizing that case, as even with the
redundant withdraws the total number of updates to zebra are still be capped
by the total number of routes in the table.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com>
2015-05-20 02:40:34 +02:00
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
if (route_map_mark_updated(rmap_name, 1) == 0)
|
|
|
|
bgp_route_map_mark_update(rmap_name);
|
bgpd: bgpd-table-map.patch
COMMAND:
table-map <route-map-name>
DESCRIPTION:
This feature is used to apply a route-map on route updates from BGP to Zebra.
All the applicable match operations are allowed, such as match on prefix,
next-hop, communities, etc. Set operations for this attach-point are limited
to metric and next-hop only. Any operation of this feature does not affect
BGPs internal RIB.
Supported for ipv4 and ipv6 address families. It works on multi-paths as well,
however, metric setting is based on the best-path only.
IMPLEMENTATION NOTES:
The route-map application at this point is not supposed to modify any of BGP
route's attributes (anything in bgp_info for that matter). To achieve that,
creating a copy of the bgp_attr was inevitable. Implementation tries to keep
the memory footprint low, code comments do point out the rationale behind a
few choices made.
bgp_zebra_announce() was already a big routine, adding this feature would
extend it further. Patch has created a few smaller routines/macros whereever
possible to keep the size of the routine in check without compromising on the
readability of the code/flow inside this routine.
For updating a partially filtered route (with its nexthops), BGP to Zebra
replacement semantic of the next-hops serves the purpose well. However, with
this patch there could be some redundant withdraws each time BGP announces a
route thats (all the nexthops) gets denied by the route-map application.
Handling of this case could be optimized by keeping state with the prefix and
the nexthops in BGP. The patch doesn't optimizing that case, as even with the
redundant withdraws the total number of updates to zebra are still be capped
by the total number of routes in the table.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com>
2015-05-20 02:40:34 +02:00
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_DELETED);
|
bgpd: bgpd-table-map.patch
COMMAND:
table-map <route-map-name>
DESCRIPTION:
This feature is used to apply a route-map on route updates from BGP to Zebra.
All the applicable match operations are allowed, such as match on prefix,
next-hop, communities, etc. Set operations for this attach-point are limited
to metric and next-hop only. Any operation of this feature does not affect
BGPs internal RIB.
Supported for ipv4 and ipv6 address families. It works on multi-paths as well,
however, metric setting is based on the best-path only.
IMPLEMENTATION NOTES:
The route-map application at this point is not supposed to modify any of BGP
route's attributes (anything in bgp_info for that matter). To achieve that,
creating a copy of the bgp_attr was inevitable. Implementation tries to keep
the memory footprint low, code comments do point out the rationale behind a
few choices made.
bgp_zebra_announce() was already a big routine, adding this feature would
extend it further. Patch has created a few smaller routines/macros whereever
possible to keep the size of the routine in check without compromising on the
readability of the code/flow inside this routine.
For updating a partially filtered route (with its nexthops), BGP to Zebra
replacement semantic of the next-hops serves the purpose well. However, with
this patch there could be some redundant withdraws each time BGP announces a
route thats (all the nexthops) gets denied by the route-map application.
Handling of this case could be optimized by keeping state with the prefix and
the nexthops in BGP. The patch doesn't optimizing that case, as even with the
redundant withdraws the total number of updates to zebra are still be capped
by the total number of routes in the table.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com>
2015-05-20 02:40:34 +02:00
|
|
|
}
|
2015-05-20 02:40:45 +02:00
|
|
|
|
bgpd: bgpd-table-map.patch
COMMAND:
table-map <route-map-name>
DESCRIPTION:
This feature is used to apply a route-map on route updates from BGP to Zebra.
All the applicable match operations are allowed, such as match on prefix,
next-hop, communities, etc. Set operations for this attach-point are limited
to metric and next-hop only. Any operation of this feature does not affect
BGPs internal RIB.
Supported for ipv4 and ipv6 address families. It works on multi-paths as well,
however, metric setting is based on the best-path only.
IMPLEMENTATION NOTES:
The route-map application at this point is not supposed to modify any of BGP
route's attributes (anything in bgp_info for that matter). To achieve that,
creating a copy of the bgp_attr was inevitable. Implementation tries to keep
the memory footprint low, code comments do point out the rationale behind a
few choices made.
bgp_zebra_announce() was already a big routine, adding this feature would
extend it further. Patch has created a few smaller routines/macros whereever
possible to keep the size of the routine in check without compromising on the
readability of the code/flow inside this routine.
For updating a partially filtered route (with its nexthops), BGP to Zebra
replacement semantic of the next-hops serves the purpose well. However, with
this patch there could be some redundant withdraws each time BGP announces a
route thats (all the nexthops) gets denied by the route-map application.
Handling of this case could be optimized by keeping state with the prefix and
the nexthops in BGP. The patch doesn't optimizing that case, as even with the
redundant withdraws the total number of updates to zebra are still be capped
by the total number of routes in the table.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com>
2015-05-20 02:40:34 +02:00
|
|
|
static void
|
2015-05-20 02:40:45 +02:00
|
|
|
bgp_route_map_event (route_map_event_t event, const char *rmap_name)
|
bgpd: bgpd-table-map.patch
COMMAND:
table-map <route-map-name>
DESCRIPTION:
This feature is used to apply a route-map on route updates from BGP to Zebra.
All the applicable match operations are allowed, such as match on prefix,
next-hop, communities, etc. Set operations for this attach-point are limited
to metric and next-hop only. Any operation of this feature does not affect
BGPs internal RIB.
Supported for ipv4 and ipv6 address families. It works on multi-paths as well,
however, metric setting is based on the best-path only.
IMPLEMENTATION NOTES:
The route-map application at this point is not supposed to modify any of BGP
route's attributes (anything in bgp_info for that matter). To achieve that,
creating a copy of the bgp_attr was inevitable. Implementation tries to keep
the memory footprint low, code comments do point out the rationale behind a
few choices made.
bgp_zebra_announce() was already a big routine, adding this feature would
extend it further. Patch has created a few smaller routines/macros whereever
possible to keep the size of the routine in check without compromising on the
readability of the code/flow inside this routine.
For updating a partially filtered route (with its nexthops), BGP to Zebra
replacement semantic of the next-hops serves the purpose well. However, with
this patch there could be some redundant withdraws each time BGP announces a
route thats (all the nexthops) gets denied by the route-map application.
Handling of this case could be optimized by keeping state with the prefix and
the nexthops in BGP. The patch doesn't optimizing that case, as even with the
redundant withdraws the total number of updates to zebra are still be capped
by the total number of routes in the table.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com>
2015-05-20 02:40:34 +02:00
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
if (route_map_mark_updated(rmap_name, 0) == 0)
|
|
|
|
bgp_route_map_mark_update(rmap_name);
|
|
|
|
|
|
|
|
route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_ADDED);
|
bgpd: bgpd-table-map.patch
COMMAND:
table-map <route-map-name>
DESCRIPTION:
This feature is used to apply a route-map on route updates from BGP to Zebra.
All the applicable match operations are allowed, such as match on prefix,
next-hop, communities, etc. Set operations for this attach-point are limited
to metric and next-hop only. Any operation of this feature does not affect
BGPs internal RIB.
Supported for ipv4 and ipv6 address families. It works on multi-paths as well,
however, metric setting is based on the best-path only.
IMPLEMENTATION NOTES:
The route-map application at this point is not supposed to modify any of BGP
route's attributes (anything in bgp_info for that matter). To achieve that,
creating a copy of the bgp_attr was inevitable. Implementation tries to keep
the memory footprint low, code comments do point out the rationale behind a
few choices made.
bgp_zebra_announce() was already a big routine, adding this feature would
extend it further. Patch has created a few smaller routines/macros whereever
possible to keep the size of the routine in check without compromising on the
readability of the code/flow inside this routine.
For updating a partially filtered route (with its nexthops), BGP to Zebra
replacement semantic of the next-hops serves the purpose well. However, with
this patch there could be some redundant withdraws each time BGP announces a
route thats (all the nexthops) gets denied by the route-map application.
Handling of this case could be optimized by keeping state with the prefix and
the nexthops in BGP. The patch doesn't optimizing that case, as even with the
redundant withdraws the total number of updates to zebra are still be capped
by the total number of routes in the table.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com>
2015-05-20 02:40:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-13 Jose Luis Rubio <jrubio@dit.upm.es>
(at Technical University of Madrid as part of Euro6ix Project)
Enhanced Route Server functionality and Route-Maps:
* bgpd/bgpd.h: Modified 'struct peer' and 'struct bgp_filter' to
support rs-clients. A 'struct bgp_table *rib' has been added to the
first (to mantain a separated RIB for each rs-client) and two new
route-maps have been added to the last (for import/export policies).
Added the following #defines: RMAP_{IN|OUT|IMPORT|EXPORT|MAX},
PEER_RMAP_TYPE_{IMPORT|EXPORT} and BGP_CLEAR_SOFT_RSCLIENT.
* bgpd/bgpd.c: Modified the functions that create/delete/etc peers in
order to consider the new fields included in 'struct peer' for
supporting rs-clients, i.e. the import/export route-maps and the
'struct bgp_table'.
* bgpd/bgp_route.{ch}: Modified several functions related with
receiving/sending announces in order to support the new Route Server
capabilities.
Function 'bgp_process' has been reorganized, creating an auxiliar
function for best path selection ('bgp_best_selection').
Modified 'bgp_show' and 'bgp_show_route' for displaying information
about any RIB (and not only the main bgp RIB).
Added commands for displaying information about RS-clients RIBs:
'show bgp rsclient (A.B.C.D|X:X::X:X)', 'show bgp rsclient
(A.B.C.D|X:X::X:X) X:X::X:X/M', etc
* bgpd/bgp_table.{ch}: The structure 'struct bgp_table' now has two
new fields: type (which can take the values BGP_TABLE_{MAIN|RSCLIENT})
and 'void *owner' which points to 'struct bgp' or 'struct peer' which
owns the table.
When creating a new bgp_table by default 'type=BGP_TABLE_MAIN' is set.
* bgpd/bgp_vty.c: The commands 'neighbor ... route-server-client' and
'no neighbor ... route-server-client' now not only set/unset the flag
PEER_FLAG_RSERVER_CLIENT, but they create/destroy the 'struct
bgp_table' of the peer. Special actions are taken for peer_groups.
Command 'neighbor ... route-map WORD (in|out)' now also supports two
new kinds of route-map: 'import' and 'export'.
Added commands 'clear bgp * rsclient', etc. These commands allow a new
kind of soft_reconfig which affects only the RIB of the specified
RS-client.
Added commands 'show bgp rsclient summary', etc which display a
summary of the rs-clients configured for the corresponding address
family.
* bgpd/bgp_routemap.c: A new match statement is available,
'match peer (A.B.C.D|X:X::X:X)'. This statement can only be used in
import/export route-maps, and it matches when the peer who announces
(when used in an import route-map) or is going to receive (when used
in an export route-map) the route is the same than the one specified
in the statement.
For peer-groups the statement matches if the specified peer is member
of the peer-group.
A special version of the command, 'match peer local', matches with
routes originated by the Route Server (defined with 'network ...',
redistributed routes and default-originate).
* lib/routemap.{ch}: Added a new clause 'call NAME' for use in
route-maps. It jumps into the specified route-map and when it returns
the first route-map ends if the called RM returns DENY_MATCH, or
continues in other case.
2004-09-13 07:12:46 +02:00
|
|
|
DEFUN (match_peer,
|
|
|
|
match_peer_cmd,
|
|
|
|
"match peer (A.B.C.D|X:X::X:X)",
|
|
|
|
MATCH_STR
|
|
|
|
"Match peer address\n"
|
|
|
|
"IPv6 address of peer\n"
|
|
|
|
"IP address of peer\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_add (vty, vty->index, "peer", argv[0],
|
|
|
|
RMAP_EVENT_MATCH_ADDED);
|
2004-09-13 Jose Luis Rubio <jrubio@dit.upm.es>
(at Technical University of Madrid as part of Euro6ix Project)
Enhanced Route Server functionality and Route-Maps:
* bgpd/bgpd.h: Modified 'struct peer' and 'struct bgp_filter' to
support rs-clients. A 'struct bgp_table *rib' has been added to the
first (to mantain a separated RIB for each rs-client) and two new
route-maps have been added to the last (for import/export policies).
Added the following #defines: RMAP_{IN|OUT|IMPORT|EXPORT|MAX},
PEER_RMAP_TYPE_{IMPORT|EXPORT} and BGP_CLEAR_SOFT_RSCLIENT.
* bgpd/bgpd.c: Modified the functions that create/delete/etc peers in
order to consider the new fields included in 'struct peer' for
supporting rs-clients, i.e. the import/export route-maps and the
'struct bgp_table'.
* bgpd/bgp_route.{ch}: Modified several functions related with
receiving/sending announces in order to support the new Route Server
capabilities.
Function 'bgp_process' has been reorganized, creating an auxiliar
function for best path selection ('bgp_best_selection').
Modified 'bgp_show' and 'bgp_show_route' for displaying information
about any RIB (and not only the main bgp RIB).
Added commands for displaying information about RS-clients RIBs:
'show bgp rsclient (A.B.C.D|X:X::X:X)', 'show bgp rsclient
(A.B.C.D|X:X::X:X) X:X::X:X/M', etc
* bgpd/bgp_table.{ch}: The structure 'struct bgp_table' now has two
new fields: type (which can take the values BGP_TABLE_{MAIN|RSCLIENT})
and 'void *owner' which points to 'struct bgp' or 'struct peer' which
owns the table.
When creating a new bgp_table by default 'type=BGP_TABLE_MAIN' is set.
* bgpd/bgp_vty.c: The commands 'neighbor ... route-server-client' and
'no neighbor ... route-server-client' now not only set/unset the flag
PEER_FLAG_RSERVER_CLIENT, but they create/destroy the 'struct
bgp_table' of the peer. Special actions are taken for peer_groups.
Command 'neighbor ... route-map WORD (in|out)' now also supports two
new kinds of route-map: 'import' and 'export'.
Added commands 'clear bgp * rsclient', etc. These commands allow a new
kind of soft_reconfig which affects only the RIB of the specified
RS-client.
Added commands 'show bgp rsclient summary', etc which display a
summary of the rs-clients configured for the corresponding address
family.
* bgpd/bgp_routemap.c: A new match statement is available,
'match peer (A.B.C.D|X:X::X:X)'. This statement can only be used in
import/export route-maps, and it matches when the peer who announces
(when used in an import route-map) or is going to receive (when used
in an export route-map) the route is the same than the one specified
in the statement.
For peer-groups the statement matches if the specified peer is member
of the peer-group.
A special version of the command, 'match peer local', matches with
routes originated by the Route Server (defined with 'network ...',
redistributed routes and default-originate).
* lib/routemap.{ch}: Added a new clause 'call NAME' for use in
route-maps. It jumps into the specified route-map and when it returns
the first route-map ends if the called RM returns DENY_MATCH, or
continues in other case.
2004-09-13 07:12:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (match_peer_local,
|
|
|
|
match_peer_local_cmd,
|
|
|
|
"match peer local",
|
|
|
|
MATCH_STR
|
|
|
|
"Match peer address\n"
|
|
|
|
"Static or Redistributed routes\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_add (vty, vty->index, "peer", "local",
|
|
|
|
RMAP_EVENT_MATCH_DELETED);
|
2004-09-13 Jose Luis Rubio <jrubio@dit.upm.es>
(at Technical University of Madrid as part of Euro6ix Project)
Enhanced Route Server functionality and Route-Maps:
* bgpd/bgpd.h: Modified 'struct peer' and 'struct bgp_filter' to
support rs-clients. A 'struct bgp_table *rib' has been added to the
first (to mantain a separated RIB for each rs-client) and two new
route-maps have been added to the last (for import/export policies).
Added the following #defines: RMAP_{IN|OUT|IMPORT|EXPORT|MAX},
PEER_RMAP_TYPE_{IMPORT|EXPORT} and BGP_CLEAR_SOFT_RSCLIENT.
* bgpd/bgpd.c: Modified the functions that create/delete/etc peers in
order to consider the new fields included in 'struct peer' for
supporting rs-clients, i.e. the import/export route-maps and the
'struct bgp_table'.
* bgpd/bgp_route.{ch}: Modified several functions related with
receiving/sending announces in order to support the new Route Server
capabilities.
Function 'bgp_process' has been reorganized, creating an auxiliar
function for best path selection ('bgp_best_selection').
Modified 'bgp_show' and 'bgp_show_route' for displaying information
about any RIB (and not only the main bgp RIB).
Added commands for displaying information about RS-clients RIBs:
'show bgp rsclient (A.B.C.D|X:X::X:X)', 'show bgp rsclient
(A.B.C.D|X:X::X:X) X:X::X:X/M', etc
* bgpd/bgp_table.{ch}: The structure 'struct bgp_table' now has two
new fields: type (which can take the values BGP_TABLE_{MAIN|RSCLIENT})
and 'void *owner' which points to 'struct bgp' or 'struct peer' which
owns the table.
When creating a new bgp_table by default 'type=BGP_TABLE_MAIN' is set.
* bgpd/bgp_vty.c: The commands 'neighbor ... route-server-client' and
'no neighbor ... route-server-client' now not only set/unset the flag
PEER_FLAG_RSERVER_CLIENT, but they create/destroy the 'struct
bgp_table' of the peer. Special actions are taken for peer_groups.
Command 'neighbor ... route-map WORD (in|out)' now also supports two
new kinds of route-map: 'import' and 'export'.
Added commands 'clear bgp * rsclient', etc. These commands allow a new
kind of soft_reconfig which affects only the RIB of the specified
RS-client.
Added commands 'show bgp rsclient summary', etc which display a
summary of the rs-clients configured for the corresponding address
family.
* bgpd/bgp_routemap.c: A new match statement is available,
'match peer (A.B.C.D|X:X::X:X)'. This statement can only be used in
import/export route-maps, and it matches when the peer who announces
(when used in an import route-map) or is going to receive (when used
in an export route-map) the route is the same than the one specified
in the statement.
For peer-groups the statement matches if the specified peer is member
of the peer-group.
A special version of the command, 'match peer local', matches with
routes originated by the Route Server (defined with 'network ...',
redistributed routes and default-originate).
* lib/routemap.{ch}: Added a new clause 'call NAME' for use in
route-maps. It jumps into the specified route-map and when it returns
the first route-map ends if the called RM returns DENY_MATCH, or
continues in other case.
2004-09-13 07:12:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_match_peer,
|
|
|
|
no_match_peer_cmd,
|
|
|
|
"no match peer",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"Match peer address\n")
|
|
|
|
{
|
|
|
|
if (argc == 0)
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_delete (vty, vty->index, "peer", NULL,
|
|
|
|
RMAP_EVENT_MATCH_DELETED);
|
2004-09-13 Jose Luis Rubio <jrubio@dit.upm.es>
(at Technical University of Madrid as part of Euro6ix Project)
Enhanced Route Server functionality and Route-Maps:
* bgpd/bgpd.h: Modified 'struct peer' and 'struct bgp_filter' to
support rs-clients. A 'struct bgp_table *rib' has been added to the
first (to mantain a separated RIB for each rs-client) and two new
route-maps have been added to the last (for import/export policies).
Added the following #defines: RMAP_{IN|OUT|IMPORT|EXPORT|MAX},
PEER_RMAP_TYPE_{IMPORT|EXPORT} and BGP_CLEAR_SOFT_RSCLIENT.
* bgpd/bgpd.c: Modified the functions that create/delete/etc peers in
order to consider the new fields included in 'struct peer' for
supporting rs-clients, i.e. the import/export route-maps and the
'struct bgp_table'.
* bgpd/bgp_route.{ch}: Modified several functions related with
receiving/sending announces in order to support the new Route Server
capabilities.
Function 'bgp_process' has been reorganized, creating an auxiliar
function for best path selection ('bgp_best_selection').
Modified 'bgp_show' and 'bgp_show_route' for displaying information
about any RIB (and not only the main bgp RIB).
Added commands for displaying information about RS-clients RIBs:
'show bgp rsclient (A.B.C.D|X:X::X:X)', 'show bgp rsclient
(A.B.C.D|X:X::X:X) X:X::X:X/M', etc
* bgpd/bgp_table.{ch}: The structure 'struct bgp_table' now has two
new fields: type (which can take the values BGP_TABLE_{MAIN|RSCLIENT})
and 'void *owner' which points to 'struct bgp' or 'struct peer' which
owns the table.
When creating a new bgp_table by default 'type=BGP_TABLE_MAIN' is set.
* bgpd/bgp_vty.c: The commands 'neighbor ... route-server-client' and
'no neighbor ... route-server-client' now not only set/unset the flag
PEER_FLAG_RSERVER_CLIENT, but they create/destroy the 'struct
bgp_table' of the peer. Special actions are taken for peer_groups.
Command 'neighbor ... route-map WORD (in|out)' now also supports two
new kinds of route-map: 'import' and 'export'.
Added commands 'clear bgp * rsclient', etc. These commands allow a new
kind of soft_reconfig which affects only the RIB of the specified
RS-client.
Added commands 'show bgp rsclient summary', etc which display a
summary of the rs-clients configured for the corresponding address
family.
* bgpd/bgp_routemap.c: A new match statement is available,
'match peer (A.B.C.D|X:X::X:X)'. This statement can only be used in
import/export route-maps, and it matches when the peer who announces
(when used in an import route-map) or is going to receive (when used
in an export route-map) the route is the same than the one specified
in the statement.
For peer-groups the statement matches if the specified peer is member
of the peer-group.
A special version of the command, 'match peer local', matches with
routes originated by the Route Server (defined with 'network ...',
redistributed routes and default-originate).
* lib/routemap.{ch}: Added a new clause 'call NAME' for use in
route-maps. It jumps into the specified route-map and when it returns
the first route-map ends if the called RM returns DENY_MATCH, or
continues in other case.
2004-09-13 07:12:46 +02:00
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_delete (vty, vty->index, "peer", argv[0],
|
|
|
|
RMAP_EVENT_MATCH_DELETED);
|
2004-09-13 Jose Luis Rubio <jrubio@dit.upm.es>
(at Technical University of Madrid as part of Euro6ix Project)
Enhanced Route Server functionality and Route-Maps:
* bgpd/bgpd.h: Modified 'struct peer' and 'struct bgp_filter' to
support rs-clients. A 'struct bgp_table *rib' has been added to the
first (to mantain a separated RIB for each rs-client) and two new
route-maps have been added to the last (for import/export policies).
Added the following #defines: RMAP_{IN|OUT|IMPORT|EXPORT|MAX},
PEER_RMAP_TYPE_{IMPORT|EXPORT} and BGP_CLEAR_SOFT_RSCLIENT.
* bgpd/bgpd.c: Modified the functions that create/delete/etc peers in
order to consider the new fields included in 'struct peer' for
supporting rs-clients, i.e. the import/export route-maps and the
'struct bgp_table'.
* bgpd/bgp_route.{ch}: Modified several functions related with
receiving/sending announces in order to support the new Route Server
capabilities.
Function 'bgp_process' has been reorganized, creating an auxiliar
function for best path selection ('bgp_best_selection').
Modified 'bgp_show' and 'bgp_show_route' for displaying information
about any RIB (and not only the main bgp RIB).
Added commands for displaying information about RS-clients RIBs:
'show bgp rsclient (A.B.C.D|X:X::X:X)', 'show bgp rsclient
(A.B.C.D|X:X::X:X) X:X::X:X/M', etc
* bgpd/bgp_table.{ch}: The structure 'struct bgp_table' now has two
new fields: type (which can take the values BGP_TABLE_{MAIN|RSCLIENT})
and 'void *owner' which points to 'struct bgp' or 'struct peer' which
owns the table.
When creating a new bgp_table by default 'type=BGP_TABLE_MAIN' is set.
* bgpd/bgp_vty.c: The commands 'neighbor ... route-server-client' and
'no neighbor ... route-server-client' now not only set/unset the flag
PEER_FLAG_RSERVER_CLIENT, but they create/destroy the 'struct
bgp_table' of the peer. Special actions are taken for peer_groups.
Command 'neighbor ... route-map WORD (in|out)' now also supports two
new kinds of route-map: 'import' and 'export'.
Added commands 'clear bgp * rsclient', etc. These commands allow a new
kind of soft_reconfig which affects only the RIB of the specified
RS-client.
Added commands 'show bgp rsclient summary', etc which display a
summary of the rs-clients configured for the corresponding address
family.
* bgpd/bgp_routemap.c: A new match statement is available,
'match peer (A.B.C.D|X:X::X:X)'. This statement can only be used in
import/export route-maps, and it matches when the peer who announces
(when used in an import route-map) or is going to receive (when used
in an export route-map) the route is the same than the one specified
in the statement.
For peer-groups the statement matches if the specified peer is member
of the peer-group.
A special version of the command, 'match peer local', matches with
routes originated by the Route Server (defined with 'network ...',
redistributed routes and default-originate).
* lib/routemap.{ch}: Added a new clause 'call NAME' for use in
route-maps. It jumps into the specified route-map and when it returns
the first route-map ends if the called RM returns DENY_MATCH, or
continues in other case.
2004-09-13 07:12:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_match_peer,
|
|
|
|
no_match_peer_val_cmd,
|
|
|
|
"no match peer (A.B.C.D|X:X::X:X)",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"Match peer address\n"
|
|
|
|
"IPv6 address of peer\n"
|
|
|
|
"IP address of peer\n")
|
|
|
|
|
|
|
|
ALIAS (no_match_peer,
|
|
|
|
no_match_peer_local_cmd,
|
|
|
|
"no match peer local",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"Match peer address\n"
|
|
|
|
"Static or Redistributed routes\n")
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
DEFUN (match_ip_address,
|
|
|
|
match_ip_address_cmd,
|
|
|
|
"match ip address (<1-199>|<1300-2699>|WORD)",
|
|
|
|
MATCH_STR
|
|
|
|
IP_STR
|
|
|
|
"Match address of route\n"
|
|
|
|
"IP access-list number\n"
|
|
|
|
"IP access-list number (expanded range)\n"
|
|
|
|
"IP Access-list name\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_add (vty, vty->index, "ip address", argv[0],
|
|
|
|
RMAP_EVENT_FILTER_ADDED);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_match_ip_address,
|
|
|
|
no_match_ip_address_cmd,
|
|
|
|
"no match ip address",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
IP_STR
|
|
|
|
"Match address of route\n")
|
|
|
|
{
|
|
|
|
if (argc == 0)
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_delete (vty, vty->index, "ip address", NULL,
|
|
|
|
RMAP_EVENT_FILTER_DELETED);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_delete (vty, vty->index, "ip address", argv[0],
|
|
|
|
RMAP_EVENT_FILTER_DELETED);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_match_ip_address,
|
|
|
|
no_match_ip_address_val_cmd,
|
|
|
|
"no match ip address (<1-199>|<1300-2699>|WORD)",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
IP_STR
|
|
|
|
"Match address of route\n"
|
|
|
|
"IP access-list number\n"
|
|
|
|
"IP access-list number (expanded range)\n"
|
|
|
|
"IP Access-list name\n")
|
|
|
|
|
|
|
|
DEFUN (match_ip_next_hop,
|
|
|
|
match_ip_next_hop_cmd,
|
|
|
|
"match ip next-hop (<1-199>|<1300-2699>|WORD)",
|
|
|
|
MATCH_STR
|
|
|
|
IP_STR
|
|
|
|
"Match next-hop address of route\n"
|
|
|
|
"IP access-list number\n"
|
|
|
|
"IP access-list number (expanded range)\n"
|
|
|
|
"IP Access-list name\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_add (vty, vty->index, "ip next-hop", argv[0],
|
|
|
|
RMAP_EVENT_FILTER_ADDED);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_match_ip_next_hop,
|
|
|
|
no_match_ip_next_hop_cmd,
|
|
|
|
"no match ip next-hop",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
IP_STR
|
|
|
|
"Match next-hop address of route\n")
|
|
|
|
{
|
|
|
|
if (argc == 0)
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_delete (vty, vty->index, "ip next-hop", NULL,
|
|
|
|
RMAP_EVENT_FILTER_DELETED);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_delete (vty, vty->index, "ip next-hop", argv[0],
|
|
|
|
RMAP_EVENT_FILTER_DELETED);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_match_ip_next_hop,
|
|
|
|
no_match_ip_next_hop_val_cmd,
|
|
|
|
"no match ip next-hop (<1-199>|<1300-2699>|WORD)",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
IP_STR
|
|
|
|
"Match next-hop address of route\n"
|
|
|
|
"IP access-list number\n"
|
|
|
|
"IP access-list number (expanded range)\n"
|
|
|
|
"IP Access-list name\n")
|
|
|
|
|
2011-11-22 17:15:10 +01:00
|
|
|
/* match probability { */
|
|
|
|
|
|
|
|
DEFUN (match_probability,
|
|
|
|
match_probability_cmd,
|
|
|
|
"match probability <0-100>",
|
|
|
|
MATCH_STR
|
|
|
|
"Match portion of routes defined by percentage value\n"
|
|
|
|
"Percentage of routes\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_add (vty, vty->index, "probability", argv[0],
|
|
|
|
RMAP_EVENT_MATCH_ADDED);
|
2011-11-22 17:15:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_match_probability,
|
|
|
|
no_match_probability_cmd,
|
|
|
|
"no match probability",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"Match portion of routes defined by percentage value\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_delete (vty, vty->index, "probability", argc ? argv[0] : NULL,
|
|
|
|
RMAP_EVENT_MATCH_DELETED);
|
2011-11-22 17:15:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_match_probability,
|
|
|
|
no_match_probability_val_cmd,
|
|
|
|
"no match probability <1-99>",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"Match portion of routes defined by percentage value\n"
|
|
|
|
"Percentage of routes\n")
|
|
|
|
|
|
|
|
/* } */
|
|
|
|
|
2005-02-02 17:43:17 +01:00
|
|
|
DEFUN (match_ip_route_source,
|
|
|
|
match_ip_route_source_cmd,
|
|
|
|
"match ip route-source (<1-199>|<1300-2699>|WORD)",
|
|
|
|
MATCH_STR
|
|
|
|
IP_STR
|
|
|
|
"Match advertising source address of route\n"
|
|
|
|
"IP access-list number\n"
|
|
|
|
"IP access-list number (expanded range)\n"
|
|
|
|
"IP standard access-list name\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_add (vty, vty->index, "ip route-source", argv[0],
|
|
|
|
RMAP_EVENT_FILTER_ADDED);
|
2005-02-02 17:43:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_match_ip_route_source,
|
|
|
|
no_match_ip_route_source_cmd,
|
|
|
|
"no match ip route-source",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
IP_STR
|
|
|
|
"Match advertising source address of route\n")
|
|
|
|
{
|
|
|
|
if (argc == 0)
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_delete (vty, vty->index, "ip route-source", NULL,
|
|
|
|
RMAP_EVENT_FILTER_DELETED);
|
2005-02-02 17:43:17 +01:00
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_delete (vty, vty->index, "ip route-source",
|
|
|
|
argv[0], RMAP_EVENT_FILTER_DELETED);
|
2005-02-02 17:43:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_match_ip_route_source,
|
|
|
|
no_match_ip_route_source_val_cmd,
|
|
|
|
"no match ip route-source (<1-199>|<1300-2699>|WORD)",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
IP_STR
|
|
|
|
"Match advertising source address of route\n"
|
|
|
|
"IP access-list number\n"
|
|
|
|
"IP access-list number (expanded range)\n"
|
2008-08-15 15:05:22 +02:00
|
|
|
"IP standard access-list name\n")
|
2005-02-02 17:43:17 +01:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
DEFUN (match_ip_address_prefix_list,
|
|
|
|
match_ip_address_prefix_list_cmd,
|
|
|
|
"match ip address prefix-list WORD",
|
|
|
|
MATCH_STR
|
|
|
|
IP_STR
|
|
|
|
"Match address of route\n"
|
|
|
|
"Match entries of prefix-lists\n"
|
|
|
|
"IP prefix-list name\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_add (vty, vty->index, "ip address prefix-list",
|
|
|
|
argv[0], RMAP_EVENT_PLIST_ADDED);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_match_ip_address_prefix_list,
|
|
|
|
no_match_ip_address_prefix_list_cmd,
|
|
|
|
"no match ip address prefix-list",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
IP_STR
|
|
|
|
"Match address of route\n"
|
|
|
|
"Match entries of prefix-lists\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_delete (vty, vty->index, "ip address prefix-list",
|
|
|
|
argc == 0 ? NULL : argv[0],
|
|
|
|
RMAP_EVENT_PLIST_DELETED);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_match_ip_address_prefix_list,
|
|
|
|
no_match_ip_address_prefix_list_val_cmd,
|
|
|
|
"no match ip address prefix-list WORD",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
IP_STR
|
|
|
|
"Match address of route\n"
|
|
|
|
"Match entries of prefix-lists\n"
|
|
|
|
"IP prefix-list name\n")
|
|
|
|
|
|
|
|
DEFUN (match_ip_next_hop_prefix_list,
|
|
|
|
match_ip_next_hop_prefix_list_cmd,
|
|
|
|
"match ip next-hop prefix-list WORD",
|
|
|
|
MATCH_STR
|
|
|
|
IP_STR
|
|
|
|
"Match next-hop address of route\n"
|
|
|
|
"Match entries of prefix-lists\n"
|
|
|
|
"IP prefix-list name\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_add (vty, vty->index, "ip next-hop prefix-list",
|
|
|
|
argv[0], RMAP_EVENT_PLIST_ADDED);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_match_ip_next_hop_prefix_list,
|
|
|
|
no_match_ip_next_hop_prefix_list_cmd,
|
|
|
|
"no match ip next-hop prefix-list",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
IP_STR
|
|
|
|
"Match next-hop address of route\n"
|
|
|
|
"Match entries of prefix-lists\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_delete (vty, vty->index, "ip next-hop prefix-list",
|
|
|
|
argc == 0 ? NULL : argv[0],
|
|
|
|
RMAP_EVENT_PLIST_DELETED);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_match_ip_next_hop_prefix_list,
|
|
|
|
no_match_ip_next_hop_prefix_list_val_cmd,
|
|
|
|
"no match ip next-hop prefix-list WORD",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
IP_STR
|
|
|
|
"Match next-hop address of route\n"
|
|
|
|
"Match entries of prefix-lists\n"
|
|
|
|
"IP prefix-list name\n")
|
|
|
|
|
2005-02-02 17:43:17 +01:00
|
|
|
DEFUN (match_ip_route_source_prefix_list,
|
|
|
|
match_ip_route_source_prefix_list_cmd,
|
|
|
|
"match ip route-source prefix-list WORD",
|
|
|
|
MATCH_STR
|
|
|
|
IP_STR
|
|
|
|
"Match advertising source address of route\n"
|
|
|
|
"Match entries of prefix-lists\n"
|
|
|
|
"IP prefix-list name\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_add (vty, vty->index, "ip route-source prefix-list",
|
|
|
|
argv[0], RMAP_EVENT_PLIST_ADDED);
|
2005-02-02 17:43:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_match_ip_route_source_prefix_list,
|
|
|
|
no_match_ip_route_source_prefix_list_cmd,
|
|
|
|
"no match ip route-source prefix-list",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
IP_STR
|
|
|
|
"Match advertising source address of route\n"
|
|
|
|
"Match entries of prefix-lists\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_delete (vty, vty->index, "ip route-source prefix-list",
|
|
|
|
argc == 0 ? NULL : argv[0],
|
|
|
|
RMAP_EVENT_PLIST_DELETED);
|
2005-02-02 17:43:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_match_ip_route_source_prefix_list,
|
|
|
|
no_match_ip_route_source_prefix_list_val_cmd,
|
|
|
|
"no match ip route-source prefix-list WORD",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
IP_STR
|
|
|
|
"Match advertising source address of route\n"
|
|
|
|
"Match entries of prefix-lists\n"
|
2008-08-15 15:05:22 +02:00
|
|
|
"IP prefix-list name\n")
|
2005-02-02 17:43:17 +01:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
DEFUN (match_metric,
|
|
|
|
match_metric_cmd,
|
|
|
|
"match metric <0-4294967295>",
|
|
|
|
MATCH_STR
|
|
|
|
"Match metric of route\n"
|
|
|
|
"Metric value\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_add (vty, vty->index, "metric", argv[0],
|
|
|
|
RMAP_EVENT_MATCH_ADDED);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_match_metric,
|
|
|
|
no_match_metric_cmd,
|
|
|
|
"no match metric",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"Match metric of route\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_delete (vty, vty->index, "metric",
|
|
|
|
argc == 0 ? NULL : argv[0],
|
|
|
|
RMAP_EVENT_MATCH_DELETED);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_match_metric,
|
|
|
|
no_match_metric_val_cmd,
|
|
|
|
"no match metric <0-4294967295>",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"Match metric of route\n"
|
|
|
|
"Metric value\n")
|
|
|
|
|
2015-05-20 02:40:40 +02:00
|
|
|
DEFUN (match_local_pref,
|
|
|
|
match_local_pref_cmd,
|
|
|
|
"match local-preference <0-4294967295>",
|
|
|
|
MATCH_STR
|
|
|
|
"Match local-preference of route\n"
|
|
|
|
"Metric value\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_add (vty, vty->index, "local-preference", argv[0],
|
|
|
|
RMAP_EVENT_MATCH_ADDED);
|
2015-05-20 02:40:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_match_local_pref,
|
|
|
|
no_match_local_pref_cmd,
|
|
|
|
"no match local-preference",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"Match local preference of route\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_delete (vty, vty->index, "local-preference",
|
|
|
|
argc == 0 ? NULL : argv[0],
|
|
|
|
RMAP_EVENT_MATCH_DELETED);
|
2015-05-20 02:40:40 +02:00
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_delete (vty, vty->index, "local-preference", argv[0],
|
|
|
|
RMAP_EVENT_MATCH_DELETED);
|
2015-05-20 02:40:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_match_local_pref,
|
|
|
|
no_match_local_pref_val_cmd,
|
|
|
|
"no match local-preference <0-4294967295>",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"Match local preference of route\n"
|
|
|
|
"Local preference value\n")
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
DEFUN (match_community,
|
|
|
|
match_community_cmd,
|
2005-02-02 17:29:31 +01:00
|
|
|
"match community (<1-99>|<100-500>|WORD)",
|
2002-12-13 21:15:29 +01:00
|
|
|
MATCH_STR
|
|
|
|
"Match BGP community list\n"
|
|
|
|
"Community-list number (standard)\n"
|
|
|
|
"Community-list number (expanded)\n"
|
|
|
|
"Community-list name\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_add (vty, vty->index, "community", argv[0],
|
|
|
|
RMAP_EVENT_CLIST_ADDED);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (match_community_exact,
|
|
|
|
match_community_exact_cmd,
|
2005-02-02 17:29:31 +01:00
|
|
|
"match community (<1-99>|<100-500>|WORD) exact-match",
|
2002-12-13 21:15:29 +01:00
|
|
|
MATCH_STR
|
|
|
|
"Match BGP community list\n"
|
|
|
|
"Community-list number (standard)\n"
|
|
|
|
"Community-list number (expanded)\n"
|
|
|
|
"Community-list name\n"
|
|
|
|
"Do exact matching of communities\n")
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
char *argstr;
|
|
|
|
|
|
|
|
argstr = XMALLOC (MTYPE_ROUTE_MAP_COMPILED,
|
|
|
|
strlen (argv[0]) + strlen ("exact-match") + 2);
|
|
|
|
|
|
|
|
sprintf (argstr, "%s exact-match", argv[0]);
|
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
ret = bgp_route_match_add (vty, vty->index, "community", argstr,
|
|
|
|
RMAP_EVENT_CLIST_ADDED);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, argstr);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_match_community,
|
|
|
|
no_match_community_cmd,
|
|
|
|
"no match community",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"Match BGP community list\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_delete (vty, vty->index, "community", NULL,
|
|
|
|
RMAP_EVENT_CLIST_DELETED);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_match_community,
|
|
|
|
no_match_community_val_cmd,
|
2005-02-02 17:29:31 +01:00
|
|
|
"no match community (<1-99>|<100-500>|WORD)",
|
2002-12-13 21:15:29 +01:00
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"Match BGP community list\n"
|
|
|
|
"Community-list number (standard)\n"
|
|
|
|
"Community-list number (expanded)\n"
|
|
|
|
"Community-list name\n")
|
|
|
|
|
|
|
|
ALIAS (no_match_community,
|
|
|
|
no_match_community_exact_cmd,
|
2005-02-02 17:29:31 +01:00
|
|
|
"no match community (<1-99>|<100-500>|WORD) exact-match",
|
2002-12-13 21:15:29 +01:00
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"Match BGP community list\n"
|
|
|
|
"Community-list number (standard)\n"
|
|
|
|
"Community-list number (expanded)\n"
|
|
|
|
"Community-list name\n"
|
|
|
|
"Do exact matching of communities\n")
|
|
|
|
|
2003-04-19 17:49:49 +02:00
|
|
|
DEFUN (match_ecommunity,
|
|
|
|
match_ecommunity_cmd,
|
2005-02-02 17:29:31 +01:00
|
|
|
"match extcommunity (<1-99>|<100-500>|WORD)",
|
2003-04-19 17:49:49 +02:00
|
|
|
MATCH_STR
|
|
|
|
"Match BGP/VPN extended community list\n"
|
|
|
|
"Extended community-list number (standard)\n"
|
|
|
|
"Extended community-list number (expanded)\n"
|
|
|
|
"Extended community-list name\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_add (vty, vty->index, "extcommunity", argv[0],
|
|
|
|
RMAP_EVENT_ECLIST_ADDED);
|
2003-04-19 17:49:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_match_ecommunity,
|
|
|
|
no_match_ecommunity_cmd,
|
|
|
|
"no match extcommunity",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"Match BGP/VPN extended community list\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_delete (vty, vty->index, "extcommunity", NULL,
|
|
|
|
RMAP_EVENT_ECLIST_DELETED);
|
2003-04-19 17:49:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_match_ecommunity,
|
|
|
|
no_match_ecommunity_val_cmd,
|
2005-02-02 17:29:31 +01:00
|
|
|
"no match extcommunity (<1-99>|<100-500>|WORD)",
|
2003-04-19 17:49:49 +02:00
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"Match BGP/VPN extended community list\n"
|
|
|
|
"Extended community-list number (standard)\n"
|
|
|
|
"Extended community-list number (expanded)\n"
|
|
|
|
"Extended community-list name\n")
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
DEFUN (match_aspath,
|
|
|
|
match_aspath_cmd,
|
|
|
|
"match as-path WORD",
|
|
|
|
MATCH_STR
|
|
|
|
"Match BGP AS path list\n"
|
|
|
|
"AS path access-list name\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_add (vty, vty->index, "as-path", argv[0],
|
|
|
|
RMAP_EVENT_ASLIST_ADDED);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_match_aspath,
|
|
|
|
no_match_aspath_cmd,
|
|
|
|
"no match as-path",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"Match BGP AS path list\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_delete (vty, vty->index, "as-path", NULL,
|
|
|
|
RMAP_EVENT_ASLIST_DELETED);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_match_aspath,
|
|
|
|
no_match_aspath_val_cmd,
|
|
|
|
"no match as-path WORD",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"Match BGP AS path list\n"
|
|
|
|
"AS path access-list name\n")
|
|
|
|
|
|
|
|
DEFUN (match_origin,
|
|
|
|
match_origin_cmd,
|
|
|
|
"match origin (egp|igp|incomplete)",
|
|
|
|
MATCH_STR
|
|
|
|
"BGP origin code\n"
|
|
|
|
"remote EGP\n"
|
|
|
|
"local IGP\n"
|
|
|
|
"unknown heritage\n")
|
|
|
|
{
|
|
|
|
if (strncmp (argv[0], "igp", 2) == 0)
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_add (vty, vty->index, "origin", "igp",
|
|
|
|
RMAP_EVENT_MATCH_ADDED);
|
2002-12-13 21:15:29 +01:00
|
|
|
if (strncmp (argv[0], "egp", 1) == 0)
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_add (vty, vty->index, "origin", "egp",
|
|
|
|
RMAP_EVENT_MATCH_ADDED);
|
2002-12-13 21:15:29 +01:00
|
|
|
if (strncmp (argv[0], "incomplete", 2) == 0)
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_add (vty, vty->index, "origin", "incomplete",
|
|
|
|
RMAP_EVENT_MATCH_ADDED);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_match_origin,
|
|
|
|
no_match_origin_cmd,
|
|
|
|
"no match origin",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"BGP origin code\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_delete (vty, vty->index, "origin", NULL,
|
|
|
|
RMAP_EVENT_MATCH_DELETED);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_match_origin,
|
|
|
|
no_match_origin_val_cmd,
|
|
|
|
"no match origin (egp|igp|incomplete)",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"BGP origin code\n"
|
|
|
|
"remote EGP\n"
|
|
|
|
"local IGP\n"
|
|
|
|
"unknown heritage\n")
|
|
|
|
|
2015-05-20 02:40:47 +02:00
|
|
|
DEFUN (match_interface,
|
|
|
|
match_interface_cmd,
|
|
|
|
"match interface WORD",
|
|
|
|
MATCH_STR
|
|
|
|
"Match first hop interface of route\n"
|
|
|
|
"Interface name\n")
|
|
|
|
{
|
|
|
|
return bgp_route_match_add (vty, vty->index, "interface", argv[0],
|
|
|
|
RMAP_EVENT_MATCH_ADDED);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_match_interface,
|
|
|
|
no_match_interface_cmd,
|
|
|
|
"no match interface",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"Match first hop interface of route\n")
|
|
|
|
{
|
|
|
|
if (argc == 0)
|
|
|
|
return bgp_route_match_delete (vty, vty->index, "interface", NULL,
|
|
|
|
RMAP_EVENT_MATCH_DELETED);
|
|
|
|
|
|
|
|
return bgp_route_match_delete (vty, vty->index, "interface", argv[0],
|
|
|
|
RMAP_EVENT_MATCH_DELETED);
|
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_match_interface,
|
|
|
|
no_match_interface_val_cmd,
|
|
|
|
"no match interface WORD",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"Match first hop interface of route\n"
|
|
|
|
"Interface name\n")
|
|
|
|
|
2015-05-20 02:46:33 +02:00
|
|
|
DEFUN (match_tag,
|
|
|
|
match_tag_cmd,
|
|
|
|
"match tag <1-65535>",
|
|
|
|
MATCH_STR
|
|
|
|
"Match tag of route\n"
|
|
|
|
"Tag value\n")
|
|
|
|
{
|
|
|
|
return bgp_route_match_add (vty, vty->index, "tag", argv[0],
|
|
|
|
RMAP_EVENT_MATCH_ADDED);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_match_tag,
|
|
|
|
no_match_tag_cmd,
|
|
|
|
"no match tag",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"Match tag of route\n")
|
|
|
|
{
|
|
|
|
if (argc == 0)
|
|
|
|
return bgp_route_match_delete (vty, vty->index, "tag", NULL,
|
|
|
|
RMAP_EVENT_MATCH_DELETED);
|
|
|
|
|
|
|
|
return bgp_route_match_delete (vty, vty->index, "tag", argv[0],
|
|
|
|
RMAP_EVENT_MATCH_DELETED);
|
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_match_tag,
|
|
|
|
no_match_tag_val_cmd,
|
|
|
|
"no match tag <1-65535>",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"Match tag of route\n"
|
|
|
|
"Tag value\n")
|
|
|
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
DEFUN (set_ip_nexthop,
|
|
|
|
set_ip_nexthop_cmd,
|
2003-11-02 08:24:40 +01:00
|
|
|
"set ip next-hop A.B.C.D",
|
2002-12-13 21:15:29 +01:00
|
|
|
SET_STR
|
|
|
|
IP_STR
|
|
|
|
"Next hop address\n"
|
2003-11-02 08:24:40 +01:00
|
|
|
"IP address of next hop\n")
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
union sockunion su;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = str2sockunion (argv[0], &su);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
vty_out (vty, "%% Malformed Next-hop address%s", VTY_NEWLINE);
|
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bgp_route_set_add (vty, vty->index, "ip next-hop", argv[0]);
|
|
|
|
}
|
|
|
|
|
2003-11-02 08:24:40 +01:00
|
|
|
DEFUN (set_ip_nexthop_peer,
|
|
|
|
set_ip_nexthop_peer_cmd,
|
|
|
|
"set ip next-hop peer-address",
|
|
|
|
SET_STR
|
|
|
|
IP_STR
|
|
|
|
"Next hop address\n"
|
|
|
|
"Use peer address (for BGP only)\n")
|
|
|
|
{
|
|
|
|
return bgp_route_set_add (vty, vty->index, "ip next-hop", "peer-address");
|
|
|
|
}
|
|
|
|
|
2005-06-28 14:44:16 +02:00
|
|
|
DEFUN_DEPRECATED (no_set_ip_nexthop_peer,
|
2003-11-02 08:24:40 +01:00
|
|
|
no_set_ip_nexthop_peer_cmd,
|
|
|
|
"no set ip next-hop peer-address",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
IP_STR
|
|
|
|
"Next hop address\n"
|
|
|
|
"Use peer address (for BGP only)\n")
|
|
|
|
{
|
|
|
|
return bgp_route_set_delete (vty, vty->index, "ip next-hop", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
DEFUN (no_set_ip_nexthop,
|
|
|
|
no_set_ip_nexthop_cmd,
|
|
|
|
"no set ip next-hop",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"Next hop address\n")
|
|
|
|
{
|
2003-11-02 08:24:40 +01:00
|
|
|
if (argc == 0)
|
2002-12-13 21:15:29 +01:00
|
|
|
return bgp_route_set_delete (vty, vty->index, "ip next-hop", NULL);
|
|
|
|
|
|
|
|
return bgp_route_set_delete (vty, vty->index, "ip next-hop", argv[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_set_ip_nexthop,
|
|
|
|
no_set_ip_nexthop_val_cmd,
|
2003-11-02 08:24:40 +01:00
|
|
|
"no set ip next-hop A.B.C.D",
|
2002-12-13 21:15:29 +01:00
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
IP_STR
|
|
|
|
"Next hop address\n"
|
2003-11-02 08:24:40 +01:00
|
|
|
"IP address of next hop\n")
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
DEFUN (set_metric,
|
|
|
|
set_metric_cmd,
|
2003-04-19 17:49:49 +02:00
|
|
|
"set metric <0-4294967295>",
|
2002-12-13 21:15:29 +01:00
|
|
|
SET_STR
|
|
|
|
"Metric value for destination routing protocol\n"
|
2003-04-19 17:49:49 +02:00
|
|
|
"Metric value\n")
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
return bgp_route_set_add (vty, vty->index, "metric", argv[0]);
|
|
|
|
}
|
|
|
|
|
2003-04-19 17:49:49 +02:00
|
|
|
ALIAS (set_metric,
|
|
|
|
set_metric_addsub_cmd,
|
|
|
|
"set metric <+/-metric>",
|
|
|
|
SET_STR
|
|
|
|
"Metric value for destination routing protocol\n"
|
2005-05-28 06:50:54 +02:00
|
|
|
"Add or subtract metric\n")
|
2003-04-19 17:49:49 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
DEFUN (no_set_metric,
|
|
|
|
no_set_metric_cmd,
|
|
|
|
"no set metric",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"Metric value for destination routing protocol\n")
|
|
|
|
{
|
|
|
|
if (argc == 0)
|
|
|
|
return bgp_route_set_delete (vty, vty->index, "metric", NULL);
|
|
|
|
|
|
|
|
return bgp_route_set_delete (vty, vty->index, "metric", argv[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_set_metric,
|
|
|
|
no_set_metric_val_cmd,
|
|
|
|
"no set metric <0-4294967295>",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"Metric value for destination routing protocol\n"
|
|
|
|
"Metric value\n")
|
|
|
|
|
|
|
|
DEFUN (set_local_pref,
|
|
|
|
set_local_pref_cmd,
|
|
|
|
"set local-preference <0-4294967295>",
|
|
|
|
SET_STR
|
|
|
|
"BGP local preference path attribute\n"
|
|
|
|
"Preference value\n")
|
|
|
|
{
|
|
|
|
return bgp_route_set_add (vty, vty->index, "local-preference", argv[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_set_local_pref,
|
|
|
|
no_set_local_pref_cmd,
|
|
|
|
"no set local-preference",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"BGP local preference path attribute\n")
|
|
|
|
{
|
|
|
|
if (argc == 0)
|
|
|
|
return bgp_route_set_delete (vty, vty->index, "local-preference", NULL);
|
|
|
|
|
|
|
|
return bgp_route_set_delete (vty, vty->index, "local-preference", argv[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_set_local_pref,
|
|
|
|
no_set_local_pref_val_cmd,
|
|
|
|
"no set local-preference <0-4294967295>",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"BGP local preference path attribute\n"
|
|
|
|
"Preference value\n")
|
|
|
|
|
|
|
|
DEFUN (set_weight,
|
|
|
|
set_weight_cmd,
|
|
|
|
"set weight <0-4294967295>",
|
|
|
|
SET_STR
|
|
|
|
"BGP weight for routing table\n"
|
|
|
|
"Weight value\n")
|
|
|
|
{
|
|
|
|
return bgp_route_set_add (vty, vty->index, "weight", argv[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_set_weight,
|
|
|
|
no_set_weight_cmd,
|
|
|
|
"no set weight",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"BGP weight for routing table\n")
|
|
|
|
{
|
|
|
|
if (argc == 0)
|
|
|
|
return bgp_route_set_delete (vty, vty->index, "weight", NULL);
|
|
|
|
|
|
|
|
return bgp_route_set_delete (vty, vty->index, "weight", argv[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_set_weight,
|
|
|
|
no_set_weight_val_cmd,
|
|
|
|
"no set weight <0-4294967295>",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"BGP weight for routing table\n"
|
|
|
|
"Weight value\n")
|
|
|
|
|
|
|
|
DEFUN (set_aspath_prepend,
|
|
|
|
set_aspath_prepend_cmd,
|
2009-06-09 13:15:33 +02:00
|
|
|
"set as-path prepend ." CMD_AS_RANGE,
|
2002-12-13 21:15:29 +01:00
|
|
|
SET_STR
|
2008-04-10 13:47:45 +02:00
|
|
|
"Transform BGP AS_PATH attribute\n"
|
2002-12-13 21:15:29 +01:00
|
|
|
"Prepend to the as-path\n"
|
|
|
|
"AS number\n")
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
str = argv_concat (argv, argc, 0);
|
|
|
|
ret = bgp_route_set_add (vty, vty->index, "as-path prepend", str);
|
|
|
|
XFREE (MTYPE_TMP, str);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_set_aspath_prepend,
|
|
|
|
no_set_aspath_prepend_cmd,
|
|
|
|
"no set as-path prepend",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
2008-04-10 13:47:45 +02:00
|
|
|
"Transform BGP AS_PATH attribute\n"
|
2002-12-13 21:15:29 +01:00
|
|
|
"Prepend to the as-path\n")
|
|
|
|
{
|
2007-12-18 16:13:06 +01:00
|
|
|
int ret;
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
if (argc == 0)
|
|
|
|
return bgp_route_set_delete (vty, vty->index, "as-path prepend", NULL);
|
|
|
|
|
|
|
|
str = argv_concat (argv, argc, 0);
|
|
|
|
ret = bgp_route_set_delete (vty, vty->index, "as-path prepend", str);
|
|
|
|
XFREE (MTYPE_TMP, str);
|
|
|
|
return ret;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_set_aspath_prepend,
|
|
|
|
no_set_aspath_prepend_val_cmd,
|
2009-06-09 13:15:33 +02:00
|
|
|
"no set as-path prepend ." CMD_AS_RANGE,
|
2002-12-13 21:15:29 +01:00
|
|
|
NO_STR
|
|
|
|
SET_STR
|
2008-04-10 13:47:45 +02:00
|
|
|
"Transform BGP AS_PATH attribute\n"
|
2002-12-13 21:15:29 +01:00
|
|
|
"Prepend to the as-path\n"
|
|
|
|
"AS number\n")
|
|
|
|
|
2008-04-10 13:47:45 +02:00
|
|
|
DEFUN (set_aspath_exclude,
|
|
|
|
set_aspath_exclude_cmd,
|
2009-06-09 13:15:33 +02:00
|
|
|
"set as-path exclude ." CMD_AS_RANGE,
|
2008-04-10 13:47:45 +02:00
|
|
|
SET_STR
|
|
|
|
"Transform BGP AS-path attribute\n"
|
|
|
|
"Exclude from the as-path\n"
|
|
|
|
"AS number\n")
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
str = argv_concat (argv, argc, 0);
|
|
|
|
ret = bgp_route_set_add (vty, vty->index, "as-path exclude", str);
|
|
|
|
XFREE (MTYPE_TMP, str);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_set_aspath_exclude,
|
|
|
|
no_set_aspath_exclude_cmd,
|
|
|
|
"no set as-path exclude",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"Transform BGP AS_PATH attribute\n"
|
|
|
|
"Exclude from the as-path\n")
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
if (argc == 0)
|
|
|
|
return bgp_route_set_delete (vty, vty->index, "as-path exclude", NULL);
|
|
|
|
|
|
|
|
str = argv_concat (argv, argc, 0);
|
|
|
|
ret = bgp_route_set_delete (vty, vty->index, "as-path exclude", str);
|
|
|
|
XFREE (MTYPE_TMP, str);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_set_aspath_exclude,
|
|
|
|
no_set_aspath_exclude_val_cmd,
|
2009-06-09 13:15:33 +02:00
|
|
|
"no set as-path exclude ." CMD_AS_RANGE,
|
2008-04-10 13:47:45 +02:00
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"Transform BGP AS_PATH attribute\n"
|
|
|
|
"Exclude from the as-path\n"
|
|
|
|
"AS number\n")
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
DEFUN (set_community,
|
|
|
|
set_community_cmd,
|
|
|
|
"set community .AA:NN",
|
|
|
|
SET_STR
|
|
|
|
"BGP community attribute\n"
|
|
|
|
"Community number in aa:nn format or local-AS|no-advertise|no-export|internet or additive\n")
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int first = 0;
|
|
|
|
int additive = 0;
|
|
|
|
struct buffer *b;
|
|
|
|
struct community *com = NULL;
|
|
|
|
char *str;
|
|
|
|
char *argstr;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
b = buffer_new (1024);
|
|
|
|
|
|
|
|
for (i = 0; i < argc; i++)
|
|
|
|
{
|
|
|
|
if (strncmp (argv[i], "additive", strlen (argv[i])) == 0)
|
|
|
|
{
|
|
|
|
additive = 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (first)
|
|
|
|
buffer_putc (b, ' ');
|
|
|
|
else
|
|
|
|
first = 1;
|
|
|
|
|
|
|
|
if (strncmp (argv[i], "internet", strlen (argv[i])) == 0)
|
|
|
|
{
|
|
|
|
buffer_putstr (b, "internet");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (strncmp (argv[i], "local-AS", strlen (argv[i])) == 0)
|
|
|
|
{
|
|
|
|
buffer_putstr (b, "local-AS");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (strncmp (argv[i], "no-a", strlen ("no-a")) == 0
|
|
|
|
&& strncmp (argv[i], "no-advertise", strlen (argv[i])) == 0)
|
|
|
|
{
|
|
|
|
buffer_putstr (b, "no-advertise");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (strncmp (argv[i], "no-e", strlen ("no-e"))== 0
|
|
|
|
&& strncmp (argv[i], "no-export", strlen (argv[i])) == 0)
|
|
|
|
{
|
|
|
|
buffer_putstr (b, "no-export");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
buffer_putstr (b, argv[i]);
|
|
|
|
}
|
|
|
|
buffer_putc (b, '\0');
|
|
|
|
|
|
|
|
/* Fetch result string then compile it to communities attribute. */
|
|
|
|
str = buffer_getstr (b);
|
|
|
|
buffer_free (b);
|
|
|
|
|
|
|
|
if (str)
|
|
|
|
{
|
|
|
|
com = community_str2com (str);
|
2005-01-29 19:19:13 +01:00
|
|
|
XFREE (MTYPE_TMP, str);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Can't compile user input into communities attribute. */
|
|
|
|
if (! com)
|
|
|
|
{
|
|
|
|
vty_out (vty, "%% Malformed communities attribute%s", VTY_NEWLINE);
|
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set communites attribute string. */
|
|
|
|
str = community_str (com);
|
|
|
|
|
|
|
|
if (additive)
|
|
|
|
{
|
|
|
|
argstr = XCALLOC (MTYPE_TMP, strlen (str) + strlen (" additive") + 1);
|
|
|
|
strcpy (argstr, str);
|
|
|
|
strcpy (argstr + strlen (str), " additive");
|
|
|
|
ret = bgp_route_set_add (vty, vty->index, "community", argstr);
|
|
|
|
XFREE (MTYPE_TMP, argstr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = bgp_route_set_add (vty, vty->index, "community", str);
|
|
|
|
|
|
|
|
community_free (com);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (set_community_none,
|
|
|
|
set_community_none_cmd,
|
|
|
|
"set community none",
|
|
|
|
SET_STR
|
|
|
|
"BGP community attribute\n"
|
|
|
|
"No community attribute\n")
|
|
|
|
{
|
|
|
|
return bgp_route_set_add (vty, vty->index, "community", "none");
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_set_community,
|
|
|
|
no_set_community_cmd,
|
|
|
|
"no set community",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"BGP community attribute\n")
|
|
|
|
{
|
|
|
|
return bgp_route_set_delete (vty, vty->index, "community", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_set_community,
|
|
|
|
no_set_community_val_cmd,
|
|
|
|
"no set community .AA:NN",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"BGP community attribute\n"
|
|
|
|
"Community number in aa:nn format or local-AS|no-advertise|no-export|internet or additive\n")
|
|
|
|
|
|
|
|
ALIAS (no_set_community,
|
|
|
|
no_set_community_none_cmd,
|
|
|
|
"no set community none",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"BGP community attribute\n"
|
|
|
|
"No community attribute\n")
|
|
|
|
|
|
|
|
DEFUN (set_community_delete,
|
|
|
|
set_community_delete_cmd,
|
2005-02-02 17:29:31 +01:00
|
|
|
"set comm-list (<1-99>|<100-500>|WORD) delete",
|
2002-12-13 21:15:29 +01:00
|
|
|
SET_STR
|
|
|
|
"set BGP community list (for deletion)\n"
|
|
|
|
"Community-list number (standard)\n"
|
2015-05-20 02:47:22 +02:00
|
|
|
"Community-list number (expanded)\n"
|
2002-12-13 21:15:29 +01:00
|
|
|
"Community-list name\n"
|
|
|
|
"Delete matching communities\n")
|
|
|
|
{
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
str = XCALLOC (MTYPE_TMP, strlen (argv[0]) + strlen (" delete") + 1);
|
|
|
|
strcpy (str, argv[0]);
|
|
|
|
strcpy (str + strlen (argv[0]), " delete");
|
|
|
|
|
|
|
|
bgp_route_set_add (vty, vty->index, "comm-list", str);
|
|
|
|
|
|
|
|
XFREE (MTYPE_TMP, str);
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_set_community_delete,
|
|
|
|
no_set_community_delete_cmd,
|
|
|
|
"no set comm-list",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"set BGP community list (for deletion)\n")
|
|
|
|
{
|
|
|
|
return bgp_route_set_delete (vty, vty->index, "comm-list", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_set_community_delete,
|
|
|
|
no_set_community_delete_val_cmd,
|
2005-02-02 17:29:31 +01:00
|
|
|
"no set comm-list (<1-99>|<100-500>|WORD) delete",
|
2002-12-13 21:15:29 +01:00
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"set BGP community list (for deletion)\n"
|
|
|
|
"Community-list number (standard)\n"
|
2015-05-20 02:47:22 +02:00
|
|
|
"Community-list number (expanded)\n"
|
2002-12-13 21:15:29 +01:00
|
|
|
"Community-list name\n"
|
|
|
|
"Delete matching communities\n")
|
|
|
|
|
|
|
|
DEFUN (set_ecommunity_rt,
|
|
|
|
set_ecommunity_rt_cmd,
|
|
|
|
"set extcommunity rt .ASN:nn_or_IP-address:nn",
|
|
|
|
SET_STR
|
|
|
|
"BGP extended community attribute\n"
|
2009-06-01 18:20:36 +02:00
|
|
|
"Route Target extended community\n"
|
2002-12-13 21:15:29 +01:00
|
|
|
"VPN extended community\n")
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
str = argv_concat (argv, argc, 0);
|
|
|
|
ret = bgp_route_set_add (vty, vty->index, "extcommunity rt", str);
|
|
|
|
XFREE (MTYPE_TMP, str);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_set_ecommunity_rt,
|
|
|
|
no_set_ecommunity_rt_cmd,
|
|
|
|
"no set extcommunity rt",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"BGP extended community attribute\n"
|
2009-06-01 18:20:36 +02:00
|
|
|
"Route Target extended community\n")
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
return bgp_route_set_delete (vty, vty->index, "extcommunity rt", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_set_ecommunity_rt,
|
|
|
|
no_set_ecommunity_rt_val_cmd,
|
|
|
|
"no set extcommunity rt .ASN:nn_or_IP-address:nn",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"BGP extended community attribute\n"
|
2009-06-01 18:20:36 +02:00
|
|
|
"Route Target extended community\n"
|
2002-12-13 21:15:29 +01:00
|
|
|
"VPN extended community\n")
|
|
|
|
|
|
|
|
DEFUN (set_ecommunity_soo,
|
|
|
|
set_ecommunity_soo_cmd,
|
|
|
|
"set extcommunity soo .ASN:nn_or_IP-address:nn",
|
|
|
|
SET_STR
|
|
|
|
"BGP extended community attribute\n"
|
|
|
|
"Site-of-Origin extended community\n"
|
|
|
|
"VPN extended community\n")
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
str = argv_concat (argv, argc, 0);
|
|
|
|
ret = bgp_route_set_add (vty, vty->index, "extcommunity soo", str);
|
|
|
|
XFREE (MTYPE_TMP, str);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_set_ecommunity_soo,
|
|
|
|
no_set_ecommunity_soo_cmd,
|
|
|
|
"no set extcommunity soo",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"BGP extended community attribute\n"
|
|
|
|
"Site-of-Origin extended community\n")
|
|
|
|
{
|
|
|
|
return bgp_route_set_delete (vty, vty->index, "extcommunity soo", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_set_ecommunity_soo,
|
|
|
|
no_set_ecommunity_soo_val_cmd,
|
|
|
|
"no set extcommunity soo .ASN:nn_or_IP-address:nn",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"BGP extended community attribute\n"
|
|
|
|
"Site-of-Origin extended community\n"
|
|
|
|
"VPN extended community\n")
|
|
|
|
|
|
|
|
DEFUN (set_origin,
|
|
|
|
set_origin_cmd,
|
|
|
|
"set origin (egp|igp|incomplete)",
|
|
|
|
SET_STR
|
|
|
|
"BGP origin code\n"
|
|
|
|
"remote EGP\n"
|
|
|
|
"local IGP\n"
|
|
|
|
"unknown heritage\n")
|
|
|
|
{
|
|
|
|
if (strncmp (argv[0], "igp", 2) == 0)
|
|
|
|
return bgp_route_set_add (vty, vty->index, "origin", "igp");
|
|
|
|
if (strncmp (argv[0], "egp", 1) == 0)
|
|
|
|
return bgp_route_set_add (vty, vty->index, "origin", "egp");
|
|
|
|
if (strncmp (argv[0], "incomplete", 2) == 0)
|
|
|
|
return bgp_route_set_add (vty, vty->index, "origin", "incomplete");
|
|
|
|
|
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_set_origin,
|
|
|
|
no_set_origin_cmd,
|
|
|
|
"no set origin",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"BGP origin code\n")
|
|
|
|
{
|
|
|
|
return bgp_route_set_delete (vty, vty->index, "origin", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_set_origin,
|
|
|
|
no_set_origin_val_cmd,
|
|
|
|
"no set origin (egp|igp|incomplete)",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"BGP origin code\n"
|
|
|
|
"remote EGP\n"
|
|
|
|
"local IGP\n"
|
|
|
|
"unknown heritage\n")
|
|
|
|
|
|
|
|
DEFUN (set_atomic_aggregate,
|
|
|
|
set_atomic_aggregate_cmd,
|
|
|
|
"set atomic-aggregate",
|
|
|
|
SET_STR
|
|
|
|
"BGP atomic aggregate attribute\n" )
|
|
|
|
{
|
|
|
|
return bgp_route_set_add (vty, vty->index, "atomic-aggregate", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_set_atomic_aggregate,
|
|
|
|
no_set_atomic_aggregate_cmd,
|
|
|
|
"no set atomic-aggregate",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"BGP atomic aggregate attribute\n" )
|
|
|
|
{
|
|
|
|
return bgp_route_set_delete (vty, vty->index, "atomic-aggregate", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (set_aggregator_as,
|
|
|
|
set_aggregator_as_cmd,
|
2008-07-02 15:40:33 +02:00
|
|
|
"set aggregator as " CMD_AS_RANGE " A.B.C.D",
|
2002-12-13 21:15:29 +01:00
|
|
|
SET_STR
|
|
|
|
"BGP aggregator attribute\n"
|
|
|
|
"AS number of aggregator\n"
|
|
|
|
"AS number\n"
|
|
|
|
"IP address of aggregator\n")
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
as_t as;
|
|
|
|
struct in_addr address;
|
|
|
|
char *argstr;
|
|
|
|
|
[bgpd] Merge AS4 support
2007-10-14 Paul Jakma <paul.jakma@sun.com>
* NEWS: Note that MRT dumps are now version 2
* (general) Merge in Juergen Kammer's AS4 patch.
2007-09-27 Paul Jakma <paul.jakma@sun.com>
* bgp_aspath.c: (assegment_normalise) remove duplicates from
from sets.
(aspath_reconcile_as4) disregard a broken part of the RFC around
error handling in path reconciliation.
* aspath_test.c: Test dupe-weeding from sets.
Test that reconciliation merges AS_PATH and AS4_PATH where
former is shorter than latter.
2007-09-26 Paul Jakma <paul.jakma@sun.com>
* aspath_test.c: Test AS4_PATH reconcilation where length
of AS_PATH and AS4_PATH is same.
2007-09-25 Paul Jakma <paul.jakma@sun.com>
* bgp_open.c: (peek_for_as4_capability) Fix to work.
* bgp_packet.c: (bgp_open_receive) Fix sanity check of as4.
* tests/bgp_capability_test.c: (general) Extend tests to validate
peek_for_as4_capability.
Add test of full OPEN Option block, with multiple capabilities,
both as a series of Option, and a single option.
Add some crap to beginning of stream, to prevent code depending
on getp == 0.
2007-09-18 Paul Jakma <paul.jakma@sun.com>
* bgp_open.c: (bgp_capability_as4) debug printf inline with others.
(peek_for_as4_capability) There's no need to signal failure, as
failure is better dealt with through full capability parser -
just return the AS4, simpler.
* bgp_packet.c: (bgp_open_receive) Update to match
peek_for_as4_capability change.
Allow use of BGP_AS_TRANS by 2b speakers.
Use NOTIFY_OPEN_ERR rather than CEASE for OPEN parsing errors.
(bgp_capability_msg_parse) missing argument to debug print
(bgp_capability_receive) missing return values.
* tests/bgp_capability_test.c: (parse_test) update for changes to
peek_for_as4_capability
2007-07-25 Paul Jakma <paul.jakma@sun.com>
* Remove 2-byte size macros, just make existing macros take
argument to indicate which size to use.
Adjust all users - typically they want '1'.
* bgp_aspath.c: (aspath_has_as4) New, return 1 if there are any
as4's in a path.
(aspath_put) Return the number of bytes actually written, to
fix the bug Juergen noted: Splitting of segments will change
the number of bytes written from that already written to the
AS_PATH header.
(aspath_snmp_pathseg) Pass 2-byte flag to aspath_put. SNMP
is still defined as 2b.
(aspath_aggregate) fix latent bug.
(aspath_reconcile_as4) AS_PATH+NEW_AS_PATH reconciliation
function.
(aspath_key_make) Hash the AS_PATH string, rather than
just taking the addition of assegment ASes as the hash value,
hopefully sligthly more collision resistant.
(bgp_attr_munge_as4_attrs) Collide the NEW_ attributes
together with the OLD 2-byte forms, code Juergen
had in bgp_attr_parse but re-organised a bit.
(bgp_attr_parse) Bunch of code from Juergen moves
to previous function.
(bgp_packet_attribute) Compact significantly by
just /always/ using extended-length attr header.
Fix bug Juergen noted, by using aspath_put's
(new) returned size value for the attr header rather
than the (guesstimate) of aspath_size() - the two could
differ when aspath_put had to split large segments, unlikely
this bug was ever hit in the 'wild'.
(bgp_dump_routes_attr) Always use extended-len and
use aspath_put return for header length. Output 4b ASN
for AS_PATH and AGGREGATOR.
* bgp_ecommunity.c: (ecommunity_{hash_make,cmp}) fix
hash callback declarations to match prototypes.
(ecommunity_gettoken) Updated for ECOMMUNITY_ENCODE_AS4,
complete rewrite of Juergen's changes (no asdot support)
* bgp_open.c: (bgp_capability_as4) New, does what it says
on the tin.
(peek_for_as4_capability) Rewritten to use streams and
bgp_capability_as4.
* bgp_packet.c: (bgp_open_send) minor edit
checked (in the abstract at least) with Juergen.
Changes are to be more accepting, e.g, allow AS_TRANS on
a 2-byte session.
* (general) Update all commands to use CMD_AS_RANGE.
* bgp_vty.c: (bgp_clear) Fix return vals to use CMD_..
Remove stuff replicated by VTY_GET_LONG
(bgp_clear_vty) Return bgp_clear directly to vty.
* tests/aspath_test.c: Exercise 32bit parsing. Test reconcile
function.
* tests/ecommunity_test.c: New, test AS4 ecommunity changes,
positive test only at this time, error cases not tested yet.
2007-07-25 Juergen Kammer <j.kammer@eurodata.de>
* (general) AS4 support.
* bgpd.h: as_t changes to 4-bytes.
* bgp_aspath.h: Add BGP_AS4_MAX and BGP_AS_TRANS defines.
* bgp_aspath.c: AS_VALUE_SIZE becomes 4-byte, AS16_VALUE_SIZE
added for 2-byte.
Add AS16 versions of length calc macros.
(aspath_count_numas) New, count number of ASes.
(aspath_has_as4) New, return 1 if there are any as4's in a
path.
(assegments_parse) Interpret assegment as 4 or 2 byte,
according to how the caller instructs us, with a new
argument.
(aspath_parse) Add use32bit argument to pass to
assegments_parse. Adjust all its callers to pass 1, unless
otherwise noted.
(assegment_data_put) Adjust to be able to write 2 or 4 byte
AS, according to new use32bit argument.
(aspath_put) Adjust to write 2 or 4.
(aspath_gettoken) Use a long for passed in asno.
* bgp_attr.c: (attr_str) Add BGP_ATTR_AS4_PATH and
BGP_ATTR_AS4_AGGREGATOR.
(bgp_attr_aspath) Call aspath_parse with right 2/4 arg, as
determined by received-capability flag.
(bgp_attr_aspath_check) New, code previously in attr_aspath
but moved to new func so it can be run after NEW_AS_PATH
reconciliation.
(bgp_attr_as4_path) New, handle NEW_AS_PATH.
(bgp_attr_aggregator) Adjust to cope with 2/4 byte ASes.
(bgp_attr_as4_aggregator) New, read NEW_AGGREGATOR.
(bgp_attr_parse) Add handoffs to previous parsers for the two
new AS4 NEW_ attributes.
Various checks added for NEW/OLD reconciliation.
(bgp_packet_attribute) Support 2/4 for AS_PATH and
AGGREGATOR, detect when NEW_ attrs need to be sent.
* bgp_debug.{c,h}: Add 'debug bgp as4'.
* bgp_dump.c: MRTv2 support, unconditionally enabled, which
supports AS4. Based on patches from Erik (RIPE?).
* bgp_ecommunity.c: (ecommunity_ecom2str) ECOMMUNITY_ENCODE_AS4
support.
* bgp_open.c: (peek_for_as4_capability) New, peek for AS4
capability prior to full capability parsing, so we know which
ASN to use for struct peer lookup.
(bgp_open_capability) Always send AS4 capability.
* bgp_packet.c: (bgp_open_send) AS4 handling for AS field
(bgp_open_receive) Peek for AS4 capability first, and figure
out which AS to believe.
* bgp_vty.c: (bgp_show_peer) Print AS4 cap
* tests/aspath_test.c: Support asn32 changes, call aspath_parse
with 16 bit.
* vtysh/extract.pl: AS4 compatibility for router bgp ASNUMBER
* vtysh/extract.pl.in: AS4 compatibility for router bgp ASNUMBER
* vtysh/vtysh.c: AS4 compatibility for router bgp ASNUMBER
2007-10-15 00:32:21 +02:00
|
|
|
VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
|
2004-10-13 07:06:08 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
ret = inet_aton (argv[1], &address);
|
|
|
|
if (ret == 0)
|
|
|
|
{
|
|
|
|
vty_out (vty, "Aggregator IP address is invalid%s", VTY_NEWLINE);
|
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
|
|
|
|
argstr = XMALLOC (MTYPE_ROUTE_MAP_COMPILED,
|
|
|
|
strlen (argv[0]) + strlen (argv[1]) + 2);
|
|
|
|
|
|
|
|
sprintf (argstr, "%s %s", argv[0], argv[1]);
|
|
|
|
|
|
|
|
ret = bgp_route_set_add (vty, vty->index, "aggregator as", argstr);
|
|
|
|
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, argstr);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_set_aggregator_as,
|
|
|
|
no_set_aggregator_as_cmd,
|
|
|
|
"no set aggregator as",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"BGP aggregator attribute\n"
|
|
|
|
"AS number of aggregator\n")
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
as_t as;
|
|
|
|
struct in_addr address;
|
|
|
|
char *argstr;
|
|
|
|
|
|
|
|
if (argv == 0)
|
|
|
|
return bgp_route_set_delete (vty, vty->index, "aggregator as", NULL);
|
|
|
|
|
[bgpd] Merge AS4 support
2007-10-14 Paul Jakma <paul.jakma@sun.com>
* NEWS: Note that MRT dumps are now version 2
* (general) Merge in Juergen Kammer's AS4 patch.
2007-09-27 Paul Jakma <paul.jakma@sun.com>
* bgp_aspath.c: (assegment_normalise) remove duplicates from
from sets.
(aspath_reconcile_as4) disregard a broken part of the RFC around
error handling in path reconciliation.
* aspath_test.c: Test dupe-weeding from sets.
Test that reconciliation merges AS_PATH and AS4_PATH where
former is shorter than latter.
2007-09-26 Paul Jakma <paul.jakma@sun.com>
* aspath_test.c: Test AS4_PATH reconcilation where length
of AS_PATH and AS4_PATH is same.
2007-09-25 Paul Jakma <paul.jakma@sun.com>
* bgp_open.c: (peek_for_as4_capability) Fix to work.
* bgp_packet.c: (bgp_open_receive) Fix sanity check of as4.
* tests/bgp_capability_test.c: (general) Extend tests to validate
peek_for_as4_capability.
Add test of full OPEN Option block, with multiple capabilities,
both as a series of Option, and a single option.
Add some crap to beginning of stream, to prevent code depending
on getp == 0.
2007-09-18 Paul Jakma <paul.jakma@sun.com>
* bgp_open.c: (bgp_capability_as4) debug printf inline with others.
(peek_for_as4_capability) There's no need to signal failure, as
failure is better dealt with through full capability parser -
just return the AS4, simpler.
* bgp_packet.c: (bgp_open_receive) Update to match
peek_for_as4_capability change.
Allow use of BGP_AS_TRANS by 2b speakers.
Use NOTIFY_OPEN_ERR rather than CEASE for OPEN parsing errors.
(bgp_capability_msg_parse) missing argument to debug print
(bgp_capability_receive) missing return values.
* tests/bgp_capability_test.c: (parse_test) update for changes to
peek_for_as4_capability
2007-07-25 Paul Jakma <paul.jakma@sun.com>
* Remove 2-byte size macros, just make existing macros take
argument to indicate which size to use.
Adjust all users - typically they want '1'.
* bgp_aspath.c: (aspath_has_as4) New, return 1 if there are any
as4's in a path.
(aspath_put) Return the number of bytes actually written, to
fix the bug Juergen noted: Splitting of segments will change
the number of bytes written from that already written to the
AS_PATH header.
(aspath_snmp_pathseg) Pass 2-byte flag to aspath_put. SNMP
is still defined as 2b.
(aspath_aggregate) fix latent bug.
(aspath_reconcile_as4) AS_PATH+NEW_AS_PATH reconciliation
function.
(aspath_key_make) Hash the AS_PATH string, rather than
just taking the addition of assegment ASes as the hash value,
hopefully sligthly more collision resistant.
(bgp_attr_munge_as4_attrs) Collide the NEW_ attributes
together with the OLD 2-byte forms, code Juergen
had in bgp_attr_parse but re-organised a bit.
(bgp_attr_parse) Bunch of code from Juergen moves
to previous function.
(bgp_packet_attribute) Compact significantly by
just /always/ using extended-length attr header.
Fix bug Juergen noted, by using aspath_put's
(new) returned size value for the attr header rather
than the (guesstimate) of aspath_size() - the two could
differ when aspath_put had to split large segments, unlikely
this bug was ever hit in the 'wild'.
(bgp_dump_routes_attr) Always use extended-len and
use aspath_put return for header length. Output 4b ASN
for AS_PATH and AGGREGATOR.
* bgp_ecommunity.c: (ecommunity_{hash_make,cmp}) fix
hash callback declarations to match prototypes.
(ecommunity_gettoken) Updated for ECOMMUNITY_ENCODE_AS4,
complete rewrite of Juergen's changes (no asdot support)
* bgp_open.c: (bgp_capability_as4) New, does what it says
on the tin.
(peek_for_as4_capability) Rewritten to use streams and
bgp_capability_as4.
* bgp_packet.c: (bgp_open_send) minor edit
checked (in the abstract at least) with Juergen.
Changes are to be more accepting, e.g, allow AS_TRANS on
a 2-byte session.
* (general) Update all commands to use CMD_AS_RANGE.
* bgp_vty.c: (bgp_clear) Fix return vals to use CMD_..
Remove stuff replicated by VTY_GET_LONG
(bgp_clear_vty) Return bgp_clear directly to vty.
* tests/aspath_test.c: Exercise 32bit parsing. Test reconcile
function.
* tests/ecommunity_test.c: New, test AS4 ecommunity changes,
positive test only at this time, error cases not tested yet.
2007-07-25 Juergen Kammer <j.kammer@eurodata.de>
* (general) AS4 support.
* bgpd.h: as_t changes to 4-bytes.
* bgp_aspath.h: Add BGP_AS4_MAX and BGP_AS_TRANS defines.
* bgp_aspath.c: AS_VALUE_SIZE becomes 4-byte, AS16_VALUE_SIZE
added for 2-byte.
Add AS16 versions of length calc macros.
(aspath_count_numas) New, count number of ASes.
(aspath_has_as4) New, return 1 if there are any as4's in a
path.
(assegments_parse) Interpret assegment as 4 or 2 byte,
according to how the caller instructs us, with a new
argument.
(aspath_parse) Add use32bit argument to pass to
assegments_parse. Adjust all its callers to pass 1, unless
otherwise noted.
(assegment_data_put) Adjust to be able to write 2 or 4 byte
AS, according to new use32bit argument.
(aspath_put) Adjust to write 2 or 4.
(aspath_gettoken) Use a long for passed in asno.
* bgp_attr.c: (attr_str) Add BGP_ATTR_AS4_PATH and
BGP_ATTR_AS4_AGGREGATOR.
(bgp_attr_aspath) Call aspath_parse with right 2/4 arg, as
determined by received-capability flag.
(bgp_attr_aspath_check) New, code previously in attr_aspath
but moved to new func so it can be run after NEW_AS_PATH
reconciliation.
(bgp_attr_as4_path) New, handle NEW_AS_PATH.
(bgp_attr_aggregator) Adjust to cope with 2/4 byte ASes.
(bgp_attr_as4_aggregator) New, read NEW_AGGREGATOR.
(bgp_attr_parse) Add handoffs to previous parsers for the two
new AS4 NEW_ attributes.
Various checks added for NEW/OLD reconciliation.
(bgp_packet_attribute) Support 2/4 for AS_PATH and
AGGREGATOR, detect when NEW_ attrs need to be sent.
* bgp_debug.{c,h}: Add 'debug bgp as4'.
* bgp_dump.c: MRTv2 support, unconditionally enabled, which
supports AS4. Based on patches from Erik (RIPE?).
* bgp_ecommunity.c: (ecommunity_ecom2str) ECOMMUNITY_ENCODE_AS4
support.
* bgp_open.c: (peek_for_as4_capability) New, peek for AS4
capability prior to full capability parsing, so we know which
ASN to use for struct peer lookup.
(bgp_open_capability) Always send AS4 capability.
* bgp_packet.c: (bgp_open_send) AS4 handling for AS field
(bgp_open_receive) Peek for AS4 capability first, and figure
out which AS to believe.
* bgp_vty.c: (bgp_show_peer) Print AS4 cap
* tests/aspath_test.c: Support asn32 changes, call aspath_parse
with 16 bit.
* vtysh/extract.pl: AS4 compatibility for router bgp ASNUMBER
* vtysh/extract.pl.in: AS4 compatibility for router bgp ASNUMBER
* vtysh/vtysh.c: AS4 compatibility for router bgp ASNUMBER
2007-10-15 00:32:21 +02:00
|
|
|
VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
ret = inet_aton (argv[1], &address);
|
|
|
|
if (ret == 0)
|
|
|
|
{
|
|
|
|
vty_out (vty, "Aggregator IP address is invalid%s", VTY_NEWLINE);
|
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
|
|
|
|
argstr = XMALLOC (MTYPE_ROUTE_MAP_COMPILED,
|
|
|
|
strlen (argv[0]) + strlen (argv[1]) + 2);
|
|
|
|
|
|
|
|
sprintf (argstr, "%s %s", argv[0], argv[1]);
|
|
|
|
|
|
|
|
ret = bgp_route_set_delete (vty, vty->index, "aggregator as", argstr);
|
|
|
|
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, argstr);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_set_aggregator_as,
|
|
|
|
no_set_aggregator_as_val_cmd,
|
2008-07-02 15:40:33 +02:00
|
|
|
"no set aggregator as " CMD_AS_RANGE " A.B.C.D",
|
2002-12-13 21:15:29 +01:00
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"BGP aggregator attribute\n"
|
|
|
|
"AS number of aggregator\n"
|
|
|
|
"AS number\n"
|
|
|
|
"IP address of aggregator\n")
|
|
|
|
|
2015-05-20 02:46:33 +02:00
|
|
|
DEFUN (set_tag,
|
|
|
|
set_tag_cmd,
|
|
|
|
"set tag <1-65535>",
|
|
|
|
SET_STR
|
|
|
|
"Tag value for routing protocol\n"
|
|
|
|
"Tag value\n")
|
|
|
|
{
|
|
|
|
return bgp_route_set_add (vty, vty->index, "tag", argv[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_set_tag,
|
|
|
|
no_set_tag_cmd,
|
|
|
|
"no set tag",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"Tag value for routing protocol\n")
|
|
|
|
{
|
|
|
|
if (argc == 0)
|
|
|
|
bgp_route_set_delete(vty, vty->index, "tag", NULL);
|
|
|
|
|
|
|
|
return bgp_route_set_delete (vty, vty->index, "tag", argv[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_set_tag,
|
|
|
|
no_set_tag_val_cmd,
|
|
|
|
"no set tag <1-65535>",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"Tag value for routing protocol\n"
|
|
|
|
"Tag value\n")
|
|
|
|
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
#ifdef HAVE_IPV6
|
|
|
|
DEFUN (match_ipv6_address,
|
|
|
|
match_ipv6_address_cmd,
|
|
|
|
"match ipv6 address WORD",
|
|
|
|
MATCH_STR
|
|
|
|
IPV6_STR
|
|
|
|
"Match IPv6 address of route\n"
|
|
|
|
"IPv6 access-list name\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_add (vty, vty->index, "ipv6 address", argv[0],
|
|
|
|
RMAP_EVENT_FILTER_ADDED);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_match_ipv6_address,
|
|
|
|
no_match_ipv6_address_cmd,
|
|
|
|
"no match ipv6 address WORD",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
IPV6_STR
|
|
|
|
"Match IPv6 address of route\n"
|
|
|
|
"IPv6 access-list name\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_delete (vty, vty->index, "ipv6 address", argv[0],
|
|
|
|
RMAP_EVENT_FILTER_DELETED);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (match_ipv6_next_hop,
|
|
|
|
match_ipv6_next_hop_cmd,
|
|
|
|
"match ipv6 next-hop X:X::X:X",
|
|
|
|
MATCH_STR
|
|
|
|
IPV6_STR
|
|
|
|
"Match IPv6 next-hop address of route\n"
|
|
|
|
"IPv6 address of next hop\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_add (vty, vty->index, "ipv6 next-hop", argv[0],
|
|
|
|
RMAP_EVENT_MATCH_ADDED);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_match_ipv6_next_hop,
|
|
|
|
no_match_ipv6_next_hop_cmd,
|
|
|
|
"no match ipv6 next-hop X:X::X:X",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
IPV6_STR
|
|
|
|
"Match IPv6 next-hop address of route\n"
|
|
|
|
"IPv6 address of next hop\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_delete (vty, vty->index, "ipv6 next-hop", argv[0],
|
|
|
|
RMAP_EVENT_MATCH_DELETED);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (match_ipv6_address_prefix_list,
|
|
|
|
match_ipv6_address_prefix_list_cmd,
|
|
|
|
"match ipv6 address prefix-list WORD",
|
|
|
|
MATCH_STR
|
|
|
|
IPV6_STR
|
|
|
|
"Match address of route\n"
|
|
|
|
"Match entries of prefix-lists\n"
|
|
|
|
"IP prefix-list name\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_add (vty, vty->index, "ipv6 address prefix-list",
|
|
|
|
argv[0], RMAP_EVENT_PLIST_ADDED);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_match_ipv6_address_prefix_list,
|
|
|
|
no_match_ipv6_address_prefix_list_cmd,
|
|
|
|
"no match ipv6 address prefix-list WORD",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
IPV6_STR
|
|
|
|
"Match address of route\n"
|
|
|
|
"Match entries of prefix-lists\n"
|
|
|
|
"IP prefix-list name\n")
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
return bgp_route_match_delete (vty, vty->index, "ipv6 address prefix-list",
|
|
|
|
argv[0], RMAP_EVENT_PLIST_DELETED);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2015-05-20 02:24:45 +02:00
|
|
|
DEFUN (set_ipv6_nexthop_peer,
|
|
|
|
set_ipv6_nexthop_peer_cmd,
|
|
|
|
"set ipv6 next-hop peer-address",
|
|
|
|
SET_STR
|
|
|
|
IPV6_STR
|
|
|
|
"Next hop address\n"
|
|
|
|
"Use peer address (for BGP only)\n")
|
|
|
|
{
|
|
|
|
return bgp_route_set_add (vty, vty->index, "ipv6 next-hop peer-address", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_set_ipv6_nexthop_peer,
|
|
|
|
no_set_ipv6_nexthop_peer_cmd,
|
|
|
|
"no set ipv6 next-hop peer-address",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
IPV6_STR
|
|
|
|
"IPv6 next-hop address\n"
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop", argv[0]);
|
|
|
|
}
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
DEFUN (set_ipv6_nexthop_global,
|
|
|
|
set_ipv6_nexthop_global_cmd,
|
|
|
|
"set ipv6 next-hop global X:X::X:X",
|
|
|
|
SET_STR
|
|
|
|
IPV6_STR
|
|
|
|
"IPv6 next-hop address\n"
|
|
|
|
"IPv6 global address\n"
|
|
|
|
"IPv6 address of next hop\n")
|
|
|
|
{
|
|
|
|
return bgp_route_set_add (vty, vty->index, "ipv6 next-hop global", argv[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_set_ipv6_nexthop_global,
|
|
|
|
no_set_ipv6_nexthop_global_cmd,
|
|
|
|
"no set ipv6 next-hop global",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
IPV6_STR
|
|
|
|
"IPv6 next-hop address\n"
|
|
|
|
"IPv6 global address\n")
|
|
|
|
{
|
|
|
|
if (argc == 0)
|
|
|
|
return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop global", NULL);
|
|
|
|
|
|
|
|
return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop global", argv[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_set_ipv6_nexthop_global,
|
|
|
|
no_set_ipv6_nexthop_global_val_cmd,
|
|
|
|
"no set ipv6 next-hop global X:X::X:X",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
IPV6_STR
|
|
|
|
"IPv6 next-hop address\n"
|
|
|
|
"IPv6 global address\n"
|
|
|
|
"IPv6 address of next hop\n")
|
|
|
|
|
|
|
|
DEFUN (set_ipv6_nexthop_local,
|
|
|
|
set_ipv6_nexthop_local_cmd,
|
|
|
|
"set ipv6 next-hop local X:X::X:X",
|
|
|
|
SET_STR
|
|
|
|
IPV6_STR
|
|
|
|
"IPv6 next-hop address\n"
|
|
|
|
"IPv6 local address\n"
|
|
|
|
"IPv6 address of next hop\n")
|
|
|
|
{
|
|
|
|
return bgp_route_set_add (vty, vty->index, "ipv6 next-hop local", argv[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_set_ipv6_nexthop_local,
|
|
|
|
no_set_ipv6_nexthop_local_cmd,
|
|
|
|
"no set ipv6 next-hop local",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
IPV6_STR
|
|
|
|
"IPv6 next-hop address\n"
|
|
|
|
"IPv6 local address\n")
|
|
|
|
{
|
|
|
|
if (argc == 0)
|
|
|
|
return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop local", NULL);
|
|
|
|
|
|
|
|
return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop local", argv[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_set_ipv6_nexthop_local,
|
|
|
|
no_set_ipv6_nexthop_local_val_cmd,
|
|
|
|
"no set ipv6 next-hop local X:X::X:X",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
IPV6_STR
|
|
|
|
"IPv6 next-hop address\n"
|
|
|
|
"IPv6 local address\n"
|
|
|
|
"IPv6 address of next hop\n")
|
|
|
|
#endif /* HAVE_IPV6 */
|
|
|
|
|
|
|
|
DEFUN (set_vpnv4_nexthop,
|
|
|
|
set_vpnv4_nexthop_cmd,
|
|
|
|
"set vpnv4 next-hop A.B.C.D",
|
|
|
|
SET_STR
|
|
|
|
"VPNv4 information\n"
|
|
|
|
"VPNv4 next-hop address\n"
|
|
|
|
"IP address of next hop\n")
|
|
|
|
{
|
|
|
|
return bgp_route_set_add (vty, vty->index, "vpnv4 next-hop", argv[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_set_vpnv4_nexthop,
|
|
|
|
no_set_vpnv4_nexthop_cmd,
|
|
|
|
"no set vpnv4 next-hop",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"VPNv4 information\n"
|
|
|
|
"VPNv4 next-hop address\n")
|
|
|
|
{
|
|
|
|
if (argc == 0)
|
|
|
|
return bgp_route_set_delete (vty, vty->index, "vpnv4 next-hop", NULL);
|
|
|
|
|
|
|
|
return bgp_route_set_delete (vty, vty->index, "vpnv4 next-hop", argv[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_set_vpnv4_nexthop,
|
|
|
|
no_set_vpnv4_nexthop_val_cmd,
|
|
|
|
"no set vpnv4 next-hop A.B.C.D",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"VPNv4 information\n"
|
|
|
|
"VPNv4 next-hop address\n"
|
|
|
|
"IP address of next hop\n")
|
|
|
|
|
|
|
|
DEFUN (set_originator_id,
|
|
|
|
set_originator_id_cmd,
|
|
|
|
"set originator-id A.B.C.D",
|
|
|
|
SET_STR
|
|
|
|
"BGP originator ID attribute\n"
|
|
|
|
"IP address of originator\n")
|
|
|
|
{
|
|
|
|
return bgp_route_set_add (vty, vty->index, "originator-id", argv[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_set_originator_id,
|
|
|
|
no_set_originator_id_cmd,
|
|
|
|
"no set originator-id",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"BGP originator ID attribute\n")
|
|
|
|
{
|
|
|
|
if (argc == 0)
|
|
|
|
return bgp_route_set_delete (vty, vty->index, "originator-id", NULL);
|
|
|
|
|
|
|
|
return bgp_route_set_delete (vty, vty->index, "originator-id", argv[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_set_originator_id,
|
|
|
|
no_set_originator_id_val_cmd,
|
|
|
|
"no set originator-id A.B.C.D",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"BGP originator ID attribute\n"
|
|
|
|
"IP address of originator\n")
|
|
|
|
|
2010-12-05 21:28:02 +01:00
|
|
|
DEFUN_DEPRECATED (set_pathlimit_ttl,
|
2007-08-06 17:24:51 +02:00
|
|
|
set_pathlimit_ttl_cmd,
|
|
|
|
"set pathlimit ttl <1-255>",
|
|
|
|
SET_STR
|
|
|
|
"BGP AS-Pathlimit attribute\n"
|
|
|
|
"Set AS-Path Hop-count TTL\n")
|
|
|
|
{
|
2010-12-05 21:28:02 +01:00
|
|
|
return CMD_SUCCESS;
|
2007-08-06 17:24:51 +02:00
|
|
|
}
|
|
|
|
|
2010-12-05 21:28:02 +01:00
|
|
|
DEFUN_DEPRECATED (no_set_pathlimit_ttl,
|
2007-08-06 17:24:51 +02:00
|
|
|
no_set_pathlimit_ttl_cmd,
|
|
|
|
"no set pathlimit ttl",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"BGP AS-Pathlimit attribute\n"
|
|
|
|
"Set AS-Path Hop-count TTL\n")
|
|
|
|
{
|
2010-12-05 21:28:02 +01:00
|
|
|
return CMD_SUCCESS;
|
2007-08-06 17:24:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_set_pathlimit_ttl,
|
|
|
|
no_set_pathlimit_ttl_val_cmd,
|
|
|
|
"no set pathlimit ttl <1-255>",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"BGP AS-Pathlimit attribute\n"
|
|
|
|
"Set AS-Path Hop-count TTL\n")
|
|
|
|
|
2010-12-05 21:28:02 +01:00
|
|
|
DEFUN_DEPRECATED (match_pathlimit_as,
|
2007-08-06 17:24:51 +02:00
|
|
|
match_pathlimit_as_cmd,
|
|
|
|
"match pathlimit as <1-65535>",
|
|
|
|
MATCH_STR
|
|
|
|
"BGP AS-Pathlimit attribute\n"
|
|
|
|
"Match Pathlimit AS number\n")
|
|
|
|
{
|
2010-12-05 21:28:02 +01:00
|
|
|
return CMD_SUCCESS;
|
2007-08-06 17:24:51 +02:00
|
|
|
}
|
|
|
|
|
2010-12-05 21:28:02 +01:00
|
|
|
DEFUN_DEPRECATED (no_match_pathlimit_as,
|
2007-08-06 17:24:51 +02:00
|
|
|
no_match_pathlimit_as_cmd,
|
|
|
|
"no match pathlimit as",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"BGP AS-Pathlimit attribute\n"
|
|
|
|
"Match Pathlimit AS number\n")
|
|
|
|
{
|
2010-12-05 21:28:02 +01:00
|
|
|
return CMD_SUCCESS;
|
2007-08-06 17:24:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ALIAS (no_match_pathlimit_as,
|
|
|
|
no_match_pathlimit_as_val_cmd,
|
|
|
|
"no match pathlimit as <1-65535>",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"BGP AS-Pathlimit attribute\n"
|
|
|
|
"Match Pathlimit ASN\n")
|
|
|
|
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Initialization of route map. */
|
|
|
|
void
|
2005-06-28 14:44:16 +02:00
|
|
|
bgp_route_map_init (void)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
route_map_init ();
|
|
|
|
route_map_init_vty ();
|
bgpd: bgpd-table-map.patch
COMMAND:
table-map <route-map-name>
DESCRIPTION:
This feature is used to apply a route-map on route updates from BGP to Zebra.
All the applicable match operations are allowed, such as match on prefix,
next-hop, communities, etc. Set operations for this attach-point are limited
to metric and next-hop only. Any operation of this feature does not affect
BGPs internal RIB.
Supported for ipv4 and ipv6 address families. It works on multi-paths as well,
however, metric setting is based on the best-path only.
IMPLEMENTATION NOTES:
The route-map application at this point is not supposed to modify any of BGP
route's attributes (anything in bgp_info for that matter). To achieve that,
creating a copy of the bgp_attr was inevitable. Implementation tries to keep
the memory footprint low, code comments do point out the rationale behind a
few choices made.
bgp_zebra_announce() was already a big routine, adding this feature would
extend it further. Patch has created a few smaller routines/macros whereever
possible to keep the size of the routine in check without compromising on the
readability of the code/flow inside this routine.
For updating a partially filtered route (with its nexthops), BGP to Zebra
replacement semantic of the next-hops serves the purpose well. However, with
this patch there could be some redundant withdraws each time BGP announces a
route thats (all the nexthops) gets denied by the route-map application.
Handling of this case could be optimized by keeping state with the prefix and
the nexthops in BGP. The patch doesn't optimizing that case, as even with the
redundant withdraws the total number of updates to zebra are still be capped
by the total number of routes in the table.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com>
2015-05-20 02:40:34 +02:00
|
|
|
route_map_add_hook (bgp_route_map_add);
|
|
|
|
route_map_delete_hook (bgp_route_map_delete);
|
|
|
|
route_map_event_hook (bgp_route_map_event);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2004-09-13 Jose Luis Rubio <jrubio@dit.upm.es>
(at Technical University of Madrid as part of Euro6ix Project)
Enhanced Route Server functionality and Route-Maps:
* bgpd/bgpd.h: Modified 'struct peer' and 'struct bgp_filter' to
support rs-clients. A 'struct bgp_table *rib' has been added to the
first (to mantain a separated RIB for each rs-client) and two new
route-maps have been added to the last (for import/export policies).
Added the following #defines: RMAP_{IN|OUT|IMPORT|EXPORT|MAX},
PEER_RMAP_TYPE_{IMPORT|EXPORT} and BGP_CLEAR_SOFT_RSCLIENT.
* bgpd/bgpd.c: Modified the functions that create/delete/etc peers in
order to consider the new fields included in 'struct peer' for
supporting rs-clients, i.e. the import/export route-maps and the
'struct bgp_table'.
* bgpd/bgp_route.{ch}: Modified several functions related with
receiving/sending announces in order to support the new Route Server
capabilities.
Function 'bgp_process' has been reorganized, creating an auxiliar
function for best path selection ('bgp_best_selection').
Modified 'bgp_show' and 'bgp_show_route' for displaying information
about any RIB (and not only the main bgp RIB).
Added commands for displaying information about RS-clients RIBs:
'show bgp rsclient (A.B.C.D|X:X::X:X)', 'show bgp rsclient
(A.B.C.D|X:X::X:X) X:X::X:X/M', etc
* bgpd/bgp_table.{ch}: The structure 'struct bgp_table' now has two
new fields: type (which can take the values BGP_TABLE_{MAIN|RSCLIENT})
and 'void *owner' which points to 'struct bgp' or 'struct peer' which
owns the table.
When creating a new bgp_table by default 'type=BGP_TABLE_MAIN' is set.
* bgpd/bgp_vty.c: The commands 'neighbor ... route-server-client' and
'no neighbor ... route-server-client' now not only set/unset the flag
PEER_FLAG_RSERVER_CLIENT, but they create/destroy the 'struct
bgp_table' of the peer. Special actions are taken for peer_groups.
Command 'neighbor ... route-map WORD (in|out)' now also supports two
new kinds of route-map: 'import' and 'export'.
Added commands 'clear bgp * rsclient', etc. These commands allow a new
kind of soft_reconfig which affects only the RIB of the specified
RS-client.
Added commands 'show bgp rsclient summary', etc which display a
summary of the rs-clients configured for the corresponding address
family.
* bgpd/bgp_routemap.c: A new match statement is available,
'match peer (A.B.C.D|X:X::X:X)'. This statement can only be used in
import/export route-maps, and it matches when the peer who announces
(when used in an import route-map) or is going to receive (when used
in an export route-map) the route is the same than the one specified
in the statement.
For peer-groups the statement matches if the specified peer is member
of the peer-group.
A special version of the command, 'match peer local', matches with
routes originated by the Route Server (defined with 'network ...',
redistributed routes and default-originate).
* lib/routemap.{ch}: Added a new clause 'call NAME' for use in
route-maps. It jumps into the specified route-map and when it returns
the first route-map ends if the called RM returns DENY_MATCH, or
continues in other case.
2004-09-13 07:12:46 +02:00
|
|
|
route_map_install_match (&route_match_peer_cmd);
|
2015-05-20 02:40:40 +02:00
|
|
|
route_map_install_match (&route_match_local_pref_cmd);
|
2002-12-13 21:15:29 +01:00
|
|
|
route_map_install_match (&route_match_ip_address_cmd);
|
|
|
|
route_map_install_match (&route_match_ip_next_hop_cmd);
|
2005-02-02 17:43:17 +01:00
|
|
|
route_map_install_match (&route_match_ip_route_source_cmd);
|
2002-12-13 21:15:29 +01:00
|
|
|
route_map_install_match (&route_match_ip_address_prefix_list_cmd);
|
|
|
|
route_map_install_match (&route_match_ip_next_hop_prefix_list_cmd);
|
2005-02-02 17:43:17 +01:00
|
|
|
route_map_install_match (&route_match_ip_route_source_prefix_list_cmd);
|
2002-12-13 21:15:29 +01:00
|
|
|
route_map_install_match (&route_match_aspath_cmd);
|
|
|
|
route_map_install_match (&route_match_community_cmd);
|
2003-04-19 17:49:49 +02:00
|
|
|
route_map_install_match (&route_match_ecommunity_cmd);
|
2015-05-20 02:40:40 +02:00
|
|
|
route_map_install_match (&route_match_local_pref_cmd);
|
2002-12-13 21:15:29 +01:00
|
|
|
route_map_install_match (&route_match_metric_cmd);
|
|
|
|
route_map_install_match (&route_match_origin_cmd);
|
2011-11-22 17:15:10 +01:00
|
|
|
route_map_install_match (&route_match_probability_cmd);
|
2015-05-20 02:40:47 +02:00
|
|
|
route_map_install_match (&route_match_interface_cmd);
|
2015-05-20 02:46:33 +02:00
|
|
|
route_map_install_match (&route_match_tag_cmd);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
route_map_install_set (&route_set_ip_nexthop_cmd);
|
|
|
|
route_map_install_set (&route_set_local_pref_cmd);
|
|
|
|
route_map_install_set (&route_set_weight_cmd);
|
|
|
|
route_map_install_set (&route_set_metric_cmd);
|
|
|
|
route_map_install_set (&route_set_aspath_prepend_cmd);
|
2008-04-10 13:47:45 +02:00
|
|
|
route_map_install_set (&route_set_aspath_exclude_cmd);
|
2002-12-13 21:15:29 +01:00
|
|
|
route_map_install_set (&route_set_origin_cmd);
|
|
|
|
route_map_install_set (&route_set_atomic_aggregate_cmd);
|
|
|
|
route_map_install_set (&route_set_aggregator_as_cmd);
|
|
|
|
route_map_install_set (&route_set_community_cmd);
|
|
|
|
route_map_install_set (&route_set_community_delete_cmd);
|
|
|
|
route_map_install_set (&route_set_vpnv4_nexthop_cmd);
|
|
|
|
route_map_install_set (&route_set_originator_id_cmd);
|
|
|
|
route_map_install_set (&route_set_ecommunity_rt_cmd);
|
|
|
|
route_map_install_set (&route_set_ecommunity_soo_cmd);
|
2015-05-20 02:46:33 +02:00
|
|
|
route_map_install_set (&route_set_tag_cmd);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2004-09-13 Jose Luis Rubio <jrubio@dit.upm.es>
(at Technical University of Madrid as part of Euro6ix Project)
Enhanced Route Server functionality and Route-Maps:
* bgpd/bgpd.h: Modified 'struct peer' and 'struct bgp_filter' to
support rs-clients. A 'struct bgp_table *rib' has been added to the
first (to mantain a separated RIB for each rs-client) and two new
route-maps have been added to the last (for import/export policies).
Added the following #defines: RMAP_{IN|OUT|IMPORT|EXPORT|MAX},
PEER_RMAP_TYPE_{IMPORT|EXPORT} and BGP_CLEAR_SOFT_RSCLIENT.
* bgpd/bgpd.c: Modified the functions that create/delete/etc peers in
order to consider the new fields included in 'struct peer' for
supporting rs-clients, i.e. the import/export route-maps and the
'struct bgp_table'.
* bgpd/bgp_route.{ch}: Modified several functions related with
receiving/sending announces in order to support the new Route Server
capabilities.
Function 'bgp_process' has been reorganized, creating an auxiliar
function for best path selection ('bgp_best_selection').
Modified 'bgp_show' and 'bgp_show_route' for displaying information
about any RIB (and not only the main bgp RIB).
Added commands for displaying information about RS-clients RIBs:
'show bgp rsclient (A.B.C.D|X:X::X:X)', 'show bgp rsclient
(A.B.C.D|X:X::X:X) X:X::X:X/M', etc
* bgpd/bgp_table.{ch}: The structure 'struct bgp_table' now has two
new fields: type (which can take the values BGP_TABLE_{MAIN|RSCLIENT})
and 'void *owner' which points to 'struct bgp' or 'struct peer' which
owns the table.
When creating a new bgp_table by default 'type=BGP_TABLE_MAIN' is set.
* bgpd/bgp_vty.c: The commands 'neighbor ... route-server-client' and
'no neighbor ... route-server-client' now not only set/unset the flag
PEER_FLAG_RSERVER_CLIENT, but they create/destroy the 'struct
bgp_table' of the peer. Special actions are taken for peer_groups.
Command 'neighbor ... route-map WORD (in|out)' now also supports two
new kinds of route-map: 'import' and 'export'.
Added commands 'clear bgp * rsclient', etc. These commands allow a new
kind of soft_reconfig which affects only the RIB of the specified
RS-client.
Added commands 'show bgp rsclient summary', etc which display a
summary of the rs-clients configured for the corresponding address
family.
* bgpd/bgp_routemap.c: A new match statement is available,
'match peer (A.B.C.D|X:X::X:X)'. This statement can only be used in
import/export route-maps, and it matches when the peer who announces
(when used in an import route-map) or is going to receive (when used
in an export route-map) the route is the same than the one specified
in the statement.
For peer-groups the statement matches if the specified peer is member
of the peer-group.
A special version of the command, 'match peer local', matches with
routes originated by the Route Server (defined with 'network ...',
redistributed routes and default-originate).
* lib/routemap.{ch}: Added a new clause 'call NAME' for use in
route-maps. It jumps into the specified route-map and when it returns
the first route-map ends if the called RM returns DENY_MATCH, or
continues in other case.
2004-09-13 07:12:46 +02:00
|
|
|
install_element (RMAP_NODE, &match_peer_cmd);
|
|
|
|
install_element (RMAP_NODE, &match_peer_local_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_peer_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_peer_val_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_peer_local_cmd);
|
2002-12-13 21:15:29 +01:00
|
|
|
install_element (RMAP_NODE, &match_ip_address_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_ip_address_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_ip_address_val_cmd);
|
|
|
|
install_element (RMAP_NODE, &match_ip_next_hop_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_ip_next_hop_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_ip_next_hop_val_cmd);
|
2005-02-02 17:43:17 +01:00
|
|
|
install_element (RMAP_NODE, &match_ip_route_source_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_ip_route_source_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_ip_route_source_val_cmd);
|
2002-12-13 21:15:29 +01:00
|
|
|
install_element (RMAP_NODE, &match_ip_address_prefix_list_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_ip_address_prefix_list_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_ip_address_prefix_list_val_cmd);
|
|
|
|
install_element (RMAP_NODE, &match_ip_next_hop_prefix_list_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_val_cmd);
|
2005-02-02 17:43:17 +01:00
|
|
|
install_element (RMAP_NODE, &match_ip_route_source_prefix_list_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_ip_route_source_prefix_list_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_ip_route_source_prefix_list_val_cmd);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
install_element (RMAP_NODE, &match_aspath_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_aspath_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_aspath_val_cmd);
|
|
|
|
install_element (RMAP_NODE, &match_metric_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_metric_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_metric_val_cmd);
|
2015-05-20 02:40:40 +02:00
|
|
|
install_element (RMAP_NODE, &match_local_pref_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_local_pref_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_local_pref_val_cmd);
|
2002-12-13 21:15:29 +01:00
|
|
|
install_element (RMAP_NODE, &match_community_cmd);
|
|
|
|
install_element (RMAP_NODE, &match_community_exact_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_community_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_community_val_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_community_exact_cmd);
|
2003-04-19 17:49:49 +02:00
|
|
|
install_element (RMAP_NODE, &match_ecommunity_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_ecommunity_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_ecommunity_val_cmd);
|
2002-12-13 21:15:29 +01:00
|
|
|
install_element (RMAP_NODE, &match_origin_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_origin_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_origin_val_cmd);
|
2011-11-22 17:15:10 +01:00
|
|
|
install_element (RMAP_NODE, &match_probability_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_probability_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_probability_val_cmd);
|
2015-05-20 02:40:47 +02:00
|
|
|
install_element (RMAP_NODE, &match_interface_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_interface_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_interface_val_cmd);
|
2015-05-20 02:46:33 +02:00
|
|
|
install_element (RMAP_NODE, &match_tag_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_tag_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_tag_val_cmd);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
install_element (RMAP_NODE, &set_ip_nexthop_cmd);
|
2003-11-02 08:24:40 +01:00
|
|
|
install_element (RMAP_NODE, &set_ip_nexthop_peer_cmd);
|
2002-12-13 21:15:29 +01:00
|
|
|
install_element (RMAP_NODE, &no_set_ip_nexthop_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_ip_nexthop_val_cmd);
|
|
|
|
install_element (RMAP_NODE, &set_local_pref_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_local_pref_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_local_pref_val_cmd);
|
|
|
|
install_element (RMAP_NODE, &set_weight_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_weight_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_weight_val_cmd);
|
|
|
|
install_element (RMAP_NODE, &set_metric_cmd);
|
2003-04-19 17:49:49 +02:00
|
|
|
install_element (RMAP_NODE, &set_metric_addsub_cmd);
|
2002-12-13 21:15:29 +01:00
|
|
|
install_element (RMAP_NODE, &no_set_metric_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_metric_val_cmd);
|
|
|
|
install_element (RMAP_NODE, &set_aspath_prepend_cmd);
|
2008-04-10 13:47:45 +02:00
|
|
|
install_element (RMAP_NODE, &set_aspath_exclude_cmd);
|
2002-12-13 21:15:29 +01:00
|
|
|
install_element (RMAP_NODE, &no_set_aspath_prepend_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_aspath_prepend_val_cmd);
|
2008-04-10 13:47:45 +02:00
|
|
|
install_element (RMAP_NODE, &no_set_aspath_exclude_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_aspath_exclude_val_cmd);
|
2002-12-13 21:15:29 +01:00
|
|
|
install_element (RMAP_NODE, &set_origin_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_origin_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_origin_val_cmd);
|
|
|
|
install_element (RMAP_NODE, &set_atomic_aggregate_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_atomic_aggregate_cmd);
|
|
|
|
install_element (RMAP_NODE, &set_aggregator_as_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_aggregator_as_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_aggregator_as_val_cmd);
|
|
|
|
install_element (RMAP_NODE, &set_community_cmd);
|
|
|
|
install_element (RMAP_NODE, &set_community_none_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_community_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_community_val_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_community_none_cmd);
|
|
|
|
install_element (RMAP_NODE, &set_community_delete_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_community_delete_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_community_delete_val_cmd);
|
|
|
|
install_element (RMAP_NODE, &set_ecommunity_rt_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_ecommunity_rt_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_ecommunity_rt_val_cmd);
|
|
|
|
install_element (RMAP_NODE, &set_ecommunity_soo_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_ecommunity_soo_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_ecommunity_soo_val_cmd);
|
|
|
|
install_element (RMAP_NODE, &set_vpnv4_nexthop_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_vpnv4_nexthop_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_vpnv4_nexthop_val_cmd);
|
|
|
|
install_element (RMAP_NODE, &set_originator_id_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_originator_id_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_originator_id_val_cmd);
|
2015-05-20 02:46:33 +02:00
|
|
|
install_element (RMAP_NODE, &set_tag_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_tag_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_tag_val_cmd);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
#ifdef HAVE_IPV6
|
|
|
|
route_map_install_match (&route_match_ipv6_address_cmd);
|
|
|
|
route_map_install_match (&route_match_ipv6_next_hop_cmd);
|
|
|
|
route_map_install_match (&route_match_ipv6_address_prefix_list_cmd);
|
|
|
|
route_map_install_set (&route_set_ipv6_nexthop_global_cmd);
|
|
|
|
route_map_install_set (&route_set_ipv6_nexthop_local_cmd);
|
2015-05-20 02:24:45 +02:00
|
|
|
route_map_install_set (&route_set_ipv6_nexthop_peer_cmd);
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
install_element (RMAP_NODE, &match_ipv6_address_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_ipv6_address_cmd);
|
|
|
|
install_element (RMAP_NODE, &match_ipv6_next_hop_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_ipv6_next_hop_cmd);
|
|
|
|
install_element (RMAP_NODE, &match_ipv6_address_prefix_list_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_ipv6_address_prefix_list_cmd);
|
|
|
|
install_element (RMAP_NODE, &set_ipv6_nexthop_global_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_ipv6_nexthop_global_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_ipv6_nexthop_global_val_cmd);
|
|
|
|
install_element (RMAP_NODE, &set_ipv6_nexthop_local_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_ipv6_nexthop_local_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_ipv6_nexthop_local_val_cmd);
|
2015-05-20 02:24:45 +02:00
|
|
|
install_element (RMAP_NODE, &set_ipv6_nexthop_peer_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_ipv6_nexthop_peer_cmd);
|
2002-12-13 21:15:29 +01:00
|
|
|
#endif /* HAVE_IPV6 */
|
2007-08-06 17:24:51 +02:00
|
|
|
|
2010-12-05 21:28:02 +01:00
|
|
|
/* AS-Pathlimit: functionality removed, commands kept for
|
|
|
|
* compatibility.
|
|
|
|
*/
|
2007-08-06 17:24:51 +02:00
|
|
|
install_element (RMAP_NODE, &set_pathlimit_ttl_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_pathlimit_ttl_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_pathlimit_ttl_val_cmd);
|
|
|
|
install_element (RMAP_NODE, &match_pathlimit_as_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_pathlimit_as_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_pathlimit_as_val_cmd);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2015-05-20 02:40:45 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
bgp_route_map_terminate (void)
|
|
|
|
{
|
|
|
|
/* ToDo: Cleanup all the used memory */
|
|
|
|
|
|
|
|
route_map_add_hook (NULL);
|
|
|
|
route_map_delete_hook (NULL);
|
|
|
|
route_map_event_hook (NULL);
|
|
|
|
route_map_finish();
|
|
|
|
|
|
|
|
}
|