Skip to content

Commit

Permalink
tcp: do not fake tcp headers in tcp_send_rcvq()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Sep 19, 2014
1 parent 3ff6425 commit cb93471
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions net/ipv4/tcp_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -4304,32 +4304,27 @@ static int __must_check tcp_queue_rcv(struct sock *sk, struct sk_buff *skb, int

int tcp_send_rcvq(struct sock *sk, struct msghdr *msg, size_t size)
{
struct sk_buff *skb = NULL;
struct tcphdr *th;
struct sk_buff *skb;
bool fragstolen;

if (size == 0)
return 0;

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

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

th = (struct tcphdr *)skb_put(skb, sizeof(*th));
skb_reset_transport_header(skb);
memset(th, 0, sizeof(*th));

if (memcpy_fromiovec(skb_put(skb, size), msg->msg_iov, size))
goto err_free;

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

if (tcp_queue_rcv(sk, skb, sizeof(*th), &fragstolen)) {
if (tcp_queue_rcv(sk, skb, 0, &fragstolen)) {
WARN_ON_ONCE(fragstolen); /* should not happen */
__kfree_skb(skb);
}
Expand Down

0 comments on commit cb93471

Please sign in to comment.