Skip to content

Commit b3d6cb9

Browse files
edumazetdavem330
authored andcommitted
tcp: do not copy headers in tcp_collapse()
tcp_collapse() wants to shrink skb so that the overhead is minimal. Now we store tcp flags into TCP_SKB_CB(skb)->tcp_flags, we no longer need to keep around full headers. Whole available space is dedicated to the payload. 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 e93a043 commit b3d6cb9

1 file changed

Lines changed: 2 additions & 15 deletions

File tree

‎net/ipv4/tcp_input.c‎

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4535,26 +4535,13 @@ tcp_collapse(struct sock *sk, struct sk_buff_head *list,
45354535
return;
45364536

45374537
while (before(start, end)) {
4538+
int copy = min_t(int, SKB_MAX_ORDER(0, 0), end - start);
45384539
struct sk_buff *nskb;
4539-
unsigned int header = skb_headroom(skb);
4540-
int copy = SKB_MAX_ORDER(header, 0);
45414540

4542-
/* Too big header? This can happen with IPv6. */
4543-
if (copy < 0)
4544-
return;
4545-
if (end - start < copy)
4546-
copy = end - start;
4547-
nskb = alloc_skb(copy + header, GFP_ATOMIC);
4541+
nskb = alloc_skb(copy, GFP_ATOMIC);
45484542
if (!nskb)
45494543
return;
45504544

4551-
skb_set_mac_header(nskb, skb_mac_header(skb) - skb->head);
4552-
skb_set_network_header(nskb, (skb_network_header(skb) -
4553-
skb->head));
4554-
skb_set_transport_header(nskb, (skb_transport_header(skb) -
4555-
skb->head));
4556-
skb_reserve(nskb, header);
4557-
memcpy(nskb->head, skb->head, header);
45584545
memcpy(nskb->cb, skb->cb, sizeof(skb->cb));
45594546
TCP_SKB_CB(nskb)->seq = TCP_SKB_CB(nskb)->end_seq = start;
45604547
__skb_queue_before(list, skb, nskb);

0 commit comments

Comments
 (0)