This is an automated email from the ASF dual-hosted git repository.

casaroli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 3e25e8af3fb net/netdev: drop the input packet the network could not 
take
3e25e8af3fb is described below

commit 3e25e8af3fb3c2effe696b48bdb2ac4b02d9b921
Author: raiden00pl <[email protected]>
AuthorDate: Thu Oct 22 15:20:39 2026 +0200

    net/netdev: drop the input packet the network could not take
    
    netdev_input() returned with d_len unchanged when no IOB was free or
    the packet was copied only in part, so the driver found a d_len of the
    received packet and sent it out again as a reply.
    
    Assisted-by: Claude Code
    Signed-off-by: raiden00pl <[email protected]>
---
 net/netdev/netdev_input.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/net/netdev/netdev_input.c b/net/netdev/netdev_input.c
index 36333d27bc8..4d91aeb26e7 100644
--- a/net/netdev/netdev_input.c
+++ b/net/netdev/netdev_input.c
@@ -77,6 +77,7 @@ int netdev_input(FAR struct net_driver_s *dev,
   ret = netdev_iob_prepare(dev, false, 0);
   if (ret != OK)
     {
+      dev->d_len = 0;
       return ret;
     }
 
@@ -90,7 +91,17 @@ int netdev_input(FAR struct net_driver_s *dev,
   /* Copy data to iob entry */
 
   ret = iob_trycopyin(dev->d_iob, buf, dev->d_len, -llhdrlen, false);
-  if (ret == dev->d_len)
+  if (ret != dev->d_len)
+    {
+      /* The packet is dropped, nothing is left to send */
+
+      dev->d_len = 0;
+      if (ret >= 0)
+        {
+          ret = -ENOMEM;
+        }
+    }
+  else
     {
       /* Update device buffer to l2 start */
 

Reply via email to