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 <raiden00@railab.me>
This commit is contained in:
raiden00pl 2026-10-09 13:08:45 +02:00 • committed by Alan C. Assis
parent afa5c7c65b
commit fd85ab56ae

View file

@ -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 */