netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wang Weidong <wangweidong1@huawei.com>
To: Daniel Borkmann <dborkman@redhat.com>
Cc: <jon.maloy@ericsson.com>, <allan.stephens@windriver.com>,
	<davem@davemloft.net>, <netdev@vger.kernel.org>,
	<tipc-discussion@lists.sourceforge.net>
Subject: Re: [PATCH net-next 1/6] tipc: add link_kfree_skbuff helper function
Date: Fri, 6 Dec 2013 17:16:50 +0800	[thread overview]
Message-ID: <52A19602.1070903@huawei.com> (raw)
In-Reply-To: <52A19433.50903@redhat.com>

On 2013/12/6 17:09, Daniel Borkmann wrote:
> On 12/06/2013 07:23 AM, Wang Weidong wrote:
>> replaces some chunks of code that kfree the sk_buff.
>> This is just code simplification, no functional changes.
>>
>> Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
>> ---
>>   net/tipc/link.c | 58 +++++++++++++++++++--------------------------------------
>>   1 file changed, 19 insertions(+), 39 deletions(-)
>>
>> diff --git a/net/tipc/link.c b/net/tipc/link.c
>> index 69cd9bf..1c27d7b 100644
>> --- a/net/tipc/link.c
>> +++ b/net/tipc/link.c
>> @@ -100,6 +100,17 @@ static unsigned int align(unsigned int i)
>>       return (i + 3) & ~3u;
>>   }
>>
>> +static void link_kfree_skbuff(struct sk_buff *buf)
>> +{
>> +    struct sk_buff *next;
>> +
>> +    while (buf) {
>> +        next = buf->next;
>> +        kfree_skb(buf);
>> +        buf = next;
>> +    }
>> +}
> 
> So kfree_skb_list() does not work for you ?
> 
> Also, in case we do not have such generic functions, they should
> go to skbuff.c instead ...
> 
No, It is work for me. I just din't not the kfree_skb_list() and I found
that use a helper function can make code more simplification. So I do that.

Regards.
Wang


