mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 14:27:37 +08:00
This commit attempts remove some long standard confusion in naming and some actual problems that result from the naming confusion. The basic problem is the standard MTU does not include the size of the Ethernet header. For clarity, I changed the naming of most things called MTU to PKTSIZE. For example, CONFIG_NET_ETH_MTU is now CONFIG_NET_ETH_PKTSIZE.
This makes the user interface a little hostile. People thing of an MTU of 1500 bytes, but the corresponding packet is really 1514 bytes (including the 14 byte Ethernet header). A more friendly solution would configure the MTU (as before), but then derive the packet buffer size by adding the MAC header length. Instead, we define the packet buffer size then derive the MTU.
The MTU is not common currency in networking. On the wire, the only real issue is the MSS which is derived from MTU by subtracting the IP header and TCP header sizes (for the case of TCP). Now it is derived for the PKTSIZE by subtracting the IP header, the TCP header, and the MAC header sizes. So we should be all good and without the recurring 14 byte error in MTU's and MSS's.
Squashed commit of the following:
Trivial update to fix some spacing issues.
net/: Rename several macros containing _MTU to _PKTSIZE.
net/: Rename CONFIG_NET_SLIP_MTU to CONFIG_NET_SLIP_PKTSIZE and similarly for CONFIG_NET_TUN_MTU. These are not the MTU which does not include the size of the link layer header. These are the full size of the packet buffer memory (minus any GUARD bytes).
net/: Rename CONFIG_NET_6LOWPAN_MTU to CONFIG_NET_6LOWPAN_PKTSIZE and similarly for CONFIG_NET_TUN_MTU. These are not the MTU which does not include the size of the link layer header. These are the full size of the packet buffer memory (minus any GUARD bytes).
net/: Rename CONFIG_NET_ETH_MTU to CONFIG_NET_ETH_PKTSIZE. This is not the MTU which does not include the size of the link layer header. This is the full size of the packet buffer memory (minus any GUARD bytes).
net/: Rename the file d_mtu in the network driver structure to d_pktsize. That value saved there is not the MTU. The packetsize is the memory large enough to hold the maximum packet PLUS the size of the link layer header. The MTU does not include the link layer header.
This commit is contained in:
@@ -287,15 +287,16 @@ config NET_6LOWPAN_MAX_MACTRANSMITS
|
||||
layer should resend packets if no link-layer ACK wasreceived. This
|
||||
only makes sense with the csma_driver.
|
||||
|
||||
config NET_6LOWPAN_MTU
|
||||
config NET_6LOWPAN_PKTSIZE
|
||||
int "6LoWPAN packet buffer size"
|
||||
default 1294
|
||||
range 590 1518
|
||||
---help---
|
||||
Packet buffer size. This size includes the TCP/UDP payload plus the
|
||||
size of TCP/UDP header, the IP header, and the Ethernet header.
|
||||
This value is normally referred to as the MTU (Maximum Transmission
|
||||
Unit); the payload is the MSS (Maximum Segment Size).
|
||||
This value is related to the MTU (Maximum Transmission Unit), except
|
||||
that it includes the size of the link layer header; the payload is
|
||||
the MSS (Maximum Segment Size).
|
||||
|
||||
NOTE that this option depends on fragmentation support. By
|
||||
supporting fragmentation, we can handle quite large "logical" packet
|
||||
|
||||
@@ -95,7 +95,7 @@ Optimal 6LoWPAN Configuration
|
||||
|
||||
5. IOBs: Must be big enough to hold one IEEE802.15.4 frame (typically 127).
|
||||
There must be enough IOBs to decompose the largest IPv6 packet
|
||||
(CONFIG_NET_6LOWPAN_MTU, default 1294, plus per frame overhead).
|
||||
(CONFIG_NET_6LOWPAN_PKTSIZE, default 1294, plus per frame overhead).
|
||||
|
||||
Fragmentation Headers
|
||||
---------------------
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
* won't work unless there are a few more.
|
||||
*/
|
||||
|
||||
#if CONFIG_NET_6LOWPAN_MTU > (CONFIG_IOB_BUFSIZE * CONFIG_IOB_NBUFFERS)
|
||||
#if CONFIG_NET_6LOWPAN_PKTSIZE > (CONFIG_IOB_BUFSIZE * CONFIG_IOB_NBUFFERS)
|
||||
# error Not enough IOBs to hold one full 6LoWPAN packet
|
||||
#endif
|
||||
|
||||
|
||||
@@ -340,9 +340,9 @@ static int sixlowpan_frame_process(FAR struct radio_driver_s *radio,
|
||||
|
||||
/* Drop the packet if it cannot fit into the d_buf */
|
||||
|
||||
if (fragsize > CONFIG_NET_6LOWPAN_MTU)
|
||||
if (fragsize > CONFIG_NET_6LOWPAN_PKTSIZE)
|
||||
{
|
||||
nwarn("WARNING: Reassembled packet size exeeds CONFIG_NET_6LOWPAN_MTU\n");
|
||||
nwarn("WARNING: Reassembled packet size exeeds CONFIG_NET_6LOWPAN_PKTSIZE\n");
|
||||
return -ENOSPC;
|
||||
}
|
||||
|
||||
@@ -521,10 +521,10 @@ static int sixlowpan_frame_process(FAR struct radio_driver_s *radio,
|
||||
*/
|
||||
|
||||
paysize = iob->io_len - g_frame_hdrlen;
|
||||
if (paysize > CONFIG_NET_6LOWPAN_MTU)
|
||||
if (paysize > CONFIG_NET_6LOWPAN_PKTSIZE)
|
||||
{
|
||||
nwarn("WARNING: Packet dropped due to payload (%u) > packet buffer (%u)\n",
|
||||
paysize, CONFIG_NET_6LOWPAN_MTU);
|
||||
paysize, CONFIG_NET_6LOWPAN_PKTSIZE);
|
||||
ret = -ENOSPC;
|
||||
goto errout_with_reass;
|
||||
}
|
||||
@@ -532,11 +532,11 @@ static int sixlowpan_frame_process(FAR struct radio_driver_s *radio,
|
||||
/* Sanity-check size of incoming packet to avoid buffer overflow */
|
||||
|
||||
reqsize = g_uncomp_hdrlen + (fragoffset << 3) + paysize;
|
||||
if (reqsize > CONFIG_NET_6LOWPAN_MTU)
|
||||
if (reqsize > CONFIG_NET_6LOWPAN_PKTSIZE)
|
||||
{
|
||||
nwarn("WARNING: Required buffer size: %u+%u+%u=%u Available=%u\n",
|
||||
g_uncomp_hdrlen, (fragoffset << 3), paysize,
|
||||
reqsize, CONFIG_NET_6LOWPAN_MTU);
|
||||
reqsize, CONFIG_NET_6LOWPAN_PKTSIZE);
|
||||
ret = -ENOMEM;
|
||||
goto errout_with_reass;
|
||||
}
|
||||
@@ -667,7 +667,7 @@ static int sixlowpan_dispatch(FAR struct radio_driver_s *radio)
|
||||
* - The io_flink field points to the next frame in the list (if enable)
|
||||
* - The last frame in the list will have io_flink == NULL.
|
||||
*
|
||||
* An non-NULL d_buf of size CONFIG_NET_6LOWPAN_MTU + CONFIG_NET_GUARDSIZE
|
||||
* An non-NULL d_buf of size CONFIG_NET_6LOWPAN_PKTSIZE + CONFIG_NET_GUARDSIZE
|
||||
* must also be provided. The frame will be decompressed and placed in
|
||||
* the d_buf. Fragmented packets will also be reassembled in the d_buf as
|
||||
* they are received (meaning for the driver, that two packet buffers are
|
||||
|
||||
@@ -140,7 +140,7 @@ static uint16_t sixlowpan_tcp_chksum(FAR const struct ipv6tcp_hdr_s *ipv6tcp,
|
||||
|
||||
/* Verify some minimal assumptions */
|
||||
|
||||
if (upperlen > CONFIG_NET_6LOWPAN_MTU)
|
||||
if (upperlen > CONFIG_NET_6LOWPAN_PKTSIZE)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ static uint16_t sixlowpan_udp_chksum(FAR const struct ipv6udp_hdr_s *ipv6udp,
|
||||
|
||||
/* Verify some minimal assumptions */
|
||||
|
||||
if (upperlen > CONFIG_NET_6LOWPAN_MTU)
|
||||
if (upperlen > CONFIG_NET_6LOWPAN_PKTSIZE)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user