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>
This commit is contained in:
Edgar E. Iglesias 2016-04-06 22:04:43 -07:00 committed by Samuel Thibault
parent bfb1ac1402
commit 27d92ebc5e

View File

@ -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;
}
}