Skip to content

Commit 466d18d

Browse files
krish2718nashif
authored andcommitted
net: l2: wifi_shell: Fix MFPR handling
When protocol says MFP is required for WPA3, no point in asking user and then validating. Signed-off-by: Chaitanya Tata <[email protected]>
1 parent 7cbcd1d commit 466d18d

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

subsys/net/l2/wifi/wifi_shell.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,14 @@ static int __wifi_args_to_params(const struct shell *sh, size_t argc, char *argv
667667
if (params->security) {
668668
secure_connection = true;
669669
}
670+
/* WPA3 security types (SAE) require MFP (802.11w) as required,
671+
* if not otherwise set.
672+
*/
673+
if (params->security == WIFI_SECURITY_TYPE_SAE_HNP ||
674+
params->security == WIFI_SECURITY_TYPE_SAE_H2E ||
675+
params->security == WIFI_SECURITY_TYPE_SAE_AUTO) {
676+
params->mfp = WIFI_MFP_REQUIRED;
677+
}
670678
break;
671679
case 'p':
672680
params->psk = state->optarg;
@@ -812,6 +820,9 @@ static int __wifi_args_to_params(const struct shell *sh, size_t argc, char *argv
812820
break;
813821
case 'S':
814822
params->wpa3_ent_mode = atoi(state->optarg);
823+
if (params->wpa3_ent_mode != WIFI_WPA3_ENTERPRISE_NA) {
824+
params->mfp = WIFI_MFP_REQUIRED;
825+
}
815826
break;
816827
case 'T':
817828
params->TLS_cipher = atoi(state->optarg);
@@ -905,16 +916,6 @@ static int __wifi_args_to_params(const struct shell *sh, size_t argc, char *argv
905916
return -EINVAL;
906917
}
907918

908-
if (params->security == WIFI_SECURITY_TYPE_SAE_HNP
909-
|| params->security == WIFI_SECURITY_TYPE_SAE_H2E
910-
|| params->security == WIFI_SECURITY_TYPE_SAE_AUTO
911-
|| params->wpa3_ent_mode != WIFI_WPA3_ENTERPRISE_NA) {
912-
if (params->mfp != WIFI_MFP_REQUIRED) {
913-
PR_ERROR("MFP is required for WPA3 mode\n");
914-
return -EINVAL;
915-
}
916-
}
917-
918919
if (iface_mode == WIFI_MODE_AP && params->channel == WIFI_CHANNEL_ANY) {
919920
PR_ERROR("Channel not provided\n");
920921
return -EINVAL;

0 commit comments

Comments
 (0)