All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hideo AOKI <haoki@redhat.com>
To: netdev <netdev@vger.kernel.org>,
	David Miller <davem@davemloft.net>,
	Herbert Xu <herbert@gondor.apana.org.au>
Subject: [RFC PATCH] [NET] [2/2] pskb_expand_head() updates truesize
Date: Tue, 25 Mar 2008 14:41:51 -0400	[thread overview]
Message-ID: <47E9476F.9000502@redhat.com> (raw)
In-Reply-To: <47E946C8.6020006@redhat.com>

This patch revises pskb_expand_head() to update truesize.

Applying this change, caller functions don't have to update truesize
by themselves. Moreover, skb can keep correct truesize even if
allocation size is aligned in pskb_expand_head().  

This patch also removes updating truesize in callers since the update
doesn't need anymore.

[Note: Updating truesize in audit_expand() is fixed by anther patch.]

Signed-off-by: Hideo Aoki <haoki@redhat.com>
---

 core/skbuff.c        |    6 ++++++
 ipv4/ipcomp.c        |    1 -
 ipv6/ipcomp6.c       |    1 -
 netlink/af_netlink.c |    3 +--
 4 files changed, 7 insertions(+), 4 deletions(-)

diff -pruN net-2.6-mod-p1/net/core/skbuff.c net-2.6-mod-p2/net/core/skbuff.c
--- net-2.6-mod-p1/net/core/skbuff.c	2008-02-25 09:05:46.000000000 -0500
+++ net-2.6-mod-p2/net/core/skbuff.c	2008-03-24 14:22:55.000000000 -0400
@@ -701,6 +701,12 @@ int pskb_expand_head(struct sk_buff *skb
 
 	skb_release_data(skb);
 
+#ifdef NET_SKBUFF_DATA_USES_OFFSET
+	skb->truesize += (size - skb->end);
+#else
+	skb->truesize += (size - (skb->end - skb->head));
+#endif
+
 	off = (data + nhead) - skb->head;
 
 	skb->head     = data;
diff -pruN net-2.6-mod-p1/net/ipv4/ipcomp.c net-2.6-mod-p2/net/ipv4/ipcomp.c
--- net-2.6-mod-p1/net/ipv4/ipcomp.c	2008-03-05 05:12:30.000000000 -0500
+++ net-2.6-mod-p2/net/ipv4/ipcomp.c	2008-03-24 14:25:47.000000000 -0400
@@ -64,7 +64,6 @@ static int ipcomp_decompress(struct xfrm
 	if (err)
 		goto out;
 
-	skb->truesize += dlen - plen;
 	__skb_put(skb, dlen - plen);
 	skb_copy_to_linear_data(skb, scratch, dlen);
 out:
diff -pruN net-2.6-mod-p1/net/ipv6/ipcomp6.c net-2.6-mod-p2/net/ipv6/ipcomp6.c
--- net-2.6-mod-p1/net/ipv6/ipcomp6.c	2008-03-05 05:12:30.000000000 -0500
+++ net-2.6-mod-p2/net/ipv6/ipcomp6.c	2008-03-24 14:22:55.000000000 -0400
@@ -108,7 +108,6 @@ static int ipcomp6_input(struct xfrm_sta
 		goto out_put_cpu;
 	}
 
-	skb->truesize += dlen - plen;
 	__skb_put(skb, dlen - plen);
 	skb_copy_to_linear_data(skb, scratch, dlen);
 	err = nexthdr;
diff -pruN net-2.6-mod-p1/net/netlink/af_netlink.c net-2.6-mod-p2/net/netlink/af_netlink.c
--- net-2.6-mod-p1/net/netlink/af_netlink.c	2008-02-05 12:00:28.000000000 -0500
+++ net-2.6-mod-p2/net/netlink/af_netlink.c	2008-03-24 14:22:55.000000000 -0400
@@ -835,8 +835,7 @@ static inline struct sk_buff *netlink_tr
 		skb = nskb;
 	}
 
-	if (!pskb_expand_head(skb, 0, -delta, allocation))
-		skb->truesize -= delta;
+	pskb_expand_head(skb, 0, -delta, allocation);
 
 	return skb;
 }
-- 
Hitachi Computer Products (America) Inc.



  parent reply	other threads:[~2008-03-25 18:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-25 18:39 [RFC] [NET] [0/2] pskb_expand_head() bugfix Hideo AOKI
2008-03-25 18:41 ` [RFC PATCH] [NET] [1/2] revert audit_expand() Hideo AOKI
2008-03-25 18:41 ` Hideo AOKI [this message]
2008-03-25 23:55 ` [RFC] [NET] [0/2] pskb_expand_head() bugfix Herbert Xu
2008-03-26 20:47   ` Hideo AOKI
2008-03-27  0:13     ` Herbert Xu
2008-03-29  1:01       ` Hideo AOKI
2008-03-27 23:49     ` David Miller
2008-03-29  1:14       ` Hideo AOKI
2008-03-27 23:48 ` David Miller
2008-03-29  1:02   ` Hideo AOKI
2008-03-29  1:11     ` David Miller
2008-03-29  1:21       ` Hideo AOKI

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=47E9476F.9000502@redhat.com \
    --to=haoki@redhat.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=netdev@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.