zebra: let the route-map rule "match interface" work for VRFs

Introduce a new "struct nexthop_vrfid" to specify a nexthop together
with the VRF ID it belongs to.

Thus in route_match_interface(), we can lookup the interface from
the correct VRF.

Signed-off-by: Feng Lu <lu.feng@6wind.com>
Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Vincent JARDIN <vincent.jardin@6wind.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>

Conflicts:
	zebra/zebra_rib.c
	zebra/zebra_routemap.c
This commit is contained in:
Feng Lu 2015-05-22 11:40:04 +02:00 committed by Vipin Kumar
parent af41b63a5e
commit 0032dd59cd
3 changed files with 16 additions and 10 deletions

View File

@ -1213,7 +1213,8 @@ nexthop_active_check (struct route_node *rn, struct rib *rib,
memset(&nexthop->rmap_src.ipv6, 0, sizeof(union g_addr));
/* It'll get set if required inside */
ret = zebra_route_map_check(family, rib->type, &rn->p, nexthop, rib->tag);
ret = zebra_route_map_check(family, rib->type, &rn->p, nexthop, rib->vrf_id,
rib->tag);
if (ret == RMAP_DENYMATCH)
{
if (IS_ZEBRA_DEBUG_RIB)

View File

@ -29,6 +29,7 @@
#include "filter.h"
#include "plist.h"
#include "nexthop.h"
#include "vrf.h"
#include "zebra/zserv.h"
#include "zebra/debug.h"
@ -45,6 +46,7 @@ extern struct zebra_t zebrad;
struct nh_rmap_obj
{
struct nexthop *nexthop;
vrf_id_t vrf_id;
u_int32_t source_protocol;
int metric;
u_short tag;
@ -255,12 +257,12 @@ route_match_interface (void *rule, struct prefix *prefix,
{
if (strcasecmp(ifname, "any") == 0)
return RMAP_MATCH;
ifindex = ifname2ifindex(ifname);
if (ifindex == 0)
return RMAP_NOMATCH;
nh_data = object;
if (!nh_data || !nh_data->nexthop)
return RMAP_NOMATCH;
ifindex = ifname2ifindex_vrf (ifname, nh_data->vrf_id);
if (ifindex == 0)
return RMAP_NOMATCH;
if (nh_data->nexthop->ifindex == ifindex)
return RMAP_MATCH;
}
@ -767,7 +769,7 @@ DEFUN (ip_protocol,
if (IS_ZEBRA_DEBUG_RIB)
zlog_debug ("%s: calling rib_update", __func__);
rib_update();
rib_update(VRF_DEFAULT);
return CMD_SUCCESS;
}
@ -804,7 +806,7 @@ DEFUN (no_ip_protocol,
if (IS_ZEBRA_DEBUG_RIB)
zlog_debug ("%s: calling rib_update", __func__);
rib_update();
rib_update(VRF_DEFAULT);
}
return CMD_SUCCESS;
}
@ -879,7 +881,7 @@ DEFUN (ipv6_protocol,
if (IS_ZEBRA_DEBUG_RIB)
zlog_debug ("%s: calling rib_update", __func__);
rib_update();
rib_update(VRF_DEFAULT);
return CMD_SUCCESS;
}
@ -916,7 +918,7 @@ DEFUN (no_ipv6_protocol,
if (IS_ZEBRA_DEBUG_RIB)
zlog_debug ("%s: calling rib_update", __func__);
rib_update();
rib_update(VRF_DEFAULT);
}
return CMD_SUCCESS;
}
@ -1590,7 +1592,7 @@ zebra_route_map_update_timer (struct thread *thread)
if (IS_ZEBRA_DEBUG_RIB)
zlog_debug ("%s: calling rib_update", __func__);
rib_update();
rib_update(VRF_DEFAULT);
zebra_evaluate_rnh(0, AF_INET, 1, RNH_NEXTHOP_TYPE, NULL);
zebra_evaluate_rnh(0, AF_INET6, 1, RNH_NEXTHOP_TYPE, NULL);
@ -1621,13 +1623,14 @@ zebra_route_map_write_delay_timer (struct vty *vty)
route_map_result_t
zebra_route_map_check (int family, int rib_type, struct prefix *p,
struct nexthop *nexthop, u_short tag)
struct nexthop *nexthop, vrf_id_t vrf_id, u_short tag)
{
struct route_map *rmap = NULL;
route_map_result_t ret = RMAP_MATCH;
struct nh_rmap_obj nh_obj;
nh_obj.nexthop = nexthop;
nh_obj.vrf_id = vrf_id;
nh_obj.source_protocol = rib_type;
nh_obj.metric = 0;
nh_obj.tag = tag;
@ -1652,6 +1655,7 @@ zebra_nht_route_map_check (int family, int client_proto, struct prefix *p,
struct nh_rmap_obj nh_obj;
nh_obj.nexthop = nexthop;
nh_obj.vrf_id = rib->vrf_id;
nh_obj.source_protocol = rib->type;
nh_obj.metric = rib->metric;
nh_obj.tag = rib->tag;

View File

@ -162,6 +162,7 @@ extern void zebra_route_map_write_delay_timer(struct vty *);
extern route_map_result_t zebra_route_map_check (int family, int rib_type,
struct prefix *p,
struct nexthop *nexthop,
vrf_id_t vrf_id,
u_short tag);
extern route_map_result_t zebra_nht_route_map_check (int family,
int client_proto,