Skip to content

Commit 1a169e1

Browse files
authored
Merge pull request #19724 from FRRouting/mergify/bp/dev/10.5/pr-19338
zebra: Cleanup early route Q when removing routes. (backport #19338)
2 parents 83c3fa0 + 1b0e7eb commit 1a169e1

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

zebra/connected.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,11 @@ static void connected_remove_kernel_for_connected(afi_t afi, safi_t safi, struct
191191
rib_dest_t *dest;
192192
struct route_table *table = zebra_vrf_table(afi, SAFI_UNICAST, zvrf->vrf->vrf_id);
193193

194+
/*
195+
* Needs to be early as that the actual route_node may not exist yet
196+
*/
197+
rib_meta_queue_early_route_cleanup(p, ZEBRA_ROUTE_KERNEL);
198+
194199
if (!table)
195200
return;
196201

zebra/rib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ int zebra_rib_queue_evpn_rem_vtep_del(vrf_id_t vrf_id, vni_t vni,
480480

481481
extern void meta_queue_free(struct meta_queue *mq, struct zebra_vrf *zvrf);
482482
extern int zebra_rib_labeled_unicast(struct route_entry *re);
483+
extern void rib_meta_queue_early_route_cleanup(const struct prefix *p, int route_type);
483484
extern struct route_table *rib_table_ipv6;
484485

485486
extern uint32_t zebra_rib_meta_queue_size(void);

zebra/zebra_rib.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4450,6 +4450,38 @@ static int rib_meta_queue_early_route_add(struct meta_queue *mq, void *data)
44504450
return 0;
44514451
}
44524452

4453+
void rib_meta_queue_early_route_cleanup(const struct prefix *p, int route_type)
4454+
{
4455+
struct listnode *node, *nnode;
4456+
struct zebra_early_route *ere;
4457+
4458+
/* Iterate through the early route subqueue */
4459+
for (ALL_LIST_ELEMENTS(zrouter.mq->subq[META_QUEUE_EARLY_ROUTE], node, nnode, ere)) {
4460+
/* Check if this entry matches the prefix and route type */
4461+
if (prefix_same(&ere->p, p) && ere->re->type == route_type) {
4462+
/* Remove from the list */
4463+
list_delete_node(zrouter.mq->subq[META_QUEUE_EARLY_ROUTE], node);
4464+
4465+
/* Update counters */
4466+
zrouter.mq->size--;
4467+
atomic_fetch_sub_explicit(&zrouter.mq->total_metaq, 1,
4468+
memory_order_relaxed);
4469+
atomic_fetch_sub_explicit(&zrouter.mq->total_subq[META_QUEUE_EARLY_ROUTE],
4470+
1, memory_order_relaxed);
4471+
4472+
/* Free the early route memory */
4473+
early_route_memory_free(ere);
4474+
4475+
if (IS_ZEBRA_DEBUG_RIB_DETAILED) {
4476+
struct vrf *vrf = vrf_lookup_by_id(ere->re->vrf_id);
4477+
4478+
zlog_debug("Route %pFX(%s) type %d removed from early route queue",
4479+
p, VRF_LOGNAME(vrf), route_type);
4480+
}
4481+
}
4482+
}
4483+
}
4484+
44534485
int rib_add_gr_run(afi_t afi, vrf_id_t vrf_id, uint8_t proto, uint8_t instance,
44544486
time_t restart_time, bool stale_client_cleanup)
44554487
{

0 commit comments

Comments
 (0)