Skip to content

Commit

Permalink
slirp: Propagate host TCP RST to the guest.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
edgarigl authored and sthibaul committed Apr 7, 2016
1 parent bfb1ac1 commit 27d92eb
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion slirp/socket.c
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 27d92eb

Please sign in to comment.