aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2015-05-21 18:44:16 -0400
committerDavid S. Miller <davem@davemloft.net>2015-05-25 17:22:23 -0400
commit485fca664d76c47fb2a17dcd2ce705a0f137cc3b (patch)
tree5c663a6fdb612d943f3a7621e971bb1f50974ea9 /net/ipv6
parent376cd36dc7b68ec7f7de1428fa055ce706a33bbf (diff)
ipv6: don't increase size when refragmenting forwarded ipv6 skbs
since commit 6aafeef03b9d ("netfilter: push reasm skb through instead of original frag skbs") we will end up sometimes re-fragmenting skbs that we've reassembled. ipv6 defrag preserves the original skbs using the skb frag list, i.e. as long as the skb frag list is preserved there is no problem since we keep original geometry of fragments intact. However, in the rare case where the frag list is munged or skb is linearized, we might send larger fragments than what we originally received. A router in the path might then send packet-too-big errors even if sender never sent fragments exceeding the reported mtu: mtu 1500 - 1500:1400 - 1400:1280 - 1280 A R1 R2 B 1 - A sends to B, fragment size 1400 2 - R2 sends pkttoobig error for 1280 3 - A sends to B, fragment size 1280 4 - R2 sends pkttoobig error for 1280 again because it sees fragments of size 1400. make sure ip6_fragment always caps MTU at largest packet size seen when defragmented skb is forwarded. Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r--net/ipv6/ip6_output.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 61741676b987..d5f7716662db 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -564,18 +564,17 @@ int ip6_fragment(struct sock *sk, struct sk_buff *skb,
564 /* We must not fragment if the socket is set to force MTU discovery 564 /* We must not fragment if the socket is set to force MTU discovery
565 * or if the skb it not generated by a local socket. 565 * or if the skb it not generated by a local socket.
566 */ 566 */
567 if (unlikely(!skb->ignore_df && skb->len > mtu) || 567 if (unlikely(!skb->ignore_df && skb->len > mtu))
568 (IP6CB(skb)->frag_max_size && 568 goto fail_toobig;
569 IP6CB(skb)->frag_max_size > mtu)) {
570 if (skb->sk && dst_allfrag(skb_dst(skb)))
571 sk_nocaps_add(skb->sk, NETIF_F_GSO_MASK);
572 569
573 skb->dev = skb_dst(skb)->dev; 570 if (IP6CB(skb)->frag_max_size) {
574 icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu); 571 if (IP6CB(skb)->frag_max_size > mtu)
575 IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)), 572 goto fail_toobig;
576 IPSTATS_MIB_FRAGFAILS); 573
577 kfree_skb(skb); 574 /* don't send fragments larger than what we received */
578 return -EMSGSIZE; 575 mtu = IP6CB(skb)->frag_max_size;
576 if (mtu < IPV6_MIN_MTU)
577 mtu = IPV6_MIN_MTU;
579 } 578 }
580 579
581 if (np && np->frag_size < mtu) { 580 if (np && np->frag_size < mtu) {
@@ -813,6 +812,14 @@ slow_path:
813 consume_skb(skb); 812 consume_skb(skb);
814 return err; 813 return err;
815 814
815fail_toobig:
816 if (skb->sk && dst_allfrag(skb_dst(skb)))
817 sk_nocaps_add(skb->sk, NETIF_F_GSO_MASK);
818
819 skb->dev = skb_dst(skb)->dev;
820 icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
821 err = -EMSGSIZE;
822
816fail: 823fail:
817 IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)), 824 IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)),
818 IPSTATS_MIB_FRAGFAILS); 825 IPSTATS_MIB_FRAGFAILS);