From fd85ab56aecd37091c38d605b45d45d552cad076 Mon Sep 17 00:00:00 2001 From: raiden00pl Date: Fri, 9 Oct 2026 13:08:45 +0200 Subject: [PATCH] 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 --- 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 #include +#include #include #include #include @@ -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 */