[CRIU] [PATCH 2/3] tcp: check repair before fastopen in tcp_sendmsg
Andrey Vagin
avagin at openvz.org
Fri Mar 21 06:33:00 PDT 2014
First of all it is logical.
And I found that sk_stream_wait_connect can be called if a socket
isn't in the TCP_ESTABLISHED state. In this case we get -EPIPE.
Cc: "David S. Miller" <davem at davemloft.net>
Cc: Alexey Kuznetsov <kuznet at ms2.inr.ac.ru>
Cc: James Morris <jmorris at namei.org>
Cc: Hideaki YOSHIFUJI <yoshfuji at linux-ipv6.org>
Cc: Patrick McHardy <kaber at trash.net>
Cc: Eric Dumazet <edumazet at google.com>
Cc: Pavel Emelyanov <xemul at parallels.com>
Cc: Cyrill Gorcunov <gorcunov at openvz.org>
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
net/ipv4/tcp.c | 33 +++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 267adb7..4cd0e87 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1084,6 +1084,23 @@ int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
lock_sock(sk);
flags = msg->msg_flags;
+
+ if (unlikely(tp->repair)) {
+ err = -EINVAL;
+ if (tp->repair_queue == TCP_NO_QUEUE)
+ goto out_err;
+
+ if (sk->sk_state != TCP_ESTABLISHED)
+ goto out_err;
+
+ if (tp->repair_queue == TCP_RECV_QUEUE) {
+ copied = tcp_send_rcvq(sk, msg, size);
+ goto out;
+ }
+
+ /* 'common' sending to sendq */
+ }
+
if (flags & MSG_FASTOPEN) {
err = tcp_sendmsg_fastopen(sk, msg, &copied_syn, size);
if (err == -EINPROGRESS && copied_syn > 0)
@@ -1105,22 +1122,6 @@ int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
goto do_error;
}
- if (unlikely(tp->repair)) {
- err = -EINVAL;
- if (tp->repair_queue == TCP_NO_QUEUE)
- goto out_err;
-
- if (sk->sk_state != TCP_ESTABLISHED)
- goto out_err;
-
- if (tp->repair_queue == TCP_RECV_QUEUE) {
- copied = tcp_send_rcvq(sk, msg, size);
- goto out;
- }
-
- /* 'common' sending to sendq */
- }
-
/* This should be in poll */
clear_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags);
--
1.8.5.3
More information about the CRIU
mailing list