wpa_supplicant: Add option to explicitly set 4addr mode

Add a new network profile option enable_4addr_mode=1 that puts an
interface in 4addr mode, for interfaces meant to be added to a bridge.

Signed-off-by: Konstantinos Natsakis <infradead.org@aleph-0.net>
This commit is contained in:
Konstantinos Natsakis 2023-02-01 02:16:18 +02:00 committed by Jouni Malinen
parent 1ffc7d1c65
commit 8085a7e656
4 changed files with 37 additions and 5 deletions

View file

@ -2710,6 +2710,7 @@ static const struct parse_data ssid_fields[] = {
{ INT_RANGE(transition_disable, 0, 255) },
{ INT_RANGE(sae_pk, 0, 2) },
{ INT_RANGE(disable_eht, 0, 1)},
{ INT_RANGE(enable_4addr_mode, 0, 1)},
};
#undef OFFSET

View file

@ -890,6 +890,7 @@ static void wpa_config_write_network(FILE *f, struct wpa_ssid *ssid)
INT(disable_he);
#endif /* CONFIG_HE_OVERRIDES */
INT(disable_eht);
INT(enable_4addr_mode);
#undef STR
#undef INT

View file

@ -1240,6 +1240,17 @@ struct wpa_ssid {
* to 1 to have it disabled.
*/
int disable_eht;
/**
* enable_4addr_mode - Set 4addr mode after association
* 0 = Do not attempt to set 4addr mode
* 1 = Try to set 4addr mode after association
*
* Linux requires that an interface is set to 4addr mode before it can
* be added to a bridge. Set this to 1 for networks where you intent
* to use the interface in a bridge.
*/
int enable_4addr_mode;
};
#endif /* CONFIG_SSID_H */

View file

@ -2705,6 +2705,26 @@ static void interworking_process_assoc_resp(struct wpa_supplicant *wpa_s,
#endif /* CONFIG_INTERWORKING */
static void wpa_supplicant_set_4addr_mode(struct wpa_supplicant *wpa_s)
{
if (wpa_s->enabled_4addr_mode) {
wpa_printf(MSG_DEBUG, "4addr mode already set");
return;
}
if (wpa_drv_set_4addr_mode(wpa_s, 1) < 0) {
wpa_msg(wpa_s, MSG_ERROR, "Failed to set 4addr mode");
goto fail;
}
wpa_s->enabled_4addr_mode = 1;
wpa_msg(wpa_s, MSG_INFO, "Successfully set 4addr mode");
return;
fail:
wpa_supplicant_deauthenticate(wpa_s, WLAN_REASON_DEAUTH_LEAVING);
}
static void multi_ap_process_assoc_resp(struct wpa_supplicant *wpa_s,
const u8 *ies, size_t ies_len)
{
@ -2757,11 +2777,7 @@ static void multi_ap_set_4addr_mode(struct wpa_supplicant *wpa_s)
goto fail;
}
if (wpa_drv_set_4addr_mode(wpa_s, 1) < 0) {
wpa_printf(MSG_ERROR, "Failed to set 4addr mode");
goto fail;
}
wpa_s->enabled_4addr_mode = 1;
wpa_supplicant_set_4addr_mode(wpa_s);
return;
fail:
@ -3849,6 +3865,9 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
#ifdef CONFIG_DPP2
wpa_s->dpp_pfs_fallback = 0;
#endif /* CONFIG_DPP2 */
if (wpa_s->current_ssid && wpa_s->current_ssid->enable_4addr_mode)
wpa_supplicant_set_4addr_mode(wpa_s);
}