Skip to contentSkip to conversation

netfilter: ip6_tables: replace the loop with xt_entry_foreach

PATCH In review Denis Kirjanov 1 participant 2 messages Jan 30, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: ip6_tables: replace the loop with xt_entry_foreach

We already have an iterator in the form of
xt_entry_foreach macro.

---
 net/ipv6/netfilter/ip6_tables.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
net/ipv6/netfilter/ip6_tables.c +2 -4
index 7d5602950ae7..84effcf4ff98 100644
@@ -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;
Signature · 1 line
2.47.2