Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: xiangxia.m.yue@gmail.com
To: dev@openvswitch.org, netdev@vger.kernel.org
Cc: pshelar@ovn.org, Tonghao Zhang <xiangxia.m.yue@gmail.com>
Subject: [PATCH net-next v1 2/3] net: openvswitch: refactor flow free function
Date: Tue, 18 Aug 2020 18:09:22 +0800	[thread overview]
Message-ID: <20200818100923.46840-3-xiangxia.m.yue@gmail.com> (raw)
In-Reply-To: <20200818100923.46840-1-xiangxia.m.yue@gmail.com>

From: Tonghao Zhang <xiangxia.m.yue@gmail.com>

Decrease table->count and ufid_count unconditionally,
and add BUG_ON in flush flows function.

Cc: Pravin B Shelar <pshelar@ovn.org>
Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
---
 net/openvswitch/flow_table.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/net/openvswitch/flow_table.c b/net/openvswitch/flow_table.c
index 4b7ab62d0e1a..f8a21dd80e72 100644
--- a/net/openvswitch/flow_table.c
+++ b/net/openvswitch/flow_table.c
@@ -459,18 +459,14 @@ static void flow_tbl_destroy_rcu_cb(struct rcu_head *rcu)
 static void table_instance_flow_free(struct flow_table *table,
 				     struct table_instance *ti,
 				     struct table_instance *ufid_ti,
-				     struct sw_flow *flow,
-				     bool count)
+				     struct sw_flow *flow)
 {
 	hlist_del_rcu(&flow->flow_table.node[ti->node_ver]);
-	if (count)
-		table->count--;
+	table->count--;
 
 	if (ovs_identifier_is_ufid(&flow->id)) {
 		hlist_del_rcu(&flow->ufid_table.node[ufid_ti->node_ver]);
-
-		if (count)
-			table->ufid_count--;
+		table->ufid_count--;
 	}
 
 	flow_mask_remove(table, flow->mask);
@@ -495,10 +491,13 @@ void table_instance_flow_flush(struct flow_table *table,
 					  flow_table.node[ti->node_ver]) {
 
 			table_instance_flow_free(table, ti, ufid_ti,
-						 flow, false);
+						 flow);
 			ovs_flow_free(flow, true);
 		}
 	}
+
+	BUG_ON(table->count != 0);
+	BUG_ON(table->ufid_count != 0);
 }
 
 static void table_instance_destroy(struct table_instance *ti,
@@ -635,8 +634,6 @@ int ovs_flow_tbl_flush(struct flow_table *flow_table)
 	rcu_assign_pointer(flow_table->ti, new_ti);
 	rcu_assign_pointer(flow_table->ufid_ti, new_ufid_ti);
 	flow_table->last_rehash = jiffies;
-	flow_table->count = 0;
-	flow_table->ufid_count = 0;
 
 	table_instance_flow_flush(flow_table, old_ti, old_ufid_ti);
 	table_instance_destroy(old_ti, old_ufid_ti);
@@ -954,7 +951,7 @@ void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow)
 	struct table_instance *ufid_ti = ovsl_dereference(table->ufid_ti);
 
 	BUG_ON(table->count == 0);
-	table_instance_flow_free(table, ti, ufid_ti, flow, true);
+	table_instance_flow_free(table, ti, ufid_ti, flow);
 }
 
 static struct sw_flow_mask *mask_alloc(void)
-- 
2.23.0


  parent reply	other threads:[~2020-08-18 10:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-18 10:09 [PATCH net-next v1 0/3] net: openvswitch: improve codes xiangxia.m.yue
2020-08-18 10:09 ` [PATCH net-next v1 1/3] net: openvswitch: improve coding style xiangxia.m.yue
2020-08-18 10:09 ` xiangxia.m.yue [this message]
2020-08-19 22:52   ` [PATCH net-next v1 2/3] net: openvswitch: refactor flow free function David Miller
     [not found]     ` <CAMDZJNVcuN29b5S0JxqzEcw4yG6S+TVSpwkiohYJMgE0TU45PA@mail.gmail.com>
2020-08-20  1:52       ` David Miller
2020-08-24  7:39         ` Tonghao Zhang
2020-08-18 10:09 ` [PATCH net-next v1 3/3] net: openvswitch: remove unnused keep_flows xiangxia.m.yue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200818100923.46840-3-xiangxia.m.yue@gmail.com \
    --to=xiangxia.m.yue@gmail.com \
    --cc=dev@openvswitch.org \
    --cc=netdev@vger.kernel.org \
    --cc=pshelar@ovn.org \
    --subject='Re: [PATCH net-next v1 2/3] net: openvswitch: refactor flow free function' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).