Skip to content

Commit

Permalink
tcp: restore fastopen with no data in SYN packet
Browse files Browse the repository at this point in the history
Yuchung tracked a regression caused by commit 57be5bd ("ip: convert
tcp_sendmsg() to iov_iter primitives") for TCP Fast Open.

Some Fast Open users do not actually add any data in the SYN packet.

Fixes: 57be5bd ("ip: convert tcp_sendmsg() to iov_iter primitives")
Reported-by: Yuchung Cheng <ycheng@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Acked-by: Yuchung Cheng <ycheng@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and davem330 committed Dec 17, 2015
1 parent 3822b5c commit 07e100f
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions net/ipv4/tcp_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -3150,7 +3150,7 @@ static int tcp_send_syn_data(struct sock *sk, struct sk_buff *syn)
{
struct tcp_sock *tp = tcp_sk(sk);
struct tcp_fastopen_request *fo = tp->fastopen_req;
int syn_loss = 0, space, err = 0, copied;
int syn_loss = 0, space, err = 0;
unsigned long last_syn_loss = 0;
struct sk_buff *syn_data;

Expand Down Expand Up @@ -3188,17 +3188,18 @@ static int tcp_send_syn_data(struct sock *sk, struct sk_buff *syn)
goto fallback;
syn_data->ip_summed = CHECKSUM_PARTIAL;
memcpy(syn_data->cb, syn->cb, sizeof(syn->cb));
copied = copy_from_iter(skb_put(syn_data, space), space,
&fo->data->msg_iter);
if (unlikely(!copied)) {
kfree_skb(syn_data);
goto fallback;
}
if (copied != space) {
skb_trim(syn_data, copied);
space = copied;
if (space) {
int copied = copy_from_iter(skb_put(syn_data, space), space,
&fo->data->msg_iter);
if (unlikely(!copied)) {
kfree_skb(syn_data);
goto fallback;
}
if (copied != space) {
skb_trim(syn_data, copied);
space = copied;
}
}

/* No more data pending in inet_wait_for_connect() */
if (space == fo->size)
fo->data = NULL;
Expand Down

0 comments on commit 07e100f

Please sign in to comment.