Skip to content

Commit b40988c

Browse files
alexaringholtmann
authored andcommitted
ieee802154: change mtu size behaviour
This patch changes the mtu size of 802.15.4 interfaces. The current setting is the meaning of the maximum transport unit with mac header, which is 127 bytes according 802.15.4. The linux meaning of the mtu size field is the maximum payload of a mac frame. Like in ethernet, which is 1500 bytes. We have dynamic length of mac frames in 802.15.4, this is why we assume the minimum header length which is hard_header_len. This contains fc and sequence fields. These can evaluated by driver layer without additional checks. We currently don't support to set the FCS from userspace, so we need to subtract this from mtu size as well. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
1 parent d58a2fa commit b40988c

3 files changed

Lines changed: 13 additions & 14 deletions

File tree

‎net/ieee802154/socket.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ static int raw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
273273
goto out;
274274
}
275275

276-
mtu = dev->mtu;
276+
mtu = IEEE802154_MTU;
277277
pr_debug("name = %s, mtu = %u\n", dev->name, mtu);
278278

279279
if (size > mtu) {
@@ -637,7 +637,7 @@ static int dgram_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
637637
err = -ENXIO;
638638
goto out;
639639
}
640-
mtu = dev->mtu;
640+
mtu = IEEE802154_MTU;
641641
pr_debug("name = %s, mtu = %u\n", dev->name, mtu);
642642

643643
if (size > mtu) {

‎net/mac802154/iface.c‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,17 @@ static void ieee802154_if_setup(struct net_device *dev)
547547
*/
548548
dev->needed_tailroom = IEEE802154_MAX_AUTH_TAG_LEN +
549549
IEEE802154_FCS_LEN;
550-
dev->mtu = IEEE802154_MTU;
550+
/* The mtu size is the payload without mac header in this case.
551+
* We have a dynamic length header with a minimum header length
552+
* which is hard_header_len. In this case we let mtu to the size
553+
* of maximum payload which is IEEE802154_MTU - IEEE802154_FCS_LEN -
554+
* hard_header_len. The FCS which is set by hardware or ndo_start_xmit
555+
* and the minimum mac header which can be evaluated inside driver
556+
* layer. The rest of mac header will be part of payload if greater
557+
* than hard_header_len.
558+
*/
559+
dev->mtu = IEEE802154_MTU - IEEE802154_FCS_LEN -
560+
dev->hard_header_len;
551561
dev->tx_queue_len = 300;
552562
dev->flags = IFF_NOARP | IFF_BROADCAST;
553563
}

‎net/mac802154/tx.c‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,6 @@ ieee802154_tx(struct ieee802154_local *local, struct sk_buff *skb)
7171
struct net_device *dev = skb->dev;
7272
int ret;
7373

74-
/* This check is for AF_PACKET RAW socket only, which doesn't
75-
* know about the FCS which is set here or by hardware. otherwise
76-
* it should not occur in any case!
77-
*
78-
* TODO: This should be handled in AF_PACKET and return -EMSGSIZE.
79-
*/
80-
if (skb->len > IEEE802154_MTU - IEEE802154_FCS_LEN) {
81-
netdev_warn(dev, "Frame len above MTU limit. Dropped.\n");
82-
goto err_tx;
83-
}
84-
8574
if (!(local->hw.flags & IEEE802154_HW_TX_OMIT_CKSUM)) {
8675
u16 crc = crc_ccitt(0, skb->data, skb->len);
8776

0 commit comments

Comments
 (0)