Skip to content

Commit cb93471

Browse files
edumazetdavem330
authored andcommitted
tcp: do not fake tcp headers in tcp_send_rcvq()
Now we no longer rely on having tcp headers for skbs in receive queue, tcp repair do not need to build fake ones. Signed-off-by: Eric Dumazet <edumazet@google.com> Acked-by: Neal Cardwell <ncardwell@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3ff6425 commit cb93471

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

‎net/ipv4/tcp_input.c‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4304,32 +4304,27 @@ static int __must_check tcp_queue_rcv(struct sock *sk, struct sk_buff *skb, int
43044304

43054305
int tcp_send_rcvq(struct sock *sk, struct msghdr *msg, size_t size)
43064306
{
4307-
struct sk_buff *skb = NULL;
4308-
struct tcphdr *th;
4307+
struct sk_buff *skb;
43094308
bool fragstolen;
43104309

43114310
if (size == 0)
43124311
return 0;
43134312

4314-
skb = alloc_skb(size + sizeof(*th), sk->sk_allocation);
4313+
skb = alloc_skb(size, sk->sk_allocation);
43154314
if (!skb)
43164315
goto err;
43174316

4318-
if (tcp_try_rmem_schedule(sk, skb, size + sizeof(*th)))
4317+
if (tcp_try_rmem_schedule(sk, skb, skb->truesize))
43194318
goto err_free;
43204319

4321-
th = (struct tcphdr *)skb_put(skb, sizeof(*th));
4322-
skb_reset_transport_header(skb);
4323-
memset(th, 0, sizeof(*th));
4324-
43254320
if (memcpy_fromiovec(skb_put(skb, size), msg->msg_iov, size))
43264321
goto err_free;
43274322

43284323
TCP_SKB_CB(skb)->seq = tcp_sk(sk)->rcv_nxt;
43294324
TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(skb)->seq + size;
43304325
TCP_SKB_CB(skb)->ack_seq = tcp_sk(sk)->snd_una - 1;
43314326

4332-
if (tcp_queue_rcv(sk, skb, sizeof(*th), &fragstolen)) {
4327+
if (tcp_queue_rcv(sk, skb, 0, &fragstolen)) {
43334328
WARN_ON_ONCE(fragstolen); /* should not happen */
43344329
__kfree_skb(skb);
43354330
}

0 commit comments

Comments
 (0)