Merged in antmerlino/nuttx/ipforward (pull request #981)

net/ipforward: Check if interface is up early on when forwarding to avoid extra work.

As noticed in a previous wireless commit, when forwarding is enabled and a packet comes in, the packet is attempted to be sent on each other netdev without regard for whether it is in the UP state. Of course this is eventually caught, but it can be caught earlier to avoid unnecessary work, especially in the 6LoWPAN case where a useless packet conversion will occur.

Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
Anthony Merlino 2019-08-10 17:53:06 +00:00 committed by Gregory Nutt
parent 1e3a60155e
commit 7c06438315
1 changed files with 9 additions and 0 deletions

View File

@ -348,6 +348,15 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev,
#endif
int ret;
/* If the interface isn't "up", we can't forward. */
if ((fwddev->d_flags & IFF_UP) == 0)
{
nwarn("WARNING: device is DOWN\n");
ret = -EHOSTUNREACH;
goto errout;
}
/* Perform any necessary packet conversions. */
ret = ipv6_packet_conversion(dev, fwddev, ipv6);