Subject: Re: [PATCH 2/2] net-timestamp: Make the clone operation stand-alone from phy timestamping

From: Alexander Duyck <[email-masked]>
Date: Wed, 03 Sep 2014 14:24:00 -0700

On 09/03/2014 11:54 AM, Willem de Bruijn wrote:
> On Wed, Sep 3, 2014 at 11:53 AM, Alexander Duyck
> <[email-masked]> wrote:
>> The phy timestamping takes a different path than the regular timestamping
>> does in that it will create a clone first so that the packets needing to be
>> timestamped can be placed in a queue, or the context block could be used.
>>
>> In order to support these use cases I am pulling the core of the code out
>> so it can be used in other drivers beyond just phy devices.
> 
> Do you already have additional such use cases?

I have a driver that I am working on that I will probably push in a
couple of weeks that will make use of this interface.  I basically need
to maintain a list of SKBs as I can multiple timestamps out for
completion at the same time.

>> +struct sk_buff *__skb_clone_tx_timestamp(struct sk_buff *skb)
>> +{
>> +       struct sock *sk = skb->sk;
>> +       struct sk_buff *clone;
>> +
>> +       if (!sk || !atomic_inc_not_zero(&sk->sk_refcnt))
>> +               return NULL;
>> +
>> +       clone = skb_clone(skb, GFP_ATOMIC);
>> +       if (!clone) {
>> +               sock_put(sk);
>> +               return NULL;
>> +       }
>> +
>> +       clone->sk = sk;
>> +
>> +       return clone;
>> +}
>> +EXPORT_SYMBOL(__skb_clone_tx_timestamp);
>> +
> 
> Code looks great. Again, this can be verified to be a functional noop.
> One minor comment is that this really is not a timestamping function,
> but an skb_clone variant. skb_clone_sk?

Let me think about this one.  Between the comment Eric had about
skb->destructor and the fact that this is essentially just forking the
skb so we can hold it for the reply I might be able to come up with a
better solution.

I'm thinking it might be worthwhile to create a simple destructor as
then I could probably tear out several spots in the phy timestamping
code where it is having to use skb_complete_tx_timestamp to free the
frames that are allocated using the approach in this function.

Thanks,

Alex