aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Luo <steven+qemu@steven676.net>2016-04-06 22:04:55 -0700
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2016-04-07 13:02:05 +0200
commitc9bea8b601ca124ae08787e40c567183c190428b (patch)
treee6b1415b1fddd106bb3f063c6052e447c897d2da
parentcc7b3257e0fff82542174c41e599d171244b0ee2 (diff)
downloadslirp-c9bea8b601ca124ae08787e40c567183c190428b.zip
slirp-c9bea8b601ca124ae08787e40c567183c190428b.tar.gz
slirp-c9bea8b601ca124ae08787e40c567183c190428b.tar.bz2
slirp: handle deferred ECONNREFUSED on non-blocking TCP socketsv2.6.0-rc2
slirp currently only handles ECONNREFUSED in the case where connect() returns immediately with that error; since we use non-blocking sockets, most of the time we won't receive the error until we later try to read from the socket. Ensure that we deliver the appropriate RST to the guest in this case. Signed-off-by: Steven Luo <steven+qemu@steven676.net> Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
-rw-r--r--socket.c3
-rw-r--r--tcp_input.c6
2 files changed, 8 insertions, 1 deletions
diff --git a/socket.c b/socket.c
index ee87a77..f3b460d 100644
--- a/socket.c
+++ b/socket.c
@@ -188,7 +188,8 @@ int soread(struct socket *so)
nn, errno, strerror(errno)));
sofcantrcvmore(so);
- if (err == ECONNRESET || err == ENOTCONN || err == EPIPE) {
+ if (err == ECONNRESET || err == ECONNREFUSED || err == ENOTCONN ||
+ err == EPIPE) {
tcp_drop(sototcpcb(so), err);
} else {
tcp_sockclosed(sototcpcb(so));
diff --git a/tcp_input.c b/tcp_input.c
index 99a16ae..7ca8b2b 100644
--- a/tcp_input.c
+++ b/tcp_input.c
@@ -724,6 +724,12 @@ findso:
so->so_ti = ti;
tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT;
tp->t_state = TCPS_SYN_RECEIVED;
+ /*
+ * Initialize receive sequence numbers now so that we can send a
+ * valid RST if the remote end rejects our connection.
+ */
+ tp->irs = ti->ti_seq;
+ tcp_rcvseqinit(tp);
tcp_template(tp);
}
return;