ip_skb_dst_mtu uses skb->sk, assuming it is an AF_INET socket (e.g. it calls ip_sk_use_pmtu which casts sk as an inet_sk). However, in the case of UDP tunneling, the skb->sk is not necessarily an inet socket (could be AF_PACKET socket, or AF_UNSPEC if arriving from tun/tap). OTOH, the sk passed as an argument throughout IP stack's output path is the one which is of PMTU interest: - In case of local sockets, sk is same as skb->sk; - In case of a udp tunnel, sk is the tunneling socket. Fix, by passing ip_finish_output's sk to ip_skb_dst_mtu. This augments 7026b1ddb6 'netfilter: Pass socket pointer down through okfn().'
Showing the changes to include/net (1 of 3 files). Show all
Unified · Split
| @@ -313,10 +313,9 @@ static inline unsigned int ip_dst_mtu_maybe_forward(const struct dst_entry *dst, · 312 unmodified lines | |||
| 313 | return min(dst->dev->mtu, IP_MAX_MTU); | 313 | return min(dst->dev->mtu, IP_MAX_MTU); |
| 314 | } | 314 | } |
| 315 | 315 | ||
| 316 | static inline unsigned int ip_skb_dst_mtu(const struct sk_buff *skb) | 316 | static inline unsigned int ip_skb_dst_mtu(struct sock *sk, |
| 317 | const struct sk_buff *skb) | ||
| 317 | { | 318 | { |
| 318 | struct sock *sk = skb->sk; | ||
| 319 | |||
| 320 | if (!sk || !sk_fullsock(sk) || ip_sk_use_pmtu(sk)) { | 319 | if (!sk || !sk_fullsock(sk) || ip_sk_use_pmtu(sk)) { |
| 321 | bool forwarding = IPCB(skb)->flags & IPSKB_FORWARDED; | 320 | bool forwarding = IPCB(skb)->flags & IPSKB_FORWARDED; |
| 322 | 321 | ||