From: Tobias Brunner Date: Thu, 21 Dec 2017 16:32:24 +0000 (+0100) Subject: ipv6: Reinject IPv6 packets if IPsec policy matches after SNAT X-Git-Tag: v4.19~1702^2~292 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=09ee9dba9611cd382fd360a99ad1c2fa23bfdca8;p=platform%2Fkernel%2Flinux-rpi3.git ipv6: Reinject IPv6 packets if IPsec policy matches after SNAT If SNAT modifies the source address the resulting packet might match an IPsec policy, reinject the packet if that's the case. The exact same thing is already done for IPv4. Signed-off-by: Tobias Brunner Acked-by: Steffen Klassert Signed-off-by: David S. Miller --- diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index ece2781..bcdb615 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -138,6 +138,14 @@ static int ip6_finish_output(struct net *net, struct sock *sk, struct sk_buff *s return ret; } +#if defined(CONFIG_NETFILTER) && defined(CONFIG_XFRM) + /* Policy lookup after SNAT yielded a new policy */ + if (skb_dst(skb)->xfrm) { + IPCB(skb)->flags |= IPSKB_REROUTED; + return dst_output(net, sk, skb); + } +#endif + if ((skb->len > ip6_skb_dst_mtu(skb) && !skb_is_gso(skb)) || dst_allfrag(skb_dst(skb)) || (IP6CB(skb)->frag_max_size && skb->len > IP6CB(skb)->frag_max_size))