diff mbox series

[net-next,2/6] netfilter: flowtable: nf_flow_table_iterate() returns the number of entries

Message ID 1582458307-17067-3-git-send-email-paulb@mellanox.com
State Changes Requested
Delegated to: David Miller
Headers show
Series act_ct: Software offload of conntrack_in | expand

Commit Message

Paul Blakey Feb. 23, 2020, 11:45 a.m. UTC
From: Pablo Neira Ayuso <pablo@netfilter.org>

Update this iterator to return the number of entries in this flowtable.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Paul Blakey <paulb@mellanox.com>
---
 net/netfilter/nf_flow_table_core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/net/netfilter/nf_flow_table_core.c b/net/netfilter/nf_flow_table_core.c
index face98b..83bc456 100644
--- a/net/netfilter/nf_flow_table_core.c
+++ b/net/netfilter/nf_flow_table_core.c
@@ -319,7 +319,7 @@  struct flow_offload_tuple_rhash *
 	struct flow_offload_tuple_rhash *tuplehash;
 	struct rhashtable_iter hti;
 	struct flow_offload *flow;
-	int err = 0;
+	int err = 0, cnt = 0;
 
 	rhashtable_walk_enter(&flow_table->rhashtable, &hti);
 	rhashtable_walk_start(&hti);
@@ -338,11 +338,12 @@  struct flow_offload_tuple_rhash *
 		flow = container_of(tuplehash, struct flow_offload, tuplehash[0]);
 
 		iter(flow_table, flow, data);
+		cnt++;
 	}
 	rhashtable_walk_stop(&hti);
 	rhashtable_walk_exit(&hti);
 
-	return err;
+	return err < 0 ? err : cnt;
 }
 
 static void nf_flow_offload_gc_step(struct nf_flowtable *flow_table,