>>   static void link_init_max_pkt(struct tipc_link *l_ptr)
>>   {
>>       u32 max_pkt;
>> @@ -387,13 +398,8 @@ exit:
>>   static void link_release_outqueue(struct tipc_link *l_ptr)
>>   {
>>       struct sk_buff *buf = l_ptr->first_out;
>> -    struct sk_buff *next;
>>
>> -    while (buf) {
>> -        next = buf->next;
>> -        kfree_skb(buf);
>> -        buf = next;
>> -    }
>> +    link_kfree_skbuff(buf);
>>       l_ptr->first_out = NULL;
>>       l_ptr->out_queue_size = 0;
>>   }
>> @@ -416,21 +422,12 @@ void tipc_link_reset_fragments(struct tipc_link *l_ptr)
>>   void tipc_link_stop(struct tipc_link *l_ptr)
>>   {
>>       struct sk_buff *buf;
>> -    struct sk_buff *next;
>>
>>       buf = l_ptr->oldest_deferred_in;
>> -    while (buf) {
>> -        next = buf->next;
>> -        kfree_skb(buf);
>> -        buf = next;
>> -    }
>> +    link_kfree_skbuff(buf);
>>
>>       buf = l_ptr->first_out;
>> -    while (buf) {
>> -        next = buf->next;
>> -        kfree_skb(buf);
>> -        buf = next;
>> -    }
>> +    link_kfree_skbuff(buf);
>>
>>       tipc_link_reset_fragments(l_ptr);
>>
>> @@ -472,11 +469,7 @@ void tipc_link_reset(struct tipc_link *l_ptr)
>>       kfree_skb(l_ptr->proto_msg_queue);
>>       l_ptr->proto_msg_queue = NULL;
>>       buf = l_ptr->oldest_deferred_in;
>> -    while (buf) {
>> -        struct sk_buff *next = buf->next;
>> -        kfree_skb(buf);
>> -        buf = next;
>> -    }
>> +    link_kfree_skbuff(buf);
>>       if (!list_empty(&l_ptr->waiting_ports))
>>           tipc_link_wakeup_ports(l_ptr, 1);
>>
>> @@ -1127,10 +1120,7 @@ again:
>>           if (copy_from_user(buf->data + fragm_crs, sect_crs, sz)) {
>>               res = -EFAULT;
>>   error:
>> -            for (; buf_chain; buf_chain = buf) {
>> -                buf = buf_chain->next;
>> -                kfree_skb(buf_chain);
>> -            }
>> +            link_kfree_skbuff(buf_chain);
>>               return res;
>>           }
>>           sect_crs += sz;
>> @@ -1180,18 +1170,12 @@ error:
>>           if (l_ptr->max_pkt < max_pkt) {
>>               sender->max_pkt = l_ptr->max_pkt;
>>               tipc_node_unlock(node);
>> -            for (; buf_chain; buf_chain = buf) {
>> -                buf = buf_chain->next;
>> -                kfree_skb(buf_chain);
>> -            }
>> +            link_kfree_skbuff(buf_chain);
>>               goto again;
>>           }
>>       } else {
>>   reject:
>> -        for (; buf_chain; buf_chain = buf) {
>> -            buf = buf_chain->next;
>> -            kfree_skb(buf_chain);
>> -        }
>> +        link_kfree_skbuff(buf_chain);
>>           return tipc_port_reject_sections(sender, hdr, msg_sect,
>>                            len, TIPC_ERR_NO_NODE);
>>       }
>> @@ -2306,11 +2290,7 @@ static int link_send_long_buf(struct tipc_link *l_ptr, struct sk_buff *buf)
>>           fragm = tipc_buf_acquire(fragm_sz + INT_H_SIZE);
>>           if (fragm == NULL) {
>>               kfree_skb(buf);
>> -            while (buf_chain) {
>> -                buf = buf_chain;
>> -                buf_chain = buf_chain->next;
>> -                kfree_skb(buf);
>> -            }
>> +            link_kfree_skbuff(buf_chain);
>>               return -ENOMEM;
>>           }
>>           msg_set_size(&fragm_hdr, fragm_sz + INT_H_SIZE);
>>
> 
> .
> 

  reply	other threads:[~2013-12-06  9:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-06  6:23 [PATCH net-next 0/6] tipc: do some clean ups Wang Weidong
2013-12-06  6:23 ` [PATCH net-next 1/6] tipc: add link_kfree_skbuff helper function Wang Weidong
2013-12-06  6:34   ` Ying Xue
2013-12-06  6:42     ` Wang Weidong
2013-12-06 14:13       ` Jon Maloy
2013-12-07  4:52         ` Wang Weidong
2013-12-06  6:44   ` Eric Dumazet
2013-12-06  9:09   ` Daniel Borkmann
2013-12-06  9:16     ` Wang Weidong [this message]
2013-12-06  6:23 ` [PATCH net-next 2/6] tipc: remove the unnecessary variable Wang Weidong
2013-12-06  6:23 ` [PATCH net-next 3/6] tipc: use a same goto path Wang Weidong
2013-12-06  6:23 ` [PATCH net-next 4/6] tipc: Use <linux/uaccess.h> instead of <asm/uaccess.h> Wang Weidong
2013-12-06  6:23 ` [PATCH net-next 5/6] tipc: change lock_sock order in connect() Wang Weidong
2013-12-06  6:23 ` [PATCH net-next 6/6] tipc: separate the check nseq and sseq allocate failed Wang Weidong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52A19602.1070903@huawei.com \
    --to=wangweidong1@huawei.com \
    --cc=allan.stephens@windriver.com \
    --cc=davem@davemloft.net \
    --cc=dborkman@redhat.com \
    --cc=jon.maloy@ericsson.com \
    --cc=netdev@vger.kernel.org \
    --cc=tipc-discussion@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).