1 From 508b09046c0f21678652fb66fd1e9959d55591d2 Mon Sep 17 00:00:00 2001
2 From: Alin Nastac <alin.nastac@gmail.com>
3 Date: Wed, 21 Nov 2018 14:00:30 +0100
4 Subject: [PATCH] netfilter: ipv6: Preserve link scope traffic original oif
6 When ip6_route_me_harder is invoked, it resets outgoing interface of:
7 - link-local scoped packets sent by neighbor discovery
8 - multicast packets sent by MLD host
9 - multicast packets send by MLD proxy daemon that sets outgoing
10 interface through IPV6_PKTINFO ipi6_ifindex
12 Link-local and multicast packets must keep their original oif after
13 ip6_route_me_harder is called.
15 Signed-off-by: Alin Nastac <alin.nastac@gmail.com>
16 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
18 net/ipv6/netfilter.c | 3 ++-
19 1 file changed, 2 insertions(+), 1 deletion(-)
21 --- a/net/ipv6/netfilter.c
22 +++ b/net/ipv6/netfilter.c
23 @@ -24,7 +24,8 @@ int ip6_route_me_harder(struct net *net,
25 struct dst_entry *dst;
27 - .flowi6_oif = skb->sk ? skb->sk->sk_bound_dev_if : 0,
28 + .flowi6_oif = skb->sk && skb->sk->sk_bound_dev_if ? skb->sk->sk_bound_dev_if :
29 + rt6_need_strict(&iph->daddr) ? skb_dst(skb)->dev->ifindex : 0,
30 .flowi6_mark = skb->mark,