Skip to content

Commit

Permalink
netfilter: flowtable: really fix NAT IPv6 offload
Browse files Browse the repository at this point in the history
[ Upstream commit 5fb45f9 ]

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: 0e07e25 ("netfilter: flowtable: fix NAT IPv6 offload mangling")
Fixes: 5c27d8d ("netfilter: nf_flow_table_offload: add IPv6 support")
Signed-off-by: Qingfang DENG <dqfext@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
LGA1150 authored and gregkh committed Dec 31, 2022
1 parent 7f47c91 commit 75b2692
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions net/netfilter/nf_flow_table_offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 75b2692

Please sign in to comment.