Skip to content

Commit 09ee9db

Browse files
tobiasbrunnerdavem330
authored andcommitted
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 <tobias@strongswan.org> Acked-by: Steffen Klassert <steffen.klassert@secunet.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 18feb87 commit 09ee9db

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎net/ipv6/ip6_output.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,14 @@ static int ip6_finish_output(struct net *net, struct sock *sk, struct sk_buff *s
138138
return ret;
139139
}
140140

141+
#if defined(CONFIG_NETFILTER) && defined(CONFIG_XFRM)
142+
/* Policy lookup after SNAT yielded a new policy */
143+
if (skb_dst(skb)->xfrm) {
144+
IPCB(skb)->flags |= IPSKB_REROUTED;
145+
return dst_output(net, sk, skb);
146+
}
147+
#endif
148+
141149
if ((skb->len > ip6_skb_dst_mtu(skb) && !skb_is_gso(skb)) ||
142150
dst_allfrag(skb_dst(skb)) ||
143151
(IP6CB(skb)->frag_max_size && skb->len > IP6CB(skb)->frag_max_size))

0 commit comments

Comments
 (0)