[PATCH 2/3] tcp: check repair before fastopen in tcp_sendmsg
From: Andrey Vagin
Date: Fri Mar 21 2014 - 09:34:51 EST
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@xxxxxxxxxxxxx>
Cc: Alexey Kuznetsov <kuznet@xxxxxxxxxxxxx>
Cc: James Morris <jmorris@xxxxxxxxx>
Cc: Hideaki YOSHIFUJI <yoshfuji@xxxxxxxxxxxxxx>
Cc: Patrick McHardy <kaber@xxxxxxxxx>
Cc: Eric Dumazet <edumazet@xxxxxxxxxx>
Cc: Pavel Emelyanov <xemul@xxxxxxxxxxxxx>
Cc: Cyrill Gorcunov <gorcunov@xxxxxxxxxx>
Signed-off-by: Andrey Vagin <avagin@xxxxxxxxxx>
---
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/