Linux wireless drivers development
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Krishna Chaitanya <chaitanya.mgit@gmail.com>
Cc: linux-wireless <linux-wireless@vger.kernel.org>,
	Chaitanya Tata <chaitanya.tata@bluwireless.co.uk>
Subject: Re: [PATCH] cfg80211: Handle bss expiry during connection
Date: Fri, 26 Apr 2019 12:45:41 +0200	[thread overview]
Message-ID: <d569a6171e50a8bdb026a2ec86c78268c9d7e989.camel@sipsolutions.net> (raw)
In-Reply-To: <CABPxzYK3MuJT=r3o6UgBqv-m1B2pqCACwq+i1DDRkC2ZHExvxQ@mail.gmail.com> (sfid-20190426_123540_416400_4CABD853)

On Fri, 2019-04-26 at 16:05 +0530, Krishna Chaitanya wrote:

> > > +             /* Meanwhile if BSS is expired then add it back to the list as
> > > +              * we have just connected with it.
> > > +              */
> > > +             if (list_empty(&ibss->list))
> > > +                     cfg80211_bss_update(rdev, ibss, ibss->pub.signal);
> > 
> > But I think this adds *another* reference, which is wrong? We do need
> > one reference (the original one the driver gave us) but not a second
> > one?
> 
> This was assuming found will be false so refcnt will be reset and a fresh ref
> is taken.

Yes, it actually adds a new entry entirely, not refs the old entry. But
then you have a new entry returned from cfg80211_bss_update() with a
reference, and leak that reference in the code as written.

You probably need to unref the old one, and keep the new one to pass on
to the next function etc.

> > Maybe the copy we do in cfg80211_bss_update() isn't so bad, but then I'd
> > probably expose it without the signal_valid part and signal/timestamp
> > updates, and just copy the information raw there? However, the "if
> > (found)" part should never be possible here, right? Actually, maybe it
> > is, if we got a *new* entry in the meantime, but then we'd override the
> > newer information with the older, which is kinda bad?
> 
> If we get new information (scan during connection) the bss would not have
> expired right? so this code will not be triggered.

It could have expired and been re-added, no? Ok, I'll admit that's a
stretch since the driver is busy connecting and not scanning, but I
suppose it could happen with multiple VIFs etc?

> My initial stab was in similar lines, something like below: But as the
> bss is expired
> we need to udpate ts, signal and other fields anyway, so I went ahead
> with full update.

Why would we want to update ts, signal etc.? We just keep the old
information, and then the entry will be held for the duration of the
connection, presumably it'll get new updates while you're connected.

> +void cfg80211_add_expired_bss(struct cfg80211_registered_device *rdev,
> +                            struct cfg80211_internal_bss *new)
> +{
> +       if (!new)
> +               return;
> +
> +       spin_lock_bh(&rdev->bss_lock);
> +       new->ts = jiffies
> +       list_add_tail(&new->list, &rdev->bss_list);
> +       rdev->bss_entries++;
> +
> +       rb_insert_bss(rdev, new);
> +       rdev->bss_generation++;
> +
> +       bss_ref_get(rdev, new);
> +
> +       spin_unlock_bh(&rdev->bss_lock);
> +}

Yeah, I was thinking along those lines too, except there's a bit of an
issue with the hidden and non-transmitting lists?

johannes


  reply	other threads:[~2019-04-26 10:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-26  9:54 [PATCH] cfg80211: Handle bss expiry during connection chaitanya.mgit
2019-04-26 10:14 ` Johannes Berg
2019-04-26 10:35   ` Krishna Chaitanya
2019-04-26 10:45     ` Johannes Berg [this message]
2019-04-26 10:56       ` Krishna Chaitanya

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=d569a6171e50a8bdb026a2ec86c78268c9d7e989.camel@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=chaitanya.mgit@gmail.com \
    --cc=chaitanya.tata@bluwireless.co.uk \
    --cc=linux-wireless@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