On Sun, Apr 29, 2018 at 03:39:07AM +0200, Jesper Wallin wrote:
> Hi all,
> 
> I recently learned that my AP behaves badly and I have packet loss when
> the background scan is running.  I had a small chat with stsp@ about it,
> asking if there is a way to disable it.  He kindly explained that if I'm
> connected to an AP with a weak signal, it will try to find another AP
> with better signal and use that one instead.
> 
> Sadly, I only have a single AP at home and this doesn't really solve my
> problem.  Though, you can also set a desired bssid to use, to force it
> to connect to a single AP.  However, the background scan will still run
> even if this is set.
> 
> Maybe the background scan has other use-cases that I'm not aware of, if
> so, I apologize in advance.  The patch below simply check if a bssid is
> specified and if so, skip the background scan.
> 
> 
> Regards,
> Jesper Wallin

I agree, even though it would be nice to understand the underlying
packet loss issue. But I cannot reproduce the problem unforunately :(
Have you verified that the problem only happens on this particular AP?

I have two suggestions:

I don't see a need for the debug printf. It's useful for local
verification that your change works but it doesn't add useful
information during regular usage.

Also, we could check this flag before adding the ic_bgscan_timeout
in the first place, rather than checking it within the timeout handler.
There is no reason to schedule the timeout if we already know that
we're not going to switch no matter what. So I suggest you modify this
code in ieee80211_input() instead:

                if (ic->ic_state == IEEE80211_S_RUN && ic->ic_bgscan_start) {
                        /* Cancel or start background scan based on RSSI. */
                        if ((*ic->ic_node_checkrssi)(ic, ni))
                                timeout_del(&ic->ic_bgscan_timeout);
                        else if (!timeout_pending(&ic->ic_bgscan_timeout) &&
                            (ic->ic_flags & IEEE80211_F_BGSCAN) == 0)
                                timeout_add_msec(&ic->ic_bgscan_timeout,
                                    500 * (ic->ic_bgscan_fail + 1));
                }

> Index: ieee80211.c
> ===================================================================
> RCS file: /cvs/src/sys/net80211/ieee80211.c,v
> retrieving revision 1.68
> diff -u -p -r1.68 ieee80211.c
> --- ieee80211.c       28 Apr 2018 14:49:07 -0000      1.68
> +++ ieee80211.c       29 Apr 2018 00:55:43 -0000
> @@ -80,6 +80,14 @@ ieee80211_begin_bgscan(struct ifnet *ifp
>           ic->ic_state != IEEE80211_S_RUN)
>               return;
>  
> +     if (ic->ic_flags & IEEE80211_F_DESBSSID) {
> +             if (ifp->if_flags & IFF_DEBUG) {
> +                     printf("%s: skipping background scan (bssid is set)\n",
> +                         ifp->if_xname);
> +             }
> +             return;
> +     }
> +
>       if (ic->ic_bgscan_start != NULL && ic->ic_bgscan_start(ic) == 0) {
>               /*
>                * Free the nodes table to ensure we get an up-to-date view
> 

Reply via email to