mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 15:58:59 +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:
@@ -81,7 +81,7 @@ void devif_forward(FAR struct forward_s *fwd)
|
||||
|
||||
/* Copy the IOB chain that contains the L3L3 headers and any data payload */
|
||||
|
||||
DEBUGASSERT(offset + fwd->f_iob->io_pktlen <= NET_DEV_MTU(fwd->f_dev));
|
||||
DEBUGASSERT(offset + fwd->f_iob->io_pktlen <= NETDEV_PKTSIZE(fwd->f_dev));
|
||||
ret = iob_copyout(&fwd->f_dev->d_buf[offset], fwd->f_iob,
|
||||
fwd->f_iob->io_pktlen, 0);
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
void devif_iob_send(FAR struct net_driver_s *dev, FAR struct iob_s *iob,
|
||||
unsigned int len, unsigned int offset)
|
||||
{
|
||||
DEBUGASSERT(dev && len > 0 && len < NET_DEV_MTU(dev));
|
||||
DEBUGASSERT(dev && len > 0 && len < NETDEV_PKTSIZE(dev));
|
||||
|
||||
/* Copy the data from the I/O buffer chain to the device buffer */
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@
|
||||
void devif_pkt_send(FAR struct net_driver_s *dev, FAR const void *buf,
|
||||
unsigned int len)
|
||||
{
|
||||
DEBUGASSERT(dev && len > 0 && len < NET_DEV_MTU(dev));
|
||||
DEBUGASSERT(dev && len > 0 && len < NETDEV_PKTSIZE(dev));
|
||||
|
||||
/* Copy the data into the device packet buffer */
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
|
||||
void devif_send(struct net_driver_s *dev, const void *buf, int len)
|
||||
{
|
||||
DEBUGASSERT(dev != NULL && len > 0 && len < NET_DEV_MTU(dev));
|
||||
DEBUGASSERT(dev != NULL && len > 0 && len < NETDEV_PKTSIZE(dev));
|
||||
|
||||
memcpy(dev->d_appdata, buf, len);
|
||||
dev->d_sndlen = len;
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
*/
|
||||
|
||||
#define IP_MF 0x20 /* See IP_FLAG_MOREFRAGS */
|
||||
#define IPv4_REASS_BUFSIZE (CONFIG_NET_ETH_MTU - ETH_HDRLEN)
|
||||
#define IPv4_REASS_BUFSIZE (CONFIG_NET_ETH_PKTSIZE - ETH_HDRLEN)
|
||||
#define IPv4_REASS_LASTFRAG 0x01
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user