]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: fix prefix VRF leaking with 'network import-check' (2/5)
authorLouis Scalbert <louis.scalbert@6wind.com>
Fri, 29 Apr 2022 12:25:21 +0000 (14:25 +0200)
committerLouis Scalbert <louis.scalbert@6wind.com>
Fri, 16 Dec 2022 13:52:47 +0000 (14:52 +0100)
Move setting of some variables backwards to prepare next commits.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
bgpd/bgp_mplsvpn.c

index eb0d9d28263cb150382684c63d5e48cdfc0ca965..84fbfbe25988756126b2d2f6af41c730a5a6e124 100644 (file)
@@ -1883,6 +1883,24 @@ static bool vpn_leak_to_vrf_update_onevrf(struct bgp *to_bgp,   /* to */
 
        int debug = BGP_DEBUG(vpn, VPN_LEAK_TO_VRF);
 
+       /*
+        * For VRF-2-VRF route-leaking,
+        * the source will be the originating VRF.
+        *
+        * If ACCEPT_OWN mechanism is enabled, then we SHOULD(?)
+        * get the source VRF (BGP) by looking at the RD.
+        */
+       struct bgp *src_bgp = bgp_lookup_by_rd(path_vpn, prd, afi);
+
+       if (path_vpn->extra && path_vpn->extra->bgp_orig)
+               src_vrf = path_vpn->extra->bgp_orig;
+       else if (src_bgp)
+               src_vrf = src_bgp;
+       else
+               src_vrf = from_bgp;
+
+       bn = bgp_afi_node_get(to_bgp->rib[afi][safi], afi, safi, p, NULL);
+
        if (!vpn_leak_from_vpn_active(to_bgp, afi, &debugmsg)) {
                if (debug)
                        zlog_debug("%s: skipping: %s", __func__, debugmsg);
@@ -2065,22 +2083,6 @@ static bool vpn_leak_to_vrf_update_onevrf(struct bgp *to_bgp,   /* to */
                zlog_debug("%s: pfx %pBD: num_labels %d", __func__,
                           path_vpn->net, num_labels);
 
-       /*
-        * For VRF-2-VRF route-leaking,
-        * the source will be the originating VRF.
-        *
-        * If ACCEPT_OWN mechanism is enabled, then we SHOULD(?)
-        * get the source VRF (BGP) by looking at the RD.
-        */
-       struct bgp *src_bgp = bgp_lookup_by_rd(path_vpn, prd, afi);
-
-       if (path_vpn->extra && path_vpn->extra->bgp_orig)
-               src_vrf = path_vpn->extra->bgp_orig;
-       else if (src_bgp)
-               src_vrf = src_bgp;
-       else
-               src_vrf = from_bgp;
-
        leak_update(to_bgp, bn, new_attr, afi, safi, path_vpn, pLabels,
                    num_labels, src_vrf, &nexthop_orig, nexthop_self_flag,
                    debug);