Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: Use l3mdev flow key when re-routing mangled packets

Commit 40867d74c374 ("net: Add l3mdev index to flow struct and avoid oif
reset for port devices") introduces a flow key specific for layer 3
domains, such as a VRF master device. This allows for explicit VRF domain
selection instead of abusing the oif flow key.

Update ip[6]_route_me_harder() to make use of that new key when re-routing
mangled packets within VRFs instead of setting the flow oif, making it
consistent with other users.

Signed-off-by: Martin Willi <martin@strongswan.org>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

authored by

Martin Willi and committed by
Pablo Neira Ayuso
2c50fc04 5cf15ce3

+2 -4
+1 -2
net/ipv4/netfilter.c
··· 45 45 fl4.saddr = saddr; 46 46 fl4.flowi4_tos = RT_TOS(iph->tos); 47 47 fl4.flowi4_oif = sk ? sk->sk_bound_dev_if : 0; 48 - if (!fl4.flowi4_oif) 49 - fl4.flowi4_oif = l3mdev_master_ifindex(dev); 48 + fl4.flowi4_l3mdev = l3mdev_master_ifindex(dev); 50 49 fl4.flowi4_mark = skb->mark; 51 50 fl4.flowi4_flags = flags; 52 51 fib4_rules_early_flow_dissect(net, skb, &fl4, &flkeys);
+1 -2
net/ipv6/netfilter.c
··· 31 31 int strict = (ipv6_addr_type(&iph->daddr) & 32 32 (IPV6_ADDR_MULTICAST | IPV6_ADDR_LINKLOCAL)); 33 33 struct flowi6 fl6 = { 34 + .flowi6_l3mdev = l3mdev_master_ifindex(dev), 34 35 .flowi6_mark = skb->mark, 35 36 .flowi6_uid = sock_net_uid(net, sk), 36 37 .daddr = iph->daddr, ··· 43 42 fl6.flowi6_oif = sk->sk_bound_dev_if; 44 43 else if (strict) 45 44 fl6.flowi6_oif = dev->ifindex; 46 - else 47 - fl6.flowi6_oif = l3mdev_master_ifindex(dev); 48 45 49 46 fib6_rules_early_flow_dissect(net, skb, &fl6, &flkeys); 50 47 dst = ip6_route_output(net, sk, &fl6);