2002-12-13 21:15:29 +01:00
|
|
|
/* Route map function.
|
2017-05-13 10:25:29 +02:00
|
|
|
* 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 this program; see the file COPYING; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
#include <zebra.h>
|
|
|
|
|
|
|
|
#include "linklist.h"
|
|
|
|
#include "memory.h"
|
|
|
|
#include "vector.h"
|
|
|
|
#include "prefix.h"
|
2016-10-06 21:56:13 +02:00
|
|
|
#include "vty.h"
|
2002-12-13 21:15:29 +01:00
|
|
|
#include "routemap.h"
|
|
|
|
#include "command.h"
|
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
|
|
|
#include "log.h"
|
2015-05-20 02:40:45 +02:00
|
|
|
#include "hash.h"
|
2017-05-08 03:06:07 +02:00
|
|
|
#include "libfrr.h"
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2015-05-29 05:48:31 +02:00
|
|
|
DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP, "Route map")
|
|
|
|
DEFINE_MTYPE( LIB, ROUTE_MAP_NAME, "Route map name")
|
|
|
|
DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP_INDEX, "Route map index")
|
|
|
|
DEFINE_MTYPE( LIB, ROUTE_MAP_RULE, "Route map rule")
|
|
|
|
DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP_RULE_STR, "Route map rule str")
|
|
|
|
DEFINE_MTYPE( LIB, ROUTE_MAP_COMPILED, "Route map compiled")
|
|
|
|
DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP_DEP, "Route map dependency")
|
|
|
|
|
2016-09-27 14:51:08 +02:00
|
|
|
DEFINE_QOBJ_TYPE(route_map_index)
|
|
|
|
DEFINE_QOBJ_TYPE(route_map)
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Vector for route match rules. */
|
|
|
|
static vector route_match_vec;
|
|
|
|
|
|
|
|
/* Vector for route set rules. */
|
|
|
|
static vector route_set_vec;
|
|
|
|
|
2016-10-06 21:56:13 +02:00
|
|
|
struct route_map_match_set_hooks
|
|
|
|
{
|
|
|
|
/* match interface */
|
|
|
|
int (*match_interface) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type);
|
|
|
|
|
|
|
|
/* no match interface */
|
|
|
|
int (*no_match_interface) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type);
|
|
|
|
|
|
|
|
/* match ip address */
|
|
|
|
int (*match_ip_address) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type);
|
|
|
|
|
|
|
|
/* no match ip address */
|
|
|
|
int (*no_match_ip_address) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type);
|
|
|
|
|
|
|
|
/* match ip address prefix list */
|
|
|
|
int (*match_ip_address_prefix_list) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type);
|
|
|
|
|
|
|
|
/* no match ip address prefix list */
|
|
|
|
int (*no_match_ip_address_prefix_list) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type);
|
|
|
|
|
|
|
|
/* match ip next hop */
|
|
|
|
int (*match_ip_next_hop) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type);
|
|
|
|
|
|
|
|
/* no match ip next hop */
|
|
|
|
int (*no_match_ip_next_hop) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type);
|
|
|
|
|
|
|
|
/* match ip next hop prefix list */
|
|
|
|
int (*match_ip_next_hop_prefix_list) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type);
|
|
|
|
|
|
|
|
/* no match ip next hop prefix list */
|
|
|
|
int (*no_match_ip_next_hop_prefix_list) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type);
|
|
|
|
|
|
|
|
/* match ipv6 address */
|
|
|
|
int (*match_ipv6_address) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type);
|
|
|
|
|
|
|
|
/* no match ipv6 address */
|
|
|
|
int (*no_match_ipv6_address) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type);
|
|
|
|
|
|
|
|
|
|
|
|
/* match ipv6 address prefix list */
|
|
|
|
int (*match_ipv6_address_prefix_list) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type);
|
|
|
|
|
|
|
|
/* no match ipv6 address prefix list */
|
|
|
|
int (*no_match_ipv6_address_prefix_list) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type);
|
|
|
|
|
|
|
|
/* match metric */
|
|
|
|
int (*match_metric) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type);
|
|
|
|
|
|
|
|
/* no match metric */
|
|
|
|
int (*no_match_metric) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type);
|
|
|
|
|
|
|
|
/* match tag */
|
|
|
|
int (*match_tag) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type);
|
|
|
|
|
|
|
|
/* no match tag */
|
|
|
|
int (*no_match_tag) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type);
|
|
|
|
|
|
|
|
/* set ip nexthop */
|
|
|
|
int (*set_ip_nexthop) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg);
|
|
|
|
|
|
|
|
/* no set ip nexthop */
|
|
|
|
int (*no_set_ip_nexthop) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg);
|
|
|
|
|
|
|
|
/* set ipv6 nexthop local */
|
|
|
|
int (*set_ipv6_nexthop_local) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg);
|
|
|
|
|
|
|
|
/* no set ipv6 nexthop local */
|
|
|
|
int (*no_set_ipv6_nexthop_local) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg);
|
|
|
|
|
|
|
|
/* set metric */
|
|
|
|
int (*set_metric) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg);
|
|
|
|
|
|
|
|
/* no set metric */
|
|
|
|
int (*no_set_metric) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg);
|
|
|
|
|
|
|
|
/* set tag */
|
|
|
|
int (*set_tag) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg);
|
|
|
|
|
|
|
|
/* no set tag */
|
|
|
|
int (*no_set_tag) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
struct route_map_match_set_hooks rmap_match_set_hook;
|
|
|
|
|
|
|
|
/* match interface */
|
|
|
|
void
|
|
|
|
route_map_match_interface_hook (int (*func) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type))
|
|
|
|
{
|
|
|
|
rmap_match_set_hook.match_interface = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no match interface */
|
|
|
|
void
|
|
|
|
route_map_no_match_interface_hook (int (*func) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type))
|
|
|
|
{
|
|
|
|
rmap_match_set_hook.no_match_interface = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* match ip address */
|
|
|
|
void
|
|
|
|
route_map_match_ip_address_hook (int (*func) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type))
|
|
|
|
{
|
|
|
|
rmap_match_set_hook.match_ip_address = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no match ip address */
|
|
|
|
void
|
|
|
|
route_map_no_match_ip_address_hook (int (*func) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type))
|
|
|
|
{
|
|
|
|
rmap_match_set_hook.no_match_ip_address = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* match ip address prefix list */
|
|
|
|
void
|
|
|
|
route_map_match_ip_address_prefix_list_hook (int (*func) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type))
|
|
|
|
{
|
|
|
|
rmap_match_set_hook.match_ip_address_prefix_list = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no match ip address prefix list */
|
|
|
|
void
|
|
|
|
route_map_no_match_ip_address_prefix_list_hook (int (*func) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type))
|
|
|
|
{
|
|
|
|
rmap_match_set_hook.no_match_ip_address_prefix_list = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* match ip next hop */
|
|
|
|
void
|
|
|
|
route_map_match_ip_next_hop_hook (int (*func) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type))
|
|
|
|
{
|
|
|
|
rmap_match_set_hook.match_ip_next_hop = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no match ip next hop */
|
|
|
|
void
|
|
|
|
route_map_no_match_ip_next_hop_hook (int (*func) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type))
|
|
|
|
{
|
|
|
|
rmap_match_set_hook.no_match_ip_next_hop = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* match ip next hop prefix list */
|
|
|
|
void
|
|
|
|
route_map_match_ip_next_hop_prefix_list_hook (int (*func) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type))
|
|
|
|
{
|
|
|
|
rmap_match_set_hook.match_ip_next_hop_prefix_list = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no match ip next hop prefix list */
|
|
|
|
void
|
|
|
|
route_map_no_match_ip_next_hop_prefix_list_hook (int (*func) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type))
|
|
|
|
{
|
|
|
|
rmap_match_set_hook.no_match_ip_next_hop_prefix_list = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* match ipv6 address */
|
|
|
|
void
|
|
|
|
route_map_match_ipv6_address_hook (int (*func) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type))
|
|
|
|
{
|
|
|
|
rmap_match_set_hook.match_ipv6_address = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no match ipv6 address */
|
|
|
|
void
|
|
|
|
route_map_no_match_ipv6_address_hook (int (*func) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type))
|
|
|
|
{
|
|
|
|
rmap_match_set_hook.no_match_ipv6_address = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* match ipv6 address prefix list */
|
|
|
|
void
|
|
|
|
route_map_match_ipv6_address_prefix_list_hook (int (*func) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type))
|
|
|
|
{
|
|
|
|
rmap_match_set_hook.match_ipv6_address_prefix_list = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no match ipv6 address prefix list */
|
|
|
|
void
|
|
|
|
route_map_no_match_ipv6_address_prefix_list_hook (int (*func) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type))
|
|
|
|
{
|
|
|
|
rmap_match_set_hook.no_match_ipv6_address_prefix_list = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* match metric */
|
|
|
|
void
|
|
|
|
route_map_match_metric_hook (int (*func) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type))
|
|
|
|
{
|
|
|
|
rmap_match_set_hook.match_metric = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no match metric */
|
|
|
|
void
|
|
|
|
route_map_no_match_metric_hook (int (*func) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type))
|
|
|
|
{
|
|
|
|
rmap_match_set_hook.no_match_metric = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* match tag */
|
|
|
|
void
|
|
|
|
route_map_match_tag_hook (int (*func) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type))
|
|
|
|
{
|
|
|
|
rmap_match_set_hook.match_tag = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no match tag */
|
|
|
|
void
|
|
|
|
route_map_no_match_tag_hook (int (*func) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg,
|
|
|
|
route_map_event_t type))
|
|
|
|
{
|
|
|
|
rmap_match_set_hook.no_match_tag = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set ip nexthop */
|
|
|
|
void
|
|
|
|
route_map_set_ip_nexthop_hook (int (*func) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg))
|
|
|
|
{
|
|
|
|
rmap_match_set_hook.set_ip_nexthop = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no set ip nexthop */
|
|
|
|
void
|
|
|
|
route_map_no_set_ip_nexthop_hook (int (*func) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg))
|
|
|
|
{
|
|
|
|
rmap_match_set_hook.no_set_ip_nexthop = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set ipv6 nexthop local */
|
|
|
|
void
|
|
|
|
route_map_set_ipv6_nexthop_local_hook (int (*func) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg))
|
|
|
|
{
|
|
|
|
rmap_match_set_hook.set_ipv6_nexthop_local = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no set ipv6 nexthop local */
|
|
|
|
void
|
|
|
|
route_map_no_set_ipv6_nexthop_local_hook (int (*func) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg))
|
|
|
|
{
|
|
|
|
rmap_match_set_hook.no_set_ipv6_nexthop_local = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set metric */
|
|
|
|
void
|
|
|
|
route_map_set_metric_hook (int (*func) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg))
|
|
|
|
{
|
|
|
|
rmap_match_set_hook.set_metric = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no set metric */
|
|
|
|
void
|
|
|
|
route_map_no_set_metric_hook (int (*func) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg))
|
|
|
|
{
|
|
|
|
rmap_match_set_hook.no_set_metric = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set tag */
|
|
|
|
void
|
|
|
|
route_map_set_tag_hook (int (*func) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg))
|
|
|
|
{
|
|
|
|
rmap_match_set_hook.set_tag = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no set tag */
|
|
|
|
void
|
|
|
|
route_map_no_set_tag_hook (int (*func) (struct vty *vty,
|
|
|
|
struct route_map_index *index,
|
|
|
|
const char *command,
|
|
|
|
const char *arg))
|
|
|
|
{
|
|
|
|
rmap_match_set_hook.no_set_tag = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
generic_match_add (struct vty *vty, struct route_map_index *index,
|
|
|
|
const char *command, const char *arg,
|
|
|
|
route_map_event_t type)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = route_map_add_match (index, command, arg);
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
switch (ret)
|
|
|
|
{
|
|
|
|
case RMAP_RULE_MISSING:
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, "%% [%s] Can't find rule.", frr_protonameinst);
|
2016-10-06 21:56:13 +02:00
|
|
|
return CMD_WARNING;
|
|
|
|
case RMAP_COMPILE_ERROR:
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, "%% [%s] Argument form is unsupported or malformed.",
|
|
|
|
frr_protonameinst);
|
2016-10-06 21:56:13 +02:00
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type != RMAP_EVENT_MATCH_ADDED)
|
|
|
|
{
|
|
|
|
route_map_upd8_dependency (type, arg, index->map->name);
|
|
|
|
}
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
generic_match_delete (struct vty *vty, struct route_map_index *index,
|
|
|
|
const char *command, const char *arg,
|
|
|
|
route_map_event_t type)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
char *dep_name = NULL;
|
|
|
|
const char *tmpstr;
|
|
|
|
char *rmap_name = NULL;
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dep_name = XSTRDUP(MTYPE_ROUTE_MAP_RULE, arg);
|
|
|
|
}
|
|
|
|
rmap_name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, index->map->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = route_map_delete_match (index, command, dep_name);
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
switch (ret)
|
|
|
|
{
|
|
|
|
case RMAP_RULE_MISSING:
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, "%% [%s] Can't find rule.%s", frr_protonameinst);
|
2016-10-06 21:56:13 +02:00
|
|
|
break;
|
|
|
|
case RMAP_COMPILE_ERROR:
|
2017-06-17 00:43:09 +02:00
|
|
|
vty_out (vty, "%% [%s] Argument form is unsupported or malformed.%s",
|
|
|
|
frr_protonameinst, VTY_NEWLINE);
|
2016-10-06 21:56:13 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (dep_name)
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_RULE, dep_name);
|
|
|
|
if (rmap_name)
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_NAME, rmap_name);
|
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type != RMAP_EVENT_MATCH_DELETED && dep_name)
|
|
|
|
route_map_upd8_dependency(type, dep_name, rmap_name);
|
|
|
|
|
|
|
|
if (dep_name)
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_RULE, dep_name);
|
|
|
|
if (rmap_name)
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_NAME, rmap_name);
|
|
|
|
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
generic_set_add (struct vty *vty, struct route_map_index *index,
|
|
|
|
const char *command, const char *arg)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = route_map_add_set (index, command, arg);
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
switch (ret)
|
|
|
|
{
|
|
|
|
case RMAP_RULE_MISSING:
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, "%% [%s] Can't find rule.%s", frr_protonameinst);
|
2016-10-06 21:56:13 +02:00
|
|
|
return CMD_WARNING;
|
|
|
|
case RMAP_COMPILE_ERROR:
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, "%% [%s] Argument form is unsupported or malformed.",
|
|
|
|
frr_protonameinst);
|
2016-10-06 21:56:13 +02:00
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
generic_set_delete (struct vty *vty, struct route_map_index *index,
|
|
|
|
const char *command, const char *arg)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = route_map_delete_set (index, command, arg);
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
switch (ret)
|
|
|
|
{
|
|
|
|
case RMAP_RULE_MISSING:
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, "%% [%s] Can't find rule.%s", frr_protonameinst);
|
2016-10-06 21:56:13 +02:00
|
|
|
return CMD_WARNING;
|
|
|
|
case RMAP_COMPILE_ERROR:
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, "%% [%s] Argument form is unsupported or malformed.%s",
|
|
|
|
frr_protonameinst);
|
2016-10-06 21:56:13 +02:00
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Route map rule. This rule has both `match' rule and `set' rule. */
|
|
|
|
struct route_map_rule
|
|
|
|
{
|
|
|
|
/* Rule type. */
|
|
|
|
struct route_map_rule_cmd *cmd;
|
|
|
|
|
|
|
|
/* For pretty printing. */
|
|
|
|
char *rule_str;
|
|
|
|
|
|
|
|
/* Pre-compiled match rule. */
|
|
|
|
void *value;
|
|
|
|
|
|
|
|
/* Linked list. */
|
|
|
|
struct route_map_rule *next;
|
|
|
|
struct route_map_rule *prev;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Making route map list. */
|
|
|
|
struct route_map_list
|
|
|
|
{
|
|
|
|
struct route_map *head;
|
|
|
|
struct route_map *tail;
|
|
|
|
|
2004-10-10 Paul Jakma <paul@dishone.st>
* version.h.in: (pid_output*) add const qualifier.
* command.h: Change DEFUN func to take const char *[] rather
than char **, to begin process of fixing compile warnings in lib/.
Nearly all other changes in this commit follow from this change.
* buffer.{c,h}: (buffer_write) pointer-arithmetic is gccism, take
const void * and cast an automatic const char *p to it.
(buffer_putstr) add const
* command.c: (zencrypt) const qualifier
(cmd_execute_command_real) ditto
(cmd_execute_command_strict) ditto
(config_log_file) ditto.
Fix leak of getcwd() returned string.
* memory.{c,h}: Add MTYPE_DISTRIBUTE_IFNAME for struct dist ifname.
* distribute.{c,h}: Update with const qualifier.
(distribute_free) use MTYPE_DISTRIBUTE_IFNAME
(distribute_lookup) Cast to char *, note that it's ok.
(distribute_hash_alloc) use MTYPE_DISTRIBUTE_IFNAME.
(distribute_get) Cast to char *, note that it's ok.
* filter.c: Update with const qualifier.
* if.{c,h}: ditto.
* if_rmap.{c,h}: ditto.
(if_rmap_lookup) Cast to char *, note that it's ok.
(if_rmap_get) ditto.
* log.{c,h}: Update with const qualifier.
* plist.{c,h}: ditto.
* routemap.{c,h}: ditto.
* smux.{c,h}: ditto. Fix some signed/unsigned comparisons.
* sockopt.c: (getsockopt_cmsg_data) add return for error case.
* vty.c: Update with const qualifier.
2004-10-10 13:56:56 +02:00
|
|
|
void (*add_hook) (const char *);
|
|
|
|
void (*delete_hook) (const char *);
|
2015-05-20 02:40:45 +02:00
|
|
|
void (*event_hook) (route_map_event_t, const char *);
|
2002-12-13 21:15:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Master list of route map. */
|
2015-05-20 02:40:45 +02:00
|
|
|
static struct route_map_list route_map_master = { NULL, NULL, NULL, NULL, NULL };
|
2015-10-28 20:12:24 +01:00
|
|
|
struct hash *route_map_master_hash = NULL;
|
|
|
|
|
|
|
|
static unsigned int
|
|
|
|
route_map_hash_key_make (void *p)
|
|
|
|
{
|
|
|
|
const struct route_map *map = p;
|
|
|
|
return string_hash_make (map->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
route_map_hash_cmp(const void *p1, const void *p2)
|
|
|
|
{
|
|
|
|
const struct route_map *map1 = p1;
|
|
|
|
const struct route_map *map2 = p2;
|
|
|
|
|
|
|
|
if (map1->deleted == map2->deleted)
|
|
|
|
{
|
|
|
|
if (map1->name && map2->name)
|
|
|
|
{
|
|
|
|
if (!strcmp (map1->name, map2->name))
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!map1->name && !map2->name)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2015-05-20 02:40:45 +02:00
|
|
|
|
|
|
|
enum route_map_upd8_type
|
|
|
|
{
|
|
|
|
ROUTE_MAP_ADD = 1,
|
|
|
|
ROUTE_MAP_DEL,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* all possible route-map dependency types */
|
|
|
|
enum route_map_dep_type
|
|
|
|
{
|
|
|
|
ROUTE_MAP_DEP_RMAP = 1,
|
|
|
|
ROUTE_MAP_DEP_CLIST,
|
|
|
|
ROUTE_MAP_DEP_ECLIST,
|
2016-11-15 11:00:39 +01:00
|
|
|
ROUTE_MAP_DEP_LCLIST,
|
2015-05-20 02:40:45 +02:00
|
|
|
ROUTE_MAP_DEP_PLIST,
|
|
|
|
ROUTE_MAP_DEP_ASPATH,
|
|
|
|
ROUTE_MAP_DEP_FILTER,
|
|
|
|
ROUTE_MAP_DEP_MAX,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct route_map_dep
|
|
|
|
{
|
|
|
|
char *dep_name;
|
|
|
|
struct hash *dep_rmap_hash;
|
|
|
|
struct hash *this_hash; /* ptr to the hash structure this is part of */
|
|
|
|
};
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
/* Hashes maintaining dependency between various sublists used by route maps */
|
|
|
|
struct hash *route_map_dep_hash[ROUTE_MAP_DEP_MAX];
|
|
|
|
|
|
|
|
static unsigned int route_map_dep_hash_make_key (void *p);
|
|
|
|
static int route_map_dep_hash_cmp (const void *p1, const void *p2);
|
|
|
|
static void route_map_clear_all_references (char *rmap_name);
|
|
|
|
static void route_map_rule_delete (struct route_map_rule_list *,
|
|
|
|
struct route_map_rule *);
|
|
|
|
static int rmap_debug = 0;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
static void
|
|
|
|
route_map_index_delete (struct route_map_index *, int);
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* New route map allocation. Please note route map's name must be
|
|
|
|
specified. */
|
|
|
|
static struct route_map *
|
2004-10-10 Paul Jakma <paul@dishone.st>
* version.h.in: (pid_output*) add const qualifier.
* command.h: Change DEFUN func to take const char *[] rather
than char **, to begin process of fixing compile warnings in lib/.
Nearly all other changes in this commit follow from this change.
* buffer.{c,h}: (buffer_write) pointer-arithmetic is gccism, take
const void * and cast an automatic const char *p to it.
(buffer_putstr) add const
* command.c: (zencrypt) const qualifier
(cmd_execute_command_real) ditto
(cmd_execute_command_strict) ditto
(config_log_file) ditto.
Fix leak of getcwd() returned string.
* memory.{c,h}: Add MTYPE_DISTRIBUTE_IFNAME for struct dist ifname.
* distribute.{c,h}: Update with const qualifier.
(distribute_free) use MTYPE_DISTRIBUTE_IFNAME
(distribute_lookup) Cast to char *, note that it's ok.
(distribute_hash_alloc) use MTYPE_DISTRIBUTE_IFNAME.
(distribute_get) Cast to char *, note that it's ok.
* filter.c: Update with const qualifier.
* if.{c,h}: ditto.
* if_rmap.{c,h}: ditto.
(if_rmap_lookup) Cast to char *, note that it's ok.
(if_rmap_get) ditto.
* log.{c,h}: Update with const qualifier.
* plist.{c,h}: ditto.
* routemap.{c,h}: ditto.
* smux.{c,h}: ditto. Fix some signed/unsigned comparisons.
* sockopt.c: (getsockopt_cmsg_data) add return for error case.
* vty.c: Update with const qualifier.
2004-10-10 13:56:56 +02:00
|
|
|
route_map_new (const char *name)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct route_map *new;
|
|
|
|
|
|
|
|
new = XCALLOC (MTYPE_ROUTE_MAP, sizeof (struct route_map));
|
|
|
|
new->name = XSTRDUP (MTYPE_ROUTE_MAP_NAME, name);
|
2016-09-27 14:51:08 +02:00
|
|
|
QOBJ_REG (new, route_map);
|
2002-12-13 21:15:29 +01:00
|
|
|
return new;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add new name to route_map. */
|
|
|
|
static struct route_map *
|
2004-10-10 Paul Jakma <paul@dishone.st>
* version.h.in: (pid_output*) add const qualifier.
* command.h: Change DEFUN func to take const char *[] rather
than char **, to begin process of fixing compile warnings in lib/.
Nearly all other changes in this commit follow from this change.
* buffer.{c,h}: (buffer_write) pointer-arithmetic is gccism, take
const void * and cast an automatic const char *p to it.
(buffer_putstr) add const
* command.c: (zencrypt) const qualifier
(cmd_execute_command_real) ditto
(cmd_execute_command_strict) ditto
(config_log_file) ditto.
Fix leak of getcwd() returned string.
* memory.{c,h}: Add MTYPE_DISTRIBUTE_IFNAME for struct dist ifname.
* distribute.{c,h}: Update with const qualifier.
(distribute_free) use MTYPE_DISTRIBUTE_IFNAME
(distribute_lookup) Cast to char *, note that it's ok.
(distribute_hash_alloc) use MTYPE_DISTRIBUTE_IFNAME.
(distribute_get) Cast to char *, note that it's ok.
* filter.c: Update with const qualifier.
* if.{c,h}: ditto.
* if_rmap.{c,h}: ditto.
(if_rmap_lookup) Cast to char *, note that it's ok.
(if_rmap_get) ditto.
* log.{c,h}: Update with const qualifier.
* plist.{c,h}: ditto.
* routemap.{c,h}: ditto.
* smux.{c,h}: ditto. Fix some signed/unsigned comparisons.
* sockopt.c: (getsockopt_cmsg_data) add return for error case.
* vty.c: Update with const qualifier.
2004-10-10 13:56:56 +02:00
|
|
|
route_map_add (const char *name)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct route_map *map;
|
|
|
|
struct route_map_list *list;
|
|
|
|
|
|
|
|
map = route_map_new (name);
|
|
|
|
list = &route_map_master;
|
2015-10-28 20:12:24 +01:00
|
|
|
|
|
|
|
/* Add map to the hash */
|
|
|
|
hash_get(route_map_master_hash, map, hash_alloc_intern);
|
|
|
|
|
2016-05-18 23:08:55 +02:00
|
|
|
/* Add new entry to the head of the list to match how it is added in the
|
|
|
|
* hash table. This is to ensure that if the same route-map has been
|
|
|
|
* created more than once and then marked for deletion (which can happen
|
|
|
|
* if prior deletions haven't completed as BGP hasn't yet done the
|
|
|
|
* route-map processing), the order of the entities is the same in both
|
|
|
|
* the list and the hash table. Otherwise, since there is nothing to
|
|
|
|
* distinguish between the two entries, the wrong entry could get freed.
|
|
|
|
* TODO: This needs to be re-examined to handle it better - e.g., revive
|
|
|
|
* a deleted entry if the route-map is created again.
|
|
|
|
*/
|
|
|
|
map->prev = NULL;
|
|
|
|
map->next = list->head;
|
|
|
|
if (list->head)
|
|
|
|
list->head->prev = map;
|
|
|
|
list->head = map;
|
|
|
|
if (!list->tail)
|
|
|
|
list->tail = map;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
/* Execute hook. */
|
|
|
|
if (route_map_master.add_hook)
|
2015-05-20 02:40:45 +02:00
|
|
|
{
|
|
|
|
(*route_map_master.add_hook) (name);
|
|
|
|
route_map_notify_dependencies(name, RMAP_EVENT_CALL_ADDED);
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
/* this is supposed to be called post processing by
|
|
|
|
* the delete hook function. Don't invoke delete_hook
|
|
|
|
* again in this routine.
|
|
|
|
*/
|
2015-05-20 03:04:26 +02:00
|
|
|
static void
|
2015-05-20 02:40:45 +02:00
|
|
|
route_map_free_map (struct route_map *map)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct route_map_list *list;
|
|
|
|
struct route_map_index *index;
|
2015-05-20 02:40:45 +02:00
|
|
|
|
2017-02-08 15:14:23 +01:00
|
|
|
if (map == NULL)
|
|
|
|
return;
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
while ((index = map->head) != NULL)
|
|
|
|
route_map_index_delete (index, 0);
|
|
|
|
|
|
|
|
list = &route_map_master;
|
|
|
|
|
2017-02-08 15:14:23 +01:00
|
|
|
QOBJ_UNREG (map);
|
2016-09-27 14:51:08 +02:00
|
|
|
|
2017-02-08 15:14:23 +01:00
|
|
|
if (map->next)
|
|
|
|
map->next->prev = map->prev;
|
|
|
|
else
|
|
|
|
list->tail = map->prev;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2017-02-08 15:14:23 +01:00
|
|
|
if (map->prev)
|
|
|
|
map->prev->next = map->next;
|
|
|
|
else
|
|
|
|
list->head = map->next;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2017-02-08 15:14:23 +01:00
|
|
|
hash_release(route_map_master_hash, map);
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_NAME, map->name);
|
|
|
|
XFREE (MTYPE_ROUTE_MAP, map);
|
2015-05-20 02:40:45 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
/* Route map delete from list. */
|
|
|
|
static void
|
|
|
|
route_map_delete (struct route_map *map)
|
|
|
|
{
|
|
|
|
struct route_map_index *index;
|
|
|
|
char *name;
|
|
|
|
|
|
|
|
while ((index = map->head) != NULL)
|
|
|
|
route_map_index_delete (index, 0);
|
|
|
|
|
|
|
|
name = map->name;
|
|
|
|
map->head = NULL;
|
|
|
|
|
|
|
|
/* Clear all dependencies */
|
|
|
|
route_map_clear_all_references(name);
|
|
|
|
map->deleted = 1;
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Execute deletion hook. */
|
|
|
|
if (route_map_master.delete_hook)
|
2015-05-20 02:40:45 +02:00
|
|
|
{
|
|
|
|
(*route_map_master.delete_hook) (name);
|
|
|
|
route_map_notify_dependencies(name, RMAP_EVENT_CALL_DELETED);
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
if (!map->to_be_processed)
|
|
|
|
{
|
|
|
|
route_map_free_map (map);
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Lookup route map by route map name string. */
|
|
|
|
struct route_map *
|
2004-10-10 Paul Jakma <paul@dishone.st>
* version.h.in: (pid_output*) add const qualifier.
* command.h: Change DEFUN func to take const char *[] rather
than char **, to begin process of fixing compile warnings in lib/.
Nearly all other changes in this commit follow from this change.
* buffer.{c,h}: (buffer_write) pointer-arithmetic is gccism, take
const void * and cast an automatic const char *p to it.
(buffer_putstr) add const
* command.c: (zencrypt) const qualifier
(cmd_execute_command_real) ditto
(cmd_execute_command_strict) ditto
(config_log_file) ditto.
Fix leak of getcwd() returned string.
* memory.{c,h}: Add MTYPE_DISTRIBUTE_IFNAME for struct dist ifname.
* distribute.{c,h}: Update with const qualifier.
(distribute_free) use MTYPE_DISTRIBUTE_IFNAME
(distribute_lookup) Cast to char *, note that it's ok.
(distribute_hash_alloc) use MTYPE_DISTRIBUTE_IFNAME.
(distribute_get) Cast to char *, note that it's ok.
* filter.c: Update with const qualifier.
* if.{c,h}: ditto.
* if_rmap.{c,h}: ditto.
(if_rmap_lookup) Cast to char *, note that it's ok.
(if_rmap_get) ditto.
* log.{c,h}: Update with const qualifier.
* plist.{c,h}: ditto.
* routemap.{c,h}: ditto.
* smux.{c,h}: ditto. Fix some signed/unsigned comparisons.
* sockopt.c: (getsockopt_cmsg_data) add return for error case.
* vty.c: Update with const qualifier.
2004-10-10 13:56:56 +02:00
|
|
|
route_map_lookup_by_name (const char *name)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct route_map *map;
|
2015-10-28 20:12:24 +01:00
|
|
|
struct route_map tmp_map;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
if (!name)
|
|
|
|
return NULL;
|
|
|
|
|
2015-10-28 20:12:24 +01:00
|
|
|
// map.deleted is 0 via memset
|
|
|
|
memset(&tmp_map, 0, sizeof(struct route_map));
|
|
|
|
tmp_map.name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, name);
|
|
|
|
map = hash_lookup(route_map_master_hash, &tmp_map);
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_NAME, tmp_map.name);
|
|
|
|
return map;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
int
|
|
|
|
route_map_mark_updated (const char *name, int del_later)
|
|
|
|
{
|
|
|
|
struct route_map *map;
|
|
|
|
int ret = -1;
|
2015-10-28 20:12:24 +01:00
|
|
|
struct route_map tmp_map;
|
2015-05-20 02:40:45 +02:00
|
|
|
|
2015-10-28 20:12:24 +01:00
|
|
|
if (!name)
|
|
|
|
return (ret);
|
|
|
|
|
|
|
|
map = route_map_lookup_by_name(name);
|
|
|
|
|
|
|
|
/* If we did not find the routemap with deleted=0 try again
|
|
|
|
* with deleted=1
|
2015-05-20 02:40:45 +02:00
|
|
|
*/
|
2015-10-28 20:12:24 +01:00
|
|
|
if (!map)
|
|
|
|
{
|
|
|
|
memset(&tmp_map, 0, sizeof(struct route_map));
|
|
|
|
tmp_map.name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, name);
|
|
|
|
tmp_map.deleted = 1;
|
|
|
|
map = hash_lookup(route_map_master_hash, &tmp_map);
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_NAME, tmp_map.name);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (map)
|
|
|
|
{
|
|
|
|
map->to_be_processed = 1;
|
|
|
|
ret = 0;
|
|
|
|
}
|
2015-05-20 02:40:45 +02:00
|
|
|
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
route_map_clear_updated (struct route_map *map)
|
|
|
|
{
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (map)
|
|
|
|
{
|
|
|
|
map->to_be_processed = 0;
|
|
|
|
if (map->deleted)
|
|
|
|
route_map_free_map(map);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (ret);
|
|
|
|
}
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Lookup route map. If there isn't route map create one and return
|
|
|
|
it. */
|
2005-05-06 Paul Jakma <paul@dishone.st>
* (general) extern and static'ification of functions in code and
header.
Cleanup any definitions with unspecified arguments.
Add casts for callback assignments where the callback is defined,
typically, as passing void *, but the function being assigned has
some other pointer type defined as its argument, as gcc complains
about casts from void * to X* via function arguments.
Fix some old K&R style function argument definitions.
Add noreturn gcc attribute to some functions, as appropriate.
Add unused gcc attribute to some functions (eg ones meant to help
while debugging)
Add guard defines to headers which were missing them.
* command.c: (install_node) add const qualifier, still doesnt shut
up the warning though, because of the double pointer.
(cmp_node) ditto
* keychain.c: (key_str2time) Add GET_LONG_RANGE() macro, derived
fromn vty.h ones to fix some of the (long) < 0 warnings.
* thread.c: (various) use thread_empty
(cpu_record_hash_key) should cast to uintptr_t, a stdint.h type
* vty.h: Add VTY_GET_IPV4_ADDRESS and VTY_GET_IPV4_PREFIX so they
removed from ospfd/ospf_vty.h
* zebra.h: Move definition of ZEBRA_PORT to here, to remove
dependence of lib on zebra/zserv.h
2005-05-06 23:25:49 +02:00
|
|
|
static struct route_map *
|
2004-10-10 Paul Jakma <paul@dishone.st>
* version.h.in: (pid_output*) add const qualifier.
* command.h: Change DEFUN func to take const char *[] rather
than char **, to begin process of fixing compile warnings in lib/.
Nearly all other changes in this commit follow from this change.
* buffer.{c,h}: (buffer_write) pointer-arithmetic is gccism, take
const void * and cast an automatic const char *p to it.
(buffer_putstr) add const
* command.c: (zencrypt) const qualifier
(cmd_execute_command_real) ditto
(cmd_execute_command_strict) ditto
(config_log_file) ditto.
Fix leak of getcwd() returned string.
* memory.{c,h}: Add MTYPE_DISTRIBUTE_IFNAME for struct dist ifname.
* distribute.{c,h}: Update with const qualifier.
(distribute_free) use MTYPE_DISTRIBUTE_IFNAME
(distribute_lookup) Cast to char *, note that it's ok.
(distribute_hash_alloc) use MTYPE_DISTRIBUTE_IFNAME.
(distribute_get) Cast to char *, note that it's ok.
* filter.c: Update with const qualifier.
* if.{c,h}: ditto.
* if_rmap.{c,h}: ditto.
(if_rmap_lookup) Cast to char *, note that it's ok.
(if_rmap_get) ditto.
* log.{c,h}: Update with const qualifier.
* plist.{c,h}: ditto.
* routemap.{c,h}: ditto.
* smux.{c,h}: ditto. Fix some signed/unsigned comparisons.
* sockopt.c: (getsockopt_cmsg_data) add return for error case.
* vty.c: Update with const qualifier.
2004-10-10 13:56:56 +02:00
|
|
|
route_map_get (const char *name)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct route_map *map;
|
|
|
|
|
|
|
|
map = route_map_lookup_by_name (name);
|
|
|
|
if (map == NULL)
|
|
|
|
map = route_map_add (name);
|
2015-05-20 02:40:45 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
void
|
2016-03-22 18:46:30 +01:00
|
|
|
route_map_walk_update_list (int (*route_map_update_fn) (char *name))
|
2015-05-20 02:40:45 +02:00
|
|
|
{
|
|
|
|
struct route_map *node;
|
|
|
|
struct route_map *nnode = NULL;
|
|
|
|
|
|
|
|
for (node = route_map_master.head; node; node = nnode)
|
|
|
|
{
|
|
|
|
if (node->to_be_processed)
|
|
|
|
{
|
|
|
|
/* DD: Should we add any thread yield code here */
|
2016-03-22 18:46:30 +01:00
|
|
|
route_map_update_fn(node->name);
|
2015-05-20 02:40:45 +02:00
|
|
|
nnode = node->next;
|
|
|
|
route_map_clear_updated(node);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
nnode = node->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Return route map's type string. */
|
2005-05-06 Paul Jakma <paul@dishone.st>
* (general) extern and static'ification of functions in code and
header.
Cleanup any definitions with unspecified arguments.
Add casts for callback assignments where the callback is defined,
typically, as passing void *, but the function being assigned has
some other pointer type defined as its argument, as gcc complains
about casts from void * to X* via function arguments.
Fix some old K&R style function argument definitions.
Add noreturn gcc attribute to some functions, as appropriate.
Add unused gcc attribute to some functions (eg ones meant to help
while debugging)
Add guard defines to headers which were missing them.
* command.c: (install_node) add const qualifier, still doesnt shut
up the warning though, because of the double pointer.
(cmp_node) ditto
* keychain.c: (key_str2time) Add GET_LONG_RANGE() macro, derived
fromn vty.h ones to fix some of the (long) < 0 warnings.
* thread.c: (various) use thread_empty
(cpu_record_hash_key) should cast to uintptr_t, a stdint.h type
* vty.h: Add VTY_GET_IPV4_ADDRESS and VTY_GET_IPV4_PREFIX so they
removed from ospfd/ospf_vty.h
* zebra.h: Move definition of ZEBRA_PORT to here, to remove
dependence of lib on zebra/zserv.h
2005-05-06 23:25:49 +02:00
|
|
|
static const char *
|
2002-12-13 21:15:29 +01:00
|
|
|
route_map_type_str (enum route_map_type type)
|
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case RMAP_PERMIT:
|
|
|
|
return "permit";
|
|
|
|
break;
|
|
|
|
case RMAP_DENY:
|
|
|
|
return "deny";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return "";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-06 Paul Jakma <paul@dishone.st>
* (general) extern and static'ification of functions in code and
header.
Cleanup any definitions with unspecified arguments.
Add casts for callback assignments where the callback is defined,
typically, as passing void *, but the function being assigned has
some other pointer type defined as its argument, as gcc complains
about casts from void * to X* via function arguments.
Fix some old K&R style function argument definitions.
Add noreturn gcc attribute to some functions, as appropriate.
Add unused gcc attribute to some functions (eg ones meant to help
while debugging)
Add guard defines to headers which were missing them.
* command.c: (install_node) add const qualifier, still doesnt shut
up the warning though, because of the double pointer.
(cmp_node) ditto
* keychain.c: (key_str2time) Add GET_LONG_RANGE() macro, derived
fromn vty.h ones to fix some of the (long) < 0 warnings.
* thread.c: (various) use thread_empty
(cpu_record_hash_key) should cast to uintptr_t, a stdint.h type
* vty.h: Add VTY_GET_IPV4_ADDRESS and VTY_GET_IPV4_PREFIX so they
removed from ospfd/ospf_vty.h
* zebra.h: Move definition of ZEBRA_PORT to here, to remove
dependence of lib on zebra/zserv.h
2005-05-06 23:25:49 +02:00
|
|
|
static int
|
2002-12-13 21:15:29 +01:00
|
|
|
route_map_empty (struct route_map *map)
|
|
|
|
{
|
|
|
|
if (map->head == NULL && map->tail == NULL)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-07-09 16:00:01 +02:00
|
|
|
/* show route-map */
|
|
|
|
static void
|
|
|
|
vty_show_route_map_entry (struct vty *vty, struct route_map *map)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct route_map_index *index;
|
|
|
|
struct route_map_rule *rule;
|
|
|
|
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, "%s:", frr_protonameinst);
|
2005-09-29 13:25:50 +02:00
|
|
|
|
2004-07-09 16:00:01 +02:00
|
|
|
for (index = map->head; index; index = index->next)
|
|
|
|
{
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, "route-map %s, %s, sequence %d",
|
2004-07-09 16:00:01 +02:00
|
|
|
map->name, route_map_type_str (index->type),
|
2017-06-21 05:10:57 +02:00
|
|
|
index->pref);
|
2005-04-09 15:27:50 +02:00
|
|
|
|
|
|
|
/* Description */
|
|
|
|
if (index->description)
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, " Description:%s %s", VTY_NEWLINE,
|
|
|
|
index->description);
|
2004-07-09 16:00:01 +02:00
|
|
|
|
|
|
|
/* Match clauses */
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, " Match clauses:");
|
2004-07-09 16:00:01 +02:00
|
|
|
for (rule = index->match_list.head; rule; rule = rule->next)
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, " %s %s",
|
|
|
|
rule->cmd->str, rule->rule_str);
|
2004-07-09 16:00:01 +02:00
|
|
|
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, " Set clauses:");
|
2004-07-09 16:00:01 +02:00
|
|
|
for (rule = index->set_list.head; rule; rule = rule->next)
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, " %s %s",
|
|
|
|
rule->cmd->str, rule->rule_str);
|
2004-07-09 16:00:01 +02:00
|
|
|
|
2005-11-12 23:36:41 +01:00
|
|
|
/* Call clause */
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, " Call clause:");
|
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 (index->nextrm)
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, " Call %s", index->nextrm);
|
2005-11-12 23:36:41 +01:00
|
|
|
|
|
|
|
/* Exit Policy */
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, " Action:");
|
2005-11-12 23:36:41 +01:00
|
|
|
if (index->exitpolicy == RMAP_GOTO)
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, " Goto %d", index->nextpref);
|
2004-07-09 16:00:01 +02:00
|
|
|
else if (index->exitpolicy == RMAP_NEXT)
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, " Continue to next entry");
|
2004-07-09 16:00:01 +02:00
|
|
|
else if (index->exitpolicy == RMAP_EXIT)
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, " Exit routemap");
|
2004-07-09 16:00:01 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2005-05-06 Paul Jakma <paul@dishone.st>
* (general) extern and static'ification of functions in code and
header.
Cleanup any definitions with unspecified arguments.
Add casts for callback assignments where the callback is defined,
typically, as passing void *, but the function being assigned has
some other pointer type defined as its argument, as gcc complains
about casts from void * to X* via function arguments.
Fix some old K&R style function argument definitions.
Add noreturn gcc attribute to some functions, as appropriate.
Add unused gcc attribute to some functions (eg ones meant to help
while debugging)
Add guard defines to headers which were missing them.
* command.c: (install_node) add const qualifier, still doesnt shut
up the warning though, because of the double pointer.
(cmp_node) ditto
* keychain.c: (key_str2time) Add GET_LONG_RANGE() macro, derived
fromn vty.h ones to fix some of the (long) < 0 warnings.
* thread.c: (various) use thread_empty
(cpu_record_hash_key) should cast to uintptr_t, a stdint.h type
* vty.h: Add VTY_GET_IPV4_ADDRESS and VTY_GET_IPV4_PREFIX so they
removed from ospfd/ospf_vty.h
* zebra.h: Move definition of ZEBRA_PORT to here, to remove
dependence of lib on zebra/zserv.h
2005-05-06 23:25:49 +02:00
|
|
|
static int
|
2004-10-10 Paul Jakma <paul@dishone.st>
* version.h.in: (pid_output*) add const qualifier.
* command.h: Change DEFUN func to take const char *[] rather
than char **, to begin process of fixing compile warnings in lib/.
Nearly all other changes in this commit follow from this change.
* buffer.{c,h}: (buffer_write) pointer-arithmetic is gccism, take
const void * and cast an automatic const char *p to it.
(buffer_putstr) add const
* command.c: (zencrypt) const qualifier
(cmd_execute_command_real) ditto
(cmd_execute_command_strict) ditto
(config_log_file) ditto.
Fix leak of getcwd() returned string.
* memory.{c,h}: Add MTYPE_DISTRIBUTE_IFNAME for struct dist ifname.
* distribute.{c,h}: Update with const qualifier.
(distribute_free) use MTYPE_DISTRIBUTE_IFNAME
(distribute_lookup) Cast to char *, note that it's ok.
(distribute_hash_alloc) use MTYPE_DISTRIBUTE_IFNAME.
(distribute_get) Cast to char *, note that it's ok.
* filter.c: Update with const qualifier.
* if.{c,h}: ditto.
* if_rmap.{c,h}: ditto.
(if_rmap_lookup) Cast to char *, note that it's ok.
(if_rmap_get) ditto.
* log.{c,h}: Update with const qualifier.
* plist.{c,h}: ditto.
* routemap.{c,h}: ditto.
* smux.{c,h}: ditto. Fix some signed/unsigned comparisons.
* sockopt.c: (getsockopt_cmsg_data) add return for error case.
* vty.c: Update with const qualifier.
2004-10-10 13:56:56 +02:00
|
|
|
vty_show_route_map (struct vty *vty, const char *name)
|
2004-07-09 16:00:01 +02:00
|
|
|
{
|
|
|
|
struct route_map *map;
|
|
|
|
|
|
|
|
if (name)
|
|
|
|
{
|
|
|
|
map = route_map_lookup_by_name (name);
|
|
|
|
|
|
|
|
if (map)
|
|
|
|
{
|
|
|
|
vty_show_route_map_entry (vty, map);
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, "%s: 'route-map %s' not found", frr_protonameinst,
|
|
|
|
name);
|
2015-10-28 20:12:24 +01:00
|
|
|
return CMD_SUCCESS;
|
2004-07-09 16:00:01 +02:00
|
|
|
}
|
|
|
|
}
|
2007-05-02 18:05:35 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
for (map = route_map_master.head; map; map = map->next)
|
2015-05-20 02:40:45 +02:00
|
|
|
if (!map->deleted)
|
|
|
|
vty_show_route_map_entry (vty, map);
|
2007-05-02 18:05:35 +02:00
|
|
|
}
|
2004-07-09 16:00:01 +02:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* New route map allocation. Please note route map's name must be
|
|
|
|
specified. */
|
2005-05-06 Paul Jakma <paul@dishone.st>
* (general) extern and static'ification of functions in code and
header.
Cleanup any definitions with unspecified arguments.
Add casts for callback assignments where the callback is defined,
typically, as passing void *, but the function being assigned has
some other pointer type defined as its argument, as gcc complains
about casts from void * to X* via function arguments.
Fix some old K&R style function argument definitions.
Add noreturn gcc attribute to some functions, as appropriate.
Add unused gcc attribute to some functions (eg ones meant to help
while debugging)
Add guard defines to headers which were missing them.
* command.c: (install_node) add const qualifier, still doesnt shut
up the warning though, because of the double pointer.
(cmp_node) ditto
* keychain.c: (key_str2time) Add GET_LONG_RANGE() macro, derived
fromn vty.h ones to fix some of the (long) < 0 warnings.
* thread.c: (various) use thread_empty
(cpu_record_hash_key) should cast to uintptr_t, a stdint.h type
* vty.h: Add VTY_GET_IPV4_ADDRESS and VTY_GET_IPV4_PREFIX so they
removed from ospfd/ospf_vty.h
* zebra.h: Move definition of ZEBRA_PORT to here, to remove
dependence of lib on zebra/zserv.h
2005-05-06 23:25:49 +02:00
|
|
|
static struct route_map_index *
|
|
|
|
route_map_index_new (void)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct route_map_index *new;
|
|
|
|
|
|
|
|
new = XCALLOC (MTYPE_ROUTE_MAP_INDEX, sizeof (struct route_map_index));
|
|
|
|
new->exitpolicy = RMAP_EXIT; /* Default to Cisco-style */
|
2016-09-27 14:51:08 +02:00
|
|
|
QOBJ_REG (new, route_map_index);
|
2002-12-13 21:15:29 +01:00
|
|
|
return new;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free route map index. */
|
|
|
|
static void
|
|
|
|
route_map_index_delete (struct route_map_index *index, int notify)
|
|
|
|
{
|
|
|
|
struct route_map_rule *rule;
|
|
|
|
|
2016-09-27 14:51:08 +02:00
|
|
|
QOBJ_UNREG (index);
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Free route match. */
|
|
|
|
while ((rule = index->match_list.head) != NULL)
|
|
|
|
route_map_rule_delete (&index->match_list, rule);
|
|
|
|
|
|
|
|
/* Free route set. */
|
|
|
|
while ((rule = index->set_list.head) != NULL)
|
|
|
|
route_map_rule_delete (&index->set_list, rule);
|
|
|
|
|
|
|
|
/* Remove index from route map list. */
|
|
|
|
if (index->next)
|
|
|
|
index->next->prev = index->prev;
|
|
|
|
else
|
|
|
|
index->map->tail = index->prev;
|
|
|
|
|
|
|
|
if (index->prev)
|
|
|
|
index->prev->next = index->next;
|
|
|
|
else
|
|
|
|
index->map->head = index->next;
|
|
|
|
|
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
|
|
|
/* Free 'char *nextrm' if not NULL */
|
|
|
|
if (index->nextrm)
|
2005-10-26 07:05:16 +02:00
|
|
|
XFREE (MTYPE_ROUTE_MAP_NAME, index->nextrm);
|
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
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Execute event hook. */
|
|
|
|
if (route_map_master.event_hook && notify)
|
2015-05-20 02:40:45 +02:00
|
|
|
{
|
|
|
|
(*route_map_master.event_hook) (RMAP_EVENT_INDEX_DELETED,
|
|
|
|
index->map->name);
|
|
|
|
route_map_notify_dependencies(index->map->name, RMAP_EVENT_CALL_ADDED);
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
XFREE (MTYPE_ROUTE_MAP_INDEX, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Lookup index from route map. */
|
2005-05-06 Paul Jakma <paul@dishone.st>
* (general) extern and static'ification of functions in code and
header.
Cleanup any definitions with unspecified arguments.
Add casts for callback assignments where the callback is defined,
typically, as passing void *, but the function being assigned has
some other pointer type defined as its argument, as gcc complains
about casts from void * to X* via function arguments.
Fix some old K&R style function argument definitions.
Add noreturn gcc attribute to some functions, as appropriate.
Add unused gcc attribute to some functions (eg ones meant to help
while debugging)
Add guard defines to headers which were missing them.
* command.c: (install_node) add const qualifier, still doesnt shut
up the warning though, because of the double pointer.
(cmp_node) ditto
* keychain.c: (key_str2time) Add GET_LONG_RANGE() macro, derived
fromn vty.h ones to fix some of the (long) < 0 warnings.
* thread.c: (various) use thread_empty
(cpu_record_hash_key) should cast to uintptr_t, a stdint.h type
* vty.h: Add VTY_GET_IPV4_ADDRESS and VTY_GET_IPV4_PREFIX so they
removed from ospfd/ospf_vty.h
* zebra.h: Move definition of ZEBRA_PORT to here, to remove
dependence of lib on zebra/zserv.h
2005-05-06 23:25:49 +02:00
|
|
|
static struct route_map_index *
|
2002-12-13 21:15:29 +01:00
|
|
|
route_map_index_lookup (struct route_map *map, enum route_map_type type,
|
|
|
|
int pref)
|
|
|
|
{
|
|
|
|
struct route_map_index *index;
|
|
|
|
|
|
|
|
for (index = map->head; index; index = index->next)
|
|
|
|
if ((index->type == type || type == RMAP_ANY)
|
|
|
|
&& index->pref == pref)
|
|
|
|
return index;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add new index to route map. */
|
2005-05-06 Paul Jakma <paul@dishone.st>
* (general) extern and static'ification of functions in code and
header.
Cleanup any definitions with unspecified arguments.
Add casts for callback assignments where the callback is defined,
typically, as passing void *, but the function being assigned has
some other pointer type defined as its argument, as gcc complains
about casts from void * to X* via function arguments.
Fix some old K&R style function argument definitions.
Add noreturn gcc attribute to some functions, as appropriate.
Add unused gcc attribute to some functions (eg ones meant to help
while debugging)
Add guard defines to headers which were missing them.
* command.c: (install_node) add const qualifier, still doesnt shut
up the warning though, because of the double pointer.
(cmp_node) ditto
* keychain.c: (key_str2time) Add GET_LONG_RANGE() macro, derived
fromn vty.h ones to fix some of the (long) < 0 warnings.
* thread.c: (various) use thread_empty
(cpu_record_hash_key) should cast to uintptr_t, a stdint.h type
* vty.h: Add VTY_GET_IPV4_ADDRESS and VTY_GET_IPV4_PREFIX so they
removed from ospfd/ospf_vty.h
* zebra.h: Move definition of ZEBRA_PORT to here, to remove
dependence of lib on zebra/zserv.h
2005-05-06 23:25:49 +02:00
|
|
|
static struct route_map_index *
|
2002-12-13 21:15:29 +01:00
|
|
|
route_map_index_add (struct route_map *map, enum route_map_type type,
|
|
|
|
int pref)
|
|
|
|
{
|
|
|
|
struct route_map_index *index;
|
|
|
|
struct route_map_index *point;
|
|
|
|
|
|
|
|
/* Allocate new route map inex. */
|
|
|
|
index = route_map_index_new ();
|
|
|
|
index->map = map;
|
|
|
|
index->type = type;
|
|
|
|
index->pref = pref;
|
|
|
|
|
|
|
|
/* Compare preference. */
|
|
|
|
for (point = map->head; point; point = point->next)
|
|
|
|
if (point->pref >= pref)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (map->head == NULL)
|
|
|
|
{
|
|
|
|
map->head = map->tail = index;
|
|
|
|
}
|
|
|
|
else if (point == NULL)
|
|
|
|
{
|
|
|
|
index->prev = map->tail;
|
|
|
|
map->tail->next = index;
|
|
|
|
map->tail = index;
|
|
|
|
}
|
|
|
|
else if (point == map->head)
|
|
|
|
{
|
|
|
|
index->next = map->head;
|
|
|
|
map->head->prev = index;
|
|
|
|
map->head = index;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
index->next = point;
|
|
|
|
index->prev = point->prev;
|
|
|
|
if (point->prev)
|
|
|
|
point->prev->next = index;
|
|
|
|
point->prev = index;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Execute event hook. */
|
|
|
|
if (route_map_master.event_hook)
|
2015-05-20 02:40:45 +02:00
|
|
|
{
|
|
|
|
(*route_map_master.event_hook) (RMAP_EVENT_INDEX_ADDED,
|
|
|
|
map->name);
|
|
|
|
route_map_notify_dependencies (map->name, RMAP_EVENT_CALL_ADDED);
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get route map index. */
|
2005-05-06 Paul Jakma <paul@dishone.st>
* (general) extern and static'ification of functions in code and
header.
Cleanup any definitions with unspecified arguments.
Add casts for callback assignments where the callback is defined,
typically, as passing void *, but the function being assigned has
some other pointer type defined as its argument, as gcc complains
about casts from void * to X* via function arguments.
Fix some old K&R style function argument definitions.
Add noreturn gcc attribute to some functions, as appropriate.
Add unused gcc attribute to some functions (eg ones meant to help
while debugging)
Add guard defines to headers which were missing them.
* command.c: (install_node) add const qualifier, still doesnt shut
up the warning though, because of the double pointer.
(cmp_node) ditto
* keychain.c: (key_str2time) Add GET_LONG_RANGE() macro, derived
fromn vty.h ones to fix some of the (long) < 0 warnings.
* thread.c: (various) use thread_empty
(cpu_record_hash_key) should cast to uintptr_t, a stdint.h type
* vty.h: Add VTY_GET_IPV4_ADDRESS and VTY_GET_IPV4_PREFIX so they
removed from ospfd/ospf_vty.h
* zebra.h: Move definition of ZEBRA_PORT to here, to remove
dependence of lib on zebra/zserv.h
2005-05-06 23:25:49 +02:00
|
|
|
static struct route_map_index *
|
2002-12-13 21:15:29 +01:00
|
|
|
route_map_index_get (struct route_map *map, enum route_map_type type,
|
|
|
|
int pref)
|
|
|
|
{
|
|
|
|
struct route_map_index *index;
|
|
|
|
|
|
|
|
index = route_map_index_lookup (map, RMAP_ANY, pref);
|
|
|
|
if (index && index->type != type)
|
|
|
|
{
|
|
|
|
/* Delete index from route map. */
|
|
|
|
route_map_index_delete (index, 1);
|
|
|
|
index = NULL;
|
|
|
|
}
|
|
|
|
if (index == NULL)
|
|
|
|
index = route_map_index_add (map, type, pref);
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* New route map rule */
|
2005-05-06 Paul Jakma <paul@dishone.st>
* (general) extern and static'ification of functions in code and
header.
Cleanup any definitions with unspecified arguments.
Add casts for callback assignments where the callback is defined,
typically, as passing void *, but the function being assigned has
some other pointer type defined as its argument, as gcc complains
about casts from void * to X* via function arguments.
Fix some old K&R style function argument definitions.
Add noreturn gcc attribute to some functions, as appropriate.
Add unused gcc attribute to some functions (eg ones meant to help
while debugging)
Add guard defines to headers which were missing them.
* command.c: (install_node) add const qualifier, still doesnt shut
up the warning though, because of the double pointer.
(cmp_node) ditto
* keychain.c: (key_str2time) Add GET_LONG_RANGE() macro, derived
fromn vty.h ones to fix some of the (long) < 0 warnings.
* thread.c: (various) use thread_empty
(cpu_record_hash_key) should cast to uintptr_t, a stdint.h type
* vty.h: Add VTY_GET_IPV4_ADDRESS and VTY_GET_IPV4_PREFIX so they
removed from ospfd/ospf_vty.h
* zebra.h: Move definition of ZEBRA_PORT to here, to remove
dependence of lib on zebra/zserv.h
2005-05-06 23:25:49 +02:00
|
|
|
static struct route_map_rule *
|
|
|
|
route_map_rule_new (void)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct route_map_rule *new;
|
|
|
|
|
|
|
|
new = XCALLOC (MTYPE_ROUTE_MAP_RULE, sizeof (struct route_map_rule));
|
|
|
|
return new;
|
|
|
|
}
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Install rule command to the match list. */
|
|
|
|
void
|
|
|
|
route_map_install_match (struct route_map_rule_cmd *cmd)
|
|
|
|
{
|
|
|
|
vector_set (route_match_vec, cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Install rule command to the set list. */
|
|
|
|
void
|
|
|
|
route_map_install_set (struct route_map_rule_cmd *cmd)
|
|
|
|
{
|
|
|
|
vector_set (route_set_vec, cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Lookup rule command from match list. */
|
2005-05-06 Paul Jakma <paul@dishone.st>
* (general) extern and static'ification of functions in code and
header.
Cleanup any definitions with unspecified arguments.
Add casts for callback assignments where the callback is defined,
typically, as passing void *, but the function being assigned has
some other pointer type defined as its argument, as gcc complains
about casts from void * to X* via function arguments.
Fix some old K&R style function argument definitions.
Add noreturn gcc attribute to some functions, as appropriate.
Add unused gcc attribute to some functions (eg ones meant to help
while debugging)
Add guard defines to headers which were missing them.
* command.c: (install_node) add const qualifier, still doesnt shut
up the warning though, because of the double pointer.
(cmp_node) ditto
* keychain.c: (key_str2time) Add GET_LONG_RANGE() macro, derived
fromn vty.h ones to fix some of the (long) < 0 warnings.
* thread.c: (various) use thread_empty
(cpu_record_hash_key) should cast to uintptr_t, a stdint.h type
* vty.h: Add VTY_GET_IPV4_ADDRESS and VTY_GET_IPV4_PREFIX so they
removed from ospfd/ospf_vty.h
* zebra.h: Move definition of ZEBRA_PORT to here, to remove
dependence of lib on zebra/zserv.h
2005-05-06 23:25:49 +02:00
|
|
|
static struct route_map_rule_cmd *
|
2004-10-08 08:29:12 +02:00
|
|
|
route_map_lookup_match (const char *name)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-10-05 23:01:23 +02:00
|
|
|
unsigned int i;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct route_map_rule_cmd *rule;
|
|
|
|
|
2005-03-14 21:19:01 +01:00
|
|
|
for (i = 0; i < vector_active (route_match_vec); i++)
|
2002-12-13 21:15:29 +01:00
|
|
|
if ((rule = vector_slot (route_match_vec, i)) != NULL)
|
|
|
|
if (strcmp (rule->str, name) == 0)
|
|
|
|
return rule;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Lookup rule command from set list. */
|
2005-05-06 Paul Jakma <paul@dishone.st>
* (general) extern and static'ification of functions in code and
header.
Cleanup any definitions with unspecified arguments.
Add casts for callback assignments where the callback is defined,
typically, as passing void *, but the function being assigned has
some other pointer type defined as its argument, as gcc complains
about casts from void * to X* via function arguments.
Fix some old K&R style function argument definitions.
Add noreturn gcc attribute to some functions, as appropriate.
Add unused gcc attribute to some functions (eg ones meant to help
while debugging)
Add guard defines to headers which were missing them.
* command.c: (install_node) add const qualifier, still doesnt shut
up the warning though, because of the double pointer.
(cmp_node) ditto
* keychain.c: (key_str2time) Add GET_LONG_RANGE() macro, derived
fromn vty.h ones to fix some of the (long) < 0 warnings.
* thread.c: (various) use thread_empty
(cpu_record_hash_key) should cast to uintptr_t, a stdint.h type
* vty.h: Add VTY_GET_IPV4_ADDRESS and VTY_GET_IPV4_PREFIX so they
removed from ospfd/ospf_vty.h
* zebra.h: Move definition of ZEBRA_PORT to here, to remove
dependence of lib on zebra/zserv.h
2005-05-06 23:25:49 +02:00
|
|
|
static struct route_map_rule_cmd *
|
2004-10-08 08:29:12 +02:00
|
|
|
route_map_lookup_set (const char *name)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-10-05 23:01:23 +02:00
|
|
|
unsigned int i;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct route_map_rule_cmd *rule;
|
|
|
|
|
2005-03-14 21:19:01 +01:00
|
|
|
for (i = 0; i < vector_active (route_set_vec); i++)
|
2002-12-13 21:15:29 +01:00
|
|
|
if ((rule = vector_slot (route_set_vec, i)) != NULL)
|
|
|
|
if (strcmp (rule->str, name) == 0)
|
|
|
|
return rule;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add match and set rule to rule list. */
|
|
|
|
static void
|
|
|
|
route_map_rule_add (struct route_map_rule_list *list,
|
|
|
|
struct route_map_rule *rule)
|
|
|
|
{
|
|
|
|
rule->next = NULL;
|
|
|
|
rule->prev = list->tail;
|
|
|
|
if (list->tail)
|
|
|
|
list->tail->next = rule;
|
|
|
|
else
|
|
|
|
list->head = rule;
|
|
|
|
list->tail = rule;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Delete rule from rule list. */
|
|
|
|
static void
|
|
|
|
route_map_rule_delete (struct route_map_rule_list *list,
|
|
|
|
struct route_map_rule *rule)
|
|
|
|
{
|
|
|
|
if (rule->cmd->func_free)
|
|
|
|
(*rule->cmd->func_free) (rule->value);
|
|
|
|
|
|
|
|
if (rule->rule_str)
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_RULE_STR, rule->rule_str);
|
|
|
|
|
|
|
|
if (rule->next)
|
|
|
|
rule->next->prev = rule->prev;
|
|
|
|
else
|
|
|
|
list->tail = rule->prev;
|
|
|
|
if (rule->prev)
|
|
|
|
rule->prev->next = rule->next;
|
|
|
|
else
|
|
|
|
list->head = rule->next;
|
|
|
|
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_RULE, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* strcmp wrapper function which don't crush even argument is NULL. */
|
2005-05-06 Paul Jakma <paul@dishone.st>
* (general) extern and static'ification of functions in code and
header.
Cleanup any definitions with unspecified arguments.
Add casts for callback assignments where the callback is defined,
typically, as passing void *, but the function being assigned has
some other pointer type defined as its argument, as gcc complains
about casts from void * to X* via function arguments.
Fix some old K&R style function argument definitions.
Add noreturn gcc attribute to some functions, as appropriate.
Add unused gcc attribute to some functions (eg ones meant to help
while debugging)
Add guard defines to headers which were missing them.
* command.c: (install_node) add const qualifier, still doesnt shut
up the warning though, because of the double pointer.
(cmp_node) ditto
* keychain.c: (key_str2time) Add GET_LONG_RANGE() macro, derived
fromn vty.h ones to fix some of the (long) < 0 warnings.
* thread.c: (various) use thread_empty
(cpu_record_hash_key) should cast to uintptr_t, a stdint.h type
* vty.h: Add VTY_GET_IPV4_ADDRESS and VTY_GET_IPV4_PREFIX so they
removed from ospfd/ospf_vty.h
* zebra.h: Move definition of ZEBRA_PORT to here, to remove
dependence of lib on zebra/zserv.h
2005-05-06 23:25:49 +02:00
|
|
|
static int
|
2004-10-11 13:28:44 +02:00
|
|
|
rulecmp (const char *dst, const char *src)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
if (dst == NULL)
|
|
|
|
{
|
|
|
|
if (src == NULL)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (src == NULL)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return strcmp (dst, src);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
/* Use this to return the already specified argument for this match. This is
|
|
|
|
* useful to get the specified argument with a route map match rule when the
|
|
|
|
* rule is being deleted and the argument is not provided.
|
|
|
|
*/
|
|
|
|
const char *
|
|
|
|
route_map_get_match_arg(struct route_map_index *index, const char *match_name)
|
|
|
|
{
|
|
|
|
struct route_map_rule *rule;
|
|
|
|
struct route_map_rule_cmd *cmd;
|
|
|
|
|
|
|
|
/* First lookup rule for add match statement. */
|
|
|
|
cmd = route_map_lookup_match (match_name);
|
|
|
|
if (cmd == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
for (rule = index->match_list.head; rule; rule = rule->next)
|
|
|
|
if (rule->cmd == cmd && rule->rule_str != NULL)
|
|
|
|
return (rule->rule_str);
|
|
|
|
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Add match statement to route map. */
|
|
|
|
int
|
2004-10-08 08:29:12 +02:00
|
|
|
route_map_add_match (struct route_map_index *index, const char *match_name,
|
2004-10-11 13:28:44 +02:00
|
|
|
const char *match_arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct route_map_rule *rule;
|
|
|
|
struct route_map_rule *next;
|
|
|
|
struct route_map_rule_cmd *cmd;
|
|
|
|
void *compile;
|
|
|
|
int replaced = 0;
|
|
|
|
|
|
|
|
/* First lookup rule for add match statement. */
|
|
|
|
cmd = route_map_lookup_match (match_name);
|
|
|
|
if (cmd == NULL)
|
|
|
|
return RMAP_RULE_MISSING;
|
|
|
|
|
|
|
|
/* Next call compile function for this match statement. */
|
|
|
|
if (cmd->func_compile)
|
|
|
|
{
|
|
|
|
compile= (*cmd->func_compile)(match_arg);
|
|
|
|
if (compile == NULL)
|
|
|
|
return RMAP_COMPILE_ERROR;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
compile = NULL;
|
|
|
|
|
|
|
|
/* If argument is completely same ignore it. */
|
|
|
|
for (rule = index->match_list.head; rule; rule = next)
|
|
|
|
{
|
|
|
|
next = rule->next;
|
|
|
|
if (rule->cmd == cmd)
|
|
|
|
{
|
|
|
|
route_map_rule_delete (&index->match_list, rule);
|
|
|
|
replaced = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add new route map match rule. */
|
|
|
|
rule = route_map_rule_new ();
|
|
|
|
rule->cmd = cmd;
|
|
|
|
rule->value = compile;
|
|
|
|
if (match_arg)
|
|
|
|
rule->rule_str = XSTRDUP (MTYPE_ROUTE_MAP_RULE_STR, match_arg);
|
|
|
|
else
|
|
|
|
rule->rule_str = NULL;
|
|
|
|
|
|
|
|
/* Add new route match rule to linked list. */
|
|
|
|
route_map_rule_add (&index->match_list, rule);
|
|
|
|
|
|
|
|
/* Execute event hook. */
|
|
|
|
if (route_map_master.event_hook)
|
2015-05-20 02:40:45 +02:00
|
|
|
{
|
|
|
|
(*route_map_master.event_hook) (replaced ?
|
|
|
|
RMAP_EVENT_MATCH_REPLACED:
|
|
|
|
RMAP_EVENT_MATCH_ADDED,
|
|
|
|
index->map->name);
|
|
|
|
route_map_notify_dependencies(index->map->name, RMAP_EVENT_CALL_ADDED);
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Delete specified route match rule. */
|
|
|
|
int
|
2004-10-08 08:29:12 +02:00
|
|
|
route_map_delete_match (struct route_map_index *index, const char *match_name,
|
2004-10-11 13:28:44 +02:00
|
|
|
const char *match_arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct route_map_rule *rule;
|
|
|
|
struct route_map_rule_cmd *cmd;
|
|
|
|
|
|
|
|
cmd = route_map_lookup_match (match_name);
|
|
|
|
if (cmd == NULL)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
for (rule = index->match_list.head; rule; rule = rule->next)
|
|
|
|
if (rule->cmd == cmd &&
|
|
|
|
(rulecmp (rule->rule_str, match_arg) == 0 || match_arg == NULL))
|
|
|
|
{
|
|
|
|
route_map_rule_delete (&index->match_list, rule);
|
|
|
|
/* Execute event hook. */
|
|
|
|
if (route_map_master.event_hook)
|
2015-05-20 02:40:45 +02:00
|
|
|
{
|
|
|
|
(*route_map_master.event_hook) (RMAP_EVENT_MATCH_DELETED,
|
|
|
|
index->map->name);
|
|
|
|
route_map_notify_dependencies(index->map->name, RMAP_EVENT_CALL_ADDED);
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* Can't find matched rule. */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add route-map set statement to the route map. */
|
|
|
|
int
|
2004-10-08 08:29:12 +02:00
|
|
|
route_map_add_set (struct route_map_index *index, const char *set_name,
|
2004-10-11 13:28:44 +02:00
|
|
|
const char *set_arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct route_map_rule *rule;
|
|
|
|
struct route_map_rule *next;
|
|
|
|
struct route_map_rule_cmd *cmd;
|
|
|
|
void *compile;
|
|
|
|
int replaced = 0;
|
|
|
|
|
|
|
|
cmd = route_map_lookup_set (set_name);
|
|
|
|
if (cmd == NULL)
|
|
|
|
return RMAP_RULE_MISSING;
|
|
|
|
|
|
|
|
/* Next call compile function for this match statement. */
|
|
|
|
if (cmd->func_compile)
|
|
|
|
{
|
|
|
|
compile= (*cmd->func_compile)(set_arg);
|
|
|
|
if (compile == NULL)
|
|
|
|
return RMAP_COMPILE_ERROR;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
compile = NULL;
|
|
|
|
|
|
|
|
/* Add by WJL. if old set command of same kind exist, delete it first
|
|
|
|
to ensure only one set command of same kind exist under a
|
|
|
|
route_map_index. */
|
|
|
|
for (rule = index->set_list.head; rule; rule = next)
|
|
|
|
{
|
|
|
|
next = rule->next;
|
|
|
|
if (rule->cmd == cmd)
|
|
|
|
{
|
|
|
|
route_map_rule_delete (&index->set_list, rule);
|
|
|
|
replaced = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add new route map match rule. */
|
|
|
|
rule = route_map_rule_new ();
|
|
|
|
rule->cmd = cmd;
|
|
|
|
rule->value = compile;
|
|
|
|
if (set_arg)
|
|
|
|
rule->rule_str = XSTRDUP (MTYPE_ROUTE_MAP_RULE_STR, set_arg);
|
|
|
|
else
|
|
|
|
rule->rule_str = NULL;
|
|
|
|
|
|
|
|
/* Add new route match rule to linked list. */
|
|
|
|
route_map_rule_add (&index->set_list, rule);
|
|
|
|
|
|
|
|
/* Execute event hook. */
|
|
|
|
if (route_map_master.event_hook)
|
2015-05-20 02:40:45 +02:00
|
|
|
{
|
|
|
|
(*route_map_master.event_hook) (replaced ?
|
|
|
|
RMAP_EVENT_SET_REPLACED:
|
|
|
|
RMAP_EVENT_SET_ADDED,
|
|
|
|
index->map->name);
|
|
|
|
route_map_notify_dependencies(index->map->name, RMAP_EVENT_CALL_ADDED);
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Delete route map set rule. */
|
|
|
|
int
|
2004-10-08 08:29:12 +02:00
|
|
|
route_map_delete_set (struct route_map_index *index, const char *set_name,
|
2004-10-11 13:28:44 +02:00
|
|
|
const char *set_arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
struct route_map_rule *rule;
|
|
|
|
struct route_map_rule_cmd *cmd;
|
|
|
|
|
|
|
|
cmd = route_map_lookup_set (set_name);
|
|
|
|
if (cmd == NULL)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
for (rule = index->set_list.head; rule; rule = rule->next)
|
|
|
|
if ((rule->cmd == cmd) &&
|
|
|
|
(rulecmp (rule->rule_str, set_arg) == 0 || set_arg == NULL))
|
|
|
|
{
|
|
|
|
route_map_rule_delete (&index->set_list, rule);
|
|
|
|
/* Execute event hook. */
|
|
|
|
if (route_map_master.event_hook)
|
2015-05-20 02:40:45 +02:00
|
|
|
{
|
|
|
|
(*route_map_master.event_hook) (RMAP_EVENT_SET_DELETED,
|
|
|
|
index->map->name);
|
|
|
|
route_map_notify_dependencies(index->map->name, RMAP_EVENT_CALL_ADDED);
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* Can't find matched rule. */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2003-10-29 07:30:19 +01:00
|
|
|
/* Apply route map's each index to the object.
|
|
|
|
|
|
|
|
The matrix for a route-map looks like this:
|
|
|
|
(note, this includes the description for the "NEXT"
|
|
|
|
and "GOTO" frobs now
|
|
|
|
|
|
|
|
Match | No Match
|
|
|
|
|
|
|
|
|
permit action | cont
|
|
|
|
|
|
|
|
|
------------------+---------------
|
|
|
|
|
|
|
|
|
deny deny | cont
|
|
|
|
|
|
|
|
|
|
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
|
|
|
action)
|
|
|
|
-Apply Set statements, accept route
|
|
|
|
-If Call statement is present jump to the specified route-map, if it
|
|
|
|
denies the route we finish.
|
|
|
|
-If NEXT is specified, goto NEXT statement
|
|
|
|
-If GOTO is specified, goto the first clause where pref > nextpref
|
|
|
|
-If nothing is specified, do as Cisco and finish
|
|
|
|
deny)
|
|
|
|
-Route is denied by route-map.
|
|
|
|
cont)
|
|
|
|
-Goto Next index
|
2003-10-29 07:30:19 +01:00
|
|
|
|
|
|
|
If we get no matches after we've processed all updates, then the route
|
|
|
|
is dropped too.
|
|
|
|
|
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
|
|
|
Some notes on the new "CALL", "NEXT" and "GOTO"
|
|
|
|
call WORD - If this clause is matched, then the set statements
|
|
|
|
are executed and then we jump to route-map 'WORD'. If
|
|
|
|
this route-map denies the route, we finish, in other case we
|
|
|
|
do whatever the exit policy (EXIT, NEXT or GOTO) tells.
|
2003-10-29 07:30:19 +01:00
|
|
|
on-match next - If this clause is matched, then the set statements
|
|
|
|
are executed and then we drop through to the next clause
|
|
|
|
on-match goto n - If this clause is matched, then the set statments
|
|
|
|
are executed and then we goto the nth clause, or the
|
|
|
|
first clause greater than this. In order to ensure
|
|
|
|
route-maps *always* exit, you cannot jump backwards.
|
|
|
|
Sorry ;)
|
|
|
|
|
|
|
|
We need to make sure our route-map processing matches the above
|
2002-12-13 21:15:29 +01:00
|
|
|
*/
|
2003-10-29 07:30:19 +01:00
|
|
|
|
2005-05-06 Paul Jakma <paul@dishone.st>
* (general) extern and static'ification of functions in code and
header.
Cleanup any definitions with unspecified arguments.
Add casts for callback assignments where the callback is defined,
typically, as passing void *, but the function being assigned has
some other pointer type defined as its argument, as gcc complains
about casts from void * to X* via function arguments.
Fix some old K&R style function argument definitions.
Add noreturn gcc attribute to some functions, as appropriate.
Add unused gcc attribute to some functions (eg ones meant to help
while debugging)
Add guard defines to headers which were missing them.
* command.c: (install_node) add const qualifier, still doesnt shut
up the warning though, because of the double pointer.
(cmp_node) ditto
* keychain.c: (key_str2time) Add GET_LONG_RANGE() macro, derived
fromn vty.h ones to fix some of the (long) < 0 warnings.
* thread.c: (various) use thread_empty
(cpu_record_hash_key) should cast to uintptr_t, a stdint.h type
* vty.h: Add VTY_GET_IPV4_ADDRESS and VTY_GET_IPV4_PREFIX so they
removed from ospfd/ospf_vty.h
* zebra.h: Move definition of ZEBRA_PORT to here, to remove
dependence of lib on zebra/zserv.h
2005-05-06 23:25:49 +02:00
|
|
|
static route_map_result_t
|
2003-10-29 07:30:19 +01:00
|
|
|
route_map_apply_match (struct route_map_rule_list *match_list,
|
|
|
|
struct prefix *prefix, route_map_object_t type,
|
|
|
|
void *object)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2003-10-29 07:30:19 +01:00
|
|
|
route_map_result_t ret = RMAP_NOMATCH;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct route_map_rule *match;
|
|
|
|
|
|
|
|
|
2003-10-29 07:30:19 +01:00
|
|
|
/* Check all match rule and if there is no match rule, go to the
|
|
|
|
set statement. */
|
|
|
|
if (!match_list->head)
|
|
|
|
ret = RMAP_MATCH;
|
|
|
|
else
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2003-10-29 07:30:19 +01:00
|
|
|
for (match = match_list->head; match; match = match->next)
|
|
|
|
{
|
|
|
|
/* Try each match statement in turn, If any do not return
|
|
|
|
RMAP_MATCH, return, otherwise continue on to next match
|
|
|
|
statement. All match statements must match for end-result
|
|
|
|
to be a match. */
|
|
|
|
ret = (*match->cmd->func_apply) (match->value, prefix,
|
|
|
|
type, object);
|
|
|
|
if (ret != RMAP_MATCH)
|
|
|
|
return ret;
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2003-10-29 07:30:19 +01:00
|
|
|
return ret;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Apply route map to the object. */
|
|
|
|
route_map_result_t
|
2003-10-29 07:30:19 +01:00
|
|
|
route_map_apply (struct route_map *map, struct prefix *prefix,
|
|
|
|
route_map_object_t type, void *object)
|
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
|
|
|
static int recursion = 0;
|
2002-12-13 21:15:29 +01:00
|
|
|
int ret = 0;
|
|
|
|
struct route_map_index *index;
|
2003-10-29 07:30:19 +01:00
|
|
|
struct route_map_rule *set;
|
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
|
|
|
if (recursion > RMAP_RECURSION_LIMIT)
|
|
|
|
{
|
*: get rid of zlog(*, LOG_LEVEL, ...)
Result of running the following Coccinelle patch + fixups:
<<EOF
/* long-forms: zlog(NULL, <level>, ...)
* => zlog_level(...)
*/
@@
expression list args;
@@
- zlog(NULL, LOG_DEBUG, args)
+ zlog_debug(args)
@@
expression list args;
@@
- zlog(NULL, LOG_NOTICE, args)
+ zlog_notice(args)
@@
expression list args;
@@
- zlog(NULL, LOG_INFO, args)
+ zlog_info(args)
@@
expression list args;
@@
- zlog(NULL, LOG_WARNING, args)
+ zlog_warn(args)
@@
expression list args;
@@
- zlog(NULL, LOG_ERR, args)
+ zlog_err(args)
/* long-forms: zlog(base->log, <level>, ...)
* => zlog_level(...)
*/
@@
expression base;
expression list args;
@@
- zlog(base->log, LOG_DEBUG, args)
+ zlog_debug(args)
@@
expression base;
expression list args;
@@
- zlog(base->log, LOG_NOTICE, args)
+ zlog_notice(args)
@@
expression base;
expression list args;
@@
- zlog(base->log, LOG_INFO, args)
+ zlog_info(args)
@@
expression base;
expression list args;
@@
- zlog(base->log, LOG_WARNING, args)
+ zlog_warn(args)
@@
expression base;
expression list args;
@@
- zlog(base->log, LOG_ERR, args)
+ zlog_err(args)
EOF
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-13 04:19:14 +01:00
|
|
|
zlog_warn("route-map recursion limit (%d) reached, discarding route",
|
|
|
|
RMAP_RECURSION_LIMIT);
|
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
|
|
|
recursion = 0;
|
|
|
|
return RMAP_DENYMATCH;
|
|
|
|
}
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (map == NULL)
|
|
|
|
return RMAP_DENYMATCH;
|
|
|
|
|
|
|
|
for (index = map->head; index; index = index->next)
|
|
|
|
{
|
2003-10-29 07:30:19 +01:00
|
|
|
/* Apply this index. */
|
|
|
|
ret = route_map_apply_match (&index->match_list, prefix, type, object);
|
|
|
|
|
|
|
|
/* Now we apply the matrix from above */
|
|
|
|
if (ret == RMAP_NOMATCH)
|
|
|
|
/* 'cont' from matrix - continue to next route-map sequence */
|
|
|
|
continue;
|
|
|
|
else if (ret == RMAP_MATCH)
|
|
|
|
{
|
|
|
|
if (index->type == RMAP_PERMIT)
|
|
|
|
/* 'action' */
|
|
|
|
{
|
|
|
|
/* permit+match must execute sets */
|
|
|
|
for (set = index->set_list.head; set; set = set->next)
|
|
|
|
ret = (*set->cmd->func_apply) (set->value, prefix,
|
|
|
|
type, object);
|
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
|
|
|
|
|
|
|
/* Call another route-map if available */
|
|
|
|
if (index->nextrm)
|
|
|
|
{
|
|
|
|
struct route_map *nextrm =
|
|
|
|
route_map_lookup_by_name (index->nextrm);
|
|
|
|
|
|
|
|
if (nextrm) /* Target route-map found, jump to it */
|
|
|
|
{
|
|
|
|
recursion++;
|
|
|
|
ret = route_map_apply (nextrm, prefix, type, object);
|
|
|
|
recursion--;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If nextrm returned 'deny', finish. */
|
|
|
|
if (ret == RMAP_DENYMATCH)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2003-10-29 07:30:19 +01:00
|
|
|
switch (index->exitpolicy)
|
|
|
|
{
|
|
|
|
case RMAP_EXIT:
|
|
|
|
return ret;
|
|
|
|
case RMAP_NEXT:
|
|
|
|
continue;
|
|
|
|
case RMAP_GOTO:
|
|
|
|
{
|
|
|
|
/* Find the next clause to jump to */
|
|
|
|
struct route_map_index *next = index->next;
|
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
|
|
|
int nextpref = index->nextpref;
|
2003-10-29 07:30:19 +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
|
|
|
while (next && next->pref < nextpref)
|
2003-10-29 07:30:19 +01:00
|
|
|
{
|
|
|
|
index = next;
|
|
|
|
next = next->next;
|
|
|
|
}
|
|
|
|
if (next == NULL)
|
|
|
|
{
|
|
|
|
/* No clauses match! */
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (index->type == RMAP_DENY)
|
|
|
|
/* 'deny' */
|
|
|
|
{
|
|
|
|
return RMAP_DENYMATCH;
|
|
|
|
}
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
/* Finally route-map does not match at all. */
|
|
|
|
return RMAP_DENYMATCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-10-10 Paul Jakma <paul@dishone.st>
* version.h.in: (pid_output*) add const qualifier.
* command.h: Change DEFUN func to take const char *[] rather
than char **, to begin process of fixing compile warnings in lib/.
Nearly all other changes in this commit follow from this change.
* buffer.{c,h}: (buffer_write) pointer-arithmetic is gccism, take
const void * and cast an automatic const char *p to it.
(buffer_putstr) add const
* command.c: (zencrypt) const qualifier
(cmd_execute_command_real) ditto
(cmd_execute_command_strict) ditto
(config_log_file) ditto.
Fix leak of getcwd() returned string.
* memory.{c,h}: Add MTYPE_DISTRIBUTE_IFNAME for struct dist ifname.
* distribute.{c,h}: Update with const qualifier.
(distribute_free) use MTYPE_DISTRIBUTE_IFNAME
(distribute_lookup) Cast to char *, note that it's ok.
(distribute_hash_alloc) use MTYPE_DISTRIBUTE_IFNAME.
(distribute_get) Cast to char *, note that it's ok.
* filter.c: Update with const qualifier.
* if.{c,h}: ditto.
* if_rmap.{c,h}: ditto.
(if_rmap_lookup) Cast to char *, note that it's ok.
(if_rmap_get) ditto.
* log.{c,h}: Update with const qualifier.
* plist.{c,h}: ditto.
* routemap.{c,h}: ditto.
* smux.{c,h}: ditto. Fix some signed/unsigned comparisons.
* sockopt.c: (getsockopt_cmsg_data) add return for error case.
* vty.c: Update with const qualifier.
2004-10-10 13:56:56 +02:00
|
|
|
route_map_add_hook (void (*func) (const char *))
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
route_map_master.add_hook = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-10-10 Paul Jakma <paul@dishone.st>
* version.h.in: (pid_output*) add const qualifier.
* command.h: Change DEFUN func to take const char *[] rather
than char **, to begin process of fixing compile warnings in lib/.
Nearly all other changes in this commit follow from this change.
* buffer.{c,h}: (buffer_write) pointer-arithmetic is gccism, take
const void * and cast an automatic const char *p to it.
(buffer_putstr) add const
* command.c: (zencrypt) const qualifier
(cmd_execute_command_real) ditto
(cmd_execute_command_strict) ditto
(config_log_file) ditto.
Fix leak of getcwd() returned string.
* memory.{c,h}: Add MTYPE_DISTRIBUTE_IFNAME for struct dist ifname.
* distribute.{c,h}: Update with const qualifier.
(distribute_free) use MTYPE_DISTRIBUTE_IFNAME
(distribute_lookup) Cast to char *, note that it's ok.
(distribute_hash_alloc) use MTYPE_DISTRIBUTE_IFNAME.
(distribute_get) Cast to char *, note that it's ok.
* filter.c: Update with const qualifier.
* if.{c,h}: ditto.
* if_rmap.{c,h}: ditto.
(if_rmap_lookup) Cast to char *, note that it's ok.
(if_rmap_get) ditto.
* log.{c,h}: Update with const qualifier.
* plist.{c,h}: ditto.
* routemap.{c,h}: ditto.
* smux.{c,h}: ditto. Fix some signed/unsigned comparisons.
* sockopt.c: (getsockopt_cmsg_data) add return for error case.
* vty.c: Update with const qualifier.
2004-10-10 13:56:56 +02:00
|
|
|
route_map_delete_hook (void (*func) (const char *))
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
route_map_master.delete_hook = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-10-10 Paul Jakma <paul@dishone.st>
* version.h.in: (pid_output*) add const qualifier.
* command.h: Change DEFUN func to take const char *[] rather
than char **, to begin process of fixing compile warnings in lib/.
Nearly all other changes in this commit follow from this change.
* buffer.{c,h}: (buffer_write) pointer-arithmetic is gccism, take
const void * and cast an automatic const char *p to it.
(buffer_putstr) add const
* command.c: (zencrypt) const qualifier
(cmd_execute_command_real) ditto
(cmd_execute_command_strict) ditto
(config_log_file) ditto.
Fix leak of getcwd() returned string.
* memory.{c,h}: Add MTYPE_DISTRIBUTE_IFNAME for struct dist ifname.
* distribute.{c,h}: Update with const qualifier.
(distribute_free) use MTYPE_DISTRIBUTE_IFNAME
(distribute_lookup) Cast to char *, note that it's ok.
(distribute_hash_alloc) use MTYPE_DISTRIBUTE_IFNAME.
(distribute_get) Cast to char *, note that it's ok.
* filter.c: Update with const qualifier.
* if.{c,h}: ditto.
* if_rmap.{c,h}: ditto.
(if_rmap_lookup) Cast to char *, note that it's ok.
(if_rmap_get) ditto.
* log.{c,h}: Update with const qualifier.
* plist.{c,h}: ditto.
* routemap.{c,h}: ditto.
* smux.{c,h}: ditto. Fix some signed/unsigned comparisons.
* sockopt.c: (getsockopt_cmsg_data) add return for error case.
* vty.c: Update with const qualifier.
2004-10-10 13:56:56 +02:00
|
|
|
route_map_event_hook (void (*func) (route_map_event_t, const char *))
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
route_map_master.event_hook = func;
|
|
|
|
}
|
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
/* Routines for route map dependency lists and dependency processing */
|
|
|
|
static int
|
|
|
|
route_map_rmap_hash_cmp (const void *p1, const void *p2)
|
|
|
|
{
|
2015-05-20 03:04:26 +02:00
|
|
|
return (strcmp((const char *)p1, (const char *)p2) == 0);
|
2015-05-20 02:40:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
route_map_dep_hash_cmp (const void *p1, const void *p2)
|
|
|
|
{
|
|
|
|
|
2015-05-20 03:04:26 +02:00
|
|
|
return (strcmp (((const struct route_map_dep *)p1)->dep_name, (const char *)p2) == 0);
|
2015-05-20 02:40:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
route_map_clear_reference(struct hash_backet *backet, void *arg)
|
|
|
|
{
|
|
|
|
struct route_map_dep *dep = (struct route_map_dep *)backet->data;
|
|
|
|
char *rmap_name;
|
|
|
|
|
|
|
|
if (dep && arg)
|
|
|
|
{
|
|
|
|
rmap_name = (char *)hash_release(dep->dep_rmap_hash, (void *)arg);
|
|
|
|
if (rmap_name)
|
|
|
|
{
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_NAME, rmap_name);
|
|
|
|
}
|
|
|
|
if (!dep->dep_rmap_hash->count)
|
|
|
|
{
|
|
|
|
dep = hash_release(dep->this_hash, (void *)dep->dep_name);
|
|
|
|
hash_free(dep->dep_rmap_hash);
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_NAME, dep->dep_name);
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_DEP, dep);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
route_map_clear_all_references (char *rmap_name)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 1; i < ROUTE_MAP_DEP_MAX; i++)
|
|
|
|
{
|
|
|
|
hash_iterate(route_map_dep_hash[i], route_map_clear_reference,
|
|
|
|
(void *)rmap_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
|
|
|
route_map_dep_hash_alloc(void *p)
|
|
|
|
{
|
|
|
|
char *dep_name = (char *)p;
|
|
|
|
struct route_map_dep *dep_entry;
|
|
|
|
|
|
|
|
dep_entry = XCALLOC(MTYPE_ROUTE_MAP_DEP, sizeof(struct route_map_dep));
|
|
|
|
dep_entry->dep_name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, dep_name);
|
|
|
|
dep_entry->dep_rmap_hash = hash_create(route_map_dep_hash_make_key,
|
|
|
|
route_map_rmap_hash_cmp);
|
|
|
|
dep_entry->this_hash = NULL;
|
|
|
|
|
|
|
|
return((void *)dep_entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
|
|
|
route_map_name_hash_alloc(void *p)
|
|
|
|
{
|
2015-05-20 03:04:26 +02:00
|
|
|
return((void *)XSTRDUP(MTYPE_ROUTE_MAP_NAME, (const char *)p));
|
2015-05-20 02:40:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int
|
|
|
|
route_map_dep_hash_make_key (void *p)
|
|
|
|
{
|
|
|
|
return (string_hash_make((char *)p));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
route_map_print_dependency (struct hash_backet *backet, void *data)
|
|
|
|
{
|
|
|
|
char *rmap_name = (char *)backet->data;
|
|
|
|
char *dep_name = (char *)data;
|
|
|
|
|
|
|
|
if (rmap_name)
|
|
|
|
zlog_debug("%s: Dependency for %s: %s", __FUNCTION__, dep_name, rmap_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
route_map_dep_update (struct hash *dephash, const char *dep_name,
|
|
|
|
const char *rmap_name,
|
|
|
|
route_map_event_t type)
|
|
|
|
{
|
2016-05-07 21:42:51 +02:00
|
|
|
struct route_map_dep *dep = NULL;
|
2015-05-20 02:40:45 +02:00
|
|
|
char *ret_map_name;
|
2015-05-20 03:04:26 +02:00
|
|
|
char *dname, *rname;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
dname = XSTRDUP(MTYPE_ROUTE_MAP_NAME, dep_name);
|
|
|
|
rname = XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_name);
|
2015-05-20 02:40:45 +02:00
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case RMAP_EVENT_PLIST_ADDED:
|
|
|
|
case RMAP_EVENT_CLIST_ADDED:
|
|
|
|
case RMAP_EVENT_ECLIST_ADDED:
|
|
|
|
case RMAP_EVENT_ASLIST_ADDED:
|
2016-11-15 11:00:39 +01:00
|
|
|
case RMAP_EVENT_LLIST_ADDED:
|
2015-05-20 02:40:45 +02:00
|
|
|
case RMAP_EVENT_CALL_ADDED:
|
|
|
|
case RMAP_EVENT_FILTER_ADDED:
|
|
|
|
if (rmap_debug)
|
|
|
|
zlog_debug("%s: Adding dependency for %s in %s", __FUNCTION__,
|
|
|
|
dep_name, rmap_name);
|
2015-05-20 03:04:26 +02:00
|
|
|
dep = (struct route_map_dep *) hash_get (dephash, dname,
|
2015-05-20 02:40:45 +02:00
|
|
|
route_map_dep_hash_alloc);
|
2015-05-20 03:04:26 +02:00
|
|
|
if (!dep) {
|
|
|
|
ret = -1;
|
|
|
|
goto out;
|
|
|
|
}
|
2015-05-20 02:40:45 +02:00
|
|
|
|
|
|
|
if (!dep->this_hash)
|
|
|
|
dep->this_hash = dephash;
|
|
|
|
|
2015-05-20 03:04:26 +02:00
|
|
|
hash_get(dep->dep_rmap_hash, rname, route_map_name_hash_alloc);
|
2015-05-20 02:40:45 +02:00
|
|
|
break;
|
|
|
|
case RMAP_EVENT_PLIST_DELETED:
|
|
|
|
case RMAP_EVENT_CLIST_DELETED:
|
|
|
|
case RMAP_EVENT_ECLIST_DELETED:
|
|
|
|
case RMAP_EVENT_ASLIST_DELETED:
|
2016-11-15 11:00:39 +01:00
|
|
|
case RMAP_EVENT_LLIST_DELETED:
|
2015-05-20 02:40:45 +02:00
|
|
|
case RMAP_EVENT_CALL_DELETED:
|
|
|
|
case RMAP_EVENT_FILTER_DELETED:
|
|
|
|
if (rmap_debug)
|
|
|
|
zlog_debug("%s: Deleting dependency for %s in %s", __FUNCTION__,
|
|
|
|
dep_name, rmap_name);
|
2015-05-20 03:04:26 +02:00
|
|
|
dep = (struct route_map_dep *) hash_get (dephash, dname, NULL);
|
|
|
|
if (!dep) {
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret_map_name = (char *)hash_release(dep->dep_rmap_hash, rname);
|
2015-05-20 02:40:45 +02:00
|
|
|
if (ret_map_name)
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_NAME, ret_map_name);
|
|
|
|
|
|
|
|
if (!dep->dep_rmap_hash->count)
|
|
|
|
{
|
2015-05-20 03:04:26 +02:00
|
|
|
dep = hash_release(dephash, dname);
|
2015-05-20 02:40:45 +02:00
|
|
|
hash_free(dep->dep_rmap_hash);
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_NAME, dep->dep_name);
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_DEP, dep);
|
|
|
|
dep = NULL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dep)
|
|
|
|
{
|
|
|
|
if (rmap_debug)
|
2015-05-20 03:04:26 +02:00
|
|
|
hash_iterate (dep->dep_rmap_hash, route_map_print_dependency, dname);
|
2015-05-20 02:40:45 +02:00
|
|
|
}
|
2015-05-20 03:04:26 +02:00
|
|
|
|
|
|
|
out:
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_NAME, rname);
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_NAME, dname);
|
|
|
|
return ret;
|
2015-05-20 02:40:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct hash *
|
|
|
|
route_map_get_dep_hash (route_map_event_t event)
|
|
|
|
{
|
|
|
|
struct hash *upd8_hash = NULL;
|
|
|
|
|
|
|
|
switch (event)
|
|
|
|
{
|
|
|
|
case RMAP_EVENT_PLIST_ADDED:
|
|
|
|
case RMAP_EVENT_PLIST_DELETED:
|
|
|
|
upd8_hash = route_map_dep_hash[ROUTE_MAP_DEP_PLIST];
|
|
|
|
break;
|
|
|
|
case RMAP_EVENT_CLIST_ADDED:
|
|
|
|
case RMAP_EVENT_CLIST_DELETED:
|
|
|
|
upd8_hash = route_map_dep_hash[ROUTE_MAP_DEP_CLIST];
|
|
|
|
break;
|
|
|
|
case RMAP_EVENT_ECLIST_ADDED:
|
|
|
|
case RMAP_EVENT_ECLIST_DELETED:
|
|
|
|
upd8_hash = route_map_dep_hash[ROUTE_MAP_DEP_ECLIST];
|
|
|
|
break;
|
|
|
|
case RMAP_EVENT_ASLIST_ADDED:
|
|
|
|
case RMAP_EVENT_ASLIST_DELETED:
|
|
|
|
upd8_hash = route_map_dep_hash[ROUTE_MAP_DEP_ASPATH];
|
|
|
|
break;
|
2016-11-15 11:00:39 +01:00
|
|
|
case RMAP_EVENT_LLIST_ADDED:
|
|
|
|
case RMAP_EVENT_LLIST_DELETED:
|
|
|
|
upd8_hash = route_map_dep_hash[ROUTE_MAP_DEP_LCLIST];
|
|
|
|
break;
|
2015-05-20 02:40:45 +02:00
|
|
|
case RMAP_EVENT_CALL_ADDED:
|
|
|
|
case RMAP_EVENT_CALL_DELETED:
|
|
|
|
upd8_hash = route_map_dep_hash[ROUTE_MAP_DEP_RMAP];
|
|
|
|
break;
|
|
|
|
case RMAP_EVENT_FILTER_ADDED:
|
|
|
|
case RMAP_EVENT_FILTER_DELETED:
|
|
|
|
upd8_hash = route_map_dep_hash[ROUTE_MAP_DEP_FILTER];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
upd8_hash = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return (upd8_hash);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
route_map_process_dependency (struct hash_backet *backet, void *data)
|
|
|
|
{
|
|
|
|
char *rmap_name;
|
2016-09-21 12:49:30 +02:00
|
|
|
route_map_event_t type = (route_map_event_t)(ptrdiff_t)data;
|
2015-05-20 02:40:45 +02:00
|
|
|
|
|
|
|
rmap_name = (char *)backet->data;
|
|
|
|
|
|
|
|
if (rmap_name)
|
|
|
|
{
|
|
|
|
if (rmap_debug)
|
|
|
|
zlog_debug("%s: Notifying %s of dependency", __FUNCTION__,
|
|
|
|
rmap_name);
|
|
|
|
if (route_map_master.event_hook)
|
|
|
|
(*route_map_master.event_hook) (type, rmap_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
route_map_upd8_dependency (route_map_event_t type, const char *arg,
|
|
|
|
const char *rmap_name)
|
|
|
|
{
|
|
|
|
struct hash *upd8_hash = NULL;
|
|
|
|
|
|
|
|
if ((upd8_hash = route_map_get_dep_hash(type)))
|
|
|
|
route_map_dep_update (upd8_hash, arg, rmap_name, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
route_map_notify_dependencies (const char *affected_name, route_map_event_t event)
|
|
|
|
{
|
|
|
|
struct route_map_dep *dep;
|
|
|
|
struct hash *upd8_hash;
|
2015-05-20 03:04:26 +02:00
|
|
|
char *name;
|
2015-05-20 02:40:45 +02:00
|
|
|
|
|
|
|
if (!affected_name)
|
|
|
|
return;
|
|
|
|
|
2015-05-20 03:04:26 +02:00
|
|
|
name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, affected_name);
|
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
if ((upd8_hash = route_map_get_dep_hash(event)) == NULL)
|
2015-08-11 17:43:00 +02:00
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_NAME, name);
|
|
|
|
return;
|
|
|
|
}
|
2015-05-20 02:40:45 +02:00
|
|
|
|
2015-05-20 03:04:26 +02:00
|
|
|
dep = (struct route_map_dep *)hash_get (upd8_hash, name,
|
2015-05-20 02:40:45 +02:00
|
|
|
NULL);
|
|
|
|
if (dep)
|
|
|
|
{
|
|
|
|
if (!dep->this_hash)
|
|
|
|
dep->this_hash = upd8_hash;
|
|
|
|
|
|
|
|
hash_iterate (dep->dep_rmap_hash, route_map_process_dependency, (void *)event);
|
|
|
|
}
|
2015-05-20 03:04:26 +02:00
|
|
|
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_NAME, name);
|
2015-05-20 02:40:45 +02:00
|
|
|
}
|
|
|
|
|
2016-10-06 21:56:13 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* VTY related functions. */
|
2016-10-06 21:56:13 +02:00
|
|
|
DEFUN (match_interface,
|
|
|
|
match_interface_cmd,
|
|
|
|
"match interface WORD",
|
|
|
|
MATCH_STR
|
|
|
|
"match first hop interface of route\n"
|
|
|
|
"Interface name\n")
|
|
|
|
{
|
|
|
|
int idx_word = 2;
|
2016-10-18 01:36:21 +02:00
|
|
|
VTY_DECLVAR_CONTEXT (route_map_index, index);
|
2016-10-06 21:56:13 +02:00
|
|
|
|
|
|
|
if (rmap_match_set_hook.match_interface)
|
2016-10-18 01:36:21 +02:00
|
|
|
return rmap_match_set_hook.match_interface (vty, index, "interface", argv[idx_word]->arg, RMAP_EVENT_MATCH_ADDED);
|
2016-10-06 21:56:13 +02:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_match_interface,
|
|
|
|
no_match_interface_cmd,
|
2016-11-19 11:57:08 +01:00
|
|
|
"no match interface [WORD]",
|
2016-10-06 21:56:13 +02:00
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"Match first hop interface of route\n"
|
|
|
|
"Interface name\n")
|
|
|
|
{
|
|
|
|
char *iface = (argc == 4) ? argv[3]->arg : NULL;
|
2016-10-18 01:36:21 +02:00
|
|
|
VTY_DECLVAR_CONTEXT (route_map_index, index);
|
2016-10-06 21:56:13 +02:00
|
|
|
|
|
|
|
if (rmap_match_set_hook.no_match_interface)
|
2016-10-18 01:36:21 +02:00
|
|
|
return rmap_match_set_hook.no_match_interface (vty, index, "interface", iface, RMAP_EVENT_MATCH_DELETED);
|
2016-10-06 21:56:13 +02:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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")
|
|
|
|
{
|
|
|
|
int idx_acl = 3;
|
2016-10-18 01:36:21 +02:00
|
|
|
VTY_DECLVAR_CONTEXT (route_map_index, index);
|
2016-10-06 21:56:13 +02:00
|
|
|
|
|
|
|
if (rmap_match_set_hook.match_ip_address)
|
2016-10-18 01:36:21 +02:00
|
|
|
return rmap_match_set_hook.match_ip_address (vty, index, "ip address", argv[idx_acl]->arg,
|
2016-10-06 21:56:13 +02:00
|
|
|
RMAP_EVENT_FILTER_ADDED);
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DEFUN (no_match_ip_address,
|
|
|
|
no_match_ip_address_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")
|
|
|
|
{
|
|
|
|
int idx_word = 4;
|
2016-10-18 01:36:21 +02:00
|
|
|
VTY_DECLVAR_CONTEXT (route_map_index, index);
|
2016-10-06 21:56:13 +02:00
|
|
|
|
|
|
|
if (rmap_match_set_hook.no_match_ip_address)
|
|
|
|
{
|
|
|
|
if (argc <= idx_word)
|
2016-10-18 01:36:21 +02:00
|
|
|
return rmap_match_set_hook.no_match_ip_address (vty, index, "ip address", NULL,
|
2016-10-06 21:56:13 +02:00
|
|
|
RMAP_EVENT_FILTER_DELETED);
|
2016-10-18 01:36:21 +02:00
|
|
|
return rmap_match_set_hook.no_match_ip_address (vty, index, "ip address", argv[idx_word]->arg,
|
2016-10-06 21:56:13 +02:00
|
|
|
RMAP_EVENT_FILTER_DELETED);
|
|
|
|
}
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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")
|
|
|
|
{
|
|
|
|
int idx_word = 4;
|
2016-10-18 01:36:21 +02:00
|
|
|
VTY_DECLVAR_CONTEXT (route_map_index, index);
|
|
|
|
|
2016-10-06 21:56:13 +02:00
|
|
|
if (rmap_match_set_hook.match_ip_address_prefix_list)
|
2016-10-18 01:36:21 +02:00
|
|
|
return rmap_match_set_hook.match_ip_address_prefix_list (vty, index, "ip address prefix-list",
|
2016-10-06 21:56:13 +02:00
|
|
|
argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED);
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DEFUN (no_match_ip_address_prefix_list,
|
|
|
|
no_match_ip_address_prefix_list_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")
|
|
|
|
{
|
|
|
|
int idx_word = 5;
|
2016-10-18 01:36:21 +02:00
|
|
|
VTY_DECLVAR_CONTEXT (route_map_index, index);
|
2016-10-06 21:56:13 +02:00
|
|
|
|
|
|
|
if (rmap_match_set_hook.no_match_ip_address_prefix_list)
|
|
|
|
{
|
|
|
|
if (argc <= idx_word)
|
2016-10-18 01:36:21 +02:00
|
|
|
return rmap_match_set_hook.no_match_ip_address_prefix_list (vty, index, "ip address prefix-list",
|
2016-10-06 21:56:13 +02:00
|
|
|
NULL, RMAP_EVENT_PLIST_DELETED);
|
2016-10-18 01:36:21 +02:00
|
|
|
return rmap_match_set_hook.no_match_ip_address_prefix_list(vty, index, "ip address prefix-list",
|
2016-10-06 21:56:13 +02:00
|
|
|
argv[idx_word]->arg, RMAP_EVENT_PLIST_DELETED);
|
|
|
|
}
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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")
|
|
|
|
{
|
|
|
|
int idx_acl = 3;
|
2016-10-18 01:36:21 +02:00
|
|
|
VTY_DECLVAR_CONTEXT (route_map_index, index);
|
|
|
|
|
2016-10-06 21:56:13 +02:00
|
|
|
if (rmap_match_set_hook.match_ip_next_hop)
|
2016-10-18 01:36:21 +02:00
|
|
|
return rmap_match_set_hook.match_ip_next_hop (vty, index, "ip next-hop", argv[idx_acl]->arg,
|
2016-10-06 21:56:13 +02:00
|
|
|
RMAP_EVENT_FILTER_ADDED);
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DEFUN (no_match_ip_next_hop,
|
|
|
|
no_match_ip_next_hop_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")
|
|
|
|
{
|
2016-10-18 01:36:21 +02:00
|
|
|
int idx_word = 4;
|
|
|
|
VTY_DECLVAR_CONTEXT (route_map_index, index);
|
2016-10-06 21:56:13 +02:00
|
|
|
|
|
|
|
if (rmap_match_set_hook.no_match_ip_next_hop)
|
|
|
|
{
|
|
|
|
if (argc <= idx_word)
|
2016-10-18 01:36:21 +02:00
|
|
|
return rmap_match_set_hook.no_match_ip_next_hop (vty, index, "ip next-hop", NULL,
|
2016-10-06 21:56:13 +02:00
|
|
|
RMAP_EVENT_FILTER_DELETED);
|
2016-10-18 01:36:21 +02:00
|
|
|
return rmap_match_set_hook.no_match_ip_next_hop (vty, index, "ip next-hop", argv[idx_word]->arg,
|
2016-10-06 21:56:13 +02:00
|
|
|
RMAP_EVENT_FILTER_DELETED);
|
|
|
|
}
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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")
|
|
|
|
{
|
|
|
|
int idx_word = 4;
|
2016-10-18 01:36:21 +02:00
|
|
|
VTY_DECLVAR_CONTEXT (route_map_index, index);
|
|
|
|
|
2016-10-06 21:56:13 +02:00
|
|
|
if (rmap_match_set_hook.match_ip_next_hop_prefix_list)
|
2016-10-18 01:36:21 +02:00
|
|
|
return rmap_match_set_hook.match_ip_next_hop_prefix_list (vty, index, "ip next-hop prefix-list",
|
2016-10-06 21:56:13 +02:00
|
|
|
argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED);
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_match_ip_next_hop_prefix_list,
|
|
|
|
no_match_ip_next_hop_prefix_list_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")
|
|
|
|
{
|
|
|
|
int idx_word = 5;
|
2016-10-18 01:36:21 +02:00
|
|
|
VTY_DECLVAR_CONTEXT (route_map_index, index);
|
2016-10-06 21:56:13 +02:00
|
|
|
|
|
|
|
if (rmap_match_set_hook.no_match_ip_next_hop)
|
|
|
|
{
|
|
|
|
if (argc <= idx_word)
|
2016-10-18 01:36:21 +02:00
|
|
|
return rmap_match_set_hook.no_match_ip_next_hop (vty, index, "ip next-hop prefix-list",
|
2016-10-06 21:56:13 +02:00
|
|
|
NULL, RMAP_EVENT_PLIST_DELETED);
|
2016-10-18 01:36:21 +02:00
|
|
|
return rmap_match_set_hook.no_match_ip_next_hop (vty, index, "ip next-hop prefix-list",
|
2016-10-06 21:56:13 +02:00
|
|
|
argv[idx_word]->arg, RMAP_EVENT_PLIST_DELETED);
|
|
|
|
}
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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")
|
|
|
|
{
|
|
|
|
int idx_word = 3;
|
2016-10-18 01:36:21 +02:00
|
|
|
VTY_DECLVAR_CONTEXT (route_map_index, index);
|
|
|
|
|
2016-10-06 21:56:13 +02:00
|
|
|
if (rmap_match_set_hook.match_ipv6_address)
|
2016-10-18 01:36:21 +02:00
|
|
|
return rmap_match_set_hook.match_ipv6_address (vty, index, "ipv6 address", argv[idx_word]->arg,
|
2016-10-06 21:56:13 +02:00
|
|
|
RMAP_EVENT_FILTER_ADDED);
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
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")
|
|
|
|
{
|
|
|
|
int idx_word = 4;
|
2016-10-18 01:36:21 +02:00
|
|
|
VTY_DECLVAR_CONTEXT (route_map_index, index);
|
|
|
|
|
2016-10-06 21:56:13 +02:00
|
|
|
if (rmap_match_set_hook.no_match_ipv6_address)
|
2016-10-18 01:36:21 +02:00
|
|
|
return rmap_match_set_hook.no_match_ipv6_address (vty, index, "ipv6 address", argv[idx_word]->arg,
|
2016-10-06 21:56:13 +02:00
|
|
|
RMAP_EVENT_FILTER_DELETED);
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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")
|
|
|
|
{
|
|
|
|
int idx_word = 4;
|
2016-10-18 01:36:21 +02:00
|
|
|
VTY_DECLVAR_CONTEXT (route_map_index, index);
|
|
|
|
|
2016-10-06 21:56:13 +02:00
|
|
|
if (rmap_match_set_hook.match_ipv6_address_prefix_list)
|
2016-10-18 01:36:21 +02:00
|
|
|
return rmap_match_set_hook.match_ipv6_address_prefix_list (vty, index, "ipv6 address prefix-list",
|
2016-10-06 21:56:13 +02:00
|
|
|
argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED);
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
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")
|
|
|
|
{
|
|
|
|
int idx_word = 5;
|
2016-10-18 01:36:21 +02:00
|
|
|
VTY_DECLVAR_CONTEXT (route_map_index, index);
|
|
|
|
|
2016-10-06 21:56:13 +02:00
|
|
|
if (rmap_match_set_hook.no_match_ipv6_address_prefix_list)
|
2016-10-18 01:36:21 +02:00
|
|
|
return rmap_match_set_hook.no_match_ipv6_address_prefix_list(vty, index, "ipv6 address prefix-list",
|
2016-10-06 21:56:13 +02:00
|
|
|
argv[idx_word]->arg, RMAP_EVENT_PLIST_DELETED);
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DEFUN (match_metric,
|
|
|
|
match_metric_cmd,
|
|
|
|
"match metric (0-4294967295)",
|
|
|
|
MATCH_STR
|
|
|
|
"Match metric of route\n"
|
|
|
|
"Metric value\n")
|
|
|
|
{
|
|
|
|
int idx_number = 2;
|
2016-10-18 01:36:21 +02:00
|
|
|
VTY_DECLVAR_CONTEXT (route_map_index, index);
|
|
|
|
|
2016-10-06 21:56:13 +02:00
|
|
|
if (rmap_match_set_hook.match_metric)
|
2016-10-18 01:36:21 +02:00
|
|
|
return rmap_match_set_hook.match_metric(vty, index, "metric", argv[idx_number]->arg,
|
2016-10-06 21:56:13 +02:00
|
|
|
RMAP_EVENT_MATCH_ADDED);
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DEFUN (no_match_metric,
|
|
|
|
no_match_metric_cmd,
|
|
|
|
"no match metric [(0-4294967295)]",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"Match metric of route\n"
|
|
|
|
"Metric value\n")
|
|
|
|
{
|
|
|
|
int idx_number = 3;
|
2016-10-18 01:36:21 +02:00
|
|
|
VTY_DECLVAR_CONTEXT (route_map_index, index);
|
|
|
|
|
2016-10-06 21:56:13 +02:00
|
|
|
if (rmap_match_set_hook.no_match_metric)
|
|
|
|
{
|
|
|
|
if (argc <= idx_number)
|
2016-10-18 01:36:21 +02:00
|
|
|
return rmap_match_set_hook.no_match_metric (vty, index, "metric",
|
2016-10-06 21:56:13 +02:00
|
|
|
NULL, RMAP_EVENT_MATCH_DELETED);
|
2017-02-07 19:55:55 +01:00
|
|
|
return rmap_match_set_hook.no_match_metric(vty, index, "metric",
|
|
|
|
argv[idx_number]->arg,
|
|
|
|
RMAP_EVENT_MATCH_DELETED);
|
2016-10-06 21:56:13 +02:00
|
|
|
}
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DEFUN (match_tag,
|
|
|
|
match_tag_cmd,
|
2016-10-18 01:36:21 +02:00
|
|
|
"match tag (1-4294967295)",
|
2016-10-06 21:56:13 +02:00
|
|
|
MATCH_STR
|
|
|
|
"Match tag of route\n"
|
|
|
|
"Tag value\n")
|
|
|
|
{
|
|
|
|
int idx_number = 2;
|
2016-10-18 01:36:21 +02:00
|
|
|
VTY_DECLVAR_CONTEXT (route_map_index, index);
|
|
|
|
|
2016-10-06 21:56:13 +02:00
|
|
|
if (rmap_match_set_hook.match_tag)
|
2016-10-18 01:36:21 +02:00
|
|
|
return rmap_match_set_hook.match_tag(vty, index, "tag", argv[idx_number]->arg,
|
2016-10-06 21:56:13 +02:00
|
|
|
RMAP_EVENT_MATCH_ADDED);
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DEFUN (no_match_tag,
|
|
|
|
no_match_tag_cmd,
|
2016-10-18 01:36:21 +02:00
|
|
|
"no match tag [(1-4294967295)]",
|
2016-10-06 21:56:13 +02:00
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"Match tag of route\n"
|
|
|
|
"Tag value\n")
|
|
|
|
{
|
2016-10-18 01:36:21 +02:00
|
|
|
VTY_DECLVAR_CONTEXT (route_map_index, index);
|
|
|
|
|
2017-01-30 20:49:24 +01:00
|
|
|
int idx = 0;
|
|
|
|
char *arg = argv_find (argv, argc, "(1-4294967295)", &idx) ?
|
|
|
|
argv[idx]->arg : NULL;
|
|
|
|
|
2016-10-06 21:56:13 +02:00
|
|
|
if (rmap_match_set_hook.no_match_tag)
|
2017-01-30 20:49:24 +01:00
|
|
|
return rmap_match_set_hook.no_match_tag (vty, index, "tag", arg,
|
2016-10-06 21:56:13 +02:00
|
|
|
RMAP_EVENT_MATCH_DELETED);
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DEFUN (set_ip_nexthop,
|
|
|
|
set_ip_nexthop_cmd,
|
|
|
|
"set ip next-hop A.B.C.D",
|
|
|
|
SET_STR
|
|
|
|
IP_STR
|
|
|
|
"Next hop address\n"
|
|
|
|
"IP address of next hop\n")
|
|
|
|
{
|
|
|
|
int idx_ipv4 = 3;
|
|
|
|
union sockunion su;
|
|
|
|
int ret;
|
2016-10-18 01:36:21 +02:00
|
|
|
VTY_DECLVAR_CONTEXT (route_map_index, index);
|
2016-10-06 21:56:13 +02:00
|
|
|
|
|
|
|
ret = str2sockunion (argv[idx_ipv4]->arg, &su);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, "%% Malformed nexthop address");
|
2016-10-06 21:56:13 +02:00
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
if (su.sin.sin_addr.s_addr == 0 ||
|
|
|
|
IPV4_CLASS_DE(su.sin.sin_addr.s_addr))
|
|
|
|
{
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty,
|
|
|
|
"%% nexthop address cannot be 0.0.0.0, multicast " "or reserved");
|
2016-10-06 21:56:13 +02:00
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rmap_match_set_hook.set_ip_nexthop)
|
2016-10-18 01:36:21 +02:00
|
|
|
return rmap_match_set_hook.set_ip_nexthop(vty, index, "ip next-hop", argv[idx_ipv4]->arg);
|
2016-10-06 21:56:13 +02:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DEFUN (no_set_ip_nexthop,
|
|
|
|
no_set_ip_nexthop_cmd,
|
|
|
|
"no set ip next-hop [<peer-address|A.B.C.D>]",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
2016-11-30 00:07:11 +01:00
|
|
|
IP_STR
|
2016-10-06 21:56:13 +02:00
|
|
|
"Next hop address\n"
|
|
|
|
"Use peer address (for BGP only)\n"
|
|
|
|
"IP address of next hop\n")
|
|
|
|
{
|
|
|
|
int idx_peer = 4;
|
2016-10-18 01:36:21 +02:00
|
|
|
VTY_DECLVAR_CONTEXT (route_map_index, index);
|
2016-10-06 21:56:13 +02:00
|
|
|
|
|
|
|
if (rmap_match_set_hook.no_set_ip_nexthop)
|
|
|
|
{
|
|
|
|
if (argc <= idx_peer)
|
2016-10-18 01:36:21 +02:00
|
|
|
return rmap_match_set_hook.no_set_ip_nexthop (vty, index, "ip next-hop", NULL);
|
|
|
|
return rmap_match_set_hook.no_set_ip_nexthop (vty, index, "ip next-hop", argv[idx_peer]->arg);
|
2016-10-06 21:56:13 +02:00
|
|
|
}
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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")
|
|
|
|
{
|
|
|
|
int idx_ipv6 = 4;
|
|
|
|
struct in6_addr addr;
|
|
|
|
int ret;
|
2016-10-18 01:36:21 +02:00
|
|
|
VTY_DECLVAR_CONTEXT (route_map_index, index);
|
2016-10-06 21:56:13 +02:00
|
|
|
|
|
|
|
ret = inet_pton (AF_INET6, argv[idx_ipv6]->arg, &addr);
|
|
|
|
if (!ret)
|
|
|
|
{
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, "%% Malformed nexthop address");
|
2016-10-06 21:56:13 +02:00
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
if (!IN6_IS_ADDR_LINKLOCAL(&addr))
|
|
|
|
{
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, "%% Invalid link-local nexthop address");
|
2016-10-06 21:56:13 +02:00
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rmap_match_set_hook.set_ipv6_nexthop_local)
|
2016-10-18 01:36:21 +02:00
|
|
|
return rmap_match_set_hook.set_ipv6_nexthop_local (vty, index, "ipv6 next-hop local", argv[idx_ipv6]->arg);
|
2016-10-06 21:56:13 +02:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DEFUN (no_set_ipv6_nexthop_local,
|
|
|
|
no_set_ipv6_nexthop_local_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")
|
|
|
|
{
|
|
|
|
int idx_ipv6 = 5;
|
2016-10-18 01:36:21 +02:00
|
|
|
VTY_DECLVAR_CONTEXT (route_map_index, index);
|
|
|
|
|
2016-10-06 21:56:13 +02:00
|
|
|
if (rmap_match_set_hook.no_set_ipv6_nexthop_local)
|
|
|
|
{
|
|
|
|
if (argc <= idx_ipv6)
|
2016-10-18 01:36:21 +02:00
|
|
|
return rmap_match_set_hook.no_set_ipv6_nexthop_local (vty, index, "ipv6 next-hop local", NULL);
|
|
|
|
return rmap_match_set_hook.no_set_ipv6_nexthop_local (vty, index, "ipv6 next-hop local", argv[5]->arg);
|
2016-10-06 21:56:13 +02:00
|
|
|
}
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (set_metric,
|
|
|
|
set_metric_cmd,
|
|
|
|
"set metric <(0-4294967295)|rtt|+rtt|-rtt|+metric|-metric>",
|
|
|
|
SET_STR
|
|
|
|
"Metric value for destination routing protocol\n"
|
|
|
|
"Metric value\n"
|
|
|
|
"Assign round trip time\n"
|
|
|
|
"Add round trip time\n"
|
|
|
|
"Subtract round trip time\n"
|
|
|
|
"Add metric\n"
|
|
|
|
"Subtract metric\n")
|
|
|
|
{
|
|
|
|
int idx_number = 2;
|
2016-10-18 01:36:21 +02:00
|
|
|
VTY_DECLVAR_CONTEXT (route_map_index, index);
|
|
|
|
|
2017-06-21 17:41:35 +02:00
|
|
|
const char *pass = (argv[idx_number]->type == RANGE_TKN) ?
|
|
|
|
argv[idx_number]->arg : argv[idx_number]->text;
|
|
|
|
|
2016-10-06 21:56:13 +02:00
|
|
|
if (rmap_match_set_hook.set_metric)
|
2017-06-21 17:41:35 +02:00
|
|
|
return rmap_match_set_hook.set_metric (vty, index, "metric", pass);
|
2016-10-06 21:56:13 +02:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DEFUN (no_set_metric,
|
|
|
|
no_set_metric_cmd,
|
|
|
|
"no set metric [(0-4294967295)]",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"Metric value for destination routing protocol\n"
|
|
|
|
"Metric value\n")
|
|
|
|
{
|
|
|
|
int idx_number = 3;
|
2016-10-18 01:36:21 +02:00
|
|
|
VTY_DECLVAR_CONTEXT (route_map_index, index);
|
|
|
|
|
2016-10-06 21:56:13 +02:00
|
|
|
if (rmap_match_set_hook.no_set_metric)
|
|
|
|
{
|
|
|
|
if (argc <= idx_number)
|
2016-10-18 01:36:21 +02:00
|
|
|
return rmap_match_set_hook.no_set_metric (vty, index, "metric", NULL);
|
|
|
|
return rmap_match_set_hook.no_set_metric (vty, index, "metric", argv[idx_number]->arg);
|
2016-10-06 21:56:13 +02:00
|
|
|
}
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DEFUN (set_tag,
|
|
|
|
set_tag_cmd,
|
2016-10-18 01:36:21 +02:00
|
|
|
"set tag (1-4294967295)",
|
2016-10-06 21:56:13 +02:00
|
|
|
SET_STR
|
|
|
|
"Tag value for routing protocol\n"
|
|
|
|
"Tag value\n")
|
|
|
|
{
|
2016-10-18 01:36:21 +02:00
|
|
|
VTY_DECLVAR_CONTEXT (route_map_index, index);
|
|
|
|
|
2016-10-06 21:56:13 +02:00
|
|
|
int idx_number = 2;
|
|
|
|
if (rmap_match_set_hook.set_tag)
|
2016-10-18 01:36:21 +02:00
|
|
|
return rmap_match_set_hook.set_tag (vty, index, "tag", argv[idx_number]->arg);
|
2016-10-06 21:56:13 +02:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DEFUN (no_set_tag,
|
|
|
|
no_set_tag_cmd,
|
2016-10-18 01:36:21 +02:00
|
|
|
"no set tag [(1-4294967295)]",
|
2016-10-06 21:56:13 +02:00
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"Tag value for routing protocol\n"
|
|
|
|
"Tag value\n")
|
|
|
|
{
|
2016-10-18 01:36:21 +02:00
|
|
|
VTY_DECLVAR_CONTEXT (route_map_index, index);
|
|
|
|
|
2016-10-06 21:56:13 +02:00
|
|
|
int idx_number = 3;
|
|
|
|
if (rmap_match_set_hook.no_set_tag)
|
|
|
|
{
|
|
|
|
if (argc <= idx_number)
|
2016-10-18 01:36:21 +02:00
|
|
|
return rmap_match_set_hook.no_set_tag (vty, index, "tag", NULL);
|
|
|
|
return rmap_match_set_hook.no_set_tag (vty, index, "tag", argv[idx_number]->arg);
|
2016-10-06 21:56:13 +02:00
|
|
|
}
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-03-22 10:38:22 +01:00
|
|
|
DEFUN_NOSH (route_map,
|
2002-12-13 21:15:29 +01:00
|
|
|
route_map_cmd,
|
2016-09-23 00:53:09 +02:00
|
|
|
"route-map WORD <deny|permit> (1-65535)",
|
2002-12-13 21:15:29 +01:00
|
|
|
"Create route-map or enter route-map command mode\n"
|
|
|
|
"Route map tag\n"
|
|
|
|
"Route map denies set operations\n"
|
|
|
|
"Route map permits set operations\n"
|
|
|
|
"Sequence to insert to/delete from existing route-map entry\n")
|
|
|
|
{
|
2016-09-23 22:17:29 +02:00
|
|
|
int idx_word = 1;
|
|
|
|
int idx_permit_deny = 2;
|
|
|
|
int idx_number = 3;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct route_map *map;
|
|
|
|
struct route_map_index *index;
|
|
|
|
char *endptr = NULL;
|
2016-09-23 22:17:29 +02:00
|
|
|
int permit = argv[idx_permit_deny]->arg[0] == 'p' ? RMAP_PERMIT : RMAP_DENY;
|
|
|
|
unsigned long pref = strtoul (argv[idx_number]->arg, &endptr, 10);
|
|
|
|
const char *mapname = argv[idx_word]->arg;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
/* Get route map. */
|
2016-09-23 00:53:09 +02:00
|
|
|
map = route_map_get (mapname);
|
2002-12-13 21:15:29 +01:00
|
|
|
index = route_map_index_get (map, permit, pref);
|
|
|
|
|
2016-12-07 17:30:16 +01:00
|
|
|
VTY_PUSH_CONTEXT (RMAP_NODE, index);
|
2002-12-13 21:15:29 +01:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_route_map_all,
|
|
|
|
no_route_map_all_cmd,
|
|
|
|
"no route-map WORD",
|
|
|
|
NO_STR
|
|
|
|
"Create route-map or enter route-map command mode\n"
|
|
|
|
"Route map tag\n")
|
|
|
|
{
|
2016-09-23 22:17:29 +02:00
|
|
|
int idx_word = 2;
|
|
|
|
const char *mapname = argv[idx_word]->arg;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct route_map *map;
|
|
|
|
|
2016-09-23 00:53:09 +02:00
|
|
|
map = route_map_lookup_by_name (mapname);
|
2002-12-13 21:15:29 +01:00
|
|
|
if (map == NULL)
|
|
|
|
{
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, "%% Could not find route-map %s", mapname);
|
2002-12-13 21:15:29 +01:00
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
|
|
|
|
route_map_delete (map);
|
|
|
|
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_route_map,
|
|
|
|
no_route_map_cmd,
|
2016-09-23 00:53:09 +02:00
|
|
|
"no route-map WORD <deny|permit> (1-65535)",
|
2002-12-13 21:15:29 +01:00
|
|
|
NO_STR
|
|
|
|
"Create route-map or enter route-map command mode\n"
|
|
|
|
"Route map tag\n"
|
|
|
|
"Route map denies set operations\n"
|
|
|
|
"Route map permits set operations\n"
|
|
|
|
"Sequence to insert to/delete from existing route-map entry\n")
|
|
|
|
{
|
2016-09-23 22:17:29 +02:00
|
|
|
int idx_word = 2;
|
|
|
|
int idx_permit_deny = 3;
|
|
|
|
int idx_number = 4;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct route_map *map;
|
|
|
|
struct route_map_index *index;
|
|
|
|
char *endptr = NULL;
|
2017-06-21 17:41:35 +02:00
|
|
|
int permit = strmatch (argv[idx_permit_deny]->text, "permit") ?
|
|
|
|
RMAP_PERMIT : RMAP_DENY;
|
2016-09-23 22:17:29 +02:00
|
|
|
const char *prefstr = argv[idx_number]->arg;
|
|
|
|
const char *mapname = argv[idx_word]->arg;
|
2016-09-23 00:53:09 +02:00
|
|
|
unsigned long pref = strtoul (prefstr, &endptr, 10);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
/* Existence check. */
|
2016-09-23 00:53:09 +02:00
|
|
|
map = route_map_lookup_by_name (mapname);
|
2002-12-13 21:15:29 +01:00
|
|
|
if (map == NULL)
|
|
|
|
{
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, "%% Could not find route-map %s", mapname);
|
2002-12-13 21:15:29 +01:00
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Lookup route map index. */
|
|
|
|
index = route_map_index_lookup (map, permit, pref);
|
|
|
|
if (index == NULL)
|
|
|
|
{
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, "%% Could not find route-map entry %s %s",
|
|
|
|
mapname, prefstr);
|
2002-12-13 21:15:29 +01:00
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Delete index from route map. */
|
|
|
|
route_map_index_delete (index, 1);
|
|
|
|
|
|
|
|
/* If this route rule is the last one, delete route map itself. */
|
|
|
|
if (route_map_empty (map))
|
|
|
|
route_map_delete (map);
|
|
|
|
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (rmap_onmatch_next,
|
|
|
|
rmap_onmatch_next_cmd,
|
|
|
|
"on-match next",
|
|
|
|
"Exit policy on matches\n"
|
|
|
|
"Next clause\n")
|
|
|
|
{
|
2016-09-26 20:17:12 +02:00
|
|
|
struct route_map_index *index = VTY_GET_CONTEXT (route_map_index);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
if (index)
|
2016-01-13 15:02:46 +01:00
|
|
|
{
|
|
|
|
if (index->type == RMAP_DENY)
|
|
|
|
{
|
|
|
|
/* Under a deny clause, match means it's finished. No need to set next */
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty,"on-match next not supported under route-map deny");
|
2016-01-13 15:02:46 +01:00
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
index->exitpolicy = RMAP_NEXT;
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_rmap_onmatch_next,
|
|
|
|
no_rmap_onmatch_next_cmd,
|
|
|
|
"no on-match next",
|
|
|
|
NO_STR
|
|
|
|
"Exit policy on matches\n"
|
|
|
|
"Next clause\n")
|
|
|
|
{
|
2016-09-26 20:17:12 +02:00
|
|
|
struct route_map_index *index = VTY_GET_CONTEXT (route_map_index);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
if (index)
|
|
|
|
index->exitpolicy = RMAP_EXIT;
|
|
|
|
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (rmap_onmatch_goto,
|
|
|
|
rmap_onmatch_goto_cmd,
|
2016-09-23 00:53:09 +02:00
|
|
|
"on-match goto (1-65535)",
|
2002-12-13 21:15:29 +01:00
|
|
|
"Exit policy on matches\n"
|
|
|
|
"Goto Clause number\n"
|
|
|
|
"Number\n")
|
|
|
|
{
|
2017-01-30 20:49:24 +01:00
|
|
|
int idx = 0;
|
|
|
|
char *num = argv_find (argv, argc, "(1-65535)", &idx) ? argv[idx]->arg : NULL;
|
2016-10-18 01:36:21 +02:00
|
|
|
|
2016-09-26 20:17:12 +02:00
|
|
|
struct route_map_index *index = VTY_GET_CONTEXT (route_map_index);
|
2002-12-13 21:15:29 +01:00
|
|
|
int d = 0;
|
|
|
|
|
|
|
|
if (index)
|
|
|
|
{
|
2016-01-13 15:02:46 +01:00
|
|
|
if (index->type == RMAP_DENY)
|
|
|
|
{
|
|
|
|
/* Under a deny clause, match means it's finished. No need to go anywhere */
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty,"on-match goto not supported under route-map deny");
|
2016-01-13 15:02:46 +01:00
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
|
2016-09-29 21:51:56 +02:00
|
|
|
if (num)
|
*: remove VTY_GET_*
CLI validates input tokens, so there's no need to do it in handler
functions anymore.
spatch follows
----------------
@getull@
expression v;
expression str;
@@
<...
- VTY_GET_ULL(..., v, str)
+ v = strtoull (str, NULL, 10)
...>
@getul@
expression v;
expression str;
@@
<...
- VTY_GET_ULONG(..., v, str)
+ v = strtoul (str, NULL, 10)
...>
@getintrange@
expression name;
expression v;
expression str;
@@
<...
- VTY_GET_INTEGER_RANGE(name, v, str, ...)
+ v = strtoul (str, NULL, 10)
...>
@getint@
expression v;
expression str;
@@
<...
- VTY_GET_INTEGER(..., v, str)
+ v = strtoul (str, NULL, 10)
...>
@getv4@
expression v;
expression str;
@@
<...
- VTY_GET_IPV4_ADDRESS(..., v, str)
+ inet_aton (str, &v)
...>
@getv4pfx@
expression v;
expression str;
@@
<...
- VTY_GET_IPV4_PREFIX(..., v, str)
+ str2prefix_ipv4 (str, &v)
...>
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-27 20:47:03 +02:00
|
|
|
d = strtoul(num, NULL, 10);
|
2005-05-23 14:43:34 +02:00
|
|
|
else
|
|
|
|
d = index->pref + 1;
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
if (d <= index->pref)
|
|
|
|
{
|
|
|
|
/* Can't allow you to do that, Dave */
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, "can't jump backwards in route-maps");
|
2002-12-13 21:15:29 +01:00
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
index->exitpolicy = RMAP_GOTO;
|
|
|
|
index->nextpref = d;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_rmap_onmatch_goto,
|
|
|
|
no_rmap_onmatch_goto_cmd,
|
|
|
|
"no on-match goto",
|
|
|
|
NO_STR
|
|
|
|
"Exit policy on matches\n"
|
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
|
|
|
"Goto Clause number\n")
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2016-09-26 20:17:12 +02:00
|
|
|
struct route_map_index *index = VTY_GET_CONTEXT (route_map_index);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
if (index)
|
|
|
|
index->exitpolicy = RMAP_EXIT;
|
|
|
|
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2016-09-23 22:08:47 +02:00
|
|
|
/* Cisco/GNU Zebra compatibility aliases */
|
|
|
|
/* ALIAS_FIXME */
|
|
|
|
DEFUN (rmap_continue,
|
|
|
|
rmap_continue_cmd,
|
|
|
|
"continue (1-65535)",
|
|
|
|
"Continue on a different entry within the route-map\n"
|
|
|
|
"Route-map entry sequence number\n")
|
|
|
|
{
|
|
|
|
return rmap_onmatch_goto (self, vty, argc, argv);
|
|
|
|
}
|
2004-07-09 16:00:01 +02:00
|
|
|
|
2016-09-23 22:08:47 +02:00
|
|
|
/* ALIAS_FIXME */
|
|
|
|
DEFUN (no_rmap_continue,
|
|
|
|
no_rmap_continue_cmd,
|
|
|
|
"no continue [(1-65535)]",
|
|
|
|
NO_STR
|
|
|
|
"Continue on a different entry within the route-map\n"
|
|
|
|
"Route-map entry sequence number\n")
|
|
|
|
{
|
|
|
|
return no_rmap_onmatch_goto (self, vty, argc, argv);
|
|
|
|
}
|
2016-09-23 05:55:26 +02:00
|
|
|
|
2004-07-09 16:00:01 +02:00
|
|
|
|
2017-06-14 20:21:17 +02:00
|
|
|
DEFUN (rmap_show_name,
|
2004-07-09 16:00:01 +02:00
|
|
|
rmap_show_name_cmd,
|
2007-05-02 18:05:35 +02:00
|
|
|
"show route-map [WORD]",
|
2004-07-09 16:00:01 +02:00
|
|
|
SHOW_STR
|
|
|
|
"route-map information\n"
|
|
|
|
"route-map name\n")
|
|
|
|
{
|
2016-09-23 22:17:29 +02:00
|
|
|
int idx_word = 2;
|
2016-09-29 21:51:56 +02:00
|
|
|
const char *name = (argc == 3) ? argv[idx_word]->arg : NULL;
|
|
|
|
return vty_show_route_map (vty, name);
|
2004-07-09 16:00:01 +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 (rmap_call,
|
|
|
|
rmap_call_cmd,
|
|
|
|
"call WORD",
|
|
|
|
"Jump to another Route-Map after match+set\n"
|
|
|
|
"Target route-map name\n")
|
|
|
|
{
|
2016-09-23 22:17:29 +02:00
|
|
|
int idx_word = 1;
|
2016-09-26 20:17:12 +02:00
|
|
|
struct route_map_index *index = VTY_GET_CONTEXT (route_map_index);
|
2016-09-23 22:17:29 +02:00
|
|
|
const char *rmap = argv[idx_word]->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
|
|
|
|
2016-12-20 04:12:32 +01:00
|
|
|
assert(index);
|
|
|
|
|
|
|
|
if (index->nextrm)
|
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
|
|
|
{
|
2016-12-20 04:12:32 +01:00
|
|
|
route_map_upd8_dependency (RMAP_EVENT_CALL_DELETED,
|
|
|
|
index->nextrm,
|
|
|
|
index->map->name);
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_NAME, index->nextrm);
|
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
|
|
|
}
|
2016-12-20 04:12:32 +01:00
|
|
|
index->nextrm = XSTRDUP (MTYPE_ROUTE_MAP_NAME, rmap);
|
2015-05-20 02:40:45 +02:00
|
|
|
|
|
|
|
/* Execute event hook. */
|
|
|
|
route_map_upd8_dependency (RMAP_EVENT_CALL_ADDED,
|
|
|
|
index->nextrm,
|
|
|
|
index->map->name);
|
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 CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_rmap_call,
|
|
|
|
no_rmap_call_cmd,
|
|
|
|
"no call",
|
|
|
|
NO_STR
|
|
|
|
"Jump to another Route-Map after match+set\n")
|
|
|
|
{
|
2016-09-26 20:17:12 +02:00
|
|
|
struct route_map_index *index = VTY_GET_CONTEXT (route_map_index);
|
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 (index->nextrm)
|
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
route_map_upd8_dependency (RMAP_EVENT_CALL_DELETED,
|
|
|
|
index->nextrm,
|
|
|
|
index->map->name);
|
2005-10-26 07:05:16 +02:00
|
|
|
XFREE (MTYPE_ROUTE_MAP_NAME, index->nextrm);
|
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
|
|
|
index->nextrm = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-04-08 16:20:18 +02:00
|
|
|
DEFUN (rmap_description,
|
|
|
|
rmap_description_cmd,
|
2016-09-23 00:53:09 +02:00
|
|
|
"description LINE...",
|
2005-04-08 16:20:18 +02:00
|
|
|
"Route-map comment\n"
|
|
|
|
"Comment describing this route-map rule\n")
|
|
|
|
{
|
2016-09-30 02:16:31 +02:00
|
|
|
int idx_line = 1;
|
2016-09-26 20:17:12 +02:00
|
|
|
struct route_map_index *index = VTY_GET_CONTEXT (route_map_index);
|
2005-04-08 16:20:18 +02:00
|
|
|
|
|
|
|
if (index)
|
|
|
|
{
|
|
|
|
if (index->description)
|
|
|
|
XFREE (MTYPE_TMP, index->description);
|
2016-09-30 02:16:31 +02:00
|
|
|
index->description = argv_concat (argv, argc, idx_line);
|
2005-04-08 16:20:18 +02:00
|
|
|
}
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_rmap_description,
|
|
|
|
no_rmap_description_cmd,
|
|
|
|
"no description",
|
|
|
|
NO_STR
|
|
|
|
"Route-map comment\n")
|
|
|
|
{
|
2016-09-26 20:17:12 +02:00
|
|
|
struct route_map_index *index = VTY_GET_CONTEXT (route_map_index);
|
2005-04-08 16:20:18 +02:00
|
|
|
|
|
|
|
if (index)
|
|
|
|
{
|
|
|
|
if (index->description)
|
|
|
|
XFREE (MTYPE_TMP, index->description);
|
|
|
|
index->description = NULL;
|
|
|
|
}
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Configuration write function. */
|
2005-05-06 Paul Jakma <paul@dishone.st>
* (general) extern and static'ification of functions in code and
header.
Cleanup any definitions with unspecified arguments.
Add casts for callback assignments where the callback is defined,
typically, as passing void *, but the function being assigned has
some other pointer type defined as its argument, as gcc complains
about casts from void * to X* via function arguments.
Fix some old K&R style function argument definitions.
Add noreturn gcc attribute to some functions, as appropriate.
Add unused gcc attribute to some functions (eg ones meant to help
while debugging)
Add guard defines to headers which were missing them.
* command.c: (install_node) add const qualifier, still doesnt shut
up the warning though, because of the double pointer.
(cmp_node) ditto
* keychain.c: (key_str2time) Add GET_LONG_RANGE() macro, derived
fromn vty.h ones to fix some of the (long) < 0 warnings.
* thread.c: (various) use thread_empty
(cpu_record_hash_key) should cast to uintptr_t, a stdint.h type
* vty.h: Add VTY_GET_IPV4_ADDRESS and VTY_GET_IPV4_PREFIX so they
removed from ospfd/ospf_vty.h
* zebra.h: Move definition of ZEBRA_PORT to here, to remove
dependence of lib on zebra/zserv.h
2005-05-06 23:25:49 +02:00
|
|
|
static int
|
2002-12-13 21:15:29 +01:00
|
|
|
route_map_config_write (struct vty *vty)
|
|
|
|
{
|
|
|
|
struct route_map *map;
|
|
|
|
struct route_map_index *index;
|
|
|
|
struct route_map_rule *rule;
|
|
|
|
int first = 1;
|
|
|
|
int write = 0;
|
|
|
|
|
|
|
|
for (map = route_map_master.head; map; map = map->next)
|
|
|
|
for (index = map->head; index; index = index->next)
|
|
|
|
{
|
|
|
|
if (!first)
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, "!");
|
2002-12-13 21:15:29 +01:00
|
|
|
else
|
|
|
|
first = 0;
|
|
|
|
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, "route-map %s %s %d",
|
2002-12-13 21:15:29 +01:00
|
|
|
map->name,
|
|
|
|
route_map_type_str (index->type),
|
2017-06-21 05:10:57 +02:00
|
|
|
index->pref);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2005-04-08 16:20:18 +02:00
|
|
|
if (index->description)
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, " description %s", index->description);
|
2005-04-08 16:20:18 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
for (rule = index->match_list.head; rule; rule = rule->next)
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, " match %s %s", rule->cmd->str,
|
|
|
|
rule->rule_str ? rule->rule_str : "");
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
for (rule = index->set_list.head; rule; rule = rule->next)
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, " set %s %s", rule->cmd->str,
|
|
|
|
rule->rule_str ? rule->rule_str : "");
|
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 (index->nextrm)
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, " call %s", index->nextrm);
|
2002-12-13 21:15:29 +01:00
|
|
|
if (index->exitpolicy == RMAP_GOTO)
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty, " on-match goto %d", index->nextpref);
|
2002-12-13 21:15:29 +01:00
|
|
|
if (index->exitpolicy == RMAP_NEXT)
|
2017-06-21 05:10:57 +02:00
|
|
|
vty_outln (vty," on-match next");
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
write++;
|
|
|
|
}
|
|
|
|
return write;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map node structure. */
|
2008-12-01 20:10:34 +01:00
|
|
|
static struct cmd_node rmap_node =
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
RMAP_NODE,
|
|
|
|
"%s(config-route-map)# ",
|
|
|
|
1
|
|
|
|
};
|
|
|
|
|
2016-10-01 20:42:34 +02:00
|
|
|
/* Common route map rules */
|
|
|
|
|
|
|
|
void *
|
|
|
|
route_map_rule_tag_compile (const char *arg)
|
|
|
|
{
|
|
|
|
unsigned long int tmp;
|
|
|
|
char *endptr;
|
|
|
|
route_tag_t *tag;
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
tmp = strtoul(arg, &endptr, 0);
|
|
|
|
if (arg[0] == '\0' || *endptr != '\0' || errno || tmp > ROUTE_TAG_MAX)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
tag = XMALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(*tag));
|
|
|
|
*tag = tmp;
|
|
|
|
|
|
|
|
return tag;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
route_map_rule_tag_free (void *rule)
|
|
|
|
{
|
|
|
|
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
2016-10-19 17:09:57 +02:00
|
|
|
void
|
|
|
|
route_map_finish (void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
vector_free (route_match_vec);
|
|
|
|
route_match_vec = NULL;
|
|
|
|
vector_free (route_set_vec);
|
|
|
|
route_set_vec = NULL;
|
|
|
|
|
|
|
|
/* cleanup route_map */
|
|
|
|
while (route_map_master.head)
|
2016-10-24 19:28:35 +02:00
|
|
|
{
|
|
|
|
struct route_map *map = route_map_master.head;
|
|
|
|
map->to_be_processed = 0;
|
|
|
|
route_map_delete (map);
|
|
|
|
}
|
2016-10-19 17:09:57 +02:00
|
|
|
|
|
|
|
for (i = 1; i < ROUTE_MAP_DEP_MAX; i++)
|
2016-12-16 02:39:46 +01:00
|
|
|
{
|
|
|
|
hash_free(route_map_dep_hash[i]);
|
|
|
|
route_map_dep_hash[i] = NULL;
|
|
|
|
}
|
2016-10-19 17:09:57 +02:00
|
|
|
|
|
|
|
hash_free (route_map_master_hash);
|
2016-12-16 02:39:46 +01:00
|
|
|
route_map_master_hash = NULL;
|
2016-10-19 17:09:57 +02:00
|
|
|
}
|
|
|
|
|
2016-11-19 11:57:08 +01:00
|
|
|
static void rmap_autocomplete(vector comps, struct cmd_token *token)
|
|
|
|
{
|
|
|
|
struct route_map *map;
|
|
|
|
|
|
|
|
for (map = route_map_master.head; map; map = map->next)
|
|
|
|
vector_set (comps, XSTRDUP (MTYPE_COMPLETION, map->name));
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct cmd_variable_handler rmap_var_handlers[] = {
|
|
|
|
{
|
|
|
|
/* "route-map WORD" */
|
|
|
|
.varname = "route_map",
|
|
|
|
.completions = rmap_autocomplete
|
|
|
|
}, {
|
|
|
|
.tokenname = "ROUTEMAP_NAME",
|
|
|
|
.completions = rmap_autocomplete
|
|
|
|
}, {
|
|
|
|
.tokenname = "RMAP_NAME",
|
|
|
|
.completions = rmap_autocomplete
|
|
|
|
}, {
|
|
|
|
.completions = NULL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Initialization of route map vector. */
|
|
|
|
void
|
2016-10-19 16:55:01 +02:00
|
|
|
route_map_init (void)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2016-10-19 16:55:01 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Make vector for match and set. */
|
|
|
|
route_match_vec = vector_init (1);
|
|
|
|
route_set_vec = vector_init (1);
|
|
|
|
route_map_master_hash = hash_create(route_map_hash_key_make, route_map_hash_cmp);
|
|
|
|
|
|
|
|
for (i = 1; i < ROUTE_MAP_DEP_MAX; i++)
|
|
|
|
route_map_dep_hash[i] = hash_create(route_map_dep_hash_make_key,
|
|
|
|
route_map_dep_hash_cmp);
|
2015-05-20 02:40:45 +02:00
|
|
|
|
2016-11-19 11:57:08 +01:00
|
|
|
cmd_variable_handler_register(rmap_var_handlers);
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Install route map top node. */
|
|
|
|
install_node (&rmap_node, route_map_config_write);
|
|
|
|
|
|
|
|
/* Install route map commands. */
|
|
|
|
install_default (RMAP_NODE);
|
|
|
|
install_element (CONFIG_NODE, &route_map_cmd);
|
|
|
|
install_element (CONFIG_NODE, &no_route_map_cmd);
|
|
|
|
install_element (CONFIG_NODE, &no_route_map_all_cmd);
|
|
|
|
|
|
|
|
/* Install the on-match stuff */
|
|
|
|
install_element (RMAP_NODE, &route_map_cmd);
|
|
|
|
install_element (RMAP_NODE, &rmap_onmatch_next_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_rmap_onmatch_next_cmd);
|
|
|
|
install_element (RMAP_NODE, &rmap_onmatch_goto_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_rmap_onmatch_goto_cmd);
|
2016-09-23 22:08:47 +02:00
|
|
|
install_element (RMAP_NODE, &rmap_continue_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_rmap_continue_cmd);
|
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 the continue stuff (ALIAS of on-match). */
|
|
|
|
|
|
|
|
/* Install the call stuff. */
|
|
|
|
install_element (RMAP_NODE, &rmap_call_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_rmap_call_cmd);
|
2005-04-08 16:20:18 +02:00
|
|
|
|
|
|
|
/* Install description commands. */
|
|
|
|
install_element (RMAP_NODE, &rmap_description_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_rmap_description_cmd);
|
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
|
|
|
|
2004-07-09 16:00:01 +02:00
|
|
|
/* Install show command */
|
|
|
|
install_element (ENABLE_NODE, &rmap_show_name_cmd);
|
2016-10-06 21:56:13 +02:00
|
|
|
|
|
|
|
install_element (RMAP_NODE, &match_interface_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_interface_cmd);
|
|
|
|
|
|
|
|
install_element (RMAP_NODE, &match_ip_address_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_ip_address_cmd);
|
|
|
|
|
|
|
|
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, &match_ip_next_hop_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_ip_next_hop_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, &match_ipv6_address_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_ipv6_address_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, &match_metric_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_metric_cmd);
|
|
|
|
|
|
|
|
install_element (RMAP_NODE, &match_tag_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_match_tag_cmd);
|
|
|
|
|
|
|
|
install_element (RMAP_NODE, &set_ip_nexthop_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_ip_nexthop_cmd);
|
|
|
|
|
|
|
|
install_element (RMAP_NODE, &set_ipv6_nexthop_local_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_ipv6_nexthop_local_cmd);
|
|
|
|
|
|
|
|
install_element (RMAP_NODE, &set_metric_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_metric_cmd);
|
|
|
|
|
|
|
|
install_element (RMAP_NODE, &set_tag_cmd);
|
|
|
|
install_element (RMAP_NODE, &no_set_tag_cmd);
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|