From: Philippe Guibert Date: Tue, 17 Apr 2018 16:32:49 +0000 (+0200) Subject: bgpd: handle FS redirect VRF rule in PBR X-Git-Tag: frr-6.1-dev~485^2~4 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=eb4244f8a2e1e2153e5ba82eee75bb7075e4c691;p=mirror%2Ffrr.git bgpd: handle FS redirect VRF rule in PBR Upon redirect VRF message from FS, add a default route to the VRF interface associated to the VRF. Signed-off-by: Philippe Guibert --- diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index e7b6b127d0..a138f7cb2d 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -2631,14 +2631,26 @@ void bgp_zebra_announce_default(struct bgp *bgp, struct nexthop *nh, zclient, &api); } else if (nh->vrf_id != bgp->vrf_id) { struct vrf *vrf; - vrf = vrf_lookup_by_id(nh->vrf_id); + struct interface *ifp; + vrf = vrf_lookup_by_id(nh->vrf_id); if (!vrf) return; - /* find default route for vrf - * BGP may not have default route distributed in - * its context. This use case is not handled for now + /* create default route with interface + * with nexthop-vrf */ + ifp = if_lookup_by_name_all_vrf(vrf->name); + if (!ifp) + return; + api_nh->vrf_id = nh->vrf_id; + api_nh->type = NEXTHOP_TYPE_IFINDEX; + api_nh->ifindex = ifp->ifindex; + if (BGP_DEBUG(zebra, ZEBRA)) + zlog_info("BGP: sending default route to %s table %d (redirect VRF)", + vrf->name, table_id); + zclient_route_send(announce ? ZEBRA_ROUTE_ADD + : ZEBRA_ROUTE_DELETE, + zclient, &api); return; } }