]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ieee802154: change mtu size behaviour
authorAlexander Aring <alex.aring@gmail.com>
Mon, 28 Sep 2015 10:36:26 +0000 (12:36 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Wed, 30 Sep 2015 11:21:32 +0000 (13:21 +0200)
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>
net/ieee802154/socket.c
net/mac802154/iface.c
net/mac802154/tx.c

index be77f211ce87ff05954fec31bc2d736542d09e23..a548be247e15d87c82cfda7a6cd3bde32a7159a7 100644 (file)
@@ -273,7 +273,7 @@ static int raw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
                goto out;
        }
 
-       mtu = dev->mtu;
+       mtu = IEEE802154_MTU;
        pr_debug("name = %s, mtu = %u\n", dev->name, mtu);
 
        if (size > mtu) {
@@ -637,7 +637,7 @@ static int dgram_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
                err = -ENXIO;
                goto out;
        }
-       mtu = dev->mtu;
+       mtu = IEEE802154_MTU;
        pr_debug("name = %s, mtu = %u\n", dev->name, mtu);
 
        if (size > mtu) {
index 3954bcff70e4ac1e45da28ffdd4f469d1149016f..7079cd32a7ad201265cf730027dda07254e622aa 100644 (file)
@@ -547,7 +547,17 @@ static void ieee802154_if_setup(struct net_device *dev)
         */
        dev->needed_tailroom    = IEEE802154_MAX_AUTH_TAG_LEN +
                                  IEEE802154_FCS_LEN;
-       dev->mtu                = IEEE802154_MTU;
+       /* The mtu size is the payload without mac header in this case.
+        * We have a dynamic length header with a minimum header length
+        * which is hard_header_len. In this case we let mtu to the size
+        * of maximum payload which is IEEE802154_MTU - IEEE802154_FCS_LEN -
+        * hard_header_len. The FCS which is set by hardware or ndo_start_xmit
+        * and the minimum mac header which can be evaluated inside driver
+        * layer. The rest of mac header will be part of payload if greater
+        * than hard_header_len.
+        */
+       dev->mtu                = IEEE802154_MTU - IEEE802154_FCS_LEN -
+                                 dev->hard_header_len;
        dev->tx_queue_len       = 300;
        dev->flags              = IFF_NOARP | IFF_BROADCAST;
 }
index b205bbec7bdfba760105fef224e03fe7474b4938..3827f359b336de356695635401820fc094344faf 100644 (file)
@@ -71,17 +71,6 @@ ieee802154_tx(struct ieee802154_local *local, struct sk_buff *skb)
        struct net_device *dev = skb->dev;
        int ret;
 
-       /* This check is for AF_PACKET RAW socket only, which doesn't
-        * know about the FCS which is set here or by hardware. otherwise
-        * it should not occur in any case!
-        *
-        * TODO: This should be handled in AF_PACKET and return -EMSGSIZE.
-        */
-       if (skb->len > IEEE802154_MTU - IEEE802154_FCS_LEN) {
-               netdev_warn(dev, "Frame len above MTU limit. Dropped.\n");
-               goto err_tx;
-       }
-
        if (!(local->hw.flags & IEEE802154_HW_TX_OMIT_CKSUM)) {
                u16 crc = crc_ccitt(0, skb->data, skb->len);