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

acassis 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 fd85ab56aec arch/sim/src/sim/posix/sim_tapdev.c: drop the frame on a 
TAP write error.
fd85ab56aec is described below

commit fd85ab56aecd37091c38d605b45d45d552cad076
Author: raiden00pl <[email protected]>
AuthorDate: Fri Oct 9 13:08:45 2026 +0200

    arch/sim/src/sim/posix/sim_tapdev.c: drop the frame on a TAP write error.
    
    sim_tapdev_send() called exit(1) when write() failed. The host fails
    every write with EIO while the TAP interface is down, so setting the
    TAP down on the host killed the sim. Drop the frame instead, like a
    NIC without carrier, and log errno (the old message logged -1).
    
    Assisted-by: Claude:claude-opus-5-5
    Signed-off-by: raiden00pl <[email protected]>
---
 arch/sim/src/sim/posix/sim_tapdev.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/arch/sim/src/sim/posix/sim_tapdev.c 
b/arch/sim/src/sim/posix/sim_tapdev.c
index 569a7a9e3fa..9c11880780f 100644
--- a/arch/sim/src/sim/posix/sim_tapdev.c
+++ b/arch/sim/src/sim/posix/sim_tapdev.c
@@ -65,6 +65,7 @@
 #include <sys/time.h>
 #include <sys/uio.h>
 
+#include <errno.h>
 #include <fcntl.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -359,14 +360,19 @@ void sim_tapdev_send(int devidx, unsigned char *buf, 
unsigned int buflen)
     }
 #endif
 
+  /* A failed write drops the frame, like a NIC without carrier: the host
+   * fails every write with EIO while the TAP interface is down.
+   */
+
   ret = write(gtapdevfd[devidx], buf, buflen);
   if (ret < 0)
     {
-      syslog(LOG_ERR, "TAPDEV: write failed: %d\n", -ret);
-      exit(1);
+      syslog(LOG_ERR, "TAPDEV: write failed: %d\n", errno);
+    }
+  else
+    {
+      dump_ethhdr("write", buf, buflen);
     }
-
-  dump_ethhdr("write", buf, buflen);
 
   /* Emulate TX done interrupt */
 

Reply via email to