Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ieee802154: 6lowpan: ensure MTU of 1280 for 6lowpan

This patch drops the userspace accessable sysfs entry for the maximum
datagram size of a 6LoWPAN fragment packet.

A fragment should not have a datagram size value greater than 1280 byte.
Instead of make this value configurable, we accept 1280 datagram size
fragment packets only.

Signed-off-by: Martin Townsend <martin.townsend@xsilon.com>
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

authored by

Martin Townsend and committed by
Marcel Holtmann
6697dabe 685d6328

+3 -13
-1
include/net/netns/ieee802154_6lowpan.h
··· 16 16 struct netns_ieee802154_lowpan { 17 17 struct netns_sysctl_lowpan sysctl; 18 18 struct netns_frags frags; 19 - int max_dsize; 20 19 }; 21 20 22 21 #endif
+3 -12
net/ieee802154/reassembly.c
··· 355 355 struct net *net = dev_net(skb->dev); 356 356 struct lowpan_frag_info *frag_info = lowpan_cb(skb); 357 357 struct ieee802154_addr source, dest; 358 - struct netns_ieee802154_lowpan *ieee802154_lowpan = 359 - net_ieee802154_lowpan(net); 360 358 int err; 361 359 362 360 source = mac_cb(skb)->source; ··· 364 366 if (err < 0) 365 367 goto err; 366 368 367 - if (frag_info->d_size > ieee802154_lowpan->max_dsize) 369 + if (frag_info->d_size > IPV6_MIN_MTU) { 370 + net_warn_ratelimited("lowpan_frag_rcv: datagram size exceeds MTU\n"); 368 371 goto err; 372 + } 369 373 370 374 fq = fq_find(net, frag_info, &source, &dest); 371 375 if (fq != NULL) { ··· 415 415 .mode = 0644, 416 416 .proc_handler = proc_dointvec_jiffies, 417 417 }, 418 - { 419 - .procname = "6lowpanfrag_max_datagram_size", 420 - .data = &init_net.ieee802154_lowpan.max_dsize, 421 - .maxlen = sizeof(int), 422 - .mode = 0644, 423 - .proc_handler = proc_dointvec 424 - }, 425 418 { } 426 419 }; 427 420 ··· 451 458 table[1].data = &ieee802154_lowpan->frags.low_thresh; 452 459 table[1].extra2 = &ieee802154_lowpan->frags.high_thresh; 453 460 table[2].data = &ieee802154_lowpan->frags.timeout; 454 - table[3].data = &ieee802154_lowpan->max_dsize; 455 461 456 462 /* Don't export sysctls to unprivileged users */ 457 463 if (net->user_ns != &init_user_ns) ··· 525 533 ieee802154_lowpan->frags.high_thresh = IPV6_FRAG_HIGH_THRESH; 526 534 ieee802154_lowpan->frags.low_thresh = IPV6_FRAG_LOW_THRESH; 527 535 ieee802154_lowpan->frags.timeout = IPV6_FRAG_TIMEOUT; 528 - ieee802154_lowpan->max_dsize = 0xFFFF; 529 536 530 537 inet_frags_init_net(&ieee802154_lowpan->frags); 531 538