From: Eric Dumazet <eric.dumazet@gmail.com>
To: cooldavid@cooldavid.org
Cc: David Miller <davem@davemloft.net>,
chavey@google.com, ethanhsiao@jmicron.com,
netdev@vger.kernel.org
Subject: Re: [PATCH v2.6.33 2/2] jme: Adding lock to protect vlgrp structure.
Date: Tue, 16 Mar 2010 08:40:24 +0100 [thread overview]
Message-ID: <1268725224.2824.22.camel@edumazet-laptop> (raw)
In-Reply-To: <20100316071242.M65171@cooldavid.org>
Le mardi 16 mars 2010 à 15:15 +0800, Guo-Fu Tseng a écrit :
> On Mon, 15 Mar 2010 15:53:50 -0700 (PDT), David Miller wrote
> > From: "Guo-Fu Tseng" <cooldavid@cooldavid.org>
> > Date: Tue, 16 Mar 2010 03:13:33 +0800
> >
> > > The vlan_rx_register is called through ioctl.
> > > And the packet feeding is called in the tasklet.
> > > I see no lock in register_vlan_dev(), register_vlan_device(), and vlan_ioctl_handler()
> > > which is related to the vlan_hwaccel_receive_skb(), vlan_hwaccel_rx().
> > >
> > > It prevents the vlgrp pointer be modified while trying to feed the packet.
> >
> > This is not how you fix this. Adding a new lock to your hot code
> > path of packet receiving is the last thing you should be doing.
> >
> > Instead, do what other drivers do, take down the device and bring it
> > back up again when changing the ->vlgrp pointer.
> >
> > See drivers/net/tg3.c:tg3_vlan_rx_register() for an example.
> I see. I'll work on it.
Then if driver is NAPI enabled, another possibility would be to rely on
RCU, since vgrp are already freed after a RCU grace period.
Completely untested patch, for ease of discussion
diff --git a/drivers/net/jme.c b/drivers/net/jme.c
index 0f31497..e19de8d 100644
--- a/drivers/net/jme.c
+++ b/drivers/net/jme.c
@@ -942,8 +942,10 @@ jme_alloc_and_feed_skb(struct jme_adapter *jme, int idx)
skb->ip_summed = CHECKSUM_NONE;
if (rxdesc->descwb.flags & cpu_to_le16(RXWBFLAG_TAGON)) {
- if (jme->vlgrp) {
- jme->jme_vlan_rx(skb, jme->vlgrp,
+ struct vlan_group *grp = rcu_dereference(jme->vlgrp);
+
+ if (grp) {
+ jme->jme_vlan_rx(skb, grp,
le16_to_cpu(rxdesc->descwb.vlan));
NET_STAT(jme).rx_bytes += 4;
}
prev parent reply other threads:[~2010-03-16 7:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-15 5:15 [PATCH v2.6.33 1/2] jme: Fix VLAN memory leak cooldavid
2010-03-15 5:15 ` [PATCH v2.6.33 2/2] jme: Adding lock to protect vlgrp structure cooldavid
2010-03-15 18:22 ` Laurent Chavey
2010-03-15 19:13 ` Guo-Fu Tseng
2010-03-15 22:53 ` David Miller
2010-03-16 7:15 ` Guo-Fu Tseng
2010-03-16 7:40 ` Eric Dumazet [this message]
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=1268725224.2824.22.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=chavey@google.com \
--cc=cooldavid@cooldavid.org \
--cc=davem@davemloft.net \
--cc=ethanhsiao@jmicron.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox