Skip to content

Commit b881ef7

Browse files
John HeffnerDavid S. Miller
authored andcommitted
[IPV6]: MTU discovery check in ip6_fragment()
Adds a check in ip6_fragment() mirroring ip_fragment() for packets that we can't fragment, and sends an ICMP Packet Too Big message in response. Signed-off-by: John Heffner <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fd44de7 commit b881ef7

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

net/ipv6/ip6_output.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,19 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
567567
nexthdr = *prevhdr;
568568

569569
mtu = dst_mtu(&rt->u.dst);
570+
571+
/* We must not fragment if the socket is set to force MTU discovery
572+
* or if the skb it not generated by a local socket. (This last
573+
* check should be redundant, but it's free.)
574+
*/
575+
if (!np || np->pmtudisc >= IPV6_PMTUDISC_DO) {
576+
skb->dev = skb->dst->dev;
577+
icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu, skb->dev);
578+
IP6_INC_STATS(ip6_dst_idev(skb->dst), IPSTATS_MIB_FRAGFAILS);
579+
kfree_skb(skb);
580+
return -EMSGSIZE;
581+
}
582+
570583
if (np && np->frag_size < mtu) {
571584
if (np->frag_size)
572585
mtu = np->frag_size;

0 commit comments

Comments
 (0)