]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: handle FS redirect VRF rule in PBR
authorPhilippe Guibert <philippe.guibert@6wind.com>
Tue, 17 Apr 2018 16:32:49 +0000 (18:32 +0200)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Thu, 3 May 2018 13:15:08 +0000 (15:15 +0200)
Upon redirect VRF message from FS, add a default route to the VRF
interface associated to the VRF.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
bgpd/bgp_zebra.c

index e7b6b127d0e4a05d701b8ed6246cd8d383bbbdac..a138f7cb2d258a5a0f78ff678cf3efb269f89138 100644 (file)
@@ -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 <VRF>
+                * with nexthop-vrf <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;
        }
 }