lkml.org 
[lkml]   [2020]   [Aug]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH] net: eliminate meaningless memcpy to data in pskb_carve_inside_nonlinear()
From
Date


On 8/10/20 5:28 AM, Miaohe Lin wrote:
> The skb_shared_info part of the data is assigned in the following loop. It
> is meaningless to do a memcpy here.
>
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
> net/core/skbuff.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 7e2e502ef519..5b983c9472f5 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -5952,9 +5952,6 @@ static int pskb_carve_inside_nonlinear(struct sk_buff *skb, const u32 off,
>
> size = SKB_WITH_OVERHEAD(ksize(data));
>
> - memcpy((struct skb_shared_info *)(data + size),
> - skb_shinfo(skb), offsetof(struct skb_shared_info,
> - frags[skb_shinfo(skb)->nr_frags]));
> if (skb_orphan_frags(skb, gfp_mask)) {
> kfree(data);
> return -ENOMEM;
>

Reminder : net-next is CLOSED.

This is not correct. We still have to copy _something_

Something like :

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 2828f6d5ba898a5e50ccce45589bf1370e474b0f..1c0519426c7ba4b04377fc8054c4223c135879ab 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -5953,8 +5953,8 @@ static int pskb_carve_inside_nonlinear(struct sk_buff *skb, const u32 off,
size = SKB_WITH_OVERHEAD(ksize(data));

memcpy((struct skb_shared_info *)(data + size),
- skb_shinfo(skb), offsetof(struct skb_shared_info,
- frags[skb_shinfo(skb)->nr_frags]));
+ skb_shinfo(skb), offsetof(struct skb_shared_info, frags[0]));
+
if (skb_orphan_frags(skb, gfp_mask)) {
kfree(data);
return -ENOMEM;
\
 
 \ /
  Last update: 2020-08-10 17:07    [W:0.630 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site