Skip to content

Commit b295810

Browse files
authored
Revert "bgpd: upon if up event, evaluate bnc with matching nexthop"
1 parent e631541 commit b295810

File tree

3 files changed

+41
-80
lines changed

3 files changed

+41
-80
lines changed

bgpd/bgp_nexthop.c

+16-20
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ int bgp_nexthop_cache_compare(const struct bgp_nexthop_cache *a,
4343
if (a->srte_color > b->srte_color)
4444
return 1;
4545

46-
if (a->ifindex_ipv6_ll < b->ifindex_ipv6_ll)
46+
if (a->ifindex < b->ifindex)
4747
return -1;
48-
if (a->ifindex_ipv6_ll > b->ifindex_ipv6_ll)
48+
if (a->ifindex > b->ifindex)
4949
return 1;
5050

5151
return prefix_cmp(&a->prefix, &b->prefix);
@@ -65,7 +65,7 @@ struct bgp_nexthop_cache *bnc_new(struct bgp_nexthop_cache_head *tree,
6565
bnc = XCALLOC(MTYPE_BGP_NEXTHOP_CACHE,
6666
sizeof(struct bgp_nexthop_cache));
6767
bnc->prefix = *prefix;
68-
bnc->ifindex_ipv6_ll = ifindex;
68+
bnc->ifindex = ifindex;
6969
bnc->srte_color = srte_color;
7070
bnc->tree = tree;
7171
LIST_INIT(&(bnc->paths));
@@ -105,7 +105,7 @@ struct bgp_nexthop_cache *bnc_find(struct bgp_nexthop_cache_head *tree,
105105

106106
bnc.prefix = *prefix;
107107
bnc.srte_color = srte_color;
108-
bnc.ifindex_ipv6_ll = ifindex;
108+
bnc.ifindex = ifindex;
109109
return bgp_nexthop_cache_find(tree, &bnc);
110110
}
111111

@@ -857,9 +857,8 @@ static void bgp_show_nexthops_detail(struct vty *vty, struct bgp *bgp,
857857
json_object_string_add(
858858
json_gate, "interfaceName",
859859
ifindex2ifname(
860-
bnc->ifindex_ipv6_ll
861-
? bnc->ifindex_ipv6_ll
862-
: nexthop->ifindex,
860+
bnc->ifindex ? bnc->ifindex
861+
: nexthop->ifindex,
863862
bgp->vrf_id));
864863
break;
865864
case NEXTHOP_TYPE_IPV4:
@@ -870,9 +869,8 @@ static void bgp_show_nexthops_detail(struct vty *vty, struct bgp *bgp,
870869
json_object_string_add(
871870
json_gate, "interfaceName",
872871
ifindex2ifname(
873-
bnc->ifindex_ipv6_ll
874-
? bnc->ifindex_ipv6_ll
875-
: nexthop->ifindex,
872+
bnc->ifindex ? bnc->ifindex
873+
: nexthop->ifindex,
876874
bgp->vrf_id));
877875
break;
878876
case NEXTHOP_TYPE_IPV4_IFINDEX:
@@ -881,9 +879,8 @@ static void bgp_show_nexthops_detail(struct vty *vty, struct bgp *bgp,
881879
json_object_string_add(
882880
json_gate, "interfaceName",
883881
ifindex2ifname(
884-
bnc->ifindex_ipv6_ll
885-
? bnc->ifindex_ipv6_ll
886-
: nexthop->ifindex,
882+
bnc->ifindex ? bnc->ifindex
883+
: nexthop->ifindex,
887884
bgp->vrf_id));
888885
break;
889886
case NEXTHOP_TYPE_BLACKHOLE:
@@ -917,9 +914,9 @@ static void bgp_show_nexthops_detail(struct vty *vty, struct bgp *bgp,
917914
case NEXTHOP_TYPE_IPV6_IFINDEX:
918915
vty_out(vty, " gate %pI6", &nexthop->gate.ipv6);
919916
if (nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX &&
920-
bnc->ifindex_ipv6_ll)
917+
bnc->ifindex)
921918
vty_out(vty, ", if %s\n",
922-
ifindex2ifname(bnc->ifindex_ipv6_ll,
919+
ifindex2ifname(bnc->ifindex,
923920
bgp->vrf_id));
924921
else if (nexthop->ifindex)
925922
vty_out(vty, ", if %s\n",
@@ -932,9 +929,9 @@ static void bgp_show_nexthops_detail(struct vty *vty, struct bgp *bgp,
932929
case NEXTHOP_TYPE_IPV4_IFINDEX:
933930
vty_out(vty, " gate %pI4", &nexthop->gate.ipv4);
934931
if (nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX &&
935-
bnc->ifindex_ipv6_ll)
932+
bnc->ifindex)
936933
vty_out(vty, ", if %s\n",
937-
ifindex2ifname(bnc->ifindex_ipv6_ll,
934+
ifindex2ifname(bnc->ifindex,
938935
bgp->vrf_id));
939936
else if (nexthop->ifindex)
940937
vty_out(vty, ", if %s\n",
@@ -945,9 +942,8 @@ static void bgp_show_nexthops_detail(struct vty *vty, struct bgp *bgp,
945942
break;
946943
case NEXTHOP_TYPE_IFINDEX:
947944
vty_out(vty, " if %s\n",
948-
ifindex2ifname(bnc->ifindex_ipv6_ll
949-
? bnc->ifindex_ipv6_ll
950-
: nexthop->ifindex,
945+
ifindex2ifname(bnc->ifindex ? bnc->ifindex
946+
: nexthop->ifindex,
951947
bgp->vrf_id));
952948
break;
953949
case NEXTHOP_TYPE_BLACKHOLE:

bgpd/bgp_nexthop.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ PREDECL_RBTREE_UNIQ(bgp_nexthop_cache);
2727
/* BGP nexthop cache value structure. */
2828
struct bgp_nexthop_cache {
2929
/* The ifindex of the outgoing interface *if* it's a v6 LL */
30-
ifindex_t ifindex_ipv6_ll;
30+
ifindex_t ifindex;
3131

3232
/* RB-tree entry. */
3333
struct bgp_nexthop_cache_item entry;

bgpd/bgp_nht.c

+24-59
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,9 @@ static int bgp_isvalid_nexthop_for_ebgp(struct bgp_nexthop_cache *bnc,
7070
if (nexthop->type == NEXTHOP_TYPE_IFINDEX ||
7171
nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX ||
7272
nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX) {
73-
ifp = if_lookup_by_index(bnc->ifindex_ipv6_ll
74-
? bnc->ifindex_ipv6_ll
75-
: nexthop->ifindex,
76-
bnc->bgp->vrf_id);
73+
ifp = if_lookup_by_index(
74+
bnc->ifindex ? bnc->ifindex : nexthop->ifindex,
75+
bnc->bgp->vrf_id);
7776
}
7877
if (!ifp)
7978
continue;
@@ -92,10 +91,9 @@ static int bgp_isvalid_nexthop_for_mplsovergre(struct bgp_nexthop_cache *bnc,
9291

9392
for (nexthop = bnc->nexthop; nexthop; nexthop = nexthop->next) {
9493
if (nexthop->type != NEXTHOP_TYPE_BLACKHOLE) {
95-
ifp = if_lookup_by_index(bnc->ifindex_ipv6_ll
96-
? bnc->ifindex_ipv6_ll
97-
: nexthop->ifindex,
98-
bnc->bgp->vrf_id);
94+
ifp = if_lookup_by_index(
95+
bnc->ifindex ? bnc->ifindex : nexthop->ifindex,
96+
bnc->bgp->vrf_id);
9997
if (ifp && (ifp->ll_type == ZEBRA_LLT_IPGRE ||
10098
ifp->ll_type == ZEBRA_LLT_IP6GRE))
10199
break;
@@ -139,8 +137,8 @@ static void bgp_unlink_nexthop_check(struct bgp_nexthop_cache *bnc)
139137
if (LIST_EMPTY(&(bnc->paths)) && !bnc->nht_info) {
140138
if (BGP_DEBUG(nht, NHT))
141139
zlog_debug("%s: freeing bnc %pFX(%d)(%u)(%s)", __func__,
142-
&bnc->prefix, bnc->ifindex_ipv6_ll,
143-
bnc->srte_color, bnc->bgp->name_pretty);
140+
&bnc->prefix, bnc->ifindex, bnc->srte_color,
141+
bnc->bgp->name_pretty);
144142
/* only unregister if this is the last nh for this prefix*/
145143
if (!bnc_existing_for_prefix(bnc))
146144
unregister_zebra_rnh(bnc);
@@ -217,7 +215,7 @@ bgp_find_ipv6_nexthop_matching_peer(struct peer *peer)
217215
if (BGP_DEBUG(nht, NHT)) {
218216
zlog_debug(
219217
"Found bnc: %pFX(%u)(%u)(%p) for peer: %s(%s) %p",
220-
&bnc->prefix, bnc->ifindex_ipv6_ll,
218+
&bnc->prefix, bnc->ifindex,
221219
bnc->srte_color, bnc, peer->host,
222220
peer->bgp->name_pretty, peer);
223221
}
@@ -364,17 +362,15 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop,
364362
bnc->bgp = bgp_nexthop;
365363
if (BGP_DEBUG(nht, NHT))
366364
zlog_debug("Allocated bnc %pFX(%d)(%u)(%s) peer %p",
367-
&bnc->prefix, bnc->ifindex_ipv6_ll,
368-
bnc->srte_color, bnc->bgp->name_pretty,
369-
peer);
365+
&bnc->prefix, bnc->ifindex, bnc->srte_color,
366+
bnc->bgp->name_pretty, peer);
370367
} else {
371368
if (BGP_DEBUG(nht, NHT))
372369
zlog_debug(
373370
"Found existing bnc %pFX(%d)(%s) flags 0x%x ifindex %d #paths %d peer %p",
374-
&bnc->prefix, bnc->ifindex_ipv6_ll,
375-
bnc->bgp->name_pretty, bnc->flags,
376-
bnc->ifindex_ipv6_ll, bnc->path_count,
377-
bnc->nht_info);
371+
&bnc->prefix, bnc->ifindex,
372+
bnc->bgp->name_pretty, bnc->flags, bnc->ifindex,
373+
bnc->path_count, bnc->nht_info);
378374
}
379375

380376
if (pi && is_route_parent_evpn(pi))
@@ -421,10 +417,10 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop,
421417
UNSET_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED);
422418
UNSET_FLAG(bnc->flags, BGP_NEXTHOP_VALID);
423419
}
424-
if (peer && (bnc->ifindex_ipv6_ll != ifindex)) {
420+
if (peer && (bnc->ifindex != ifindex)) {
425421
UNSET_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED);
426422
UNSET_FLAG(bnc->flags, BGP_NEXTHOP_VALID);
427-
bnc->ifindex_ipv6_ll = ifindex;
423+
bnc->ifindex = ifindex;
428424
}
429425
if (bgp_route->inst_type == BGP_INSTANCE_TYPE_VIEW) {
430426
SET_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED);
@@ -553,8 +549,8 @@ static void bgp_process_nexthop_update(struct bgp_nexthop_cache *bnc,
553549
zlog_debug(
554550
"%s(%u): Rcvd NH update %pFX(%u)(%u) - metric %d/%d #nhops %d/%d flags %s",
555551
bnc->bgp->name_pretty, bnc->bgp->vrf_id, &nhr->prefix,
556-
bnc->ifindex_ipv6_ll, bnc->srte_color, nhr->metric,
557-
bnc->metric, nhr->nexthop_num, bnc->nexthop_num,
552+
bnc->ifindex, bnc->srte_color, nhr->metric, bnc->metric,
553+
nhr->nexthop_num, bnc->nexthop_num,
558554
bgp_nexthop_dump_bnc_flags(bnc, bnc_buf,
559555
sizeof(bnc_buf)));
560556
}
@@ -707,40 +703,9 @@ static void bgp_nht_ifp_table_handle(struct bgp *bgp,
707703
struct interface *ifp, bool up)
708704
{
709705
struct bgp_nexthop_cache *bnc;
710-
struct nexthop *nhop;
711-
uint8_t other_nh_count;
712-
bool nhop_found;
713706

714707
frr_each (bgp_nexthop_cache, table, bnc) {
715-
other_nh_count = 0;
716-
nhop_found = bnc->ifindex_ipv6_ll == ifp->ifindex;
717-
for (nhop = bnc->nexthop; nhop; nhop = nhop->next) {
718-
if (nhop->ifindex == bnc->ifindex_ipv6_ll)
719-
continue;
720-
721-
if (nhop->ifindex != ifp->ifindex) {
722-
other_nh_count++;
723-
continue;
724-
}
725-
if (nhop->vrf_id != ifp->vrf->vrf_id) {
726-
other_nh_count++;
727-
continue;
728-
}
729-
nhop_found = true;
730-
}
731-
732-
if (!nhop_found)
733-
/* The event interface does not match the nexthop cache
734-
* entry */
735-
continue;
736-
737-
if (!up && other_nh_count > 0)
738-
/* Down event ignored in case of multiple next-hop
739-
* interfaces. The other might interfaces might be still
740-
* up. The cases where all interfaces are down or a bnc
741-
* is invalid are processed by a separate zebra rnh
742-
* messages.
743-
*/
708+
if (bnc->ifindex != ifp->ifindex)
744709
continue;
745710

746711
bnc->last_update = monotime(NULL);
@@ -848,9 +813,9 @@ void bgp_nht_interface_events(struct peer *peer)
848813
if (!bnc)
849814
return;
850815

851-
if (bnc->ifindex_ipv6_ll)
816+
if (bnc->ifindex)
852817
event_add_event(bm->master, bgp_nht_ifp_initial, bnc->bgp,
853-
bnc->ifindex_ipv6_ll, NULL);
818+
bnc->ifindex, NULL);
854819
}
855820

856821
void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id)
@@ -1109,7 +1074,7 @@ static void register_zebra_rnh(struct bgp_nexthop_cache *bnc)
11091074
if (bnc->flags & BGP_NEXTHOP_REGISTERED)
11101075
return;
11111076

1112-
if (bnc->ifindex_ipv6_ll) {
1077+
if (bnc->ifindex) {
11131078
SET_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED);
11141079
return;
11151080
}
@@ -1130,7 +1095,7 @@ static void unregister_zebra_rnh(struct bgp_nexthop_cache *bnc)
11301095
if (!CHECK_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED))
11311096
return;
11321097

1133-
if (bnc->ifindex_ipv6_ll) {
1098+
if (bnc->ifindex) {
11341099
UNSET_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED);
11351100
return;
11361101
}
@@ -1163,7 +1128,7 @@ void evaluate_paths(struct bgp_nexthop_cache *bnc)
11631128

11641129
zlog_debug(
11651130
"NH update for %pFX(%d)(%u)(%s) - flags %s chgflags %s- evaluate paths",
1166-
&bnc->prefix, bnc->ifindex_ipv6_ll, bnc->srte_color,
1131+
&bnc->prefix, bnc->ifindex, bnc->srte_color,
11671132
bnc->bgp->name_pretty,
11681133
bgp_nexthop_dump_bnc_flags(bnc, bnc_buf,
11691134
sizeof(bnc_buf)),

0 commit comments

Comments
 (0)