Skip to content

Commit c2cedab

Browse files
authored
Revert "bgpd: combine import_check_table and nexthop_check_table"
1 parent 5752340 commit c2cedab

File tree

4 files changed

+41
-41
lines changed

4 files changed

+41
-41
lines changed

bgpd/bgp_nexthop.c

+13-20
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ void bnc_nexthop_free(struct bgp_nexthop_cache *bnc)
5858

5959
struct bgp_nexthop_cache *bnc_new(struct bgp_nexthop_cache_head *tree,
6060
struct prefix *prefix, uint32_t srte_color,
61-
ifindex_t ifindex, bool import_check_table,
62-
bool nexthop_check_table)
61+
ifindex_t ifindex)
6362
{
6463
struct bgp_nexthop_cache *bnc;
6564

@@ -69,9 +68,6 @@ struct bgp_nexthop_cache *bnc_new(struct bgp_nexthop_cache_head *tree,
6968
bnc->ifindex_ipv6_ll = ifindex;
7069
bnc->srte_color = srte_color;
7170
bnc->tree = tree;
72-
bnc->import_check_table = import_check_table;
73-
bnc->nexthop_check_table = nexthop_check_table;
74-
7571
LIST_INIT(&(bnc->paths));
7672
bgp_nexthop_cache_add(tree, bnc);
7773

@@ -972,7 +968,7 @@ static void bgp_show_nexthops_detail(struct vty *vty, struct bgp *bgp,
972968

973969
static void bgp_show_nexthop(struct vty *vty, struct bgp *bgp,
974970
struct bgp_nexthop_cache *bnc, bool specific,
975-
bool import_check_table, json_object *json)
971+
json_object *json)
976972
{
977973
char buf[PREFIX2STR_BUFFER];
978974
time_t tbuf;
@@ -981,12 +977,6 @@ static void bgp_show_nexthop(struct vty *vty, struct bgp *bgp,
981977
json_object *json_last_update = NULL;
982978
json_object *json_nexthop = NULL;
983979

984-
if (bnc->import_check_table && !import_check_table)
985-
return;
986-
987-
if (bnc->nexthop_check_table && import_check_table)
988-
return;
989-
990980
peer = (struct peer *)bnc->nht_info;
991981

992982
if (json)
@@ -1113,14 +1103,16 @@ static void bgp_show_nexthops(struct vty *vty, struct bgp *bgp,
11131103
else
11141104
vty_out(vty, "Current BGP nexthop cache:\n");
11151105
}
1106+
if (import_table)
1107+
tree = &bgp->import_check_table;
1108+
else
1109+
tree = &bgp->nexthop_cache_table;
11161110

1117-
tree = &bgp->nexthop_cache_table;
11181111
if (afi == AFI_IP || afi == AFI_IP6) {
11191112
if (json)
11201113
json_afi = json_object_new_object();
11211114
frr_each (bgp_nexthop_cache, &(*tree)[afi], bnc) {
1122-
bgp_show_nexthop(vty, bgp, bnc, detail, import_table,
1123-
json_afi);
1115+
bgp_show_nexthop(vty, bgp, bnc, detail, json_afi);
11241116
found = true;
11251117
}
11261118
if (found && json)
@@ -1134,8 +1126,7 @@ static void bgp_show_nexthops(struct vty *vty, struct bgp *bgp,
11341126
if (json && (afi == AFI_IP || afi == AFI_IP6))
11351127
json_afi = json_object_new_object();
11361128
frr_each (bgp_nexthop_cache, &(*tree)[afi], bnc)
1137-
bgp_show_nexthop(vty, bgp, bnc, detail, import_table,
1138-
json_afi);
1129+
bgp_show_nexthop(vty, bgp, bnc, detail, json_afi);
11391130
if (json && (afi == AFI_IP || afi == AFI_IP6))
11401131
json_object_object_add(
11411132
json, (afi == AFI_IP) ? "ipv4" : "ipv6",
@@ -1171,15 +1162,15 @@ static int show_ip_bgp_nexthop_table(struct vty *vty, const char *name,
11711162
vty_out(vty, "nexthop address is malformed\n");
11721163
return CMD_WARNING;
11731164
}
1174-
tree = &bgp->nexthop_cache_table;
1165+
tree = import_table ? &bgp->import_check_table
1166+
: &bgp->nexthop_cache_table;
11751167
if (json)
11761168
json_afi = json_object_new_object();
11771169
frr_each (bgp_nexthop_cache, &(*tree)[family2afi(nhop.family)],
11781170
bnc) {
11791171
if (prefix_cmp(&bnc->prefix, &nhop))
11801172
continue;
1181-
bgp_show_nexthop(vty, bgp, bnc, true, import_table,
1182-
json_afi);
1173+
bgp_show_nexthop(vty, bgp, bnc, true, json_afi);
11831174
found = true;
11841175
}
11851176
if (json)
@@ -1322,6 +1313,7 @@ void bgp_scan_init(struct bgp *bgp)
13221313

13231314
for (afi = AFI_IP; afi < AFI_MAX; afi++) {
13241315
bgp_nexthop_cache_init(&bgp->nexthop_cache_table[afi]);
1316+
bgp_nexthop_cache_init(&bgp->import_check_table[afi]);
13251317
bgp->connected_table[afi] = bgp_table_init(bgp, afi,
13261318
SAFI_UNICAST);
13271319
}
@@ -1341,6 +1333,7 @@ void bgp_scan_finish(struct bgp *bgp)
13411333
for (afi = AFI_IP; afi < AFI_MAX; afi++) {
13421334
/* Only the current one needs to be reset. */
13431335
bgp_nexthop_cache_reset(&bgp->nexthop_cache_table[afi]);
1336+
bgp_nexthop_cache_reset(&bgp->import_check_table[afi]);
13441337

13451338
bgp->connected_table[afi]->route_table->cleanup =
13461339
bgp_connected_cleanup;

bgpd/bgp_nexthop.h

+2-6
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,6 @@ struct bgp_nexthop_cache {
9191
* nexthop.
9292
*/
9393
bool is_evpn_gwip_nexthop;
94-
95-
bool import_check_table;
96-
bool nexthop_check_table;
9794
};
9895

9996
extern int bgp_nexthop_cache_compare(const struct bgp_nexthop_cache *a,
@@ -135,9 +132,8 @@ extern bool bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type,
135132
struct bgp_dest *dest);
136133
extern struct bgp_nexthop_cache *bnc_new(struct bgp_nexthop_cache_head *tree,
137134
struct prefix *prefix,
138-
uint32_t srte_color, ifindex_t ifindex,
139-
bool import_check_table,
140-
bool nexthop_check_table);
135+
uint32_t srte_color,
136+
ifindex_t ifindex);
141137
extern bool bnc_existing_for_prefix(struct bgp_nexthop_cache *bnc);
142138
extern void bnc_free(struct bgp_nexthop_cache *bnc);
143139
extern struct bgp_nexthop_cache *bnc_find(struct bgp_nexthop_cache_head *tree,

bgpd/bgp_nht.c

+23-15
Original file line numberDiff line numberDiff line change
@@ -378,24 +378,21 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop,
378378
} else
379379
return 0;
380380

381-
tree = &bgp_nexthop->nexthop_cache_table[afi];
381+
if (is_bgp_static_route)
382+
tree = &bgp_nexthop->import_check_table[afi];
383+
else
384+
tree = &bgp_nexthop->nexthop_cache_table[afi];
382385

383386
bnc = bnc_find(tree, &p, srte_color, ifindex);
384387
if (!bnc) {
385-
bnc = bnc_new(tree, &p, srte_color, ifindex,
386-
is_bgp_static_route, !is_bgp_static_route);
388+
bnc = bnc_new(tree, &p, srte_color, ifindex);
387389
bnc->bgp = bgp_nexthop;
388390
if (BGP_DEBUG(nht, NHT))
389391
zlog_debug("Allocated bnc %pFX(%d)(%u)(%s) peer %p",
390392
&bnc->prefix, bnc->ifindex_ipv6_ll,
391393
bnc->srte_color, bnc->bgp->name_pretty,
392394
peer);
393395
} else {
394-
if (is_bgp_static_route)
395-
bnc->import_check_table = true;
396-
else
397-
bnc->nexthop_check_table = true;
398-
399396
if (BGP_DEBUG(nht, NHT))
400397
zlog_debug(
401398
"Found existing bnc %pFX(%d)(%s) flags 0x%x ifindex %d #paths %d peer %p",
@@ -822,8 +819,12 @@ static void bgp_nht_ifp_handle(struct interface *ifp, bool up)
822819

823820
bgp_nht_ifp_table_handle(bgp, &bgp->nexthop_cache_table[AFI_IP], ifp,
824821
up);
822+
bgp_nht_ifp_table_handle(bgp, &bgp->import_check_table[AFI_IP], ifp,
823+
up);
825824
bgp_nht_ifp_table_handle(bgp, &bgp->nexthop_cache_table[AFI_IP6], ifp,
826825
up);
826+
bgp_nht_ifp_table_handle(bgp, &bgp->import_check_table[AFI_IP6], ifp,
827+
up);
827828
}
828829

829830
void bgp_nht_ifp_up(struct interface *ifp)
@@ -899,7 +900,7 @@ void bgp_nht_interface_events(struct peer *peer)
899900
void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id)
900901
{
901902
struct bgp_nexthop_cache_head *tree = NULL;
902-
struct bgp_nexthop_cache *bnc_nhc;
903+
struct bgp_nexthop_cache *bnc_nhc, *bnc_import;
903904
struct bgp *bgp;
904905
struct prefix match;
905906
struct zapi_route nhr;
@@ -929,12 +930,19 @@ void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id)
929930
zlog_debug(
930931
"parse nexthop update %pFX(%u)(%s): bnc info not found for nexthop cache",
931932
&nhr.prefix, nhr.srte_color, bgp->name_pretty);
932-
} else {
933-
if (bnc_nhc->nexthop_check_table)
934-
bgp_process_nexthop_update(bnc_nhc, &nhr, false);
935-
if (bnc_nhc->import_check_table)
936-
bgp_process_nexthop_update(bnc_nhc, &nhr, true);
937-
}
933+
} else
934+
bgp_process_nexthop_update(bnc_nhc, &nhr, false);
935+
936+
tree = &bgp->import_check_table[afi];
937+
938+
bnc_import = bnc_find(tree, &match, nhr.srte_color, 0);
939+
if (!bnc_import) {
940+
if (BGP_DEBUG(nht, NHT))
941+
zlog_debug(
942+
"parse nexthop update %pFX(%u)(%s): bnc info not found for import check",
943+
&nhr.prefix, nhr.srte_color, bgp->name_pretty);
944+
} else
945+
bgp_process_nexthop_update(bnc_import, &nhr, true);
938946

939947
/*
940948
* HACK: if any BGP route is dependant on an SR-policy that doesn't

bgpd/bgpd.h

+3
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,9 @@ struct bgp {
559559
/* Tree for next-hop lookup cache. */
560560
struct bgp_nexthop_cache_head nexthop_cache_table[AFI_MAX];
561561

562+
/* Tree for import-check */
563+
struct bgp_nexthop_cache_head import_check_table[AFI_MAX];
564+
562565
struct bgp_table *connected_table[AFI_MAX];
563566

564567
struct hash *address_hash;

0 commit comments

Comments
 (0)