]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_zebra.c
Revert "Merge pull request #11127 from louis-6wind/bgp-leak"
[mirror_frr.git] / bgpd / bgp_zebra.c
index f6e7b444c6f467d198d6b0fdd179fdbd38c414d5..8ce17ab49e4baad6f758206f3fe23b1a68d619dc 100644 (file)
@@ -234,7 +234,6 @@ static int bgp_ifp_up(struct interface *ifp)
        struct connected *c;
        struct nbr_connected *nc;
        struct listnode *node, *nnode;
-       struct bgp *bgp_default = bgp_get_default();
        struct bgp *bgp;
 
        bgp = ifp->vrf->info;
@@ -257,14 +256,6 @@ static int bgp_ifp_up(struct interface *ifp)
        hook_call(bgp_vrf_status_changed, bgp, ifp);
        bgp_nht_ifp_up(ifp);
 
-       if (bgp_default && if_is_loopback(ifp)) {
-               vpn_leak_zebra_vrf_label_update(bgp, AFI_IP);
-               vpn_leak_zebra_vrf_label_update(bgp, AFI_IP6);
-               vpn_leak_zebra_vrf_sid_update(bgp, AFI_IP);
-               vpn_leak_zebra_vrf_sid_update(bgp, AFI_IP6);
-               vpn_leak_postchange_all();
-       }
-
        return 0;
 }
 
@@ -273,7 +264,6 @@ static int bgp_ifp_down(struct interface *ifp)
        struct connected *c;
        struct nbr_connected *nc;
        struct listnode *node, *nnode;
-       struct bgp *bgp_default = bgp_get_default();
        struct bgp *bgp;
        struct peer *peer;
 
@@ -313,14 +303,6 @@ static int bgp_ifp_down(struct interface *ifp)
        hook_call(bgp_vrf_status_changed, bgp, ifp);
        bgp_nht_ifp_down(ifp);
 
-       if (bgp_default && if_is_loopback(ifp)) {
-               vpn_leak_zebra_vrf_label_update(bgp, AFI_IP);
-               vpn_leak_zebra_vrf_label_update(bgp, AFI_IP6);
-               vpn_leak_zebra_vrf_sid_update(bgp, AFI_IP);
-               vpn_leak_zebra_vrf_sid_update(bgp, AFI_IP6);
-               vpn_leak_postchange_all();
-       }
-
        return 0;
 }
 
@@ -408,16 +390,10 @@ static int bgp_interface_address_add(ZAPI_CALLBACK_ARGS)
 static int bgp_interface_address_delete(ZAPI_CALLBACK_ARGS)
 {
        struct listnode *node, *nnode;
-       struct bgp_path_info *pi;
-       struct bgp_table *table;
-       struct bgp_dest *dest;
        struct connected *ifc;
        struct peer *peer;
-       struct bgp *bgp, *from_bgp, *bgp_default;
-       struct listnode *next;
+       struct bgp *bgp;
        struct prefix *addr;
-       afi_t afi;
-       safi_t safi;
 
        bgp = bgp_lookup_by_vrf_id(vrf_id);
 
@@ -445,6 +421,9 @@ static int bgp_interface_address_delete(ZAPI_CALLBACK_ARGS)
                 * we do not want the peering to bounce.
                 */
                for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
+                       afi_t afi;
+                       safi_t safi;
+
                        if (addr->family == AF_INET)
                                continue;
 
@@ -460,44 +439,6 @@ static int bgp_interface_address_delete(ZAPI_CALLBACK_ARGS)
                }
        }
 
-       bgp_default = bgp_get_default();
-       afi = family2afi(addr->family);
-       safi = SAFI_UNICAST;
-
-       /* When the last IPv4 address was deleted, Linux removes all routes
-        * using the interface so that bgpd needs to re-send them.
-        */
-       if (bgp_default && afi == AFI_IP) {
-               for (ALL_LIST_ELEMENTS_RO(bm->bgp, next, from_bgp)) {
-                       table = from_bgp->rib[afi][safi];
-                       if (!table)
-                               continue;
-
-                       for (dest = bgp_table_top(table); dest;
-                            dest = bgp_route_next(dest)) {
-                               for (pi = bgp_dest_get_bgp_path_info(dest); pi;
-                                    pi = pi->next) {
-                                       if (pi->type == ZEBRA_ROUTE_BGP &&
-                                           pi->attr &&
-                                           pi->attr->nh_ifindex ==
-                                                   ifc->ifp->ifindex) {
-                                               SET_FLAG(pi->attr->nh_flag,
-                                                        BGP_ATTR_NH_REFRESH);
-                                       }
-                               }
-                       }
-
-                       if (from_bgp->inst_type != BGP_INSTANCE_TYPE_VRF)
-                               continue;
-
-                       vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi,
-                                           bgp_default, from_bgp);
-
-                       vpn_leak_postchange(BGP_VPN_POLICY_DIR_FROMVPN, afi,
-                                           bgp_default, from_bgp);
-               }
-       }
-
        connected_free(&ifc);
 
        return 0;
@@ -1066,8 +1007,7 @@ bgp_path_info_to_ipv6_nexthop(struct bgp_path_info *path, ifindex_t *ifindex)
            || path->attr->mp_nexthop_len
                       == BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL) {
                /* Check if route-map is set to prefer global over link-local */
-               if (CHECK_FLAG(path->attr->nh_flag,
-                              BGP_ATTR_NH_MP_PREFER_GLOBAL)) {
+               if (path->attr->mp_nexthop_prefer_global) {
                        nexthop = &path->attr->mp_nexthop_global;
                        if (IN6_IS_ADDR_LINKLOCAL(nexthop))
                                *ifindex = path->attr->nh_ifindex;
@@ -1367,7 +1307,6 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
        uint8_t distance;
        struct peer *peer;
        struct bgp_path_info *mpinfo;
-       struct bgp_path_info *bpi_ultimate;
        struct bgp *bgp_orig;
        uint32_t metric;
        struct attr local_attr;
@@ -1416,9 +1355,13 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
 
        peer = info->peer;
 
-       if (info->type == ZEBRA_ROUTE_BGP) {
-               bpi_ultimate = bgp_get_imported_bpi_ultimate(info);
-               peer = bpi_ultimate->peer;
+       if (info->type == ZEBRA_ROUTE_BGP
+           && info->sub_type == BGP_ROUTE_IMPORTED) {
+
+               /* Obtain peer from parent */
+               if (info->extra && info->extra->parent)
+                       peer = ((struct bgp_path_info *)(info->extra->parent))
+                                      ->peer;
        }
 
        tag = info->attr->tag;
@@ -3250,7 +3193,6 @@ extern struct zebra_privs_t bgpd_privs;
 
 static int bgp_ifp_create(struct interface *ifp)
 {
-       struct bgp *bgp_default = bgp_get_default();
        struct bgp *bgp;
 
        if (BGP_DEBUG(zebra, ZEBRA))
@@ -3265,17 +3207,6 @@ static int bgp_ifp_create(struct interface *ifp)
 
        bgp_update_interface_nbrs(bgp, ifp, ifp);
        hook_call(bgp_vrf_status_changed, bgp, ifp);
-
-       if (bgp_default &&
-           (if_is_loopback_exact(ifp) ||
-            (if_is_vrf(ifp) && ifp->vrf->vrf_id != VRF_DEFAULT))) {
-               vpn_leak_zebra_vrf_label_update(bgp, AFI_IP);
-               vpn_leak_zebra_vrf_label_update(bgp, AFI_IP6);
-               vpn_leak_zebra_vrf_sid_update(bgp, AFI_IP);
-               vpn_leak_zebra_vrf_sid_update(bgp, AFI_IP6);
-               vpn_leak_postchange_all();
-       }
-
        return 0;
 }