public inbox for iwd@lists.linux.dev
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Subject: Re: [RFC 2/4] station: unify scan cancelation
Date: Wed, 13 Dec 2023 09:32:43 -0800	[thread overview]
Message-ID: <bd054f31-541e-46ff-adf7-0cadbfacbf15@gmail.com> (raw)
In-Reply-To: <20231213172546.145998-3-prestwoj@gmail.com>


On 12/13/23 09:25, James Prestwood wrote:
> The scan cancelation was all being done manually so group all the
> automatic-type scans into a single cancel function. This includes
> hidden, quick, owe, and periodic scans.
>
> This is being done in order to avoid scan failures after DPP
> initiates a connection. This is ultimately done through
> __station_connect_network which has no cancelation logic. This
> patch will move the scan cancelation into station_enter_state
> when the state changes to CONNECTING. All the mentioned scans will
> be canceled at that point.
>
> DBus scans were left out intentionally as they are an explicit
> type of scan rather than one that IWD starts on its own.
> ---
>   src/station.c | 96 +++++++++++++++++++++++----------------------------
>   1 file changed, 43 insertions(+), 53 deletions(-)
>
> diff --git a/src/station.c b/src/station.c
> index 10860808..95ffee05 100644
> --- a/src/station.c
> +++ b/src/station.c
> @@ -279,16 +279,8 @@ static int station_autoconnect_next(struct station *station)
>   			bss->signal_strength);
>   
>   		r = network_autoconnect(network, bss);
> -		if (!r) {
> -			if (station->quick_scan_id) {
> -				scan_cancel(netdev_get_wdev_id(station->netdev),
> -						station->quick_scan_id);
> -				station->quick_scan_id = 0;
> -				station_property_set_scanning(station, false);
> -			}
> -
> +		if (!r)
>   			return 0;
> -		}
>   
>   		l_debug("autoconnect: network_autoconnect: %s (%d)",
>   							strerror(-r), r);
> @@ -1542,6 +1534,36 @@ static void station_set_drop_unicast_l2_multicast(struct station *station,
>   
>   static void station_signal_agent_notify(struct station *station);
>   
> +static void station_cancel_scans(struct station *station)
> +{
> +	if (station->hidden_network_scan_id) {
> +		scan_cancel(netdev_get_wdev_id(station->netdev),
> +				station->hidden_network_scan_id);
> +
> +		dbus_pending_reply(&station->hidden_pending,
> +				dbus_error_failed(station->hidden_pending));
> +	}
> +
> +	if (station->quick_scan_id) {
> +		scan_cancel(netdev_get_wdev_id(station->netdev),
> +				station->quick_scan_id);
> +		station->quick_scan_id = 0;
> +		station_property_set_scanning(station, false);
> +	}
> +
> +	if (station->owe_hidden_scan_ids) {
> +		void *ptr;
> +
> +		while ((ptr = l_queue_pop_head(station->owe_hidden_scan_ids)))
> +			scan_cancel(netdev_get_wdev_id(station->netdev),
> +					L_PTR_TO_UINT(ptr));
> +
> +		l_queue_destroy(station->owe_hidden_scan_ids, NULL);
Just realized I should set this to NULL here or we could reference it 
somewhere else after its freed.
> +	}
> +
> +	periodic_scan_stop(station);
> +}
> +
>   static void station_enter_state(struct station *station,
>   						enum station_state state)
>   {
> @@ -1594,7 +1616,9 @@ static void station_enter_state(struct station *station,
>   		if (station->signal_agent)
>   			station_signal_agent_notify(station);
>   
> -		periodic_scan_stop(station);
> +		/* Scans issued during a connection will fail */
> +		station_cancel_scans(station);
> +
>   		break;
>   	case STATION_STATE_CONNECTED:
>   		l_dbus_object_add_interface(dbus,
> @@ -3539,27 +3563,15 @@ void station_connect_network(struct station *station, struct network *network,
>   	struct l_dbus *dbus = dbus_get_bus();
>   	int err;
>   
> -	/*
> -	 * If a hidden scan is not completed, station_is_busy would not
> -	 * indicate anything is going on so we need to cancel the scan and
> -	 * fail the connection now.
> -	 */
> -	if (station->hidden_network_scan_id) {
> -		scan_cancel(netdev_get_wdev_id(station->netdev),
> -				station->hidden_network_scan_id);
> -
> -		dbus_pending_reply(&station->hidden_pending,
> -				dbus_error_failed(station->hidden_pending));
> -	}
> -
> -	if (station->quick_scan_id) {
> -		scan_cancel(netdev_get_wdev_id(station->netdev),
> -				station->quick_scan_id);
> -		station->quick_scan_id = 0;
> -		station_property_set_scanning(station, false);
> -	}
> -
>   	if (station_is_busy(station)) {
> +		/*
> +		 * All scans will be canceled when entering into a connecting
> +		 * state but since we have an async disconnect callback cancel
> +		 * them early so we don't potentially trigger a scan in the
> +		 * middle of connecting. This also takes care of failing any
> +		 * hidden network connection
> +		 */
> +		station_cancel_scans(station);
>   		station_disconnect_onconnect(station, network, bss, message);
>   
>   		return;
> @@ -4539,8 +4551,6 @@ static void station_free(struct station *station)
>   		station->netconfig = NULL;
>   	}
>   
> -	periodic_scan_stop(station);
> -
>   	if (station->signal_agent) {
>   		station_signal_agent_release(station->signal_agent,
>   					netdev_get_path(station->netdev));
> @@ -4551,10 +4561,6 @@ static void station_free(struct station *station)
>   		dbus_pending_reply(&station->connect_pending,
>   				dbus_error_aborted(station->connect_pending));
>   
> -	if (station->hidden_pending)
> -		dbus_pending_reply(&station->hidden_pending,
> -				dbus_error_aborted(station->hidden_pending));
> -
>   	if (station->disconnect_pending)
>   		dbus_pending_reply(&station->disconnect_pending,
>   			dbus_error_aborted(station->disconnect_pending));
> @@ -4567,23 +4573,7 @@ static void station_free(struct station *station)
>   		scan_cancel(netdev_get_wdev_id(station->netdev),
>   				station->dbus_scan_id);
>   
> -	if (station->quick_scan_id)
> -		scan_cancel(netdev_get_wdev_id(station->netdev),
> -				station->quick_scan_id);
> -
> -	if (station->hidden_network_scan_id)
> -		scan_cancel(netdev_get_wdev_id(station->netdev),
> -				station->hidden_network_scan_id);
> -
> -	if (station->owe_hidden_scan_ids) {
> -		void *ptr;
> -
> -		while ((ptr = l_queue_pop_head(station->owe_hidden_scan_ids)))
> -			scan_cancel(netdev_get_wdev_id(station->netdev),
> -					L_PTR_TO_UINT(ptr));
> -
> -		l_queue_destroy(station->owe_hidden_scan_ids, NULL);
> -	}
> +	station_cancel_scans(station);
>   
>   	station_roam_state_clear(station);
>   

  reply	other threads:[~2023-12-13 17:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-13 17:25 [RFC 0/4] Fix extra settings not being taken post-DPP James Prestwood
2023-12-13 17:25 ` [RFC 1/4] knownnetworks: set ops on info in __network_info_init James Prestwood
2023-12-13 17:25 ` [RFC 2/4] station: unify scan cancelation James Prestwood
2023-12-13 17:32   ` James Prestwood [this message]
2023-12-13 17:25 ` [RFC 3/4] dpp: fix non-scan connect path in DPP James Prestwood
2023-12-13 17:25 ` [RFC 4/4] auto-t: add a few more DPP tests for seen/known networks James Prestwood
2023-12-13 22:59 ` [RFC 0/4] Fix extra settings not being taken post-DPP Denis Kenzior

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=bd054f31-541e-46ff-adf7-0cadbfacbf15@gmail.com \
    --to=prestwoj@gmail.com \
    --cc=iwd@lists.linux.dev \
    /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