net/devif_loopback: Add robustness to avoid infinite loop

When ipv4_input/ipv6_input called by devif_loopback writes wrong data into buffer (another bug we're fixing), the else block does nothing but only record the 'dropped' statistic, then infinite loop happens.

Refers to previous lo device with dropping logic:
https://github.com/apache/nuttx/blob/releases/11.0/drivers/net/loopback.c#L178-L180

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
This commit is contained in:
Zhe Weng 2022-12-23 14:31:27 +08:00 committed by Xiang Xiao
parent 45394eb6dc
commit 7f9cf184e5
1 changed files with 2 additions and 0 deletions

View File

@ -119,7 +119,9 @@ int devif_loopback(FAR struct net_driver_s *dev)
else
#endif
{
nwarn("WARNING: Unrecognized IP version\n");
NETDEV_RXDROPPED(dev);
dev->d_len = 0;
}
NETDEV_TXDONE(dev);