mirror of
https://github.com/apache/nuttx.git
synced 2025-12-10 12:14:36 +08:00
net/ipfwd: limit number of ipforward struct to be less than number of IOB
If ipforward consumes all the IOB, devif_poll will not poll any more. Without polling, ipforward will not release any IOB, then all the network stack may fail with no IOB available. Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
This commit is contained in:
@@ -925,6 +925,7 @@ int devif_poll(FAR struct net_driver_s *dev, devif_poll_callback_t callback)
|
||||
|
||||
if (netdev_iob_prepare(dev, false, 0) != OK)
|
||||
{
|
||||
nwarn("WARNING: IOB Prepare failed for dev %s!\n", dev->d_ifname);
|
||||
bstop = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -36,3 +36,7 @@ config NET_IPFORWARD_NSTRUCT
|
||||
packets that may be waiting to be forwarded from one network device
|
||||
to another. CONFIG_IOB_NBUFFERS also limits the forward because the
|
||||
payload of the packet (up to the MSS) is retain in IOBs.
|
||||
|
||||
WARNING: DO NOT set this setting to a value greater than or equal to
|
||||
CONFIG_IOB_NBUFFERS, otherwise it may consume all the IOB and let
|
||||
netdev fail to work.
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#undef HAVE_FWDALLOC
|
||||
@@ -42,6 +43,9 @@
|
||||
# define CONFIG_NET_IPFORWARD_NSTRUCT 4
|
||||
#endif
|
||||
|
||||
static_assert(CONFIG_IOB_NBUFFERS > CONFIG_NET_IPFORWARD_NSTRUCT,
|
||||
"IP forward may consume all the IOB and break netdev logic");
|
||||
|
||||
/* Allocate a new IP forwarding data callback */
|
||||
|
||||
#define ipfwd_callback_alloc(dev) devif_callback_alloc(dev, \
|
||||
|
||||
Reference in New Issue
Block a user