From: Feng Lu <[email protected]> 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 <[email protected]> Reviewed-by: Alain Ritoux <[email protected]> Signed-off-by: Nicolas Dichtel <[email protected]> --- zebra/rib.h | 8 ++++++++ zebra/zebra_rib.c | 3 ++- zebra/zebra_routemap.c | 8 ++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/zebra/rib.h b/zebra/rib.h index 2d8805a88a83..84cd3da6c02c 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -317,6 +317,14 @@ struct nexthop : ((tnexthop) = (nexthop)->next)) \ : (((recursing) = 0),((tnexthop) = (tnexthop)->next))) +/* Structure holding nexthop & VRF identifier, + * used for applying the route-map. */ +struct nexthop_vrfid +{ + struct nexthop *nexthop; + vrf_id_t vrf_id; +}; + /* Routing table instance. */ struct zebra_vrf { diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index b7b4c4f00485..21bfe0bbd9ab 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -1066,7 +1066,8 @@ nexthop_active_check (struct route_node *rn, struct rib *rib, if (!rmap && proto_rm[family][ZEBRA_ROUTE_MAX]) rmap = route_map_lookup_by_name (proto_rm[family][ZEBRA_ROUTE_MAX]); if (rmap) { - ret = route_map_apply(rmap, &rn->p, RMAP_ZEBRA, nexthop); + struct nexthop_vrfid nh_vrf = {nexthop, rib->vrf_id}; + ret = route_map_apply(rmap, &rn->p, RMAP_ZEBRA, &nh_vrf); } if (ret == RMAP_DENYMATCH) diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c index b0dca088bdb6..f3737757de9c 100644 --- a/zebra/zebra_routemap.c +++ b/zebra/zebra_routemap.c @@ -130,6 +130,7 @@ static route_map_result_t 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 @@ route_match_interface (void *rule, struct prefix *prefix, { 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) -- 2.2.2 _______________________________________________ Quagga-dev mailing list [email protected] https://lists.quagga.net/mailman/listinfo/quagga-dev
