History

ipv4: Fix ip_skb_dst_mtu to use the sk passed by ip_finish_output

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().'

Shmulik Ladkani committed 10 years ago

Commit fedbb6b1 parent 5ab0d6a3 files · +5 −6Browse files

Unified · Split

3 files
  1. include/net/ip.h +2 −3
  2. net/bridge/br_netfilter_hooks.c +1 −1
  3. net/ipv4/ip_output.c +2 −2
include/net/ip.h+2−3
@@ -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
316static inline unsigned int ip_skb_dst_mtu(const struct sk_buff *skb)316static 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
net/bridge/br_netfilter_hooks.c+1−1
@@ -700,7 +700,7 @@ static int · 699 unmodified lines
700br_nf_ip_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,700br_nf_ip_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
701 int (*output)(struct net *, struct sock *, struct sk_buff *))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 struct iphdr *iph = ip_hdr(skb);704 struct iphdr *iph = ip_hdr(skb);
705 705
706 if (unlikely(((iph->frag_off & htons(IP_DF)) && !skb->ignore_df) ||706 if (unlikely(((iph->frag_off & htons(IP_DF)) && !skb->ignore_df) ||
net/ipv4/ip_output.c+2−2
@@ -271,7 +271,7 @@ static int ip_finish_output(struct net *net, struct sock *sk, struct sk_buff *sk · 270 unmodified lines
271 return dst_output(net, sk, skb);271 return dst_output(net, sk, skb);
272 }272 }
273#endif273#endif
274 mtu = ip_skb_dst_mtu(skb);274 mtu = ip_skb_dst_mtu(sk, skb);
275 if (skb_is_gso(skb))275 if (skb_is_gso(skb))
276 return ip_finish_output_gso(net, sk, skb, mtu);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 iph = ip_hdr(skb);542 iph = ip_hdr(skb);
543 543
544 mtu = ip_skb_dst_mtu(skb);544 mtu = ip_skb_dst_mtu(sk, skb);
545 if (IPCB(skb)->frag_max_size && IPCB(skb)->frag_max_size < mtu)545 if (IPCB(skb)->frag_max_size && IPCB(skb)->frag_max_size < mtu)
546 mtu = IPCB(skb)->frag_max_size;546 mtu = IPCB(skb)->frag_max_size;
547 547

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t