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
313313 return min(dst->dev->mtu, IP_MAX_MTU);
314314 }
315315
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)
317318 {
318− struct sock *sk = skb->sk;
319−
320319 if (!sk || !sk_fullsock(sk) || ip_sk_use_pmtu(sk)) {
321320 bool forwarding = IPCB(skb)->flags & IPSKB_FORWARDED;
322321
net/bridge/br_netfilter_hooks.c+1−1
@@ -700,7 +700,7 @@ static int · 699 unmodified lines
700700 br_nf_ip_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
701701 int (*output)(struct net *, struct sock *, struct sk_buff *))
702702 {
703− unsigned int mtu = ip_skb_dst_mtu(skb);
703+ unsigned int mtu = ip_skb_dst_mtu(sk, skb);
704704 struct iphdr *iph = ip_hdr(skb);
705705
706706 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
271271 return dst_output(net, sk, skb);
272272 }
273273 #endif
274− mtu = ip_skb_dst_mtu(skb);
274+ mtu = ip_skb_dst_mtu(sk, skb);
275275 if (skb_is_gso(skb))
276276 return ip_finish_output_gso(net, sk, skb, mtu);
277277
@@ -541,7 +541,7 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, · 263 unmodified lines
541541
542542 iph = ip_hdr(skb);
543543
544− mtu = ip_skb_dst_mtu(skb);
544+ mtu = ip_skb_dst_mtu(sk, skb);
545545 if (IPCB(skb)->frag_max_size && IPCB(skb)->frag_max_size < mtu)
546546 mtu = IPCB(skb)->frag_max_size;
547547

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