Networking: Fix loopback device MTU

This commit is contained in:
Gregory Nutt 2015-08-26 10:33:44 -06:00
parent 70620d3dd6
commit 7a168a791f
2 changed files with 37 additions and 14 deletions

View File

@ -110,6 +110,10 @@ struct lo_driver_s
static struct lo_driver_s g_loopback;
#ifdef CONFIG_NET_MULTIBUFFER
static uint8_t g_iobuffer[[MAX_NET_DEV_MTU + CONFIG_NET_GUARDSIZE];
#endif
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
@ -507,18 +511,21 @@ int localhost_initialize(void)
/* Initialize the driver structure */
memset(priv, 0, sizeof(struct lo_driver_s));
priv->lo_dev.d_ifup = lo_ifup; /* I/F up (new IP address) callback */
priv->lo_dev.d_ifdown = lo_ifdown; /* I/F down callback */
priv->lo_dev.d_txavail = lo_txavail; /* New TX data callback */
priv->lo_dev.d_ifup = lo_ifup; /* I/F up (new IP address) callback */
priv->lo_dev.d_ifdown = lo_ifdown; /* I/F down callback */
priv->lo_dev.d_txavail = lo_txavail; /* New TX data callback */
#ifdef CONFIG_NET_IGMP
priv->lo_dev.d_addmac = lo_addmac; /* Add multicast MAC address */
priv->lo_dev.d_rmmac = lo_rmmac; /* Remove multicast MAC address */
priv->lo_dev.d_addmac = lo_addmac; /* Add multicast MAC address */
priv->lo_dev.d_rmmac = lo_rmmac; /* Remove multicast MAC address */
#endif
priv->lo_dev.d_private = (void*)priv; /* Used to recover private state from dev */
#ifdef CONFIG_NET_MULTIBUFFER
priv->lo_dev.d_buf = g_iobuffer; /* Attach the IO buffer */
#endif
priv->lo_dev.d_private = (void*)priv; /* Used to recover private state from dev */
/* Create a watchdog for timing polling for and timing of transmissions */
priv->lo_polldog = wd_create(); /* Create periodic poll timer */
priv->lo_polldog = wd_create(); /* Create periodic poll timer */
/* Register the loopabck device with the OS so that socket IOCTLs can b
* performed.

View File

@ -62,6 +62,14 @@
* Public Type Definitions
****************************************************************************/
#ifndef MAX
# define MAX(a,b) ((a) > (b) ? (a) : (b))
#endif
#ifndef MIN
# define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
/* Layer 2 Configuration Options ********************************************/
/* The default data link layer for uIP is Ethernet. If CONFIG_NET_SLIP is
@ -125,20 +133,28 @@
# define _MAX_ETH_MTU 0
# endif
# ifdef CONFIG_NET_SLIP
# define _MIN_SLIP_MTU MIN(_MIN_ETH_MTU,CONFIG_NET_SLIP_MTU)
# define _MAX_SLIP_MTU MAX(_MAX_ETH_MTU,CONFIG_NET_SLIP_MTU)
# ifdef CONFIG_NET_LOOPBACK
# define _MIN_LO_MTU MIN(_MIN_ETH_MTU,1518)
# define _MAX_LO_MTU MAX(_MAX_ETH_MTU,574)
# else
# define _MIN_SLIP_MTU _MIN_ETH_MTU
# define _MAX_SLIP_MTU _MAX_ETH_MTU
# define _MIN_LO_MTU _MIN_ETH_MTU
# define _MAX_LO_MTU _MAX_ETH_MTU
# endif
# ifdef CONFIG_NET_SLIP
# define _MIN_SLIP_MTU MIN(_MIN_LO_MTU,CONFIG_NET_SLIP_MTU)
# define _MAX_SLIP_MTU MAX(_MAX_LO_MTU,CONFIG_NET_SLIP_MTU)
# else
# define _MIN_SLIP_MTU _MIN_LO_MTU
# define _MAX_SLIP_MTU _MAX_LO_MTU
# endif
# define MIN_NET_DEV_MTU _MIN_SLIP_MTU
# define MAX_NET_DEV_MTU _MAX_SLIP_MTU
/* For the loopback device, we will use the largest representable MTU */
/* For the loopback device, we will use the largest MTU */
# define NET_LO_MTU UINT16_MAX
# define NET_LO_MTU MAX_NET_DEV_MTU
#elif defined(CONFIG_NET_SLIP)
/* There is no link layer header with SLIP */