diff mbox series

[net-next,01/11] netfilter: nf_tables: replace unnecessary use of list_for_each_entry_continue()

Message ID 20220411102744.282101-2-pablo@netfilter.org
State Accepted
Delegated to: Pablo Neira
Headers show
Series [net-next,01/11] netfilter: nf_tables: replace unnecessary use of list_for_each_entry_continue() | expand

Commit Message

Pablo Neira Ayuso April 11, 2022, 10:27 a.m. UTC
From: Jakob Koschel <jakobkoschel@gmail.com>

Since there is no way for list_for_each_entry_continue() to start
interating in the middle of the list they can be replaced with a call
to list_for_each_entry().

In preparation to limit the scope of the list iterator to the list
traversal loop, the list iterator variable 'rule' should not be used
past the loop.

v1->v2:
- also replace first usage of list_for_each_entry_continue() (Florian
Westphal)

Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
Reviewed-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/nf_tables_api.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org April 11, 2022, 10:50 a.m. UTC | #1
Hello:

This series was applied to netdev/net-next.git (master)
by Pablo Neira Ayuso <pablo@netfilter.org>:

On Mon, 11 Apr 2022 12:27:34 +0200 you wrote:
> From: Jakob Koschel <jakobkoschel@gmail.com>
> 
> Since there is no way for list_for_each_entry_continue() to start
> interating in the middle of the list they can be replaced with a call
> to list_for_each_entry().
> 
> In preparation to limit the scope of the list iterator to the list
> traversal loop, the list iterator variable 'rule' should not be used
> past the loop.
> 
> [...]

Here is the summary with links:
  - [net-next,01/11] netfilter: nf_tables: replace unnecessary use of list_for_each_entry_continue()
    https://git.kernel.org/netdev/net-next/c/10377d42281e
  - [net-next,02/11] netfilter: ecache: move to separate structure
    https://git.kernel.org/netdev/net-next/c/9027ce0b071a
  - [net-next,03/11] netfilter: conntrack: split inner loop of list dumping to own function
    https://git.kernel.org/netdev/net-next/c/49001a2e83a8
  - [net-next,04/11] netfilter: cttimeout: inc/dec module refcount per object, not per use refcount
    https://git.kernel.org/netdev/net-next/c/523895e5b278
  - [net-next,05/11] netfilter: nf_log_syslog: Merge MAC header dumpers
    https://git.kernel.org/netdev/net-next/c/39ab798fc14d
  - [net-next,06/11] netfilter: nf_log_syslog: Don't ignore unknown protocols
    https://git.kernel.org/netdev/net-next/c/0c8783806f63
  - [net-next,07/11] netfilter: nf_log_syslog: Consolidate entry checks
    https://git.kernel.org/netdev/net-next/c/c3e348666713
  - [net-next,08/11] netfilter: bitwise: replace hard-coded size with `sizeof` expression
    https://git.kernel.org/netdev/net-next/c/c70b921fc1e8
  - [net-next,09/11] netfilter: bitwise: improve error goto labels
    https://git.kernel.org/netdev/net-next/c/00bd435208e5
  - [net-next,10/11] netfilter: nft_fib: reverse path filter for policy-based routing on iif
    https://git.kernel.org/netdev/net-next/c/be8be04e5ddb
  - [net-next,11/11] selftests: netfilter: add fib expression forward test case
    https://git.kernel.org/netdev/net-next/c/0c7b27616fbd

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 5ddfdb2adaf1..060aa56e54d9 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -8367,10 +8367,8 @@  static int nf_tables_commit_chain_prepare(struct net *net, struct nft_chain *cha
 	if (chain->blob_next || !nft_is_active_next(net, chain))
 		return 0;
 
-	rule = list_entry(&chain->rules, struct nft_rule, list);
-
 	data_size = 0;
-	list_for_each_entry_continue(rule, &chain->rules, list) {
+	list_for_each_entry(rule, &chain->rules, list) {
 		if (nft_is_active_next(net, rule)) {
 			data_size += sizeof(*prule) + rule->dlen;
 			if (data_size > INT_MAX)
@@ -8387,7 +8385,7 @@  static int nf_tables_commit_chain_prepare(struct net *net, struct nft_chain *cha
 	data_boundary = data + data_size;
 	size = 0;
 
-	list_for_each_entry_continue(rule, &chain->rules, list) {
+	list_for_each_entry(rule, &chain->rules, list) {
 		if (!nft_is_active_next(net, rule))
 			continue;