lkml.org 
[lkml]   [2008]   [May]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] netfilter: use krealloc() in nf_conntrack_extend.c V2
Pekka J Enberg wrote:
> The ksize() API is going away because it is being abused and it doesn't even
> work consistenly across different allocators. Therefore, convert
> net/netfilter/nf_conntrack_extend.c to use krealloc().
>
> Cc: <netfilter-devel@vger.kernel.org>
> Cc: <netdev@vger.kernel.org>
> Cc: Matt Mackall <mpm@selenic.com>
> Cc: Christoph Lameter <clameter@sgi.com>
> Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
> ---
> Patrick, please use this patch instead. The previous one did the moving
> unconditionally which is wrong. This one moves entries around only if
> krealloc() allocated a new buffer.
>
> net/netfilter/nf_conntrack_extend.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> Index: slab-2.6/net/netfilter/nf_conntrack_extend.c
> ===================================================================
> --- slab-2.6.orig/net/netfilter/nf_conntrack_extend.c 2008-05-22 21:52:12.000000000 +0300
> +++ slab-2.6/net/netfilter/nf_conntrack_extend.c 2008-05-22 21:52:26.000000000 +0300
> @@ -88,13 +88,11 @@
> newlen = newoff + t->len;
> rcu_read_unlock();
>
> - if (newlen >= ksize(ct->ext)) {
> - new = kmalloc(newlen, gfp);
> - if (!new)
> - return NULL;
> -
> - memcpy(new, ct->ext, ct->ext->len);
> + new = krealloc(ct->ext, newlen, gfp);

Unfortunately this means we'll always have to reallocate, even
if there's still some room left from the previous allocation.
Any chance to avoid that?



\
 
 \ /
  Last update: 2008-05-22 21:11    [W:0.046 / U:1.812 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site