From 9401af4506decfb133e0cb947dba07c1da6f3b01 Mon Sep 17 00:00:00 2001 From: Ramanathan Choodamani Date: Mon, 17 Apr 2023 21:40:55 -0700 Subject: [PATCH] hostapd: Add config support for updating bridge connections Add config support for updating bridge connections during bringup. This function will be called when all the interfaces are up. Signed-off-by: Ramanathan Choodamani --- hostapd/config_file.c | 2 ++ hostapd/main.c | 2 ++ src/ap/ap_config.h | 1 + src/ap/drv_callbacks.c | 26 ++++++++++++++++++++++++++ src/ap/hostapd.h | 1 + 5 files changed, 32 insertions(+) --- a/hostapd/config_file.c +++ b/hostapd/config_file.c @@ -4812,7 +4812,8 @@ static int hostapd_config_fill(struct ho line); return 1; } - + } else if (os_strcmp(buf, "bonded") == 0) { + bss->is_bonded_iface_enabled = true; #endif /* CONFIG_IEEE80211BE */ } else if (os_strcmp(buf, "disable_csa_dfs") == 0) { conf->disable_csa_dfs = atoi(pos); --- a/hostapd/main.c +++ b/hostapd/main.c @@ -271,6 +271,8 @@ static int hostapd_driver_init(struct ho params.own_addr = hapd->own_addr; hapd->drv_priv = hapd->driver->hapd_init(hapd, ¶ms); + if (hapd->conf->is_bonded_iface_enabled) + hostapd_mld_update_bridge_conn(hapd->conf->bridge, hapd->conf->iface); os_free(params.bridge); if (hapd->drv_priv == NULL) { wpa_printf(MSG_ERROR, "%s driver initialization failed.", --- a/src/ap/ap_config.h +++ b/src/ap/ap_config.h @@ -953,6 +953,7 @@ struct hostapd_bss_config { /* The MLD ID to which the AP MLD is affiliated with */ u8 mld_id; + bool is_bonded_iface_enabled; #endif /* CONFIG_IEEE80211BE */ enum { FILS_UBPR_USER_DISABLED, --- a/src/ap/drv_callbacks.c +++ b/src/ap/drv_callbacks.c @@ -2040,6 +2040,32 @@ err: } #endif /* CONFIG_OWE */ +int hostapd_mld_update_bridge_conn(char *brname, + char *ifname) +{ + char bonded_ifname[IFNAMSIZ + 3]; + char buf[128]; + int res = 0; + + os_snprintf(bonded_ifname, sizeof(bonded_ifname), "%s_b", ifname); + os_snprintf(buf, sizeof(buf), "brctl delif %s %s", + brname, ifname); + res = system(buf); + if (res) + return -1; + os_memset(buf, 0, sizeof(buf)); + os_snprintf(buf, sizeof(buf), "brctl addif %s %s", + brname, bonded_ifname); + res = system(buf); + os_memset(buf, 0, sizeof(buf)); + os_snprintf(buf, sizeof(buf), "ifconfig %s up", + bonded_ifname); + res = system(buf); + if (res) + return -1; + + return 0; +} void hostapd_wpa_event(void *ctx, enum wpa_event_type event, union wpa_event_data *data)