linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Christian Lamparter <chunkeey@googlemail.com>
Cc: Amit Shakya <amit.shakya@stericsson.com>,
	"John W. Linville" <linville@tuxdriver.com>,
	linux-wireless <linux-wireless@vger.kernel.org>
Subject: Re: [PATCH] mac80211: Fix PN corruption in case of multiple virtual interface
Date: Mon, 04 Feb 2013 18:30:18 +0100	[thread overview]
Message-ID: <1359999018.17993.13.camel@jlt4.sipsolutions.net> (raw)
In-Reply-To: <201302041814.11894.chunkeey@googlemail.com> (sfid-20130204_181415_037008_8DCF254D)

On Mon, 2013-02-04 at 18:14 +0100, Christian Lamparter wrote:
> On Monday, February 04, 2013 04:28:28 PM Johannes Berg wrote:
> > On Mon, 2013-02-04 at 16:48 +0530, Amit Shakya wrote:
> > > @@ -2790,7 +2791,20 @@ static void ieee80211_rx_handlers(struct ieee80211_rx_data *rx)
> > >  
> > >     rx->local->running_rx_handler = true;
> > >  
> > > -   while ((skb = __skb_dequeue(&rx->local->rx_skb_queue))) {
> > > +   skb_queue_walk_safe(&rx->local->rx_skb_queue, skb, tmp) {
> > > +           if (!skb)
> > > +                   break;
> > > +           hdr = (struct ieee80211_hdr *) skb->data;
> > > +           /*
> > > +           * Additional check to ensure that the packets corresponding
> > > +           * to same sta entry as in rx->sta are de-queued. The queue
> > > +           * can have different interface packets in case of multiple vifs
> > > +           */
> > > +           if ((rx->sta && hdr) && (ieee80211_is_data(hdr->frame_control))
> > > +                   && (memcmp(rx->sta->sta.addr, hdr->addr2, ETH_ALEN)))
> > > +                                   continue;
> > > +           __skb_unlink(skb, &rx->local->rx_skb_queue);
> > 
> > Christian, is there any reason to not just have the queue be on the
> > stack, and use a separate spinlock in the local struct to lock out the
> > unwanted concurrency?

> Let's see.
> 
> The original "AMPDU rx reorder timeout timer" had the rx_skb_queue (frames)
> on the stack. But that didn't work because the rx-path isn't thread-safe. This
> issue was addressed by "mac80211: serialize rx path workers" (24a8fda). 

It seems this actually caused the problem, because this part:

    Only one active rx handler worker [ieee80211_rx_handlers]
    is needed. All other threads which have lost the race of
    "runnning_rx_handler" can now simply "return", knowing that
    the thread who had the "edge" will also take care of their
    workload.

forgot to account for the fact that the on-stack versions of "struct
ieee80211_rx_data" can be different. Right?

> Interestingly, the RFC [1] of this patch mentioned the reason why I/we didn't
> go for a rx-path lock:
> "       1. Locking is easy to implement but hard to maintain.
>            Furthermore, Johannes worked very hard to get rid
>            of as many as possible."
> 
> > It seems to me that should work just as well, since there are never frames
> > on the rx_skb_queue for very long, right?
> Yes it should. At least we didn't find anything wrong with it back then.

But ... that doesn't necessarily mean an RX path lock, does it? 

I mean, in order to fix the above, we *do* have to make the RX
tasklet/timer wait for each other. So it's not really a big difference
between what we do now and having one of them block, is it? I guess that
they can still do all the local work, and then call the RX handlers with
the lock held? Hmm. That does kinda mean an RX path lock :-)

I guess it's the only way I see, since we can't really disable RX from
drivers when the timer starts running.

johannes



  reply	other threads:[~2013-02-04 17:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-04 11:18 [PATCH] mac80211: Fix PN corruption in case of multiple virtual interface Amit Shakya
2013-02-04 15:28 ` Johannes Berg
2013-02-04 17:14   ` Christian Lamparter
2013-02-04 17:30     ` Johannes Berg [this message]
2013-02-04 17:44       ` Christian Lamparter
2013-02-04 17:55         ` Johannes Berg
2013-02-06  5:50   ` Amit SHAKYA
2013-02-06  6:56   ` Amit SHAKYA
2013-02-06 13:33     ` Christian Lamparter
2013-02-08  7:10       ` Amit SHAKYA
2013-02-08  8:50         ` Johannes Berg
2013-02-08 15:02           ` Ben Greear
     [not found]           ` <E1U3pik-0005vi-Jv@debian64.localnet>
2013-02-08 21:36             ` [PATCH] mac80211: protect rx-path with spinlock Johannes Berg
2013-02-08 21:45               ` Christian Lamparter

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=1359999018.17993.13.camel@jlt4.sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=amit.shakya@stericsson.com \
    --cc=chunkeey@googlemail.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    /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).