Re: [PATCH net-next] tcp: avoid expensive pskb_expand_head() calls

Eric Dumazet
2012-04-18T19:18:36Z

On Wed, 2012-04-18 at 14:40 -0400, Neal Cardwell wrote:

>
> > + prev_packets_acked = tcp_skb_pcount(skb);
>
> FWIW, I'd find old_pcount or prev_pcount a little easier to read than
> prev_packets_acked here (I see "oldpcount" is used in tcp_output
> in a similar context).
>

You're right, I'll change this.

> > TCP_SKB_CB(skb)->seq += len;
> > + TCP_SKB_CB(skb)->header.offset_ack = 0;
>
> If the caller decides to trim a prefix of the skb that does not extend
> to snd_una, then setting offset_ack to 0 here will cause us to forget
> that some prefix is ACKed when we should have remembered this.
> However, the API for the function invites the caller to chop off an
> arbitrary amount (and there's no comment to disuade the caller from
> trying this). This seems to risk bugs in the future.
>
> To attempt to make this API safer and simpler for future generations,
> what do you think about calculating the len inside tcp_trim_head(),
> something like:
>
> static int tcp_trim_head(struct sock *sk, struct sk_buff *skb)
> {
> u32 len = tp->snd_una - TCP_SKB_CB(skb)->seq;
> ...
>
> ...
> if (tcp_trim_head(sk, skb))
> ...
>

Very good point, I'll use this suggestion too in v2.

Thanks !