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().'
Unified · Split
| @@ -313,10 +313,9 @@ static inline unsigned int ip_dst_mtu_maybe_forward(const struct dst_entry *dst, · 312 unmodified lines | ||
| 313 | 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 | 319 | if (!sk || !sk_fullsock(sk) || ip_sk_use_pmtu(sk)) { |
| 321 | 320 | bool forwarding = IPCB(skb)->flags & IPSKB_FORWARDED; |
| 322 | 321 | |
| @@ -700,7 +700,7 @@ static int · 699 unmodified lines | ||
| 700 | 700 | br_nf_ip_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, |
| 701 | 701 | int (*output)(struct net *, struct sock *, struct sk_buff *)) |
| 702 | 702 | { |
| 703 | − unsigned int mtu = ip_skb_dst_mtu(skb); | |
| 703 | + unsigned int mtu = ip_skb_dst_mtu(sk, skb); | |
| 704 | 704 | struct iphdr *iph = ip_hdr(skb); |
| 705 | 705 | |
| 706 | 706 | if (unlikely(((iph->frag_off & htons(IP_DF)) && !skb->ignore_df) || |
| @@ -271,7 +271,7 @@ static int ip_finish_output(struct net *net, struct sock *sk, struct sk_buff *sk · 270 unmodified lines | ||
| 271 | 271 | return dst_output(net, sk, skb); |
| 272 | 272 | } |
| 273 | 273 | #endif |
| 274 | − mtu = ip_skb_dst_mtu(skb); | |
| 274 | + mtu = ip_skb_dst_mtu(sk, skb); | |
| 275 | 275 | if (skb_is_gso(skb)) |
| 276 | 276 | return ip_finish_output_gso(net, sk, skb, mtu); |
| 277 | 277 | |
| @@ -541,7 +541,7 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, · 263 unmodified lines | ||
| 541 | 541 | |
| 542 | 542 | iph = ip_hdr(skb); |
| 543 | 543 | |
| 544 | − mtu = ip_skb_dst_mtu(skb); | |
| 544 | + mtu = ip_skb_dst_mtu(sk, skb); | |
| 545 | 545 | if (IPCB(skb)->frag_max_size && IPCB(skb)->frag_max_size < mtu) |
| 546 | 546 | mtu = IPCB(skb)->frag_max_size; |
| 547 | 547 | |