Skip to contentSkip to conversation

ipv6: Preserve link scope traffic original oif

PATCH In review Alin Nastac 2 participants 5 messages Mar 1, 2017 – Mar 3, 2017

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

PATCH 1/1 ipv6: Preserve link scope traffic original oif

Link-local and multicast packets must keep their original oif after ip6_route_me_harder is called.

---
 net/ipv6/netfilter.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv6/netfilter.c +2 -1
index 39970e2..02811c5 100644
@@ -24,7 +24,8 @@ int ip6_route_me_harder(struct net *net, struct sk_buff *skb)
 	unsigned int hh_len;
 	struct dst_entry *dst;
 	struct flowi6 fl6 = {
-		.flowi6_oif = skb->sk ? skb->sk->sk_bound_dev_if : 0,
+		.flowi6_oif = skb->sk ? skb->sk->sk_bound_dev_if :
+			rt6_need_strict(&iph->daddr) ? skb_dst(skb)->dev->ifindex : 0,
 		.flowi6_mark = skb->mark,
 		.flowi6_uid = sock_net_uid(net, skb->sk),
 		.daddr = iph->daddr,
Signature · 1 line
1.7.12.4
#1 lore raw
Quoted 2 lines · Alin Nastac

Link-local and multicast packets must keep their original oif after ip6_route_me_harder is called.

Out of curiosity, how does the setup you use look like to trigger this problem?

#2 lore raw
Quoted 6 lines · Pablo Neira Ayuso
Quoted 2 lines · Alin Nastac

Link-local and multicast packets must keep their original oif after ip6_route_me_harder is called.

Out of curiosity, how does the setup you use look like to trigger this problem?

ICMPv6 RA/NS/NA are marked by a -j MARK iptables rule (the mark value is used to set the QoS queue).
Because skb->mark value changed, ip6t_mangle_out will call ip6_route_me_harder.

#3 lore raw
Quoted 11 lines · Alin Năstac
Quoted 6 lines · Pablo Neira Ayuso
Quoted 2 lines · Alin Nastac

Link-local and multicast packets must keep their original oif after ip6_route_me_harder is called.

Out of curiosity, how does the setup you use look like to trigger this problem?

ICMPv6 RA/NS/NA are marked by a -j MARK iptables rule (the mark value is used to set the QoS queue).
Because skb->mark value changed, ip6t_mangle_out will call ip6_route_me_harder.

That sounds quite standard. Did this broke after kernel upgrade? I'm trying to guess if the problem is somewhere else...

#4 lore raw
Quoted 9 lines · Pablo Neira Ayuso
Quoted 8 lines · Alin Năstac
Quoted 6 lines · Pablo Neira Ayuso
Quoted 2 lines · Alin Nastac

Link-local and multicast packets must keep their original oif after ip6_route_me_harder is called.

Out of curiosity, how does the setup you use look like to trigger this problem?

Quoted 6 lines
Quoted 3 lines

ICMPv6 RA/NS/NA are marked by a -j MARK iptables rule (the mark value is used to set the QoS queue).
Because skb->mark value changed, ip6t_mangle_out will call ip6_route_me_harder.

That sounds quite standard. Did this broke after kernel upgrade? I'm trying to guess if the problem is somewhere else...

I used kernel version 4.1 to test an adapted version of this patch.

Judging after ip6_route_output_flags() definition present in kernel version 4.10, callers are expected to provide a valid value for fl6->flowi6_oif when rt6_need_strict(&fl6->daddr) is true.