Skip to contentSkip to conversation

netfilter: flowtable: really fix NAT IPv6 offload

PATCH Applied Qingfang DENG 2 participants 2 messages Dec 8, 2022

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

PATCH 1/1 netfilter: flowtable: really fix NAT IPv6 offload

The for-loop was broken from the start. It translates to:

	for (i = 0; i < 4; i += 4)

which means the loop statement is run only once, so only the highest 32-bit of the IPv6 address gets mangled.

Fix the loop increment.

Fixes 0e07e25b481a ("netfilter: flowtable: fix NAT IPv6 offload mangling")
Fixes 5c27d8d76ce8 ("netfilter: nf_flow_table_offload: add IPv6 support")
---
 net/netfilter/nf_flow_table_offload.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
net/netfilter/nf_flow_table_offload.c +3 -3
index 00b522890d77..921eddf96dc4 100644
@@ -383,12 +383,12 @@ static void flow_offload_ipv6_mangle(struct nf_flow_rule *flow_rule,
 				     const __be32 *addr, const __be32 *mask)
 {
 	struct flow_action_entry *entry;
-	int i, j;
+	int i;
 
-	for (i = 0, j = 0; i < sizeof(struct in6_addr) / sizeof(u32); i += sizeof(u32), j++) {
+	for (i = 0; i < sizeof(struct in6_addr) / sizeof(u32); i++) {
 		entry = flow_action_entry_next(flow_rule);
 		flow_offload_mangle(entry, FLOW_ACT_MANGLE_HDR_TYPE_IP6,
-				    offset + i, &addr[j], mask);
+				    offset + i * sizeof(u32), &addr[i], mask);
 	}
 }
 
Signature · 1 line
2.34.1
maintainer Applied
#1 lore raw
Quoted 8 lines · Qingfang DENG

The for-loop was broken from the start. It translates to:

	for (i = 0; i < 4; i += 4)

which means the loop statement is run only once, so only the highest 32-bit of the IPv6 address gets mangled.

Fix the loop increment.

Applied, thanks