From 850a8b49cd40311f691fe2f802c65adbdebc3f7c Mon Sep 17 00:00:00 2001 From: Numan Siddique Date: Thu, 8 Feb 2024 11:51:48 -0500 Subject: [PATCH] northd: Fix lflow ref node's reference counting. When the lflows in an lflow_ref are unlinked by calling lflow_ref_unlink_lflows(lflow_ref), the dp_ref counter for each lflow in the lflow_ref is decremented (by calling dp_refcnt_release()), but it is not incremented later when the same lflow is linked back to the lflow_ref. This patch fixes it. Fixes: a623606052ea ("northd: Refactor lflow management into a separate module.") Signed-off-by: Numan Siddique --- northd/lflow-mgr.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/northd/lflow-mgr.c b/northd/lflow-mgr.c index 61729e9039..df62cd6ab4 100644 --- a/northd/lflow-mgr.c +++ b/northd/lflow-mgr.c @@ -690,19 +690,24 @@ lflow_table_add_lflow(struct lflow_table *lflow_table, if (lrn->dpgrp_lflow) { lrn->dpgrp_bitmap = bitmap_clone(dp_bitmap, dp_bitmap_len); lrn->dpgrp_bitmap_len = dp_bitmap_len; + } else { + lrn->dp_index = od->index; + } + ovs_list_insert(&lflow->referenced_by, &lrn->ref_list_node); + hmap_insert(&lflow_ref->lflow_ref_nodes, &lrn->ref_node, hash); + } + if (!lrn->linked) { + if (lrn->dpgrp_lflow) { + ovs_assert(lrn->dpgrp_bitmap_len == dp_bitmap_len); size_t index; BITMAP_FOR_EACH_1 (index, dp_bitmap_len, dp_bitmap) { dp_refcnt_use(&lflow->dp_refcnts_map, index); } } else { - lrn->dp_index = od->index; dp_refcnt_use(&lflow->dp_refcnts_map, lrn->dp_index); } - ovs_list_insert(&lflow->referenced_by, &lrn->ref_list_node); - hmap_insert(&lflow_ref->lflow_ref_nodes, &lrn->ref_node, hash); } - lrn->linked = true; }