IP forwarding: A few fixes from early testing; In TUN driver, do all polling on worker thread. Otherwise, the stack gets very deep.
This commit is contained in:
parent
d61b551bca
commit
99ef7c6669
@ -303,7 +303,7 @@ CONFIG_SCHED_LPWORK=y
|
||||
CONFIG_SCHED_LPNTHREADS=1
|
||||
CONFIG_SCHED_LPWORKPRIORITY=140
|
||||
CONFIG_SCHED_LPWORKPERIOD=50000
|
||||
CONFIG_SCHED_LPWORKSTACKSIZE=2048
|
||||
CONFIG_SCHED_LPWORKSTACKSIZE=8192
|
||||
|
||||
#
|
||||
# Stack and heap information
|
||||
@ -376,9 +376,26 @@ CONFIG_DEV_LOOP=y
|
||||
# CONFIG_MODEM is not set
|
||||
# CONFIG_MTD is not set
|
||||
# CONFIG_EEPROM is not set
|
||||
# CONFIG_NETDEVICES is not set
|
||||
CONFIG_NETDEVICES=y
|
||||
|
||||
#
|
||||
# General Ethernet MAC Driver Options
|
||||
#
|
||||
# CONFIG_NETDEV_LOOPBACK is not set
|
||||
# CONFIG_NETDEV_TELNET is not set
|
||||
CONFIG_NETDEV_MULTINIC=y
|
||||
CONFIG_ARCH_HAVE_NETDEV_STATISTICS=y
|
||||
# CONFIG_NETDEV_LATEINIT is not set
|
||||
# CONFIG_NET_DUMPPACKET is not set
|
||||
|
||||
#
|
||||
# External Ethernet MAC Device Support
|
||||
#
|
||||
# CONFIG_NET_DM90x0 is not set
|
||||
# CONFIG_ENC28J60 is not set
|
||||
# CONFIG_ENCX24J600 is not set
|
||||
# CONFIG_NET_SLIP is not set
|
||||
# CONFIG_NET_FTMAC100 is not set
|
||||
# CONFIG_PIPES is not set
|
||||
# CONFIG_PM is not set
|
||||
# CONFIG_POWER is not set
|
||||
@ -480,6 +497,8 @@ CONFIG_TUN_LPWORK=y
|
||||
CONFIG_NET_IPv6=y
|
||||
CONFIG_NET_IPv6_NCONF_ENTRIES=4
|
||||
CONFIG_NET_IPFORWARD=y
|
||||
# CONFIG_NET_IPFORWARD_BROADCAST is not set
|
||||
CONFIG_NET_IPFORWARD_NSTRUCT=4
|
||||
|
||||
#
|
||||
# Socket Support
|
||||
@ -790,7 +809,7 @@ CONFIG_BUILTIN_PROXY_STACKSIZE=1024
|
||||
# CONFIG_EXAMPLES_IGMP is not set
|
||||
CONFIG_EXAMPLES_IPFORWARD=y
|
||||
CONFIG_EXAMPLES_IPFORWARD_PRIORITY=100
|
||||
CONFIG_EXAMPLES_IPFORWARD_STACKSIZE=2048
|
||||
CONFIG_EXAMPLES_IPFORWARD_STACKSIZE=8192
|
||||
# CONFIG_EXAMPLES_JSON is not set
|
||||
# CONFIG_EXAMPLES_MEDIA is not set
|
||||
# CONFIG_EXAMPLES_MM is not set
|
||||
|
@ -684,7 +684,7 @@ static int tun_ifdown(struct net_driver_s *dev)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tun_txavail
|
||||
* Name: tun_txavail_work
|
||||
*
|
||||
* Description:
|
||||
* Driver callback invoked when new TX data is available. This is a
|
||||
@ -702,9 +702,9 @@ static int tun_ifdown(struct net_driver_s *dev)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int tun_txavail(struct net_driver_s *dev)
|
||||
static void tun_txavail_work(FAR void *arg)
|
||||
{
|
||||
FAR struct tun_device_s *priv = (FAR struct tun_device_s *)dev->d_private;
|
||||
FAR struct tun_device_s *priv = (FAR struct tun_device_s *)arg;
|
||||
|
||||
tun_lock(priv);
|
||||
|
||||
@ -713,11 +713,10 @@ static int tun_txavail(struct net_driver_s *dev)
|
||||
if (priv->read_d_len != 0 || priv->write_d_len != 0)
|
||||
{
|
||||
tun_unlock(priv);
|
||||
return OK;
|
||||
return;
|
||||
}
|
||||
|
||||
net_lock();
|
||||
|
||||
if (priv->bifup)
|
||||
{
|
||||
/* Poll the network for new XMIT data */
|
||||
@ -728,6 +727,37 @@ static int tun_txavail(struct net_driver_s *dev)
|
||||
|
||||
net_unlock();
|
||||
tun_unlock(priv);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tun_txavail
|
||||
*
|
||||
* Description:
|
||||
* Driver callback invoked when new TX data is available. This is a
|
||||
* stimulus perform an out-of-cycle poll and, thereby, reduce the TX
|
||||
* latency.
|
||||
*
|
||||
* Parameters:
|
||||
* dev - Reference to the NuttX driver state structure
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
* Assumptions:
|
||||
* Called from the network stack with the network locked.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int tun_txavail(struct net_driver_s *dev)
|
||||
{
|
||||
FAR struct tun_device_s *priv = (FAR struct tun_device_s *)dev->d_private;
|
||||
|
||||
/* Schedule to perform the TX poll on the worker thread. */
|
||||
|
||||
if (work_available(&priv->work))
|
||||
{
|
||||
work_queue(TUNWORK, &priv->work, tun_txavail_work, priv, 0);
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ static int ipv4_hdrsize(FAR struct ipv4_hdr_s *ipv4)
|
||||
case IP_PROTO_TCP:
|
||||
{
|
||||
FAR struct tcp_hdr_s *tcp =
|
||||
(FAR struct tcp_hdr_s *)((FAR uintptr_t *)ipv4 + IPv4_HDRLEN);
|
||||
(FAR struct tcp_hdr_s *)((FAR uint8_t *)ipv4 + IPv4_HDRLEN);
|
||||
unsigned int tcpsize;
|
||||
|
||||
/* The TCP header length is encoded in the top 4 bits of the
|
||||
|
@ -97,7 +97,7 @@ static int ipv6_hdrsize(FAR struct ipv6_hdr_s *ipv6)
|
||||
case IP_PROTO_TCP:
|
||||
{
|
||||
FAR struct tcp_hdr_s *tcp =
|
||||
(FAR struct tcp_hdr_s *)((FAR uintptr_t *)ipv6 + IPv6_HDRLEN);
|
||||
(FAR struct tcp_hdr_s *)((FAR uint8_t *)ipv6 + IPv6_HDRLEN);
|
||||
unsigned int tcpsize;
|
||||
|
||||
/* The TCP header length is encoded in the top 4 bits of the
|
||||
@ -337,7 +337,7 @@ static int ipv6_packet_conversion(FAR struct net_driver_s *dev,
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
# define ipv6_packet_conversion(dev, ipv6) (PACKET_NOT_FORWARDED)
|
||||
# define ipv6_packet_conversion(dev, fwddev, ipv6) (PACKET_NOT_FORWARDED)
|
||||
#endif /* CONFIG_NET_6LOWPAN */
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -167,7 +167,7 @@ void netdev_ipv6_txnotify(FAR const net_ipv6addr_t ripaddr)
|
||||
|
||||
void netdev_txnotify_dev(FAR struct net_driver_s *dev)
|
||||
{
|
||||
if (dev && dev->d_txavail)
|
||||
if (dev != NULL && dev->d_txavail != NULL)
|
||||
{
|
||||
/* Notify the device driver that new TX data is available. */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user