netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, simon@fire.lp0.eu,
	linux-atm-general@lists.sourceforge.net, nathan@traverse.com.au
Subject: Re: [PATCH RFC] solos-pci: Fix BUG() with shared skb
Date: Wed, 04 Sep 2013 21:41:15 +0100	[thread overview]
Message-ID: <1378327275.2627.28.camel@shinybook.infradead.org> (raw)
In-Reply-To: <20130904.143056.1558570610941220565.davem@davemloft.net>

[-- Attachment #1: Type: text/plain, Size: 1591 bytes --]

On Wed, 2013-09-04 at 14:30 -0400, David Miller wrote:
> skb_realloc_headroom() should do everything you need.

Great, thanks! Something like this then... ? 

Do I really need the truesize check? And if so, is there a better way to
handle the ATM accounting? It just *happens* to be the case that the the
br2684_pop() and pppoatm_pop() functions don't mind being bypassed in
this fashion, and we should probably get away with tweaking the core ATM
accounting directly like this. Doesn't make me happy though...

diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
index 32784d1..4492c0f 100644
--- a/drivers/atm/solos-pci.c
+++ b/drivers/atm/solos-pci.c
@@ -1145,19 +1145,19 @@ static int psend(struct atm_vcc *vcc, struct sk_buff *skb)
 		return 0;
 	}
 
-	if (!skb_clone_writable(skb, sizeof(*header))) {
-		int expand_by = 0;
-		int ret;
-
-		if (skb_headroom(skb) < sizeof(*header))
-			expand_by = sizeof(*header) - skb_headroom(skb);
-
-		ret = pskb_expand_head(skb, expand_by, 0, GFP_ATOMIC);
-		if (ret) {
-			dev_warn(&card->dev->dev, "pskb_expand_head failed.\n");
-			solos_pop(vcc, skb);
-			return ret;
-		}
+	if (skb_headroom(skb) < sizeof(*header)) {
+		struct sk_buff *nskb;
+
+		nskb = skb_realloc_headroom(skb, sizeof(*header));
+		if (!nskb) {
+			solos_pop(vcc, skb);
+			return -ENOMEM;
+		}
+		if (skb->truesize != nskb->truesize)
+			atm_force_charge(vcc, nskb->truesize - skb->truesize);
+ 
+		dev_kfree_skb_any(skb);
+		skb = nskb;
 	}
 
 	header = (void *)skb_push(skb, sizeof(*header));


-- 
dwmw2


[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 5745 bytes --]

  reply	other threads:[~2013-09-04 20:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-03 15:45 [PATCH RFC] solos-pci: Fix BUG() with shared skb David Woodhouse
2013-09-04 18:30 ` David Miller
2013-09-04 20:41   ` David Woodhouse [this message]
2013-09-04 21:51     ` David Miller
2015-09-15 19:10     ` David Woodhouse
2015-09-16 11:32       ` Simon Arlott

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=1378327275.2627.28.camel@shinybook.infradead.org \
    --to=dwmw2@infradead.org \
    --cc=davem@davemloft.net \
    --cc=linux-atm-general@lists.sourceforge.net \
    --cc=nathan@traverse.com.au \
    --cc=netdev@vger.kernel.org \
    --cc=simon@fire.lp0.eu \
    /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).