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>
diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c
index b0dca08..f373775 100644
--- a/zebra/zebra_routemap.c
+++ b/zebra/zebra_routemap.c
@@ -130,6 +130,7 @@
route_match_interface (void *rule, struct prefix *prefix,
route_map_object_t type, void *object)
{
+ struct nexthop_vrfid *nh_vrf;
struct nexthop *nexthop;
char *ifname = rule;
unsigned int ifindex;
@@ -138,10 +139,13 @@
{
if (strcasecmp(ifname, "any") == 0)
return RMAP_MATCH;
- ifindex = ifname2ifindex(ifname);
+ nh_vrf = object;
+ if (!nh_vrf)
+ return RMAP_NOMATCH;
+ ifindex = ifname2ifindex_vrf (ifname, nh_vrf->vrf_id);
if (ifindex == 0)
return RMAP_NOMATCH;
- nexthop = object;
+ nexthop = nh_vrf->nexthop;
if (!nexthop)
return RMAP_NOMATCH;
if (nexthop->ifindex == ifindex)