mirror of
https://github.com/apache/nuttx.git
synced 2026-10-10 07:40:27 +00:00
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:
parent
afa5c7c65b
commit
fd85ab56ae
1 changed files with 10 additions and 4 deletions
|
|
@ -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 */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue