aboutsummaryrefslogtreecommitdiff
path: root/slirp
diff options
context:
space:
mode:
authorEdgar E. Iglesias <edgar.iglesias@gmail.com>2016-04-06 22:04:43 -0700
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2016-04-07 13:01:45 +0200
commit27d92ebc5ed1bb0b518d0ebc4c609182ad20a799 (patch)
tree5ea5ed300e638a9cfe77ef8632979f7612e260ff /slirp
parentbfb1ac14029ee72b19296109fba880c0551755d5 (diff)
slirp: Propagate host TCP RST to the guest.
When the host aborts (RST) its 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. Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> [steven@steven676.net: coding style adjustments] Signed-off-by: Steven Luo <steven+qemu@steven676.net> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Diffstat (limited to 'slirp')
-rw-r--r--slirp/socket.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/slirp/socket.c b/slirp/socket.c
index 7f022a6769..0d67b12678 100644
--- a/slirp/socket.c
+++ b/slirp/socket.c
@@ -176,9 +176,24 @@ soread(struct socket *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;
}
}