mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-09 07:56:29 +00:00
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP Traditionally route map MATCH rule apis were designed to return a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH. (Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR). Depending on this response, the following statemachine decided the course of action: State1: If match cmd returns RMAP_MATCH then, keep existing behaviour. If routemap type is PERMIT, execute set cmds or call cmds if applicable, otherwise PERMIT! Else If routemap type is DENY, we DENYMATCH right away State2: If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH We require a 3rd state because of the following situation: The issue - what if, the rule api needs to abort or ignore a rule?: "match evpn vni xx" route-map filter can be applied to incoming routes regardless of whether the tunnel type is vxlan or mpls. This rule should be N/A for mpls based evpn route, but applicable to only vxlan based evpn route. Also, this rule should be applicable for routes with VNI label only, and not for routes without labels. For example, type 3 and type 4 EVPN routes do not have labels, so, this match cmd should let them through. Today, the filter produces either a match or nomatch response regardless of whether it is mpls/vxlan, resulting in either permitting or denying the route.. So an mpls evpn route may get filtered out incorrectly. Eg: "route-map RM1 permit 10 ; match evpn vni 20" or "route-map RM2 deny 20 ; match vni 20" With the introduction of the 3rd state, we can abort this rule check safely. How? The rules api can now return RMAP_NOOP to indicate that it encountered an invalid check, and needs to abort just that rule, but continue with other rules. As a result we have a 3rd state: State3: If match cmd returned RMAP_NOOP Then, proceed to other route-map, otherwise if there are no more rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH. Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
This commit is contained in:
parent
f1b9024dd5
commit
b68885f9b7
@ -4411,7 +4411,7 @@ void bgp_evpn_advertise_type5_routes(struct bgp *bgp_vrf, afi_t afi,
|
|||||||
|
|
||||||
/* apply the route-map */
|
/* apply the route-map */
|
||||||
if (bgp_vrf->adv_cmd_rmap[afi][safi].map) {
|
if (bgp_vrf->adv_cmd_rmap[afi][safi].map) {
|
||||||
int ret = 0;
|
route_map_result_t ret;
|
||||||
|
|
||||||
ret = route_map_apply(
|
ret = route_map_apply(
|
||||||
bgp_vrf->adv_cmd_rmap[afi][safi]
|
bgp_vrf->adv_cmd_rmap[afi][safi]
|
||||||
|
@ -1465,7 +1465,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
|
|||||||
struct bgp *bgp;
|
struct bgp *bgp;
|
||||||
struct attr *piattr;
|
struct attr *piattr;
|
||||||
char buf[PREFIX_STRLEN];
|
char buf[PREFIX_STRLEN];
|
||||||
int ret;
|
route_map_result_t ret;
|
||||||
int transparent;
|
int transparent;
|
||||||
int reflect;
|
int reflect;
|
||||||
afi_t afi;
|
afi_t afi;
|
||||||
@ -2544,12 +2544,12 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn,
|
|||||||
|
|
||||||
/* apply the route-map */
|
/* apply the route-map */
|
||||||
if (bgp->adv_cmd_rmap[afi][safi].map) {
|
if (bgp->adv_cmd_rmap[afi][safi].map) {
|
||||||
int ret = 0;
|
route_map_result_t ret;
|
||||||
|
|
||||||
ret = route_map_apply(
|
ret = route_map_apply(
|
||||||
bgp->adv_cmd_rmap[afi][safi].map,
|
bgp->adv_cmd_rmap[afi][safi].map,
|
||||||
&rn->p, RMAP_BGP, new_select);
|
&rn->p, RMAP_BGP, new_select);
|
||||||
if (ret == RMAP_MATCH)
|
if (ret == RMAP_PERMITMATCH)
|
||||||
bgp_evpn_advertise_type5_route(
|
bgp_evpn_advertise_type5_route(
|
||||||
bgp, &rn->p, new_select->attr,
|
bgp, &rn->p, new_select->attr,
|
||||||
afi, safi);
|
afi, safi);
|
||||||
@ -4593,7 +4593,7 @@ void bgp_static_update(struct bgp *bgp, struct prefix *p,
|
|||||||
struct bgp_path_info rmap_path;
|
struct bgp_path_info rmap_path;
|
||||||
struct attr attr;
|
struct attr attr;
|
||||||
struct attr *attr_new;
|
struct attr *attr_new;
|
||||||
int ret;
|
route_map_result_t ret;
|
||||||
#if ENABLE_BGP_VNC
|
#if ENABLE_BGP_VNC
|
||||||
int vnc_implicit_withdraw = 0;
|
int vnc_implicit_withdraw = 0;
|
||||||
#endif
|
#endif
|
||||||
@ -4941,7 +4941,7 @@ static void bgp_static_update_safi(struct bgp *bgp, struct prefix *p,
|
|||||||
if (bgp_static->rmap.name) {
|
if (bgp_static->rmap.name) {
|
||||||
struct attr attr_tmp = attr;
|
struct attr attr_tmp = attr;
|
||||||
struct bgp_path_info rmap_path;
|
struct bgp_path_info rmap_path;
|
||||||
int ret;
|
route_map_result_t ret;
|
||||||
|
|
||||||
rmap_path.peer = bgp->peer_self;
|
rmap_path.peer = bgp->peer_self;
|
||||||
rmap_path.attr = &attr_tmp;
|
rmap_path.attr = &attr_tmp;
|
||||||
@ -6620,7 +6620,7 @@ void bgp_redistribute_add(struct bgp *bgp, struct prefix *p,
|
|||||||
struct attr attr;
|
struct attr attr;
|
||||||
struct attr *new_attr;
|
struct attr *new_attr;
|
||||||
afi_t afi;
|
afi_t afi;
|
||||||
int ret;
|
route_map_result_t ret;
|
||||||
struct bgp_redist *red;
|
struct bgp_redist *red;
|
||||||
|
|
||||||
/* Make default attribute. */
|
/* Make default attribute. */
|
||||||
@ -9139,7 +9139,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
|
|||||||
struct route_map *rmap = output_arg;
|
struct route_map *rmap = output_arg;
|
||||||
struct bgp_path_info path;
|
struct bgp_path_info path;
|
||||||
struct attr dummy_attr;
|
struct attr dummy_attr;
|
||||||
int ret;
|
route_map_result_t ret;
|
||||||
|
|
||||||
bgp_attr_dup(&dummy_attr, pi->attr);
|
bgp_attr_dup(&dummy_attr, pi->attr);
|
||||||
|
|
||||||
|
@ -239,10 +239,9 @@ struct bgp_match_peer_compiled {
|
|||||||
/* Compares the peer specified in the 'match peer' clause with the peer
|
/* Compares the peer specified in the 'match peer' clause with the peer
|
||||||
received in bgp_path_info->peer. If it is the same, or if the peer structure
|
received in bgp_path_info->peer. If it is the same, or if the peer structure
|
||||||
received is a peer_group containing it, returns RMAP_MATCH. */
|
received is a peer_group containing it, returns RMAP_MATCH. */
|
||||||
static route_map_result_t route_match_peer(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_peer(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct bgp_match_peer_compiled *pc;
|
struct bgp_match_peer_compiled *pc;
|
||||||
union sockunion *su;
|
union sockunion *su;
|
||||||
@ -335,10 +334,9 @@ struct route_map_rule_cmd route_match_peer_cmd = {"peer", route_match_peer,
|
|||||||
route_match_peer_free};
|
route_match_peer_free};
|
||||||
|
|
||||||
#if defined(HAVE_LUA)
|
#if defined(HAVE_LUA)
|
||||||
static route_map_result_t route_match_command(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_command(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
int status = RMAP_NOMATCH;
|
int status = RMAP_NOMATCH;
|
||||||
u_int32_t locpref = 0;
|
u_int32_t locpref = 0;
|
||||||
@ -434,10 +432,9 @@ struct route_map_rule_cmd route_match_command_cmd = {
|
|||||||
|
|
||||||
/* Match function should return 1 if match is success else return
|
/* Match function should return 1 if match is success else return
|
||||||
zero. */
|
zero. */
|
||||||
static route_map_result_t route_match_ip_address(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_ip_address(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct access_list *alist;
|
struct access_list *alist;
|
||||||
|
|
||||||
@ -474,10 +471,9 @@ struct route_map_rule_cmd route_match_ip_address_cmd = {
|
|||||||
/* `match ip next-hop IP_ADDRESS' */
|
/* `match ip next-hop IP_ADDRESS' */
|
||||||
|
|
||||||
/* Match function return 1 if match is success else return zero. */
|
/* Match function return 1 if match is success else return zero. */
|
||||||
static route_map_result_t route_match_ip_next_hop(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_ip_next_hop(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct access_list *alist;
|
struct access_list *alist;
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
@ -521,10 +517,9 @@ struct route_map_rule_cmd route_match_ip_next_hop_cmd = {
|
|||||||
/* `match ip route-source ACCESS-LIST' */
|
/* `match ip route-source ACCESS-LIST' */
|
||||||
|
|
||||||
/* Match function return 1 if match is success else return zero. */
|
/* Match function return 1 if match is success else return zero. */
|
||||||
static route_map_result_t route_match_ip_route_source(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *pfx,
|
route_match_ip_route_source(void *rule, const struct prefix *pfx,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct access_list *alist;
|
struct access_list *alist;
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
@ -571,9 +566,9 @@ struct route_map_rule_cmd route_match_ip_route_source_cmd = {
|
|||||||
"ip route-source", route_match_ip_route_source,
|
"ip route-source", route_match_ip_route_source,
|
||||||
route_match_ip_route_source_compile, route_match_ip_route_source_free};
|
route_match_ip_route_source_compile, route_match_ip_route_source_free};
|
||||||
|
|
||||||
static route_map_result_t route_match_prefix_list_flowspec(afi_t afi,
|
static enum route_map_cmd_result_t
|
||||||
struct prefix_list *plist,
|
route_match_prefix_list_flowspec(afi_t afi, struct prefix_list *plist,
|
||||||
const struct prefix *p)
|
const struct prefix *p)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct bgp_pbr_entry_main api;
|
struct bgp_pbr_entry_main api;
|
||||||
@ -604,8 +599,7 @@ static route_map_result_t route_match_prefix_list_flowspec(afi_t afi,
|
|||||||
return RMAP_NOMATCH;
|
return RMAP_NOMATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* `match ip address prefix-list PREFIX_LIST' */
|
static enum route_map_cmd_result_t
|
||||||
static route_map_result_t
|
|
||||||
route_match_address_prefix_list(void *rule, afi_t afi,
|
route_match_address_prefix_list(void *rule, afi_t afi,
|
||||||
const struct prefix *prefix,
|
const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
@ -626,7 +620,7 @@ route_match_address_prefix_list(void *rule, afi_t afi,
|
|||||||
: RMAP_MATCH);
|
: RMAP_MATCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
route_match_ip_address_prefix_list(void *rule, const struct prefix *prefix,
|
route_match_ip_address_prefix_list(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
@ -651,7 +645,7 @@ struct route_map_rule_cmd route_match_ip_address_prefix_list_cmd = {
|
|||||||
|
|
||||||
/* `match ip next-hop prefix-list PREFIX_LIST' */
|
/* `match ip next-hop prefix-list PREFIX_LIST' */
|
||||||
|
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
route_match_ip_next_hop_prefix_list(void *rule, const struct prefix *prefix,
|
route_match_ip_next_hop_prefix_list(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
@ -693,7 +687,7 @@ struct route_map_rule_cmd route_match_ip_next_hop_prefix_list_cmd = {
|
|||||||
|
|
||||||
/* `match ip next-hop type <blackhole>' */
|
/* `match ip next-hop type <blackhole>' */
|
||||||
|
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
route_match_ip_next_hop_type(void *rule, const struct prefix *prefix,
|
route_match_ip_next_hop_type(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
@ -702,7 +696,7 @@ route_match_ip_next_hop_type(void *rule, const struct prefix *prefix,
|
|||||||
if (type == RMAP_BGP && prefix->family == AF_INET) {
|
if (type == RMAP_BGP && prefix->family == AF_INET) {
|
||||||
path = (struct bgp_path_info *)object;
|
path = (struct bgp_path_info *)object;
|
||||||
if (!path || !path->attr)
|
if (!path || !path->attr)
|
||||||
return RMAP_DENYMATCH;
|
return RMAP_NOMATCH;
|
||||||
|
|
||||||
/* If nexthop interface's index can't be resolved and nexthop is
|
/* If nexthop interface's index can't be resolved and nexthop is
|
||||||
set to any address then mark it as type `blackhole`.
|
set to any address then mark it as type `blackhole`.
|
||||||
@ -732,7 +726,7 @@ static struct route_map_rule_cmd route_match_ip_next_hop_type_cmd = {
|
|||||||
|
|
||||||
/* `match ip route-source prefix-list PREFIX_LIST' */
|
/* `match ip route-source prefix-list PREFIX_LIST' */
|
||||||
|
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
route_match_ip_route_source_prefix_list(void *rule,
|
route_match_ip_route_source_prefix_list(void *rule,
|
||||||
const struct prefix *prefix,
|
const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
@ -782,10 +776,9 @@ struct route_map_rule_cmd route_match_ip_route_source_prefix_list_cmd = {
|
|||||||
/* `match evpn default-route' */
|
/* `match evpn default-route' */
|
||||||
|
|
||||||
/* Match function should return 1 if match is success else 0 */
|
/* Match function should return 1 if match is success else 0 */
|
||||||
static route_map_result_t route_match_evpn_default_route(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *p,
|
route_match_evpn_default_route(void *rule, const struct prefix *p,
|
||||||
route_map_object_t
|
route_map_object_t type, void *object)
|
||||||
type, void *object)
|
|
||||||
{
|
{
|
||||||
if (type == RMAP_BGP && is_evpn_prefix_default(p))
|
if (type == RMAP_BGP && is_evpn_prefix_default(p))
|
||||||
return RMAP_MATCH;
|
return RMAP_MATCH;
|
||||||
@ -801,10 +794,9 @@ struct route_map_rule_cmd route_match_evpn_default_route_cmd = {
|
|||||||
|
|
||||||
/* Match function should return 1 if match is success else return
|
/* Match function should return 1 if match is success else return
|
||||||
zero. */
|
zero. */
|
||||||
static route_map_result_t route_match_mac_address(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_mac_address(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct access_list *alist;
|
struct access_list *alist;
|
||||||
struct prefix p;
|
struct prefix p;
|
||||||
@ -851,9 +843,9 @@ struct route_map_rule_cmd route_match_mac_address_cmd = {
|
|||||||
|
|
||||||
/* Match function should return 1 if match is success else return
|
/* Match function should return 1 if match is success else return
|
||||||
zero. */
|
zero. */
|
||||||
static route_map_result_t route_match_vni(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_vni(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
vni_t vni = 0;
|
vni_t vni = 0;
|
||||||
struct bgp_path_info *path = NULL;
|
struct bgp_path_info *path = NULL;
|
||||||
@ -904,10 +896,9 @@ struct route_map_rule_cmd route_match_evpn_vni_cmd = {
|
|||||||
|
|
||||||
/* Match function should return 1 if match is success else return
|
/* Match function should return 1 if match is success else return
|
||||||
zero. */
|
zero. */
|
||||||
static route_map_result_t route_match_evpn_route_type(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *pfx,
|
route_match_evpn_route_type(void *rule, const struct prefix *pfx,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
uint8_t route_type = 0;
|
uint8_t route_type = 0;
|
||||||
|
|
||||||
@ -950,7 +941,7 @@ struct route_map_rule_cmd route_match_evpn_route_type_cmd = {
|
|||||||
route_match_evpn_route_type_compile, route_match_evpn_route_type_free};
|
route_match_evpn_route_type_compile, route_match_evpn_route_type_free};
|
||||||
|
|
||||||
/* Route map commands for VRF route leak with source vrf matching */
|
/* Route map commands for VRF route leak with source vrf matching */
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
route_match_vrl_source_vrf(void *rule, const struct prefix *prefix,
|
route_match_vrl_source_vrf(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
@ -999,10 +990,9 @@ struct route_map_rule_cmd route_match_vrl_source_vrf_cmd = {
|
|||||||
/* `match local-preference LOCAL-PREF' */
|
/* `match local-preference LOCAL-PREF' */
|
||||||
|
|
||||||
/* Match function return 1 if match is success else return zero. */
|
/* Match function return 1 if match is success else return zero. */
|
||||||
static route_map_result_t route_match_local_pref(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_local_pref(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
uint32_t *local_pref;
|
uint32_t *local_pref;
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
@ -1056,10 +1046,9 @@ struct route_map_rule_cmd route_match_local_pref_cmd = {
|
|||||||
/* `match metric METRIC' */
|
/* `match metric METRIC' */
|
||||||
|
|
||||||
/* Match function return 1 if match is success else return zero. */
|
/* Match function return 1 if match is success else return zero. */
|
||||||
static route_map_result_t route_match_metric(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_metric(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct rmap_value *rv;
|
struct rmap_value *rv;
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
@ -1080,10 +1069,9 @@ struct route_map_rule_cmd route_match_metric_cmd = {
|
|||||||
/* `match as-path ASPATH' */
|
/* `match as-path ASPATH' */
|
||||||
|
|
||||||
/* Match function for as-path match. I assume given object is */
|
/* Match function for as-path match. I assume given object is */
|
||||||
static route_map_result_t route_match_aspath(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_aspath(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
struct as_list *as_list;
|
struct as_list *as_list;
|
||||||
@ -1130,10 +1118,9 @@ struct rmap_community {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Match function for community match. */
|
/* Match function for community match. */
|
||||||
static route_map_result_t route_match_community(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_community(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct community_list *list;
|
struct community_list *list;
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
@ -1200,10 +1187,9 @@ struct route_map_rule_cmd route_match_community_cmd = {
|
|||||||
route_match_community_free};
|
route_match_community_free};
|
||||||
|
|
||||||
/* Match function for lcommunity match. */
|
/* Match function for lcommunity match. */
|
||||||
static route_map_result_t route_match_lcommunity(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_lcommunity(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct community_list *list;
|
struct community_list *list;
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
@ -1273,10 +1259,9 @@ struct route_map_rule_cmd route_match_lcommunity_cmd = {
|
|||||||
|
|
||||||
|
|
||||||
/* Match function for extcommunity match. */
|
/* Match function for extcommunity match. */
|
||||||
static route_map_result_t route_match_ecommunity(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_ecommunity(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct community_list *list;
|
struct community_list *list;
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
@ -1327,10 +1312,9 @@ struct route_map_rule_cmd route_match_ecommunity_cmd = {
|
|||||||
and `address-family vpnv4'. */
|
and `address-family vpnv4'. */
|
||||||
|
|
||||||
/* `match origin' */
|
/* `match origin' */
|
||||||
static route_map_result_t route_match_origin(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_origin(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
uint8_t *origin;
|
uint8_t *origin;
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
@ -1375,10 +1359,9 @@ struct route_map_rule_cmd route_match_origin_cmd = {
|
|||||||
|
|
||||||
/* match probability { */
|
/* match probability { */
|
||||||
|
|
||||||
static route_map_result_t route_match_probability(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_probability(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
long r = random();
|
long r = random();
|
||||||
|
|
||||||
@ -1430,10 +1413,9 @@ struct route_map_rule_cmd route_match_probability_cmd = {
|
|||||||
/* `match interface IFNAME' */
|
/* `match interface IFNAME' */
|
||||||
/* Match function should return 1 if match is success else return
|
/* Match function should return 1 if match is success else return
|
||||||
zero. */
|
zero. */
|
||||||
static route_map_result_t route_match_interface(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_interface(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct interface *ifp;
|
struct interface *ifp;
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
@ -1477,9 +1459,9 @@ struct route_map_rule_cmd route_match_interface_cmd = {
|
|||||||
/* `set ip next-hop IP_ADDRESS' */
|
/* `set ip next-hop IP_ADDRESS' */
|
||||||
|
|
||||||
/* Match function return 1 if match is success else return zero. */
|
/* Match function return 1 if match is success else return zero. */
|
||||||
static route_map_result_t route_match_tag(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_tag(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
route_tag_t *tag;
|
route_tag_t *tag;
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
@ -1509,10 +1491,9 @@ struct rmap_ip_nexthop_set {
|
|||||||
int unchanged;
|
int unchanged;
|
||||||
};
|
};
|
||||||
|
|
||||||
static route_map_result_t route_set_ip_nexthop(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_set_ip_nexthop(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct rmap_ip_nexthop_set *rins = rule;
|
struct rmap_ip_nexthop_set *rins = rule;
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
@ -1615,10 +1596,9 @@ struct route_map_rule_cmd route_set_ip_nexthop_cmd = {
|
|||||||
/* `set local-preference LOCAL_PREF' */
|
/* `set local-preference LOCAL_PREF' */
|
||||||
|
|
||||||
/* Set local preference. */
|
/* Set local preference. */
|
||||||
static route_map_result_t route_set_local_pref(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_set_local_pref(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct rmap_value *rv;
|
struct rmap_value *rv;
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
@ -1650,10 +1630,9 @@ struct route_map_rule_cmd route_set_local_pref_cmd = {
|
|||||||
/* `set weight WEIGHT' */
|
/* `set weight WEIGHT' */
|
||||||
|
|
||||||
/* Set weight. */
|
/* Set weight. */
|
||||||
static route_map_result_t route_set_weight(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_set_weight(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct rmap_value *rv;
|
struct rmap_value *rv;
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
@ -1678,10 +1657,9 @@ struct route_map_rule_cmd route_set_weight_cmd = {
|
|||||||
/* `set metric METRIC' */
|
/* `set metric METRIC' */
|
||||||
|
|
||||||
/* Set metric to attribute. */
|
/* Set metric to attribute. */
|
||||||
static route_map_result_t route_set_metric(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_set_metric(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct rmap_value *rv;
|
struct rmap_value *rv;
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
@ -1709,10 +1687,9 @@ struct route_map_rule_cmd route_set_metric_cmd = {
|
|||||||
/* `set as-path prepend ASPATH' */
|
/* `set as-path prepend ASPATH' */
|
||||||
|
|
||||||
/* For AS path prepend mechanism. */
|
/* For AS path prepend mechanism. */
|
||||||
static route_map_result_t route_set_aspath_prepend(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_set_aspath_prepend(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct aspath *aspath;
|
struct aspath *aspath;
|
||||||
struct aspath *new;
|
struct aspath *new;
|
||||||
@ -1772,10 +1749,9 @@ struct route_map_rule_cmd route_set_aspath_prepend_cmd = {
|
|||||||
* one.
|
* one.
|
||||||
* Make a deep copy of existing AS_PATH, but for the first ASn only.
|
* Make a deep copy of existing AS_PATH, but for the first ASn only.
|
||||||
*/
|
*/
|
||||||
static route_map_result_t route_set_aspath_exclude(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *dummy,
|
route_set_aspath_exclude(void *rule, const struct prefix *dummy,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct aspath *new_path, *exclude_path;
|
struct aspath *new_path, *exclude_path;
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
@ -1807,10 +1783,9 @@ struct rmap_com_set {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* For community set mechanism. */
|
/* For community set mechanism. */
|
||||||
static route_map_result_t route_set_community(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_set_community(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct rmap_com_set *rcs;
|
struct rmap_com_set *rcs;
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
@ -1923,10 +1898,9 @@ struct rmap_lcom_set {
|
|||||||
|
|
||||||
|
|
||||||
/* For lcommunity set mechanism. */
|
/* For lcommunity set mechanism. */
|
||||||
static route_map_result_t route_set_lcommunity(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_set_lcommunity(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct rmap_lcom_set *rcs;
|
struct rmap_lcom_set *rcs;
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
@ -2036,10 +2010,9 @@ struct route_map_rule_cmd route_set_lcommunity_cmd = {
|
|||||||
/* `set large-comm-list (<1-99>|<100-500>|WORD) delete' */
|
/* `set large-comm-list (<1-99>|<100-500>|WORD) delete' */
|
||||||
|
|
||||||
/* For large community set mechanism. */
|
/* For large community set mechanism. */
|
||||||
static route_map_result_t route_set_lcommunity_delete(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *pfx,
|
route_set_lcommunity_delete(void *rule, const struct prefix *pfx,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct community_list *list;
|
struct community_list *list;
|
||||||
struct lcommunity *merge;
|
struct lcommunity *merge;
|
||||||
@ -2120,11 +2093,9 @@ struct route_map_rule_cmd route_set_lcommunity_delete_cmd = {
|
|||||||
/* `set comm-list (<1-99>|<100-500>|WORD) delete' */
|
/* `set comm-list (<1-99>|<100-500>|WORD) delete' */
|
||||||
|
|
||||||
/* For community set mechanism. */
|
/* For community set mechanism. */
|
||||||
static route_map_result_t route_set_community_delete(
|
static enum route_map_cmd_result_t
|
||||||
void *rule,
|
route_set_community_delete(void *rule, const struct prefix *prefix,
|
||||||
const struct prefix *prefix,
|
route_map_object_t type, void *object)
|
||||||
route_map_object_t type,
|
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct community_list *list;
|
struct community_list *list;
|
||||||
struct community *merge;
|
struct community *merge;
|
||||||
@ -2204,10 +2175,9 @@ struct route_map_rule_cmd route_set_community_delete_cmd = {
|
|||||||
/* `set extcommunity rt COMMUNITY' */
|
/* `set extcommunity rt COMMUNITY' */
|
||||||
|
|
||||||
/* For community set mechanism. Used by _rt and _soo. */
|
/* For community set mechanism. Used by _rt and _soo. */
|
||||||
static route_map_result_t route_set_ecommunity(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_set_ecommunity(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct ecommunity *ecom;
|
struct ecommunity *ecom;
|
||||||
struct ecommunity *new_ecom;
|
struct ecommunity *new_ecom;
|
||||||
@ -2292,10 +2262,9 @@ struct route_map_rule_cmd route_set_ecommunity_soo_cmd = {
|
|||||||
/* `set origin ORIGIN' */
|
/* `set origin ORIGIN' */
|
||||||
|
|
||||||
/* For origin set. */
|
/* For origin set. */
|
||||||
static route_map_result_t route_set_origin(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_set_origin(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
uint8_t *origin;
|
uint8_t *origin;
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
@ -2342,10 +2311,9 @@ struct route_map_rule_cmd route_set_origin_cmd = {
|
|||||||
/* `set atomic-aggregate' */
|
/* `set atomic-aggregate' */
|
||||||
|
|
||||||
/* For atomic aggregate set. */
|
/* For atomic aggregate set. */
|
||||||
static route_map_result_t route_set_atomic_aggregate(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *pfx,
|
route_set_atomic_aggregate(void *rule, const struct prefix *pfx,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
|
|
||||||
@ -2381,10 +2349,9 @@ struct aggregator {
|
|||||||
struct in_addr address;
|
struct in_addr address;
|
||||||
};
|
};
|
||||||
|
|
||||||
static route_map_result_t route_set_aggregator_as(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_set_aggregator_as(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
struct aggregator *aggregator;
|
struct aggregator *aggregator;
|
||||||
@ -2435,9 +2402,9 @@ struct route_map_rule_cmd route_set_aggregator_as_cmd = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Set tag to object. object must be pointer to struct bgp_path_info */
|
/* Set tag to object. object must be pointer to struct bgp_path_info */
|
||||||
static route_map_result_t route_set_tag(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_set_tag(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
route_tag_t *tag;
|
route_tag_t *tag;
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
@ -2460,10 +2427,9 @@ static struct route_map_rule_cmd route_set_tag_cmd = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Set label-index to object. object must be pointer to struct bgp_path_info */
|
/* Set label-index to object. object must be pointer to struct bgp_path_info */
|
||||||
static route_map_result_t route_set_label_index(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_set_label_index(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct rmap_value *rv;
|
struct rmap_value *rv;
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
@ -2493,10 +2459,9 @@ static struct route_map_rule_cmd route_set_label_index_cmd = {
|
|||||||
|
|
||||||
/* `match ipv6 address IP_ACCESS_LIST' */
|
/* `match ipv6 address IP_ACCESS_LIST' */
|
||||||
|
|
||||||
static route_map_result_t route_match_ipv6_address(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_ipv6_address(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct access_list *alist;
|
struct access_list *alist;
|
||||||
|
|
||||||
@ -2529,10 +2494,9 @@ struct route_map_rule_cmd route_match_ipv6_address_cmd = {
|
|||||||
|
|
||||||
/* `match ipv6 next-hop IP_ADDRESS' */
|
/* `match ipv6 next-hop IP_ADDRESS' */
|
||||||
|
|
||||||
static route_map_result_t route_match_ipv6_next_hop(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_ipv6_next_hop(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct in6_addr *addr = rule;
|
struct in6_addr *addr = rule;
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
@ -2581,7 +2545,7 @@ struct route_map_rule_cmd route_match_ipv6_next_hop_cmd = {
|
|||||||
|
|
||||||
/* `match ipv6 address prefix-list PREFIX_LIST' */
|
/* `match ipv6 address prefix-list PREFIX_LIST' */
|
||||||
|
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
route_match_ipv6_address_prefix_list(void *rule, const struct prefix *prefix,
|
route_match_ipv6_address_prefix_list(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
@ -2606,9 +2570,9 @@ struct route_map_rule_cmd route_match_ipv6_address_prefix_list_cmd = {
|
|||||||
|
|
||||||
/* `match ipv6 next-hop type <TYPE>' */
|
/* `match ipv6 next-hop type <TYPE>' */
|
||||||
|
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
route_match_ipv6_next_hop_type(void *rule, const struct prefix *prefix,
|
route_match_ipv6_next_hop_type(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
struct in6_addr *addr = rule;
|
struct in6_addr *addr = rule;
|
||||||
@ -2616,7 +2580,7 @@ route_match_ipv6_next_hop_type(void *rule, const struct prefix *prefix,
|
|||||||
if (type == RMAP_BGP && prefix->family == AF_INET6) {
|
if (type == RMAP_BGP && prefix->family == AF_INET6) {
|
||||||
path = (struct bgp_path_info *)object;
|
path = (struct bgp_path_info *)object;
|
||||||
if (!path || !path->attr)
|
if (!path || !path->attr)
|
||||||
return RMAP_DENYMATCH;
|
return RMAP_NOMATCH;
|
||||||
|
|
||||||
if (IPV6_ADDR_SAME(&path->attr->mp_nexthop_global, addr)
|
if (IPV6_ADDR_SAME(&path->attr->mp_nexthop_global, addr)
|
||||||
&& !path->attr->nh_ifindex)
|
&& !path->attr->nh_ifindex)
|
||||||
@ -2654,10 +2618,9 @@ struct route_map_rule_cmd route_match_ipv6_next_hop_type_cmd = {
|
|||||||
/* `set ipv6 nexthop global IP_ADDRESS' */
|
/* `set ipv6 nexthop global IP_ADDRESS' */
|
||||||
|
|
||||||
/* Set nexthop to object. ojbect must be pointer to struct attr. */
|
/* Set nexthop to object. ojbect must be pointer to struct attr. */
|
||||||
static route_map_result_t route_set_ipv6_nexthop_global(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *p,
|
route_set_ipv6_nexthop_global(void *rule, const struct prefix *p,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct in6_addr *address;
|
struct in6_addr *address;
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
@ -2713,7 +2676,7 @@ struct route_map_rule_cmd route_set_ipv6_nexthop_global_cmd = {
|
|||||||
route_set_ipv6_nexthop_global_free};
|
route_set_ipv6_nexthop_global_free};
|
||||||
|
|
||||||
/* Set next-hop preference value. */
|
/* Set next-hop preference value. */
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
route_set_ipv6_nexthop_prefer_global(void *rule, const struct prefix *prefix,
|
route_set_ipv6_nexthop_prefer_global(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
@ -2767,10 +2730,9 @@ struct route_map_rule_cmd route_set_ipv6_nexthop_prefer_global_cmd = {
|
|||||||
/* `set ipv6 nexthop local IP_ADDRESS' */
|
/* `set ipv6 nexthop local IP_ADDRESS' */
|
||||||
|
|
||||||
/* Set nexthop to object. ojbect must be pointer to struct attr. */
|
/* Set nexthop to object. ojbect must be pointer to struct attr. */
|
||||||
static route_map_result_t route_set_ipv6_nexthop_local(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *p,
|
route_set_ipv6_nexthop_local(void *rule, const struct prefix *p,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct in6_addr *address;
|
struct in6_addr *address;
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
@ -2830,10 +2792,9 @@ struct route_map_rule_cmd route_set_ipv6_nexthop_local_cmd = {
|
|||||||
/* `set ipv6 nexthop peer-address' */
|
/* `set ipv6 nexthop peer-address' */
|
||||||
|
|
||||||
/* Set nexthop to object. ojbect must be pointer to struct attr. */
|
/* Set nexthop to object. ojbect must be pointer to struct attr. */
|
||||||
static route_map_result_t route_set_ipv6_nexthop_peer(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *pfx,
|
route_set_ipv6_nexthop_peer(void *rule, const struct prefix *pfx,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct in6_addr peer_address;
|
struct in6_addr peer_address;
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
@ -2908,10 +2869,9 @@ struct route_map_rule_cmd route_set_ipv6_nexthop_peer_cmd = {
|
|||||||
|
|
||||||
/* `set ipv4 vpn next-hop A.B.C.D' */
|
/* `set ipv4 vpn next-hop A.B.C.D' */
|
||||||
|
|
||||||
static route_map_result_t route_set_vpnv4_nexthop(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_set_vpnv4_nexthop(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct in_addr *address;
|
struct in_addr *address;
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
@ -2948,10 +2908,9 @@ static void *route_set_vpnv4_nexthop_compile(const char *arg)
|
|||||||
|
|
||||||
/* `set ipv6 vpn next-hop A.B.C.D' */
|
/* `set ipv6 vpn next-hop A.B.C.D' */
|
||||||
|
|
||||||
static route_map_result_t route_set_vpnv6_nexthop(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_set_vpnv6_nexthop(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct in6_addr *address;
|
struct in6_addr *address;
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
@ -3004,10 +2963,9 @@ struct route_map_rule_cmd route_set_vpnv6_nexthop_cmd = {
|
|||||||
/* `set originator-id' */
|
/* `set originator-id' */
|
||||||
|
|
||||||
/* For origin set. */
|
/* For origin set. */
|
||||||
static route_map_result_t route_set_originator_id(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_set_originator_id(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct in_addr *address;
|
struct in_addr *address;
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
|
@ -129,8 +129,10 @@ static void print_record(const struct pfx_record *record, struct vty *vty);
|
|||||||
static int is_synchronized(void);
|
static int is_synchronized(void);
|
||||||
static int is_running(void);
|
static int is_running(void);
|
||||||
static void route_match_free(void *rule);
|
static void route_match_free(void *rule);
|
||||||
static route_map_result_t route_match(void *rule, const struct prefix *prefix,
|
static enum route_map_cmd_result_t route_match(void *rule,
|
||||||
route_map_object_t type, void *object);
|
const struct prefix *prefix,
|
||||||
|
route_map_object_t type,
|
||||||
|
void *object);
|
||||||
static void *route_match_compile(const char *arg);
|
static void *route_match_compile(const char *arg);
|
||||||
static void revalidate_bgp_node(struct bgp_node *bgp_node, afi_t afi,
|
static void revalidate_bgp_node(struct bgp_node *bgp_node, afi_t afi,
|
||||||
safi_t safi);
|
safi_t safi);
|
||||||
@ -213,8 +215,10 @@ static void ipv6_addr_to_host_byte_order(const uint32_t *src, uint32_t *dest)
|
|||||||
dest[i] = ntohl(src[i]);
|
dest[i] = ntohl(src[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static route_map_result_t route_match(void *rule, const struct prefix *prefix,
|
static enum route_map_cmd_result_t route_match(void *rule,
|
||||||
route_map_object_t type, void *object)
|
const struct prefix *prefix,
|
||||||
|
route_map_object_t type,
|
||||||
|
void *object)
|
||||||
{
|
{
|
||||||
int *rpki_status = rule;
|
int *rpki_status = rule;
|
||||||
struct bgp_path_info *path;
|
struct bgp_path_info *path;
|
||||||
|
@ -716,7 +716,7 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
|
|||||||
struct bgp_node *rn;
|
struct bgp_node *rn;
|
||||||
struct bgp_path_info *ri;
|
struct bgp_path_info *ri;
|
||||||
struct peer *peer;
|
struct peer *peer;
|
||||||
int ret = RMAP_DENYMATCH;
|
route_map_result_t ret = RMAP_DENYMATCH;
|
||||||
afi_t afi;
|
afi_t afi;
|
||||||
safi_t safi;
|
safi_t safi;
|
||||||
|
|
||||||
|
@ -251,9 +251,9 @@ void eigrp_route_map_update(const char *notused)
|
|||||||
|
|
||||||
/* `match metric METRIC' */
|
/* `match metric METRIC' */
|
||||||
/* Match function return 1 if match is success else return zero. */
|
/* Match function return 1 if match is success else return zero. */
|
||||||
static route_map_result_t route_match_metric(void *rule, struct prefix *prefix,
|
static enum route_map_cmd_result_t
|
||||||
route_map_object_t type,
|
route_match_metric(void *rule, struct prefix *prefix, route_map_object_t type,
|
||||||
void *object)
|
void *object)
|
||||||
{
|
{
|
||||||
// uint32_t *metric;
|
// uint32_t *metric;
|
||||||
// uint32_t check;
|
// uint32_t check;
|
||||||
@ -311,10 +311,9 @@ struct route_map_rule_cmd route_match_metric_cmd = {
|
|||||||
|
|
||||||
/* `match interface IFNAME' */
|
/* `match interface IFNAME' */
|
||||||
/* Match function return 1 if match is success else return zero. */
|
/* Match function return 1 if match is success else return zero. */
|
||||||
static route_map_result_t route_match_interface(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
struct prefix *prefix,
|
route_match_interface(void *rule, struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
// struct rip_info *rinfo;
|
// struct rip_info *rinfo;
|
||||||
// struct interface *ifp;
|
// struct interface *ifp;
|
||||||
@ -360,10 +359,9 @@ struct route_map_rule_cmd route_match_interface_cmd = {
|
|||||||
/* `match ip next-hop IP_ACCESS_LIST' */
|
/* `match ip next-hop IP_ACCESS_LIST' */
|
||||||
|
|
||||||
/* Match function return 1 if match is success else return zero. */
|
/* Match function return 1 if match is success else return zero. */
|
||||||
static route_map_result_t route_match_ip_next_hop(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
struct prefix *prefix,
|
route_match_ip_next_hop(void *rule, struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
// struct access_list *alist;
|
// struct access_list *alist;
|
||||||
// struct rip_info *rinfo;
|
// struct rip_info *rinfo;
|
||||||
@ -407,7 +405,7 @@ static struct route_map_rule_cmd route_match_ip_next_hop_cmd = {
|
|||||||
|
|
||||||
/* `match ip next-hop prefix-list PREFIX_LIST' */
|
/* `match ip next-hop prefix-list PREFIX_LIST' */
|
||||||
|
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
route_match_ip_next_hop_prefix_list(void *rule, struct prefix *prefix,
|
route_match_ip_next_hop_prefix_list(void *rule, struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
@ -452,10 +450,9 @@ static struct route_map_rule_cmd route_match_ip_next_hop_prefix_list_cmd = {
|
|||||||
|
|
||||||
/* Match function should return 1 if match is success else return
|
/* Match function should return 1 if match is success else return
|
||||||
zero. */
|
zero. */
|
||||||
static route_map_result_t route_match_ip_address(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
struct prefix *prefix,
|
route_match_ip_address(void *rule, struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct access_list *alist;
|
struct access_list *alist;
|
||||||
|
|
||||||
@ -491,7 +488,7 @@ static struct route_map_rule_cmd route_match_ip_address_cmd = {
|
|||||||
|
|
||||||
/* `match ip address prefix-list PREFIX_LIST' */
|
/* `match ip address prefix-list PREFIX_LIST' */
|
||||||
|
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
route_match_ip_address_prefix_list(void *rule, struct prefix *prefix,
|
route_match_ip_address_prefix_list(void *rule, struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
@ -526,8 +523,9 @@ static struct route_map_rule_cmd route_match_ip_address_prefix_list_cmd = {
|
|||||||
|
|
||||||
/* `match tag TAG' */
|
/* `match tag TAG' */
|
||||||
/* Match function return 1 if match is success else return zero. */
|
/* Match function return 1 if match is success else return zero. */
|
||||||
static route_map_result_t route_match_tag(void *rule, struct prefix *prefix,
|
static enum route_map_cmd_result_t
|
||||||
route_map_object_t type, void *object)
|
route_match_tag(void *rule, struct prefix *prefix, route_map_object_t type,
|
||||||
|
void *object)
|
||||||
{
|
{
|
||||||
// unsigned short *tag;
|
// unsigned short *tag;
|
||||||
// struct rip_info *rinfo;
|
// struct rip_info *rinfo;
|
||||||
@ -568,9 +566,9 @@ struct route_map_rule_cmd route_match_tag_cmd = {
|
|||||||
"tag", route_match_tag, route_match_tag_compile, route_match_tag_free};
|
"tag", route_match_tag, route_match_tag_compile, route_match_tag_free};
|
||||||
|
|
||||||
/* Set metric to attribute. */
|
/* Set metric to attribute. */
|
||||||
static route_map_result_t route_set_metric(void *rule, struct prefix *prefix,
|
static enum route_map_cmd_result_t
|
||||||
route_map_object_t type,
|
route_set_metric(void *rule, struct prefix *prefix,
|
||||||
void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
// if (type == RMAP_RIP)
|
// if (type == RMAP_RIP)
|
||||||
// {
|
// {
|
||||||
@ -662,10 +660,9 @@ static struct route_map_rule_cmd route_set_metric_cmd = {
|
|||||||
/* `set ip next-hop IP_ADDRESS' */
|
/* `set ip next-hop IP_ADDRESS' */
|
||||||
|
|
||||||
/* Set nexthop to object. ojbect must be pointer to struct attr. */
|
/* Set nexthop to object. ojbect must be pointer to struct attr. */
|
||||||
static route_map_result_t route_set_ip_nexthop(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
struct prefix *prefix,
|
route_set_ip_nexthop(void *rule, struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
// struct in_addr *address;
|
// struct in_addr *address;
|
||||||
// struct rip_info *rinfo;
|
// struct rip_info *rinfo;
|
||||||
@ -718,8 +715,9 @@ static struct route_map_rule_cmd route_set_ip_nexthop_cmd = {
|
|||||||
/* `set tag TAG' */
|
/* `set tag TAG' */
|
||||||
|
|
||||||
/* Set tag to object. ojbect must be pointer to struct attr. */
|
/* Set tag to object. ojbect must be pointer to struct attr. */
|
||||||
static route_map_result_t route_set_tag(void *rule, struct prefix *prefix,
|
static enum route_map_cmd_result_t
|
||||||
route_map_object_t type, void *object)
|
route_set_tag(void *rule, struct prefix *prefix,
|
||||||
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
// unsigned short *tag;
|
// unsigned short *tag;
|
||||||
// struct rip_info *rinfo;
|
// struct rip_info *rinfo;
|
||||||
|
@ -48,10 +48,9 @@
|
|||||||
#include "isis_zebra.h"
|
#include "isis_zebra.h"
|
||||||
#include "isis_routemap.h"
|
#include "isis_routemap.h"
|
||||||
|
|
||||||
static route_map_result_t route_match_ip_address(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_ip_address(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct access_list *alist;
|
struct access_list *alist;
|
||||||
|
|
||||||
@ -81,7 +80,7 @@ static struct route_map_rule_cmd route_match_ip_address_cmd = {
|
|||||||
|
|
||||||
/* ------------------------------------------------------------*/
|
/* ------------------------------------------------------------*/
|
||||||
|
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
route_match_ip_address_prefix_list(void *rule, const struct prefix *prefix,
|
route_match_ip_address_prefix_list(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
@ -114,10 +113,9 @@ struct route_map_rule_cmd route_match_ip_address_prefix_list_cmd = {
|
|||||||
|
|
||||||
/* ------------------------------------------------------------*/
|
/* ------------------------------------------------------------*/
|
||||||
|
|
||||||
static route_map_result_t route_match_ipv6_address(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_ipv6_address(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct access_list *alist;
|
struct access_list *alist;
|
||||||
|
|
||||||
@ -147,7 +145,7 @@ static struct route_map_rule_cmd route_match_ipv6_address_cmd = {
|
|||||||
|
|
||||||
/* ------------------------------------------------------------*/
|
/* ------------------------------------------------------------*/
|
||||||
|
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
route_match_ipv6_address_prefix_list(void *rule, const struct prefix *prefix,
|
route_match_ipv6_address_prefix_list(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
@ -180,10 +178,9 @@ struct route_map_rule_cmd route_match_ipv6_address_prefix_list_cmd = {
|
|||||||
|
|
||||||
/* ------------------------------------------------------------*/
|
/* ------------------------------------------------------------*/
|
||||||
|
|
||||||
static route_map_result_t route_set_metric(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_set_metric(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
uint32_t *metric;
|
uint32_t *metric;
|
||||||
struct isis_ext_info *info;
|
struct isis_ext_info *info;
|
||||||
|
203
lib/routemap.c
203
lib/routemap.c
@ -927,15 +927,15 @@ static const char *route_map_type_str(enum route_map_type type)
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *route_map_result_str(route_map_result_t res)
|
static const char *route_map_cmd_result_str(enum route_map_cmd_result_t res)
|
||||||
{
|
{
|
||||||
switch (res) {
|
switch (res) {
|
||||||
case RMAP_MATCH:
|
case RMAP_MATCH:
|
||||||
return "match";
|
return "match";
|
||||||
case RMAP_DENYMATCH:
|
|
||||||
return "deny";
|
|
||||||
case RMAP_NOMATCH:
|
case RMAP_NOMATCH:
|
||||||
return "no match";
|
return "no match";
|
||||||
|
case RMAP_NOOP:
|
||||||
|
return "noop";
|
||||||
case RMAP_ERROR:
|
case RMAP_ERROR:
|
||||||
return "error";
|
return "error";
|
||||||
case RMAP_OKAY:
|
case RMAP_OKAY:
|
||||||
@ -945,6 +945,18 @@ static const char *route_map_result_str(route_map_result_t res)
|
|||||||
return "invalid";
|
return "invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *route_map_result_str(route_map_result_t res)
|
||||||
|
{
|
||||||
|
switch (res) {
|
||||||
|
case RMAP_DENYMATCH:
|
||||||
|
return "deny";
|
||||||
|
case RMAP_PERMITMATCH:
|
||||||
|
return "permit";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "invalid";
|
||||||
|
}
|
||||||
|
|
||||||
static int route_map_empty(struct route_map *map)
|
static int route_map_empty(struct route_map *map)
|
||||||
{
|
{
|
||||||
if (map->head == NULL && map->tail == NULL)
|
if (map->head == NULL && map->tail == NULL)
|
||||||
@ -1558,20 +1570,98 @@ int route_map_delete_set(struct route_map_index *index, const char *set_name,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static enum route_map_cmd_result_t
|
||||||
|
route_map_apply_match(struct route_map_rule_list *match_list,
|
||||||
|
const struct prefix *prefix, route_map_object_t type,
|
||||||
|
void *object)
|
||||||
|
{
|
||||||
|
enum route_map_cmd_result_t ret = RMAP_NOMATCH;
|
||||||
|
struct route_map_rule *match;
|
||||||
|
bool is_matched = false;
|
||||||
|
|
||||||
|
|
||||||
|
/* Check all match rule and if there is no match rule, go to the
|
||||||
|
set statement. */
|
||||||
|
if (!match_list->head)
|
||||||
|
ret = RMAP_MATCH;
|
||||||
|
else {
|
||||||
|
for (match = match_list->head; match; match = match->next) {
|
||||||
|
/*
|
||||||
|
* Try each match statement. If any match does not
|
||||||
|
* return RMAP_MATCH or RMAP_NOOP, return.
|
||||||
|
* Otherwise continue on to next match statement.
|
||||||
|
* All match statements must MATCH for
|
||||||
|
* end-result to be a match.
|
||||||
|
* (Exception:If match stmts result in a mix of
|
||||||
|
* MATCH/NOOP, then also end-result is a match)
|
||||||
|
* If all result in NOOP, end-result is NOOP.
|
||||||
|
*/
|
||||||
|
ret = (*match->cmd->func_apply)(match->value, prefix,
|
||||||
|
type, object);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the consolidated result of func_apply is:
|
||||||
|
* -----------------------------------------------
|
||||||
|
* | MATCH | NOMATCH | NOOP | Final Result |
|
||||||
|
* ------------------------------------------------
|
||||||
|
* | yes | yes | yes | NOMATCH |
|
||||||
|
* | no | no | yes | NOOP |
|
||||||
|
* | yes | no | yes | MATCH |
|
||||||
|
* | no | yes | yes | NOMATCH |
|
||||||
|
* |-----------------------------------------------
|
||||||
|
*
|
||||||
|
* Traditionally, all rules within route-map
|
||||||
|
* should match for it to MATCH.
|
||||||
|
* If there are noops within the route-map rules,
|
||||||
|
* it follows the above matrix.
|
||||||
|
*
|
||||||
|
* Eg: route-map rm1 permit 10
|
||||||
|
* match rule1
|
||||||
|
* match rule2
|
||||||
|
* match rule3
|
||||||
|
* ....
|
||||||
|
* route-map rm1 permit 20
|
||||||
|
* match ruleX
|
||||||
|
* match ruleY
|
||||||
|
* ...
|
||||||
|
*/
|
||||||
|
|
||||||
|
switch (ret) {
|
||||||
|
case RMAP_MATCH:
|
||||||
|
is_matched = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RMAP_NOMATCH:
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
case RMAP_NOOP:
|
||||||
|
if (is_matched)
|
||||||
|
ret = RMAP_MATCH;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* Apply route map's each index to the object.
|
/* Apply route map's each index to the object.
|
||||||
|
|
||||||
The matrix for a route-map looks like this:
|
The matrix for a route-map looks like this:
|
||||||
(note, this includes the description for the "NEXT"
|
(note, this includes the description for the "NEXT"
|
||||||
and "GOTO" frobs now
|
and "GOTO" frobs now
|
||||||
|
|
||||||
Match | No Match
|
| Match | No Match | No op
|
||||||
|
|
|-----------|--------------|-------
|
||||||
permit action | cont
|
permit | action | cont | cont.
|
||||||
|
|
| | default:deny | default:permit
|
||||||
------------------+---------------
|
-------------------+-----------------------
|
||||||
|
|
| deny | cont | cont.
|
||||||
deny deny | cont
|
deny | | default:deny | default:permit
|
||||||
|
|
|-----------|--------------|--------
|
||||||
|
|
||||||
action)
|
action)
|
||||||
-Apply Set statements, accept route
|
-Apply Set statements, accept route
|
||||||
@ -1604,45 +1694,13 @@ int route_map_delete_set(struct route_map_index *index, const char *set_name,
|
|||||||
|
|
||||||
We need to make sure our route-map processing matches the above
|
We need to make sure our route-map processing matches the above
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static route_map_result_t
|
|
||||||
route_map_apply_match(struct route_map_rule_list *match_list,
|
|
||||||
const struct prefix *prefix, route_map_object_t type,
|
|
||||||
void *object)
|
|
||||||
{
|
|
||||||
route_map_result_t ret = RMAP_NOMATCH;
|
|
||||||
struct route_map_rule *match;
|
|
||||||
|
|
||||||
|
|
||||||
/* Check all match rule and if there is no match rule, go to the
|
|
||||||
set statement. */
|
|
||||||
if (!match_list->head)
|
|
||||||
ret = RMAP_MATCH;
|
|
||||||
else {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Apply route map to the object. */
|
|
||||||
route_map_result_t route_map_apply(struct route_map *map,
|
route_map_result_t route_map_apply(struct route_map *map,
|
||||||
const struct prefix *prefix,
|
const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
static int recursion = 0;
|
static int recursion = 0;
|
||||||
int ret = 0;
|
enum route_map_cmd_result_t match_ret = RMAP_NOMATCH;
|
||||||
|
route_map_result_t ret = RMAP_PERMITMATCH;
|
||||||
struct route_map_index *index;
|
struct route_map_index *index;
|
||||||
struct route_map_rule *set;
|
struct route_map_rule *set;
|
||||||
char buf[PREFIX_STRLEN];
|
char buf[PREFIX_STRLEN];
|
||||||
@ -1656,7 +1714,7 @@ route_map_result_t route_map_apply(struct route_map *map,
|
|||||||
return RMAP_DENYMATCH;
|
return RMAP_DENYMATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (map == NULL) {
|
if (map == NULL || map->head == NULL) {
|
||||||
ret = RMAP_DENYMATCH;
|
ret = RMAP_DENYMATCH;
|
||||||
goto route_map_apply_end;
|
goto route_map_apply_end;
|
||||||
}
|
}
|
||||||
@ -1665,29 +1723,64 @@ route_map_result_t route_map_apply(struct route_map *map,
|
|||||||
for (index = map->head; index; index = index->next) {
|
for (index = map->head; index; index = index->next) {
|
||||||
/* Apply this index. */
|
/* Apply this index. */
|
||||||
index->applied++;
|
index->applied++;
|
||||||
ret = route_map_apply_match(&index->match_list, prefix, type,
|
match_ret = route_map_apply_match(&index->match_list, prefix,
|
||||||
object);
|
type, object);
|
||||||
|
|
||||||
if (rmap_debug) {
|
if (rmap_debug) {
|
||||||
zlog_debug("Route-map: %s, sequence: %d, prefix: %s, result: %s",
|
zlog_debug("Route-map: %s, sequence: %d, prefix: %s, result: %s",
|
||||||
map->name, index->pref,
|
map->name, index->pref,
|
||||||
prefix2str(prefix, buf, sizeof(buf)),
|
prefix2str(prefix, buf, sizeof(buf)),
|
||||||
route_map_result_str(ret));
|
route_map_cmd_result_str(match_ret));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now we apply the matrix from above */
|
/* Now we apply the matrix from above */
|
||||||
if (ret == RMAP_NOMATCH)
|
if (match_ret == RMAP_NOOP)
|
||||||
/* 'cont' from matrix - continue to next route-map
|
/*
|
||||||
* sequence */
|
* Do not change the return value. Retain the previous
|
||||||
|
* return value. Previous values can be:
|
||||||
|
* 1)permitmatch (if a nomatch was never
|
||||||
|
* seen before in this route-map.)
|
||||||
|
* 2)denymatch (if a nomatch was seen earlier in one
|
||||||
|
* of the previous sequences)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 'cont' from matrix - continue to next route-map
|
||||||
|
* sequence
|
||||||
|
*/
|
||||||
continue;
|
continue;
|
||||||
else if (ret == RMAP_MATCH) {
|
else if (match_ret == RMAP_NOMATCH) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The return value is now changed to denymatch.
|
||||||
|
* So from here on out, even if we see more noops,
|
||||||
|
* we retain this return value and return this
|
||||||
|
* eventually if there are no matches.
|
||||||
|
*/
|
||||||
|
ret = RMAP_DENYMATCH;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 'cont' from matrix - continue to next route-map
|
||||||
|
* sequence
|
||||||
|
*/
|
||||||
|
continue;
|
||||||
|
} else if (match_ret == RMAP_MATCH) {
|
||||||
if (index->type == RMAP_PERMIT)
|
if (index->type == RMAP_PERMIT)
|
||||||
/* 'action' */
|
/* 'action' */
|
||||||
{
|
{
|
||||||
|
/* Match succeeded, rmap is of type permit */
|
||||||
|
ret = RMAP_PERMITMATCH;
|
||||||
|
|
||||||
/* permit+match must execute sets */
|
/* permit+match must execute sets */
|
||||||
for (set = index->set_list.head; set;
|
for (set = index->set_list.head; set;
|
||||||
set = set->next)
|
set = set->next)
|
||||||
ret = (*set->cmd->func_apply)(
|
/*
|
||||||
|
* set cmds return RMAP_OKAY or
|
||||||
|
* RMAP_ERROR. We do not care if
|
||||||
|
* set succeeded or not. So, ignore
|
||||||
|
* return code.
|
||||||
|
*/
|
||||||
|
(void) (*set->cmd->func_apply)(
|
||||||
set->value, prefix, type,
|
set->value, prefix, type,
|
||||||
object);
|
object);
|
||||||
|
|
||||||
@ -1741,8 +1834,6 @@ route_map_result_t route_map_apply(struct route_map *map,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Finally route-map does not match at all. */
|
|
||||||
ret = RMAP_DENYMATCH;
|
|
||||||
|
|
||||||
route_map_apply_end:
|
route_map_apply_end:
|
||||||
if (rmap_debug) {
|
if (rmap_debug) {
|
||||||
|
@ -38,13 +38,35 @@ DECLARE_MTYPE(ROUTE_MAP_COMPILED)
|
|||||||
enum route_map_type { RMAP_PERMIT, RMAP_DENY, RMAP_ANY };
|
enum route_map_type { RMAP_PERMIT, RMAP_DENY, RMAP_ANY };
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
RMAP_MATCH,
|
|
||||||
RMAP_DENYMATCH,
|
RMAP_DENYMATCH,
|
||||||
RMAP_NOMATCH,
|
RMAP_PERMITMATCH
|
||||||
RMAP_ERROR,
|
|
||||||
RMAP_OKAY
|
|
||||||
} route_map_result_t;
|
} route_map_result_t;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Route-map match or set result "Eg: match evpn vni xx"
|
||||||
|
* route-map match cmd always returns match/nomatch/noop
|
||||||
|
* match--> found a match
|
||||||
|
* nomatch--> didnt find a match
|
||||||
|
* noop--> not applicable
|
||||||
|
* route-map set retuns okay/error
|
||||||
|
* okay --> set was successful
|
||||||
|
* error --> set was not successful
|
||||||
|
*/
|
||||||
|
enum route_map_cmd_result_t {
|
||||||
|
/*
|
||||||
|
* route-map match cmd results
|
||||||
|
*/
|
||||||
|
RMAP_MATCH,
|
||||||
|
RMAP_NOMATCH,
|
||||||
|
RMAP_NOOP,
|
||||||
|
/*
|
||||||
|
* route-map set cmd results
|
||||||
|
*/
|
||||||
|
RMAP_OKAY,
|
||||||
|
RMAP_ERROR
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
RMAP_RIP,
|
RMAP_RIP,
|
||||||
RMAP_RIPNG,
|
RMAP_RIPNG,
|
||||||
@ -91,10 +113,10 @@ struct route_map_rule_cmd {
|
|||||||
const char *str;
|
const char *str;
|
||||||
|
|
||||||
/* Function for value set or match. */
|
/* Function for value set or match. */
|
||||||
route_map_result_t (*func_apply)(void *rule,
|
enum route_map_cmd_result_t (*func_apply)(void *rule,
|
||||||
const struct prefix *prefix,
|
const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type,
|
||||||
void *object);
|
void *object);
|
||||||
|
|
||||||
/* Compile argument and return result as void *. */
|
/* Compile argument and return result as void *. */
|
||||||
void *(*func_compile)(const char *);
|
void *(*func_compile)(const char *);
|
||||||
|
@ -1018,7 +1018,7 @@ void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex,
|
|||||||
unsigned int nexthop_num,
|
unsigned int nexthop_num,
|
||||||
struct in6_addr *nexthop, route_tag_t tag)
|
struct in6_addr *nexthop, route_tag_t tag)
|
||||||
{
|
{
|
||||||
int ret;
|
route_map_result_t ret;
|
||||||
struct ospf6_route troute;
|
struct ospf6_route troute;
|
||||||
struct ospf6_external_info tinfo;
|
struct ospf6_external_info tinfo;
|
||||||
struct ospf6_route *route, *match;
|
struct ospf6_route *route, *match;
|
||||||
@ -1355,7 +1355,7 @@ static void ospf6_redistribute_show_config(struct vty *vty)
|
|||||||
|
|
||||||
|
|
||||||
/* Routemap Functions */
|
/* Routemap Functions */
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
ospf6_routemap_rule_match_address_prefixlist(void *rule,
|
ospf6_routemap_rule_match_address_prefixlist(void *rule,
|
||||||
const struct prefix *prefix,
|
const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type,
|
||||||
@ -1395,7 +1395,7 @@ struct route_map_rule_cmd ospf6_routemap_rule_match_address_prefixlist_cmd = {
|
|||||||
/* `match interface IFNAME' */
|
/* `match interface IFNAME' */
|
||||||
/* Match function should return 1 if match is success else return
|
/* Match function should return 1 if match is success else return
|
||||||
zero. */
|
zero. */
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
ospf6_routemap_rule_match_interface(void *rule, const struct prefix *prefix,
|
ospf6_routemap_rule_match_interface(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
@ -1433,10 +1433,9 @@ struct route_map_rule_cmd ospf6_routemap_rule_match_interface_cmd = {
|
|||||||
ospf6_routemap_rule_match_interface_free};
|
ospf6_routemap_rule_match_interface_free};
|
||||||
|
|
||||||
/* Match function for matching route tags */
|
/* Match function for matching route tags */
|
||||||
static route_map_result_t ospf6_routemap_rule_match_tag(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *p,
|
ospf6_routemap_rule_match_tag(void *rule, const struct prefix *p,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
route_tag_t *tag = rule;
|
route_tag_t *tag = rule;
|
||||||
struct ospf6_route *route = object;
|
struct ospf6_route *route = object;
|
||||||
@ -1453,7 +1452,7 @@ static struct route_map_rule_cmd ospf6_routemap_rule_match_tag_cmd = {
|
|||||||
route_map_rule_tag_free,
|
route_map_rule_tag_free,
|
||||||
};
|
};
|
||||||
|
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
ospf6_routemap_rule_set_metric_type(void *rule, const struct prefix *prefix,
|
ospf6_routemap_rule_set_metric_type(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
@ -1489,7 +1488,7 @@ struct route_map_rule_cmd ospf6_routemap_rule_set_metric_type_cmd = {
|
|||||||
ospf6_routemap_rule_set_metric_type_free,
|
ospf6_routemap_rule_set_metric_type_free,
|
||||||
};
|
};
|
||||||
|
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
ospf6_routemap_rule_set_metric(void *rule, const struct prefix *prefix,
|
ospf6_routemap_rule_set_metric(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
@ -1524,7 +1523,7 @@ struct route_map_rule_cmd ospf6_routemap_rule_set_metric_cmd = {
|
|||||||
ospf6_routemap_rule_set_metric_free,
|
ospf6_routemap_rule_set_metric_free,
|
||||||
};
|
};
|
||||||
|
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
ospf6_routemap_rule_set_forwarding(void *rule, const struct prefix *prefix,
|
ospf6_routemap_rule_set_forwarding(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
@ -1562,10 +1561,9 @@ struct route_map_rule_cmd ospf6_routemap_rule_set_forwarding_cmd = {
|
|||||||
ospf6_routemap_rule_set_forwarding_free,
|
ospf6_routemap_rule_set_forwarding_free,
|
||||||
};
|
};
|
||||||
|
|
||||||
static route_map_result_t ospf6_routemap_rule_set_tag(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *p,
|
ospf6_routemap_rule_set_tag(void *rule, const struct prefix *p,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
route_tag_t *tag = rule;
|
route_tag_t *tag = rule;
|
||||||
struct ospf6_route *route = object;
|
struct ospf6_route *route = object;
|
||||||
|
@ -126,10 +126,9 @@ static void ospf_route_map_event(const char *name)
|
|||||||
|
|
||||||
/* `match ip netxthop ' */
|
/* `match ip netxthop ' */
|
||||||
/* Match function return 1 if match is success else return zero. */
|
/* Match function return 1 if match is success else return zero. */
|
||||||
static route_map_result_t route_match_ip_nexthop(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_ip_nexthop(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct access_list *alist;
|
struct access_list *alist;
|
||||||
struct external_info *ei = object;
|
struct external_info *ei = object;
|
||||||
@ -171,7 +170,7 @@ struct route_map_rule_cmd route_match_ip_nexthop_cmd = {
|
|||||||
|
|
||||||
/* `match ip next-hop prefix-list PREFIX_LIST' */
|
/* `match ip next-hop prefix-list PREFIX_LIST' */
|
||||||
|
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
route_match_ip_next_hop_prefix_list(void *rule, const struct prefix *prefix,
|
route_match_ip_next_hop_prefix_list(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
@ -212,7 +211,7 @@ struct route_map_rule_cmd route_match_ip_next_hop_prefix_list_cmd = {
|
|||||||
|
|
||||||
/* `match ip next-hop type <blackhole>' */
|
/* `match ip next-hop type <blackhole>' */
|
||||||
|
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
route_match_ip_next_hop_type(void *rule, const struct prefix *prefix,
|
route_match_ip_next_hop_type(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
@ -221,7 +220,7 @@ route_match_ip_next_hop_type(void *rule, const struct prefix *prefix,
|
|||||||
if (type == RMAP_OSPF && prefix->family == AF_INET) {
|
if (type == RMAP_OSPF && prefix->family == AF_INET) {
|
||||||
ei = (struct external_info *)object;
|
ei = (struct external_info *)object;
|
||||||
if (!ei)
|
if (!ei)
|
||||||
return RMAP_DENYMATCH;
|
return RMAP_NOMATCH;
|
||||||
|
|
||||||
if (ei->nexthop.s_addr == INADDR_ANY && !ei->ifindex)
|
if (ei->nexthop.s_addr == INADDR_ANY && !ei->ifindex)
|
||||||
return RMAP_MATCH;
|
return RMAP_MATCH;
|
||||||
@ -247,10 +246,9 @@ static struct route_map_rule_cmd route_match_ip_next_hop_type_cmd = {
|
|||||||
/* `match ip address IP_ACCESS_LIST' */
|
/* `match ip address IP_ACCESS_LIST' */
|
||||||
/* Match function should return 1 if match is success else return
|
/* Match function should return 1 if match is success else return
|
||||||
zero. */
|
zero. */
|
||||||
static route_map_result_t route_match_ip_address(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_ip_address(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct access_list *alist;
|
struct access_list *alist;
|
||||||
/* struct prefix_ipv4 match; */
|
/* struct prefix_ipv4 match; */
|
||||||
@ -286,7 +284,7 @@ struct route_map_rule_cmd route_match_ip_address_cmd = {
|
|||||||
route_match_ip_address_free};
|
route_match_ip_address_free};
|
||||||
|
|
||||||
/* `match ip address prefix-list PREFIX_LIST' */
|
/* `match ip address prefix-list PREFIX_LIST' */
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
route_match_ip_address_prefix_list(void *rule, const struct prefix *prefix,
|
route_match_ip_address_prefix_list(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
@ -322,10 +320,9 @@ struct route_map_rule_cmd route_match_ip_address_prefix_list_cmd = {
|
|||||||
/* `match interface IFNAME' */
|
/* `match interface IFNAME' */
|
||||||
/* Match function should return 1 if match is success else return
|
/* Match function should return 1 if match is success else return
|
||||||
zero. */
|
zero. */
|
||||||
static route_map_result_t route_match_interface(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_interface(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct interface *ifp;
|
struct interface *ifp;
|
||||||
struct external_info *ei;
|
struct external_info *ei;
|
||||||
@ -361,9 +358,9 @@ struct route_map_rule_cmd route_match_interface_cmd = {
|
|||||||
route_match_interface_free};
|
route_match_interface_free};
|
||||||
|
|
||||||
/* Match function return 1 if match is success else return zero. */
|
/* Match function return 1 if match is success else return zero. */
|
||||||
static route_map_result_t route_match_tag(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_tag(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
route_tag_t *tag;
|
route_tag_t *tag;
|
||||||
struct external_info *ei;
|
struct external_info *ei;
|
||||||
@ -392,10 +389,9 @@ struct ospf_metric {
|
|||||||
|
|
||||||
/* `set metric METRIC' */
|
/* `set metric METRIC' */
|
||||||
/* Set metric to attribute. */
|
/* Set metric to attribute. */
|
||||||
static route_map_result_t route_set_metric(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_set_metric(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct ospf_metric *metric;
|
struct ospf_metric *metric;
|
||||||
struct external_info *ei;
|
struct external_info *ei;
|
||||||
@ -473,10 +469,9 @@ struct route_map_rule_cmd route_set_metric_cmd = {
|
|||||||
|
|
||||||
/* `set metric-type TYPE' */
|
/* `set metric-type TYPE' */
|
||||||
/* Set metric-type to attribute. */
|
/* Set metric-type to attribute. */
|
||||||
static route_map_result_t route_set_metric_type(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_set_metric_type(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
uint32_t *metric_type;
|
uint32_t *metric_type;
|
||||||
struct external_info *ei;
|
struct external_info *ei;
|
||||||
@ -523,8 +518,9 @@ struct route_map_rule_cmd route_set_metric_type_cmd = {
|
|||||||
route_set_metric_type_free,
|
route_set_metric_type_free,
|
||||||
};
|
};
|
||||||
|
|
||||||
static route_map_result_t route_set_tag(void *rule, const struct prefix *prefix,
|
static enum route_map_cmd_result_t
|
||||||
route_map_object_t type, void *object)
|
route_set_tag(void *rule, const struct prefix *prefix, route_map_object_t type,
|
||||||
|
void *object)
|
||||||
{
|
{
|
||||||
route_tag_t *tag;
|
route_tag_t *tag;
|
||||||
struct external_info *ei;
|
struct external_info *ei;
|
||||||
|
@ -943,7 +943,7 @@ int ospf_redistribute_check(struct ospf *ospf, struct external_info *ei,
|
|||||||
/* apply route-map if needed */
|
/* apply route-map if needed */
|
||||||
red = ospf_redist_lookup(ospf, type, instance);
|
red = ospf_redist_lookup(ospf, type, instance);
|
||||||
if (red && ROUTEMAP_NAME(red)) {
|
if (red && ROUTEMAP_NAME(red)) {
|
||||||
int ret;
|
route_map_result_t ret;
|
||||||
|
|
||||||
ret = route_map_apply(ROUTEMAP(red), (struct prefix *)p,
|
ret = route_map_apply(ROUTEMAP(red), (struct prefix *)p,
|
||||||
RMAP_OSPF, ei);
|
RMAP_OSPF, ei);
|
||||||
|
@ -42,10 +42,9 @@ struct rip_metric_modifier {
|
|||||||
|
|
||||||
/* `match metric METRIC' */
|
/* `match metric METRIC' */
|
||||||
/* Match function return 1 if match is success else return zero. */
|
/* Match function return 1 if match is success else return zero. */
|
||||||
static route_map_result_t route_match_metric(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_metric(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
uint32_t *metric;
|
uint32_t *metric;
|
||||||
uint32_t check;
|
uint32_t check;
|
||||||
@ -95,10 +94,9 @@ struct route_map_rule_cmd route_match_metric_cmd = {
|
|||||||
|
|
||||||
/* `match interface IFNAME' */
|
/* `match interface IFNAME' */
|
||||||
/* Match function return 1 if match is success else return zero. */
|
/* Match function return 1 if match is success else return zero. */
|
||||||
static route_map_result_t route_match_interface(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_interface(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct rip_info *rinfo;
|
struct rip_info *rinfo;
|
||||||
struct interface *ifp;
|
struct interface *ifp;
|
||||||
@ -143,10 +141,9 @@ struct route_map_rule_cmd route_match_interface_cmd = {
|
|||||||
/* `match ip next-hop IP_ACCESS_LIST' */
|
/* `match ip next-hop IP_ACCESS_LIST' */
|
||||||
|
|
||||||
/* Match function return 1 if match is success else return zero. */
|
/* Match function return 1 if match is success else return zero. */
|
||||||
static route_map_result_t route_match_ip_next_hop(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_ip_next_hop(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct access_list *alist;
|
struct access_list *alist;
|
||||||
struct rip_info *rinfo;
|
struct rip_info *rinfo;
|
||||||
@ -190,7 +187,7 @@ static struct route_map_rule_cmd route_match_ip_next_hop_cmd = {
|
|||||||
|
|
||||||
/* `match ip next-hop prefix-list PREFIX_LIST' */
|
/* `match ip next-hop prefix-list PREFIX_LIST' */
|
||||||
|
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
route_match_ip_next_hop_prefix_list(void *rule, const struct prefix *prefix,
|
route_match_ip_next_hop_prefix_list(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
@ -233,7 +230,7 @@ static struct route_map_rule_cmd route_match_ip_next_hop_prefix_list_cmd = {
|
|||||||
|
|
||||||
/* `match ip next-hop type <blackhole>' */
|
/* `match ip next-hop type <blackhole>' */
|
||||||
|
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
route_match_ip_next_hop_type(void *rule, const struct prefix *prefix,
|
route_match_ip_next_hop_type(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
@ -242,7 +239,7 @@ route_match_ip_next_hop_type(void *rule, const struct prefix *prefix,
|
|||||||
if (type == RMAP_RIP && prefix->family == AF_INET) {
|
if (type == RMAP_RIP && prefix->family == AF_INET) {
|
||||||
rinfo = (struct rip_info *)object;
|
rinfo = (struct rip_info *)object;
|
||||||
if (!rinfo)
|
if (!rinfo)
|
||||||
return RMAP_DENYMATCH;
|
return RMAP_NOMATCH;
|
||||||
|
|
||||||
if (rinfo->nh.type == NEXTHOP_TYPE_BLACKHOLE)
|
if (rinfo->nh.type == NEXTHOP_TYPE_BLACKHOLE)
|
||||||
return RMAP_MATCH;
|
return RMAP_MATCH;
|
||||||
@ -269,10 +266,9 @@ static struct route_map_rule_cmd route_match_ip_next_hop_type_cmd = {
|
|||||||
|
|
||||||
/* Match function should return 1 if match is success else return
|
/* Match function should return 1 if match is success else return
|
||||||
zero. */
|
zero. */
|
||||||
static route_map_result_t route_match_ip_address(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_ip_address(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct access_list *alist;
|
struct access_list *alist;
|
||||||
|
|
||||||
@ -308,7 +304,7 @@ static struct route_map_rule_cmd route_match_ip_address_cmd = {
|
|||||||
|
|
||||||
/* `match ip address prefix-list PREFIX_LIST' */
|
/* `match ip address prefix-list PREFIX_LIST' */
|
||||||
|
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
route_match_ip_address_prefix_list(void *rule, const struct prefix *prefix,
|
route_match_ip_address_prefix_list(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
@ -343,8 +339,9 @@ static struct route_map_rule_cmd route_match_ip_address_prefix_list_cmd = {
|
|||||||
|
|
||||||
/* `match tag TAG' */
|
/* `match tag TAG' */
|
||||||
/* Match function return 1 if match is success else return zero. */
|
/* Match function return 1 if match is success else return zero. */
|
||||||
static route_map_result_t route_match_tag(void *rule, const struct prefix *p,
|
static enum route_map_cmd_result_t
|
||||||
route_map_object_t type, void *object)
|
route_match_tag(void *rule, const struct prefix *p, route_map_object_t type,
|
||||||
|
void *object)
|
||||||
{
|
{
|
||||||
route_tag_t *tag;
|
route_tag_t *tag;
|
||||||
struct rip_info *rinfo;
|
struct rip_info *rinfo;
|
||||||
@ -373,10 +370,9 @@ static struct route_map_rule_cmd route_match_tag_cmd = {
|
|||||||
/* `set metric METRIC' */
|
/* `set metric METRIC' */
|
||||||
|
|
||||||
/* Set metric to attribute. */
|
/* Set metric to attribute. */
|
||||||
static route_map_result_t route_set_metric(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_set_metric(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
if (type == RMAP_RIP) {
|
if (type == RMAP_RIP) {
|
||||||
struct rip_metric_modifier *mod;
|
struct rip_metric_modifier *mod;
|
||||||
@ -472,10 +468,10 @@ static struct route_map_rule_cmd route_set_metric_cmd = {
|
|||||||
/* `set ip next-hop IP_ADDRESS' */
|
/* `set ip next-hop IP_ADDRESS' */
|
||||||
|
|
||||||
/* Set nexthop to object. ojbect must be pointer to struct attr. */
|
/* Set nexthop to object. ojbect must be pointer to struct attr. */
|
||||||
static route_map_result_t route_set_ip_nexthop(void *rule,
|
static enum route_map_cmd_result_t route_set_ip_nexthop(void *rule,
|
||||||
const struct prefix *prefix,
|
const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type,
|
||||||
void *object)
|
void *object)
|
||||||
{
|
{
|
||||||
struct in_addr *address;
|
struct in_addr *address;
|
||||||
struct rip_info *rinfo;
|
struct rip_info *rinfo;
|
||||||
@ -525,8 +521,9 @@ static struct route_map_rule_cmd route_set_ip_nexthop_cmd = {
|
|||||||
/* `set tag TAG' */
|
/* `set tag TAG' */
|
||||||
|
|
||||||
/* Set tag to object. ojbect must be pointer to struct attr. */
|
/* Set tag to object. ojbect must be pointer to struct attr. */
|
||||||
static route_map_result_t route_set_tag(void *rule, const struct prefix *prefix,
|
static enum route_map_cmd_result_t
|
||||||
route_map_object_t type, void *object)
|
route_set_tag(void *rule, const struct prefix *prefix, route_map_object_t type,
|
||||||
|
void *object)
|
||||||
{
|
{
|
||||||
route_tag_t *tag;
|
route_tag_t *tag;
|
||||||
struct rip_info *rinfo;
|
struct rip_info *rinfo;
|
||||||
|
@ -38,10 +38,9 @@ struct rip_metric_modifier {
|
|||||||
|
|
||||||
/* `match metric METRIC' */
|
/* `match metric METRIC' */
|
||||||
/* Match function return 1 if match is success else return zero. */
|
/* Match function return 1 if match is success else return zero. */
|
||||||
static route_map_result_t route_match_metric(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_metric(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
uint32_t *metric;
|
uint32_t *metric;
|
||||||
struct ripng_info *rinfo;
|
struct ripng_info *rinfo;
|
||||||
@ -86,10 +85,9 @@ static struct route_map_rule_cmd route_match_metric_cmd = {
|
|||||||
|
|
||||||
/* `match interface IFNAME' */
|
/* `match interface IFNAME' */
|
||||||
/* Match function return 1 if match is success else return zero. */
|
/* Match function return 1 if match is success else return zero. */
|
||||||
static route_map_result_t route_match_interface(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_interface(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct ripng_info *rinfo;
|
struct ripng_info *rinfo;
|
||||||
struct interface *ifp;
|
struct interface *ifp;
|
||||||
@ -129,9 +127,10 @@ static struct route_map_rule_cmd route_match_interface_cmd = {
|
|||||||
|
|
||||||
/* `match tag TAG' */
|
/* `match tag TAG' */
|
||||||
/* Match function return 1 if match is success else return zero. */
|
/* Match function return 1 if match is success else return zero. */
|
||||||
static route_map_result_t route_match_tag(void *rule,
|
static enum route_map_cmd_result_t route_match_tag(void *rule,
|
||||||
const struct prefix *prefix,
|
const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type,
|
||||||
|
void *object)
|
||||||
{
|
{
|
||||||
route_tag_t *tag;
|
route_tag_t *tag;
|
||||||
struct ripng_info *rinfo;
|
struct ripng_info *rinfo;
|
||||||
@ -159,10 +158,9 @@ static struct route_map_rule_cmd route_match_tag_cmd = {
|
|||||||
/* `set metric METRIC' */
|
/* `set metric METRIC' */
|
||||||
|
|
||||||
/* Set metric to attribute. */
|
/* Set metric to attribute. */
|
||||||
static route_map_result_t route_set_metric(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_set_metric(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
if (type == RMAP_RIPNG) {
|
if (type == RMAP_RIPNG) {
|
||||||
struct rip_metric_modifier *mod;
|
struct rip_metric_modifier *mod;
|
||||||
@ -256,10 +254,9 @@ static struct route_map_rule_cmd route_set_metric_cmd = {
|
|||||||
/* `set ipv6 next-hop local IP_ADDRESS' */
|
/* `set ipv6 next-hop local IP_ADDRESS' */
|
||||||
|
|
||||||
/* Set nexthop to object. ojbect must be pointer to struct attr. */
|
/* Set nexthop to object. ojbect must be pointer to struct attr. */
|
||||||
static route_map_result_t route_set_ipv6_nexthop_local(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *p,
|
route_set_ipv6_nexthop_local(void *rule, const struct prefix *p,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct in6_addr *address;
|
struct in6_addr *address;
|
||||||
struct ripng_info *rinfo;
|
struct ripng_info *rinfo;
|
||||||
@ -310,9 +307,9 @@ static struct route_map_rule_cmd route_set_ipv6_nexthop_local_cmd = {
|
|||||||
/* `set tag TAG' */
|
/* `set tag TAG' */
|
||||||
|
|
||||||
/* Set tag to object. ojbect must be pointer to struct attr. */
|
/* Set tag to object. ojbect must be pointer to struct attr. */
|
||||||
static route_map_result_t route_set_tag(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_set_tag(void *rule, const struct prefix *prefix, route_map_object_t type,
|
||||||
route_map_object_t type, void *object)
|
void *object)
|
||||||
{
|
{
|
||||||
route_tag_t *tag;
|
route_tag_t *tag;
|
||||||
struct ripng_info *rinfo;
|
struct ripng_info *rinfo;
|
||||||
|
@ -574,7 +574,7 @@ int zebra_add_import_table_entry(struct zebra_vrf *zvrf, struct route_node *rn,
|
|||||||
struct route_entry *newre;
|
struct route_entry *newre;
|
||||||
struct route_entry *same;
|
struct route_entry *same;
|
||||||
struct prefix p;
|
struct prefix p;
|
||||||
route_map_result_t ret = RMAP_MATCH;
|
route_map_result_t ret = RMAP_PERMITMATCH;
|
||||||
afi_t afi;
|
afi_t afi;
|
||||||
|
|
||||||
afi = family2afi(rn->p.family);
|
afi = family2afi(rn->p.family);
|
||||||
@ -583,7 +583,7 @@ int zebra_add_import_table_entry(struct zebra_vrf *zvrf, struct route_node *rn,
|
|||||||
afi, re->type, re->instance, &rn->p, re->ng.nexthop,
|
afi, re->type, re->instance, &rn->p, re->ng.nexthop,
|
||||||
zvrf->vrf->vrf_id, re->tag, rmap_name);
|
zvrf->vrf->vrf_id, re->tag, rmap_name);
|
||||||
|
|
||||||
if (ret != RMAP_MATCH) {
|
if (ret != RMAP_PERMITMATCH) {
|
||||||
UNSET_FLAG(re->flags, ZEBRA_FLAG_SELECTED);
|
UNSET_FLAG(re->flags, ZEBRA_FLAG_SELECTED);
|
||||||
zebra_del_import_table_entry(zvrf, rn, re);
|
zebra_del_import_table_entry(zvrf, rn, re);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -339,7 +339,7 @@ static unsigned nexthop_active_check(struct route_node *rn,
|
|||||||
struct nexthop *nexthop)
|
struct nexthop *nexthop)
|
||||||
{
|
{
|
||||||
struct interface *ifp;
|
struct interface *ifp;
|
||||||
route_map_result_t ret = RMAP_MATCH;
|
route_map_result_t ret = RMAP_PERMITMATCH;
|
||||||
int family;
|
int family;
|
||||||
char buf[SRCDEST2STR_BUFFER];
|
char buf[SRCDEST2STR_BUFFER];
|
||||||
const struct prefix *p, *src_p;
|
const struct prefix *p, *src_p;
|
||||||
|
@ -403,7 +403,7 @@ static int zebra_rnh_apply_nht_rmap(afi_t afi, struct zebra_vrf *zvrf,
|
|||||||
{
|
{
|
||||||
int at_least_one = 0;
|
int at_least_one = 0;
|
||||||
struct nexthop *nexthop;
|
struct nexthop *nexthop;
|
||||||
int ret;
|
route_map_result_t ret;
|
||||||
|
|
||||||
if (prn && re) {
|
if (prn && re) {
|
||||||
for (nexthop = re->ng.nexthop; nexthop;
|
for (nexthop = re->ng.nexthop; nexthop;
|
||||||
|
@ -136,9 +136,9 @@ static int zebra_route_match_delete(struct vty *vty, const char *command,
|
|||||||
/* 'match tag TAG'
|
/* 'match tag TAG'
|
||||||
* Match function return 1 if match is success else return 0
|
* Match function return 1 if match is success else return 0
|
||||||
*/
|
*/
|
||||||
static route_map_result_t route_match_tag(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_tag(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
route_tag_t *tag;
|
route_tag_t *tag;
|
||||||
struct nh_rmap_obj *nh_data;
|
struct nh_rmap_obj *nh_data;
|
||||||
@ -162,10 +162,9 @@ static struct route_map_rule_cmd route_match_tag_cmd = {
|
|||||||
|
|
||||||
/* `match interface IFNAME' */
|
/* `match interface IFNAME' */
|
||||||
/* Match function return 1 if match is success else return zero. */
|
/* Match function return 1 if match is success else return zero. */
|
||||||
static route_map_result_t route_match_interface(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_interface(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct nh_rmap_obj *nh_data;
|
struct nh_rmap_obj *nh_data;
|
||||||
char *ifname = rule;
|
char *ifname = rule;
|
||||||
@ -1025,10 +1024,9 @@ DEFPY (show_ipv6_protocol_nht,
|
|||||||
/* `match ip next-hop IP_ACCESS_LIST' */
|
/* `match ip next-hop IP_ACCESS_LIST' */
|
||||||
|
|
||||||
/* Match function return 1 if match is success else return zero. */
|
/* Match function return 1 if match is success else return zero. */
|
||||||
static route_map_result_t route_match_ip_next_hop(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_ip_next_hop(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct access_list *alist;
|
struct access_list *alist;
|
||||||
struct nh_rmap_obj *nh_data;
|
struct nh_rmap_obj *nh_data;
|
||||||
@ -1037,7 +1035,7 @@ static route_map_result_t route_match_ip_next_hop(void *rule,
|
|||||||
if (type == RMAP_ZEBRA) {
|
if (type == RMAP_ZEBRA) {
|
||||||
nh_data = object;
|
nh_data = object;
|
||||||
if (!nh_data)
|
if (!nh_data)
|
||||||
return RMAP_DENYMATCH;
|
return RMAP_NOMATCH;
|
||||||
|
|
||||||
switch (nh_data->nexthop->type) {
|
switch (nh_data->nexthop->type) {
|
||||||
case NEXTHOP_TYPE_IFINDEX:
|
case NEXTHOP_TYPE_IFINDEX:
|
||||||
@ -1083,7 +1081,7 @@ static struct route_map_rule_cmd route_match_ip_next_hop_cmd = {
|
|||||||
|
|
||||||
/* `match ip next-hop prefix-list PREFIX_LIST' */
|
/* `match ip next-hop prefix-list PREFIX_LIST' */
|
||||||
|
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
route_match_ip_next_hop_prefix_list(void *rule, const struct prefix *prefix,
|
route_match_ip_next_hop_prefix_list(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
@ -1094,7 +1092,7 @@ route_match_ip_next_hop_prefix_list(void *rule, const struct prefix *prefix,
|
|||||||
if (type == RMAP_ZEBRA) {
|
if (type == RMAP_ZEBRA) {
|
||||||
nh_data = (struct nh_rmap_obj *)object;
|
nh_data = (struct nh_rmap_obj *)object;
|
||||||
if (!nh_data)
|
if (!nh_data)
|
||||||
return RMAP_DENYMATCH;
|
return RMAP_NOMATCH;
|
||||||
|
|
||||||
switch (nh_data->nexthop->type) {
|
switch (nh_data->nexthop->type) {
|
||||||
case NEXTHOP_TYPE_IFINDEX:
|
case NEXTHOP_TYPE_IFINDEX:
|
||||||
@ -1139,10 +1137,9 @@ static struct route_map_rule_cmd route_match_ip_next_hop_prefix_list_cmd = {
|
|||||||
|
|
||||||
/* Match function should return 1 if match is success else return
|
/* Match function should return 1 if match is success else return
|
||||||
zero. */
|
zero. */
|
||||||
static route_map_result_t route_match_address(afi_t afi, void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_address(afi_t afi, void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
struct access_list *alist;
|
struct access_list *alist;
|
||||||
|
|
||||||
@ -1158,19 +1155,16 @@ static route_map_result_t route_match_address(afi_t afi, void *rule,
|
|||||||
return RMAP_NOMATCH;
|
return RMAP_NOMATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
static route_map_result_t route_match_ip_address(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_ip_address(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
return route_match_address(AFI_IP, rule, prefix, type, object);
|
return route_match_address(AFI_IP, rule, prefix, type, object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static route_map_result_t route_match_ipv6_address(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *prefix,
|
route_match_ipv6_address(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
|
|
||||||
{
|
{
|
||||||
return route_match_address(AFI_IP6, rule, prefix, type, object);
|
return route_match_address(AFI_IP6, rule, prefix, type, object);
|
||||||
}
|
}
|
||||||
@ -1200,7 +1194,7 @@ static struct route_map_rule_cmd route_match_ipv6_address_cmd = {
|
|||||||
|
|
||||||
/* `match ip address prefix-list PREFIX_LIST' */
|
/* `match ip address prefix-list PREFIX_LIST' */
|
||||||
|
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
route_match_address_prefix_list(void *rule, const struct prefix *prefix,
|
route_match_address_prefix_list(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object, afi_t afi)
|
route_map_object_t type, void *object, afi_t afi)
|
||||||
{
|
{
|
||||||
@ -1218,7 +1212,7 @@ route_match_address_prefix_list(void *rule, const struct prefix *prefix,
|
|||||||
return RMAP_NOMATCH;
|
return RMAP_NOMATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
route_match_ip_address_prefix_list(void *rule, const struct prefix *prefix,
|
route_match_ip_address_prefix_list(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
@ -1241,7 +1235,7 @@ static struct route_map_rule_cmd route_match_ip_address_prefix_list_cmd = {
|
|||||||
route_match_address_prefix_list_compile,
|
route_match_address_prefix_list_compile,
|
||||||
route_match_address_prefix_list_free};
|
route_match_address_prefix_list_free};
|
||||||
|
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
route_match_ipv6_address_prefix_list(void *rule, const struct prefix *prefix,
|
route_match_ipv6_address_prefix_list(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
@ -1256,7 +1250,7 @@ static struct route_map_rule_cmd route_match_ipv6_address_prefix_list_cmd = {
|
|||||||
|
|
||||||
/* `match ipv6 next-hop type <TYPE>' */
|
/* `match ipv6 next-hop type <TYPE>' */
|
||||||
|
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
route_match_ipv6_next_hop_type(void *rule, const struct prefix *prefix,
|
route_match_ipv6_next_hop_type(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
@ -1265,7 +1259,7 @@ route_match_ipv6_next_hop_type(void *rule, const struct prefix *prefix,
|
|||||||
if (type == RMAP_ZEBRA && prefix->family == AF_INET6) {
|
if (type == RMAP_ZEBRA && prefix->family == AF_INET6) {
|
||||||
nh_data = (struct nh_rmap_obj *)object;
|
nh_data = (struct nh_rmap_obj *)object;
|
||||||
if (!nh_data)
|
if (!nh_data)
|
||||||
return RMAP_DENYMATCH;
|
return RMAP_NOMATCH;
|
||||||
|
|
||||||
if (nh_data->nexthop->type == NEXTHOP_TYPE_BLACKHOLE)
|
if (nh_data->nexthop->type == NEXTHOP_TYPE_BLACKHOLE)
|
||||||
return RMAP_MATCH;
|
return RMAP_MATCH;
|
||||||
@ -1290,7 +1284,7 @@ struct route_map_rule_cmd route_match_ipv6_next_hop_type_cmd = {
|
|||||||
|
|
||||||
/* `match ip address prefix-len PREFIXLEN' */
|
/* `match ip address prefix-len PREFIXLEN' */
|
||||||
|
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
route_match_address_prefix_len(void *rule, const struct prefix *prefix,
|
route_match_address_prefix_len(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
@ -1341,7 +1335,7 @@ static struct route_map_rule_cmd route_match_ipv6_address_prefix_len_cmd = {
|
|||||||
|
|
||||||
/* `match ip nexthop prefix-len PREFIXLEN' */
|
/* `match ip nexthop prefix-len PREFIXLEN' */
|
||||||
|
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
route_match_ip_nexthop_prefix_len(void *rule, const struct prefix *prefix,
|
route_match_ip_nexthop_prefix_len(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
@ -1352,7 +1346,7 @@ route_match_ip_nexthop_prefix_len(void *rule, const struct prefix *prefix,
|
|||||||
if (type == RMAP_ZEBRA) {
|
if (type == RMAP_ZEBRA) {
|
||||||
nh_data = (struct nh_rmap_obj *)object;
|
nh_data = (struct nh_rmap_obj *)object;
|
||||||
if (!nh_data || !nh_data->nexthop)
|
if (!nh_data || !nh_data->nexthop)
|
||||||
return RMAP_DENYMATCH;
|
return RMAP_NOMATCH;
|
||||||
|
|
||||||
switch (nh_data->nexthop->type) {
|
switch (nh_data->nexthop->type) {
|
||||||
case NEXTHOP_TYPE_IFINDEX:
|
case NEXTHOP_TYPE_IFINDEX:
|
||||||
@ -1381,7 +1375,7 @@ static struct route_map_rule_cmd route_match_ip_nexthop_prefix_len_cmd = {
|
|||||||
|
|
||||||
/* `match ip next-hop type <blackhole>' */
|
/* `match ip next-hop type <blackhole>' */
|
||||||
|
|
||||||
static route_map_result_t
|
static enum route_map_cmd_result_t
|
||||||
route_match_ip_next_hop_type(void *rule, const struct prefix *prefix,
|
route_match_ip_next_hop_type(void *rule, const struct prefix *prefix,
|
||||||
route_map_object_t type, void *object)
|
route_map_object_t type, void *object)
|
||||||
{
|
{
|
||||||
@ -1390,7 +1384,7 @@ route_match_ip_next_hop_type(void *rule, const struct prefix *prefix,
|
|||||||
if (type == RMAP_ZEBRA && prefix->family == AF_INET) {
|
if (type == RMAP_ZEBRA && prefix->family == AF_INET) {
|
||||||
nh_data = (struct nh_rmap_obj *)object;
|
nh_data = (struct nh_rmap_obj *)object;
|
||||||
if (!nh_data)
|
if (!nh_data)
|
||||||
return RMAP_DENYMATCH;
|
return RMAP_NOMATCH;
|
||||||
|
|
||||||
if (nh_data->nexthop->type == NEXTHOP_TYPE_BLACKHOLE)
|
if (nh_data->nexthop->type == NEXTHOP_TYPE_BLACKHOLE)
|
||||||
return RMAP_MATCH;
|
return RMAP_MATCH;
|
||||||
@ -1415,10 +1409,9 @@ static struct route_map_rule_cmd route_match_ip_next_hop_type_cmd = {
|
|||||||
|
|
||||||
/* `match source-protocol PROTOCOL' */
|
/* `match source-protocol PROTOCOL' */
|
||||||
|
|
||||||
static route_map_result_t route_match_source_protocol(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *p,
|
route_match_source_protocol(void *rule, const struct prefix *p,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
uint32_t *rib_type = (uint32_t *)rule;
|
uint32_t *rib_type = (uint32_t *)rule;
|
||||||
struct nh_rmap_obj *nh_data;
|
struct nh_rmap_obj *nh_data;
|
||||||
@ -1426,7 +1419,7 @@ static route_map_result_t route_match_source_protocol(void *rule,
|
|||||||
if (type == RMAP_ZEBRA) {
|
if (type == RMAP_ZEBRA) {
|
||||||
nh_data = (struct nh_rmap_obj *)object;
|
nh_data = (struct nh_rmap_obj *)object;
|
||||||
if (!nh_data)
|
if (!nh_data)
|
||||||
return RMAP_DENYMATCH;
|
return RMAP_NOMATCH;
|
||||||
|
|
||||||
return ((nh_data->source_protocol == *rib_type) ? RMAP_MATCH
|
return ((nh_data->source_protocol == *rib_type) ? RMAP_MATCH
|
||||||
: RMAP_NOMATCH);
|
: RMAP_NOMATCH);
|
||||||
@ -1457,10 +1450,9 @@ static struct route_map_rule_cmd route_match_source_protocol_cmd = {
|
|||||||
route_match_source_protocol_compile, route_match_source_protocol_free};
|
route_match_source_protocol_compile, route_match_source_protocol_free};
|
||||||
|
|
||||||
/* `source-instance` */
|
/* `source-instance` */
|
||||||
static route_map_result_t route_match_source_instance(void *rule,
|
static enum route_map_cmd_result_t
|
||||||
const struct prefix *p,
|
route_match_source_instance(void *rule, const struct prefix *p,
|
||||||
route_map_object_t type,
|
route_map_object_t type, void *object)
|
||||||
void *object)
|
|
||||||
{
|
{
|
||||||
uint8_t *instance = (uint8_t *)rule;
|
uint8_t *instance = (uint8_t *)rule;
|
||||||
struct nh_rmap_obj *nh_data;
|
struct nh_rmap_obj *nh_data;
|
||||||
@ -1470,7 +1462,7 @@ static route_map_result_t route_match_source_instance(void *rule,
|
|||||||
|
|
||||||
nh_data = (struct nh_rmap_obj *)object;
|
nh_data = (struct nh_rmap_obj *)object;
|
||||||
if (!nh_data)
|
if (!nh_data)
|
||||||
return RMAP_DENYMATCH;
|
return RMAP_NOMATCH;
|
||||||
|
|
||||||
return (nh_data->instance == *instance) ? RMAP_MATCH : RMAP_NOMATCH;
|
return (nh_data->instance == *instance) ? RMAP_MATCH : RMAP_NOMATCH;
|
||||||
}
|
}
|
||||||
@ -1500,8 +1492,9 @@ static struct route_map_rule_cmd route_match_source_instance_cmd = {
|
|||||||
/* `set src A.B.C.D' */
|
/* `set src A.B.C.D' */
|
||||||
|
|
||||||
/* Set src. */
|
/* Set src. */
|
||||||
static route_map_result_t route_set_src(void *rule, const struct prefix *prefix,
|
static enum route_map_cmd_result_t
|
||||||
route_map_object_t type, void *object)
|
route_set_src(void *rule, const struct prefix *prefix, route_map_object_t type,
|
||||||
|
void *object)
|
||||||
{
|
{
|
||||||
struct nh_rmap_obj *nh_data;
|
struct nh_rmap_obj *nh_data;
|
||||||
|
|
||||||
@ -1767,7 +1760,7 @@ zebra_route_map_check(int family, int rib_type, uint8_t instance,
|
|||||||
struct zebra_vrf *zvrf, route_tag_t tag)
|
struct zebra_vrf *zvrf, route_tag_t tag)
|
||||||
{
|
{
|
||||||
struct route_map *rmap = NULL;
|
struct route_map *rmap = NULL;
|
||||||
route_map_result_t ret = RMAP_MATCH;
|
route_map_result_t ret = RMAP_PERMITMATCH;
|
||||||
struct nh_rmap_obj nh_obj;
|
struct nh_rmap_obj nh_obj;
|
||||||
|
|
||||||
nh_obj.nexthop = nexthop;
|
nh_obj.nexthop = nexthop;
|
||||||
@ -1839,7 +1832,7 @@ route_map_result_t zebra_nht_route_map_check(afi_t afi, int client_proto,
|
|||||||
struct nexthop *nexthop)
|
struct nexthop *nexthop)
|
||||||
{
|
{
|
||||||
struct route_map *rmap = NULL;
|
struct route_map *rmap = NULL;
|
||||||
route_map_result_t ret = RMAP_MATCH;
|
route_map_result_t ret = RMAP_PERMITMATCH;
|
||||||
struct nh_rmap_obj nh_obj;
|
struct nh_rmap_obj nh_obj;
|
||||||
|
|
||||||
nh_obj.nexthop = nexthop;
|
nh_obj.nexthop = nexthop;
|
||||||
|
Loading…
Reference in New Issue
Block a user