Skip to content

Commit

Permalink
nexthop: reset before putting back in pool
Browse files Browse the repository at this point in the history
It feels weird to reset the nexthop to 0 *after* putting it back into
the available nexthops mempool.

It is working at the moment because we only have a single thread
processing them but let's change that to make it cleaner.

Fixes: 6271221 ("infra: implement generic nexthop pool")
Reported-by: David Marchand <[email protected]>
Signed-off-by: Robin Jarry <[email protected]>
  • Loading branch information
rjarry committed Jan 10, 2025
1 parent fa8a788 commit a679e9f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/infra/control/nexthop.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,16 @@ struct nexthop *nexthop_lookup(struct nh_pool *nhp, uint16_t vrf_id, const void

void nexthop_decref(struct nexthop *nh) {
if (nh->ref_count <= 1) {
struct nh_pool *nhp = nh->pool;
struct rte_mempool *pool = nh->pool->mp;
// Flush all held packets.
struct rte_mbuf *m = nh->held_pkts_head;
while (m != NULL) {
struct rte_mbuf *next = queue_mbuf_data(m)->next;
rte_pktmbuf_free(m);
m = next;
}
rte_mempool_put(nhp->mp, nh);
memset(nh, 0, sizeof(*nh));
rte_mempool_put(pool, nh);
} else {
nh->ref_count--;
}
Expand Down

0 comments on commit a679e9f

Please sign in to comment.