[Qemu-devel] [PULL 4/4] slirp: handle deferred ECONNREFUSED on non-blocking TCP sockets
From: Steven Luoslirp 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 Reviewed-by: Edgar E. Iglesias Signed-off-by: Samuel Thibault --- slirp/socket.c| 2 +- slirp/tcp_input.c | 6 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/slirp/socket.c b/slirp/socket.c index 0d67b12..bd97b2d 100644 --- a/slirp/socket.c +++ b/slirp/socket.c @@ -188,7 +188,7 @@ soread(struct socket *so) DEBUG_MISC((dfd, " --- soread() disconnected, nn = %d, errno = %d-%s\n", nn, errno,strerror(errno))); sofcantrcvmore(so); - if (err == ECONNRESET + if (err == ECONNRESET || err == ECONNREFUSED || err == ENOTCONN || err == EPIPE) { tcp_drop(sototcpcb(so), err); } else { diff --git a/slirp/tcp_input.c b/slirp/tcp_input.c index 1fcca30..5433e7f 100644 --- a/slirp/tcp_input.c +++ b/slirp/tcp_input.c @@ -725,6 +725,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; -- 2.8.0.rc3
[Qemu-devel] [PULL 4/4] slirp: handle deferred ECONNREFUSED on non-blocking TCP sockets
From: Steven Luoslirp 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 Reviewed-by: Edgar E. Iglesias Signed-off-by: Samuel Thibault --- slirp/socket.c| 2 +- slirp/tcp_input.c | 6 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/slirp/socket.c b/slirp/socket.c index 0d67b12..bd97b2d 100644 --- a/slirp/socket.c +++ b/slirp/socket.c @@ -188,7 +188,7 @@ soread(struct socket *so) DEBUG_MISC((dfd, " --- soread() disconnected, nn = %d, errno = %d-%s\n", nn, errno,strerror(errno))); sofcantrcvmore(so); - if (err == ECONNRESET + if (err == ECONNRESET || err == ECONNREFUSED || err == ENOTCONN || err == EPIPE) { tcp_drop(sototcpcb(so), err); } else { diff --git a/slirp/tcp_input.c b/slirp/tcp_input.c index 1fcca30..5433e7f 100644 --- a/slirp/tcp_input.c +++ b/slirp/tcp_input.c @@ -725,6 +725,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; -- 2.8.0.rc3