[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] slirp: Propagate host TCP RST to the guest.
From: |
Edgar E. Iglesias |
Subject: |
[Qemu-devel] [PATCH] slirp: Propagate host TCP RST to the guest. |
Date: |
Wed, 11 Jun 2008 23:47:50 +0200 |
User-agent: |
Mutt/1.5.16 (2007-06-09) |
Hi,
Jason found a bug in teh slirp TCP RST code. Here is a patch to fix it.
Is this OK to commit?
Best regards
--
Edgar E. Iglesias
Axis Communications AB
When the host aborts (RST) it's side of a TCP connection we need to
propagate that RST to the guest. The current code can leave such guest
connections dangling forever. Spotted by Jason Wessel.
diff --git a/slirp/socket.c b/slirp/socket.c
index 75003af..bb10d69 100644
--- a/slirp/socket.c
+++ b/slirp/socket.c
@@ -165,9 +165,21 @@ soread(so)
if (nn < 0 && (errno == EINTR || errno == EAGAIN))
return 0;
else {
+ int err;
+ socklen_t slen = sizeof err;
+
+ err = errno;
+ if (nn == 0)
+ getsockopt(so->s, SOL_SOCKET, SO_ERROR,
+ &err, &slen);
+
DEBUG_MISC((dfd, " --- soread() disconnected, nn = %d,
errno = %d-%s\n", nn, errno,strerror(errno)));
sofcantrcvmore(so);
- tcp_sockclosed(sototcpcb(so));
+ if (err == ECONNRESET
+ || err == ENOTCONN || err == EPIPE)
+ tcp_drop(sototcpcb(so), err);
+ else
+ tcp_sockclosed(sototcpcb(so));
return -1;
}
}