summaryrefslogtreecommitdiff
path: root/bgpd
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2023-01-11 10:14:11 -0500
committerDonald Sharp <sharpd@nvidia.com>2023-01-13 08:13:52 -0500
commit2bb8b49ce13aee725fbce975eac1493890f8caff (patch)
treebd594621e7bd3e909684f6bd7f20f5d6ae1b4131 /bgpd
parent1ab8721a5ca32842b2904333ac6d62e90a81a129 (diff)
Revert "Merge pull request #11127 from louis-6wind/bgp-leak"
This reverts commit 16aa1809e7c8caad37e8edd4e5aaac4f344bc7d3, reversing changes made to f616e716089b16d9a678846282a6ac5c55e31a56.
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_attr.c101
-rw-r--r--bgpd/bgp_attr.h9
-rw-r--r--bgpd/bgp_mpath.c14
-rw-r--r--bgpd/bgp_mplsvpn.c83
-rw-r--r--bgpd/bgp_nht.c49
-rw-r--r--bgpd/bgp_route.c28
-rw-r--r--bgpd/bgp_routemap.c4
-rw-r--r--bgpd/bgp_snmp_bgp4v2.c6
-rw-r--r--bgpd/bgp_zebra.c93
9 files changed, 110 insertions, 277 deletions
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index f5780eca4d..908c024e9d 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -824,56 +824,55 @@ bool attrhash_cmp(const void *p1, const void *p2)
&& attr1->med == attr2->med
&& attr1->local_pref == attr2->local_pref
&& attr1->rmap_change_flags == attr2->rmap_change_flags) {
- if (attr1->aggregator_as == attr2->aggregator_as &&
- attr1->aggregator_addr.s_addr ==
- attr2->aggregator_addr.s_addr &&
- attr1->weight == attr2->weight &&
- attr1->tag == attr2->tag &&
- attr1->label_index == attr2->label_index &&
- attr1->mp_nexthop_len == attr2->mp_nexthop_len &&
- bgp_attr_get_ecommunity(attr1) ==
- bgp_attr_get_ecommunity(attr2) &&
- bgp_attr_get_ipv6_ecommunity(attr1) ==
- bgp_attr_get_ipv6_ecommunity(attr2) &&
- bgp_attr_get_lcommunity(attr1) ==
- bgp_attr_get_lcommunity(attr2) &&
- bgp_attr_get_cluster(attr1) ==
- bgp_attr_get_cluster(attr2) &&
- bgp_attr_get_transit(attr1) ==
- bgp_attr_get_transit(attr2) &&
- bgp_attr_get_aigp_metric(attr1) ==
- bgp_attr_get_aigp_metric(attr2) &&
- attr1->rmap_table_id == attr2->rmap_table_id &&
- (attr1->encap_tunneltype == attr2->encap_tunneltype) &&
- encap_same(attr1->encap_subtlvs, attr2->encap_subtlvs)
+ if (attr1->aggregator_as == attr2->aggregator_as
+ && attr1->aggregator_addr.s_addr
+ == attr2->aggregator_addr.s_addr
+ && attr1->weight == attr2->weight
+ && attr1->tag == attr2->tag
+ && attr1->label_index == attr2->label_index
+ && attr1->mp_nexthop_len == attr2->mp_nexthop_len
+ && bgp_attr_get_ecommunity(attr1)
+ == bgp_attr_get_ecommunity(attr2)
+ && bgp_attr_get_ipv6_ecommunity(attr1)
+ == bgp_attr_get_ipv6_ecommunity(attr2)
+ && bgp_attr_get_lcommunity(attr1)
+ == bgp_attr_get_lcommunity(attr2)
+ && bgp_attr_get_cluster(attr1)
+ == bgp_attr_get_cluster(attr2)
+ && bgp_attr_get_transit(attr1)
+ == bgp_attr_get_transit(attr2)
+ && bgp_attr_get_aigp_metric(attr1)
+ == bgp_attr_get_aigp_metric(attr2)
+ && attr1->rmap_table_id == attr2->rmap_table_id
+ && (attr1->encap_tunneltype == attr2->encap_tunneltype)
+ && encap_same(attr1->encap_subtlvs, attr2->encap_subtlvs)
#ifdef ENABLE_BGP_VNC
&& encap_same(bgp_attr_get_vnc_subtlvs(attr1),
bgp_attr_get_vnc_subtlvs(attr2))
#endif
&& IPV6_ADDR_SAME(&attr1->mp_nexthop_global,
- &attr2->mp_nexthop_global) &&
- IPV6_ADDR_SAME(&attr1->mp_nexthop_local,
- &attr2->mp_nexthop_local) &&
- IPV4_ADDR_SAME(&attr1->mp_nexthop_global_in,
- &attr2->mp_nexthop_global_in) &&
- IPV4_ADDR_SAME(&attr1->originator_id,
- &attr2->originator_id) &&
- overlay_index_same(attr1, attr2) &&
- !memcmp(&attr1->esi, &attr2->esi, sizeof(esi_t)) &&
- attr1->es_flags == attr2->es_flags &&
- attr1->mm_sync_seqnum == attr2->mm_sync_seqnum &&
- attr1->df_pref == attr2->df_pref &&
- attr1->df_alg == attr2->df_alg &&
- attr1->nh_ifindex == attr2->nh_ifindex &&
- attr1->nh_flag == attr2->nh_flag &&
- attr1->nh_lla_ifindex == attr2->nh_lla_ifindex &&
- attr1->distance == attr2->distance &&
- srv6_l3vpn_same(attr1->srv6_l3vpn, attr2->srv6_l3vpn) &&
- srv6_vpn_same(attr1->srv6_vpn, attr2->srv6_vpn) &&
- attr1->srte_color == attr2->srte_color &&
- attr1->nh_type == attr2->nh_type &&
- attr1->bh_type == attr2->bh_type &&
- attr1->otc == attr2->otc)
+ &attr2->mp_nexthop_global)
+ && IPV6_ADDR_SAME(&attr1->mp_nexthop_local,
+ &attr2->mp_nexthop_local)
+ && IPV4_ADDR_SAME(&attr1->mp_nexthop_global_in,
+ &attr2->mp_nexthop_global_in)
+ && IPV4_ADDR_SAME(&attr1->originator_id,
+ &attr2->originator_id)
+ && overlay_index_same(attr1, attr2)
+ && !memcmp(&attr1->esi, &attr2->esi, sizeof(esi_t))
+ && attr1->es_flags == attr2->es_flags
+ && attr1->mm_sync_seqnum == attr2->mm_sync_seqnum
+ && attr1->df_pref == attr2->df_pref
+ && attr1->df_alg == attr2->df_alg
+ && attr1->nh_ifindex == attr2->nh_ifindex
+ && attr1->nh_lla_ifindex == attr2->nh_lla_ifindex
+ && attr1->distance == attr2->distance
+ && srv6_l3vpn_same(attr1->srv6_l3vpn, attr2->srv6_l3vpn)
+ && srv6_vpn_same(attr1->srv6_vpn, attr2->srv6_vpn)
+ && attr1->srte_color == attr2->srte_color
+ && attr1->nh_type == attr2->nh_type
+ && attr1->bh_type == attr2->bh_type
+ && attr1->otc == attr2->otc)
return true;
}
@@ -2254,12 +2253,6 @@ int bgp_mp_reach_parse(struct bgp_attr_parser_args *args,
return BGP_ATTR_PARSE_WITHDRAW;
}
attr->nh_ifindex = peer->nexthop.ifp->ifindex;
- if (if_is_operative(peer->nexthop.ifp))
- SET_FLAG(attr->nh_flag,
- BGP_ATTR_NH_IF_OPERSTATE);
- else
- UNSET_FLAG(attr->nh_flag,
- BGP_ATTR_NH_IF_OPERSTATE);
}
break;
case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL:
@@ -2277,12 +2270,6 @@ int bgp_mp_reach_parse(struct bgp_attr_parser_args *args,
return BGP_ATTR_PARSE_WITHDRAW;
}
attr->nh_ifindex = peer->nexthop.ifp->ifindex;
- if (if_is_operative(peer->nexthop.ifp))
- SET_FLAG(attr->nh_flag,
- BGP_ATTR_NH_IF_OPERSTATE);
- else
- UNSET_FLAG(attr->nh_flag,
- BGP_ATTR_NH_IF_OPERSTATE);
}
if (attr->mp_nexthop_len
== BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL) {
diff --git a/bgpd/bgp_attr.h b/bgpd/bgp_attr.h
index f8beb5fba9..a34da1a6de 100644
--- a/bgpd/bgp_attr.h
+++ b/bgpd/bgp_attr.h
@@ -170,12 +170,6 @@ struct attr {
uint32_t med;
uint32_t local_pref;
ifindex_t nh_ifindex;
- uint8_t nh_flag;
-
-#define BGP_ATTR_NH_VALID 0x01
-#define BGP_ATTR_NH_IF_OPERSTATE 0x02
-#define BGP_ATTR_NH_MP_PREFER_GLOBAL 0x04 /* MP Nexthop preference */
-#define BGP_ATTR_NH_REFRESH 0x08
/* Path origin attribute */
uint8_t origin;
@@ -226,6 +220,9 @@ struct attr {
/* MP Nexthop length */
uint8_t mp_nexthop_len;
+ /* MP Nexthop preference */
+ uint8_t mp_nexthop_prefer_global;
+
/* Static MAC for EVPN */
uint8_t sticky;
diff --git a/bgpd/bgp_mpath.c b/bgpd/bgp_mpath.c
index 84c847d796..32a5e14b11 100644
--- a/bgpd/bgp_mpath.c
+++ b/bgpd/bgp_mpath.c
@@ -142,21 +142,15 @@ int bgp_path_info_nexthop_cmp(struct bgp_path_info *bpi1,
&bpi2->attr->mp_nexthop_global);
break;
case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL:
- addr1 = (CHECK_FLAG(
- bpi1->attr->nh_flag,
- BGP_ATTR_NH_MP_PREFER_GLOBAL))
+ addr1 = (bpi1->attr->mp_nexthop_prefer_global)
? bpi1->attr->mp_nexthop_global
: bpi1->attr->mp_nexthop_local;
- addr2 = (CHECK_FLAG(
- bpi2->attr->nh_flag,
- BGP_ATTR_NH_MP_PREFER_GLOBAL))
+ addr2 = (bpi2->attr->mp_nexthop_prefer_global)
? bpi2->attr->mp_nexthop_global
: bpi2->attr->mp_nexthop_local;
- if (!CHECK_FLAG(bpi1->attr->nh_flag,
- BGP_ATTR_NH_MP_PREFER_GLOBAL) &&
- !CHECK_FLAG(bpi2->attr->nh_flag,
- BGP_ATTR_NH_MP_PREFER_GLOBAL))
+ if (!bpi1->attr->mp_nexthop_prefer_global
+ && !bpi2->attr->mp_nexthop_prefer_global)
compare = !bgp_interface_same(
bpi1->peer->ifp,
bpi2->peer->ifp);
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index 9b86c9b4b1..c92d678eff 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -1060,11 +1060,9 @@ static bool leak_update_nexthop_valid(struct bgp *to_bgp, struct bgp_dest *bn,
{
struct bgp_path_info *bpi_ultimate;
struct bgp *bgp_nexthop;
- struct bgp_table *table;
bool nh_valid;
bpi_ultimate = bgp_get_imported_bpi_ultimate(source_bpi);
- table = bgp_dest_table(bpi_ultimate->net);
if (bpi->extra && bpi->extra->bgp_orig)
bgp_nexthop = bpi->extra->bgp_orig;
@@ -1072,25 +1070,13 @@ static bool leak_update_nexthop_valid(struct bgp *to_bgp, struct bgp_dest *bn,
bgp_nexthop = bgp_orig;
/*
- * No nexthop tracking for redistributed routes,
- * for static (i.e. coming from the bgp network statement or for
+ * No nexthop tracking for redistributed routes or for
* EVPN-imported routes that get leaked.
*/
if (bpi_ultimate->sub_type == BGP_ROUTE_REDISTRIBUTE ||
is_pi_family_evpn(bpi_ultimate))
nh_valid = 1;
- else if (bpi_ultimate->type == ZEBRA_ROUTE_BGP &&
- bpi_ultimate->sub_type == BGP_ROUTE_STATIC && table &&
- (table->safi == SAFI_UNICAST ||
- table->safi == SAFI_LABELED_UNICAST)) {
- /* Routes from network statement */
- if (CHECK_FLAG(bgp_nexthop->flags, BGP_FLAG_IMPORT_CHECK))
- nh_valid = bgp_find_or_add_nexthop(
- to_bgp, bgp_nexthop, afi, safi, bpi_ultimate,
- NULL, 0, p);
- else
- nh_valid = 1;
- } else
+ else
/*
* TBD do we need to do anything about the
* 'connected' parameter?
@@ -1280,7 +1266,6 @@ leak_update(struct bgp *to_bgp, struct bgp_dest *bn,
if (debug)
zlog_debug("%s: ->%s: %pBD Found route, changed attr",
__func__, to_bgp->name_pretty, bn);
- UNSET_FLAG(bpi->attr->nh_flag, BGP_ATTR_NH_REFRESH);
return bpi;
}
@@ -1879,31 +1864,11 @@ static bool vpn_leak_to_vrf_update_onevrf(struct bgp *to_bgp, /* to */
uint32_t num_labels = 0;
int nexthop_self_flag = 1;
struct bgp_path_info *bpi_ultimate = NULL;
- struct bgp_path_info *bpi;
int origin_local = 0;
struct bgp *src_vrf;
- struct interface *ifp;
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);
@@ -1963,18 +1928,6 @@ static bool vpn_leak_to_vrf_update_onevrf(struct bgp *to_bgp, /* to */
community_strip_accept_own(&static_attr);
- for (bpi = bgp_dest_get_bgp_path_info(bn); bpi; bpi = bpi->next) {
- if (bpi->extra && bpi->extra->parent == path_vpn)
- break;
- }
-
- if (bpi &&
- leak_update_nexthop_valid(to_bgp, bn, &static_attr, afi, safi,
- path_vpn, bpi, src_vrf, p, debug))
- SET_FLAG(static_attr.nh_flag, BGP_ATTR_NH_VALID);
- else
- UNSET_FLAG(static_attr.nh_flag, BGP_ATTR_NH_VALID);
-
/*
* Nexthop: stash and clear
*
@@ -2017,22 +1970,6 @@ static bool vpn_leak_to_vrf_update_onevrf(struct bgp *to_bgp, /* to */
break;
}
- if (static_attr.nexthop.s_addr == INADDR_ANY &&
- IN6_IS_ADDR_UNSPECIFIED(&static_attr.mp_nexthop_global)) {
- ifp = if_get_vrf_loopback(src_vrf->vrf_id);
- if (ifp)
- static_attr.nh_ifindex = ifp->ifindex;
- } else if (static_attr.nh_ifindex)
- ifp = if_lookup_by_index(static_attr.nh_ifindex,
- src_vrf->vrf_id);
- else
- ifp = NULL;
-
- if (ifp && if_is_operative(ifp))
- SET_FLAG(static_attr.nh_flag, BGP_ATTR_NH_IF_OPERSTATE);
- else
- UNSET_FLAG(static_attr.nh_flag, BGP_ATTR_NH_IF_OPERSTATE);
-
/*
* route map handling
*/
@@ -2114,6 +2051,22 @@ 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);
diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c
index b6b0c584d7..cf8ff524e9 100644
--- a/bgpd/bgp_nht.c
+++ b/bgpd/bgp_nht.c
@@ -46,7 +46,6 @@
#include "bgpd/bgp_flowspec_util.h"
#include "bgpd/bgp_evpn.h"
#include "bgpd/bgp_rd.h"
-#include "bgpd/bgp_mplsvpn.h"
extern struct zclient *zclient;
@@ -389,7 +388,7 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop,
if (pi && is_route_parent_evpn(pi))
bnc->is_evpn_gwip_nexthop = true;
- if (is_bgp_static_route && !CHECK_FLAG(bnc->flags, BGP_STATIC_ROUTE)) {
+ if (is_bgp_static_route) {
SET_FLAG(bnc->flags, BGP_STATIC_ROUTE);
/* If we're toggling the type, re-register */
@@ -424,8 +423,8 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop,
SET_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED);
UNSET_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED);
UNSET_FLAG(bnc->flags, BGP_NEXTHOP_VALID);
- } else if (peer && !connected &&
- CHECK_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED)) {
+ } else if (peer && !connected
+ && CHECK_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED)) {
UNSET_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED);
UNSET_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED);
UNSET_FLAG(bnc->flags, BGP_NEXTHOP_VALID);
@@ -835,13 +834,10 @@ void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id)
{
struct bgp_nexthop_cache_head *tree = NULL;
struct bgp_nexthop_cache *bnc_nhc, *bnc_import;
- struct bgp_path_info *pi;
- struct bgp_dest *dest;
struct bgp *bgp;
struct prefix match;
struct zapi_route nhr;
afi_t afi;
- safi_t safi;
bgp = bgp_lookup_by_vrf_id(vrf_id);
if (!bgp) {
@@ -862,37 +858,25 @@ void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id)
tree = &bgp->nexthop_cache_table[afi];
bnc_nhc = bnc_find(tree, &match, nhr.srte_color, 0);
- if (bnc_nhc)
+ if (!bnc_nhc) {
+ if (BGP_DEBUG(nht, NHT))
+ zlog_debug(
+ "parse nexthop update(%pFX(%u)(%s)): bnc info not found for nexthop cache",
+ &nhr.prefix, nhr.srte_color, bgp->name_pretty);
+ } else
bgp_process_nexthop_update(bnc_nhc, &nhr, false);
- else if (BGP_DEBUG(nht, NHT))
- zlog_debug(
- "parse nexthop update(%pFX(%u)(%s)): bnc info not found for nexthop cache",
- &nhr.prefix, nhr.srte_color, bgp->name_pretty);
tree = &bgp->import_check_table[afi];
bnc_import = bnc_find(tree, &match, nhr.srte_color, 0);
- if (bnc_import) {
+ if (!bnc_import) {
+ if (BGP_DEBUG(nht, NHT))
+ zlog_debug(
+ "parse nexthop update(%pFX(%u)(%s)): bnc info not found for import check",
+ &nhr.prefix, nhr.srte_color, bgp->name_pretty);
+ } else
bgp_process_nexthop_update(bnc_import, &nhr, true);
- safi = nhr.safi;
- if (bgp->rib[afi][safi]) {
- dest = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi,
- &match, NULL);
-
- for (pi = bgp_dest_get_bgp_path_info(dest); pi;
- pi = pi->next)
- if (pi->peer == bgp->peer_self &&
- pi->type == ZEBRA_ROUTE_BGP &&
- pi->sub_type == BGP_ROUTE_STATIC)
- vpn_leak_from_vrf_update(
- bgp_get_default(), bgp, pi);
- }
- } else if (BGP_DEBUG(nht, NHT))
- zlog_debug(
- "parse nexthop update(%pFX(%u)(%s)): bnc info not found for import check",
- &nhr.prefix, nhr.srte_color, bgp->name_pretty);
-
/*
* HACK: if any BGP route is dependant on an SR-policy that doesn't
* exist, zebra will never send NH updates relative to that policy. In
@@ -1005,8 +989,7 @@ static int make_prefix(int afi, struct bgp_path_info *pi, struct prefix *p)
*/
else if (pi->attr->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) {
- if (CHECK_FLAG(pi->attr->nh_flag,
- BGP_ATTR_NH_MP_PREFER_GLOBAL))
+ if (pi->attr->mp_nexthop_prefer_global)
p->u.prefix6 =
pi->attr->mp_nexthop_global;
else
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index a2792b9b79..87871573f0 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -8684,7 +8684,6 @@ void bgp_redistribute_add(struct bgp *bgp, struct prefix *p,
afi_t afi;
route_map_result_t ret;
struct bgp_redist *red;
- struct interface *ifp;
/* Make default attribute. */
bgp_attr_default_set(&attr, bgp, BGP_ORIGIN_INCOMPLETE);
@@ -8734,11 +8733,6 @@ void bgp_redistribute_add(struct bgp *bgp, struct prefix *p,
}
attr.nh_type = nhtype;
attr.nh_ifindex = ifindex;
- ifp = if_lookup_by_index(ifindex, bgp->vrf_id);
- if (ifp && if_is_operative(ifp))
- SET_FLAG(attr.nh_flag, BGP_ATTR_NH_IF_OPERSTATE);
- else
- UNSET_FLAG(attr.nh_flag, BGP_ATTR_NH_IF_OPERSTATE);
attr.med = metric;
attr.distance = distance;
@@ -9425,10 +9419,9 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
"link-local");
if ((IPV6_ADDR_CMP(&attr->mp_nexthop_global,
- &attr->mp_nexthop_local) !=
- 0) &&
- !CHECK_FLAG(attr->nh_flag,
- BGP_ATTR_NH_MP_PREFER_GLOBAL))
+ &attr->mp_nexthop_local)
+ != 0)
+ && !attr->mp_nexthop_prefer_global)
json_object_boolean_true_add(
json_nexthop_ll, "used");
else
@@ -9440,11 +9433,10 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
} else {
/* Display LL if LL/Global both in table unless
* prefer-global is set */
- if (((attr->mp_nexthop_len ==
- BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) &&
- !CHECK_FLAG(attr->nh_flag,
- BGP_ATTR_NH_MP_PREFER_GLOBAL)) ||
- (path->peer->conf_if)) {
+ if (((attr->mp_nexthop_len
+ == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
+ && !attr->mp_nexthop_prefer_global)
+ || (path->peer->conf_if)) {
if (path->peer->conf_if) {
len = vty_out(vty, "%s",
path->peer->conf_if);
@@ -10706,8 +10698,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
json_object_boolean_true_add(json_nexthop_ll,
"accessible");
- if (!CHECK_FLAG(attr->nh_flag,
- BGP_ATTR_NH_MP_PREFER_GLOBAL))
+ if (!attr->mp_nexthop_prefer_global)
json_object_boolean_true_add(json_nexthop_ll,
"used");
else
@@ -10717,8 +10708,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
vty_out(vty, " (%s) %s\n",
inet_ntop(AF_INET6, &attr->mp_nexthop_local,
buf, INET6_ADDRSTRLEN),
- CHECK_FLAG(attr->nh_flag,
- BGP_ATTR_NH_MP_PREFER_GLOBAL)
+ attr->mp_nexthop_prefer_global
? "(prefer-global)"
: "(used)");
}
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index f779b34371..1ce2eb4352 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -3531,11 +3531,11 @@ route_set_ipv6_nexthop_prefer_global(void *rule, const struct prefix *prefix,
if (CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IN)
|| CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IMPORT)) {
/* Set next hop preference to global */
- SET_FLAG(path->attr->nh_flag, BGP_ATTR_NH_MP_PREFER_GLOBAL);
+ path->attr->mp_nexthop_prefer_global = true;
SET_FLAG(path->attr->rmap_change_flags,
BATTR_RMAP_IPV6_PREFER_GLOBAL_CHANGED);
} else {
- UNSET_FLAG(path->attr->nh_flag, BGP_ATTR_NH_MP_PREFER_GLOBAL);
+ path->attr->mp_nexthop_prefer_global = false;
SET_FLAG(path->attr->rmap_change_flags,
BATTR_RMAP_IPV6_PREFER_GLOBAL_CHANGED);
}
diff --git a/bgpd/bgp_snmp_bgp4v2.c b/bgpd/bgp_snmp_bgp4v2.c
index fe0c33251e..d8d8549960 100644
--- a/bgpd/bgp_snmp_bgp4v2.c
+++ b/bgpd/bgp_snmp_bgp4v2.c
@@ -704,8 +704,7 @@ static uint8_t *bgp4v2PathAttrTable(struct variable *v, oid name[],
case BGP_ATTR_NHLEN_IPV6_GLOBAL:
return SNMP_INTEGER(2);
case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL:
- if (CHECK_FLAG(path->attr->nh_flag,
- BGP_ATTR_NH_MP_PREFER_GLOBAL))
+ if (path->attr->mp_nexthop_prefer_global)
return SNMP_INTEGER(2);
else
return SNMP_INTEGER(4);
@@ -719,8 +718,7 @@ static uint8_t *bgp4v2PathAttrTable(struct variable *v, oid name[],
case BGP_ATTR_NHLEN_IPV6_GLOBAL:
return SNMP_IP6ADDRESS(path->attr->mp_nexthop_global);
case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL:
- if (CHECK_FLAG(path->attr->nh_flag,
- BGP_ATTR_NH_MP_PREFER_GLOBAL))
+ if (path->attr->mp_nexthop_prefer_global)
return SNMP_IP6ADDRESS(
path->attr->mp_nexthop_global);
else
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index f6e7b444c6..8ce17ab49e 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -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;
}