diff mbox series

[nf-next] netfilter: ip6_tables: replace the loop with xt_entry_foreach

Message ID 20250130142037.1945-1-kirjanov@gmail.com (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series [nf-next] netfilter: ip6_tables: replace the loop with xt_entry_foreach | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 6 maintainers not CCed: pabeni@redhat.com edumazet@google.com coreteam@netfilter.org dsahern@kernel.org horms@kernel.org kuba@kernel.org
netdev/build_clang fail Errors and warnings before: 1 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 4 this patch: 4
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Denis Kirjanov Jan. 30, 2025, 2:20 p.m. UTC
We already have an iterator in the form of
xt_entry_foreach macro.

Signed-off-by: Denis Kirjanov <kirjanov@gmail.com>
---
 net/ipv6/netfilter/ip6_tables.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Denis Kirjanov Jan. 30, 2025, 3:01 p.m. UTC | #1
please ignore
diff mbox series

Patch

diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index 7d5602950ae7..84effcf4ff98 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -840,14 +840,12 @@  copy_entries_to_user(unsigned int total_size,
 
 	loc_cpu_entry = private->entries;
 
-	/* FIXME: use iterator macros --RR */
-	/* ... then go back and fix counters and names */
-	for (off = 0, num = 0; off < total_size; off += e->next_offset, num++){
+	num = 0;
+	xt_entry_foreach(e, loc_cpu_entry, total_size) {
 		unsigned int i;
 		const struct xt_entry_match *m;
 		const struct xt_entry_target *t;
 
-		e = loc_cpu_entry + off;
 		if (copy_to_user(userptr + off, e, sizeof(*e))) {
 			ret = -EFAULT;
 			goto free_counters;