diff mbox series

[7/7] netdev: Simplify FILS handling in netdev_connect_common

Message ID 20240805140721.57518-7-denkenz@gmail.com (mailing list archive)
State New
Headers show
Series [1/7] monitor: Decode RMNet Mux Identifier | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-ci-gitlint success GitLint

Commit Message

Denis Kenzior Aug. 5, 2024, 2:07 p.m. UTC
---
 src/netdev.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

Comments

James Prestwood Aug. 5, 2024, 2:21 p.m. UTC | #1
Hi Denis,

On 8/5/24 7:07 AM, Denis Kenzior wrote:
> ---
>   src/netdev.c | 18 +++++++++---------
>   1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/src/netdev.c b/src/netdev.c
> index fb095fdca561..494e46a59de2 100644
> --- a/src/netdev.c
> +++ b/src/netdev.c
> @@ -3833,6 +3833,14 @@ static void netdev_connect_common(struct netdev *netdev,
>   		goto build_cmd_connect;
>   	}
>   
> +	if (IE_AKM_IS_FILS(hs->akm_suite)) {
> +		netdev->ap = fils_sm_new(hs, netdev_fils_tx_authenticate,
> +						netdev_fils_tx_associate,
> +						netdev_get_oci,
> +						netdev);
> +		goto done;
> +	}
> +
>   	if (nhs->type != CONNECTION_TYPE_SOFTMAC)
>   		goto build_cmd_connect;
>   
> @@ -3855,15 +3863,6 @@ static void netdev_connect_common(struct netdev *netdev,
>   		}
>   
>   		break;
> -	case IE_RSN_AKM_SUITE_FILS_SHA256:
> -	case IE_RSN_AKM_SUITE_FILS_SHA384:
> -	case IE_RSN_AKM_SUITE_FT_OVER_FILS_SHA256:
> -	case IE_RSN_AKM_SUITE_FT_OVER_FILS_SHA384:
> -		netdev->ap = fils_sm_new(hs, netdev_fils_tx_authenticate,
> -						netdev_fils_tx_associate,
> -						netdev_get_oci,
> -						netdev);
> -		break;
>   	default:
>   build_cmd_connect:
>   		cmd_connect = netdev_build_cmd_connect(netdev, hs, prev_bssid);
> @@ -3876,6 +3875,7 @@ build_cmd_connect:
>   		}
>   	}
>   
> +done:
>   	netdev->connect_cmd = cmd_connect;
>   	netdev->event_filter = event_filter;
>   	netdev->connect_cb = cb;

Mostly just an observation, but the switch block is pretty much just 
checks for SAE now, and the default build_cmd_connect case. It may look 
nicer to just have if/else if's for:

IE_AKM_IS_FILS()
IE_AKM_IS_OWE()
IE_AKM_IS_SAE()

But I'm also fine leaving it how you have it.
Denis Kenzior Aug. 5, 2024, 2:34 p.m. UTC | #2
Hi James,

> 
> Mostly just an observation, but the switch block is pretty much just checks for 
> SAE now, and the default build_cmd_connect case. It may look nicer to just have 
> if/else if's for:
> 
> IE_AKM_IS_FILS()
> IE_AKM_IS_OWE()
> IE_AKM_IS_SAE()

Totally agreed.  I have taken out the switch in my pending patchset, but wanted 
to get the easy stuff out of the way first :)

Reminds me we should add IE_AKM_IS_PSK() as well.

Regards,
-Denis
diff mbox series

Patch

diff --git a/src/netdev.c b/src/netdev.c
index fb095fdca561..494e46a59de2 100644
--- a/src/netdev.c
+++ b/src/netdev.c
@@ -3833,6 +3833,14 @@  static void netdev_connect_common(struct netdev *netdev,
 		goto build_cmd_connect;
 	}
 
+	if (IE_AKM_IS_FILS(hs->akm_suite)) {
+		netdev->ap = fils_sm_new(hs, netdev_fils_tx_authenticate,
+						netdev_fils_tx_associate,
+						netdev_get_oci,
+						netdev);
+		goto done;
+	}
+
 	if (nhs->type != CONNECTION_TYPE_SOFTMAC)
 		goto build_cmd_connect;
 
@@ -3855,15 +3863,6 @@  static void netdev_connect_common(struct netdev *netdev,
 		}
 
 		break;
-	case IE_RSN_AKM_SUITE_FILS_SHA256:
-	case IE_RSN_AKM_SUITE_FILS_SHA384:
-	case IE_RSN_AKM_SUITE_FT_OVER_FILS_SHA256:
-	case IE_RSN_AKM_SUITE_FT_OVER_FILS_SHA384:
-		netdev->ap = fils_sm_new(hs, netdev_fils_tx_authenticate,
-						netdev_fils_tx_associate,
-						netdev_get_oci,
-						netdev);
-		break;
 	default:
 build_cmd_connect:
 		cmd_connect = netdev_build_cmd_connect(netdev, hs, prev_bssid);
@@ -3876,6 +3875,7 @@  build_cmd_connect:
 		}
 	}
 
+done:
 	netdev->connect_cmd = cmd_connect;
 	netdev->event_filter = event_filter;
 	netdev->connect_cb = cb;