diff --git a/src/agent.c b/src/agent.c index 33ac8272b3c49666306fb4af73e8ac5ec15f5505..314087dcc142ede0fac0c0528ee11ed081432e47 100644 --- a/src/agent.c +++ b/src/agent.c @@ -2604,6 +2604,16 @@ out_str: } } +static void apply_iface_assocation_mode(struct agent *a, const char *ifname) +{ + struct netif_ap *iface = get_netif_by_name(a, ifname); + + if (iface) { + wifi_set_backhaul_bss_association_mode(ifname, + iface->cfg->disallow_assoc); + } +} + static void wifi_iface_event_handler(void *c, struct blob_attr *msg) { struct agent *a = (struct agent *)c; @@ -2649,6 +2659,8 @@ static void wifi_iface_event_handler(void *c, struct blob_attr *msg) * BTM, WNM, ANQP */ wifi_parse_all_frame(a, ifname, data); + } else if (!strcmp(event, "bss-up")) { + apply_iface_assocation_mode(a, ifname); } out_json: diff --git a/src/agent_map.c b/src/agent_map.c index 145aaf8f4c8a92f3c32f2f526c97c338f2d4a173..644f9f9ce12989b4b5a8e41166c75ced08ab1e0d 100644 --- a/src/agent_map.c +++ b/src/agent_map.c @@ -3968,20 +3968,22 @@ int agent_process_assoc_cntl_tlv(void *agent, uint8_t *p, ret = -1; } - // If bssid is backhaul BSS and STA addr. is ff:ff:ff:ff:ff:ff - // block/unblock associations for all macs. - if (!ret && (fh->cfg->multi_ap & 0x01) && data->num_sta == 1 && + /* If bssid is backhaul BSS and STA addr. is ff:ff:ff:ff:ff:ff + * block/unblock associations for all macs. + */ + if (!ret && (ap->cfg->multi_ap & 0x01) && data->num_sta == 1 && hwaddr_is_bcast(data->sta[0].macaddr)) { - bool allow = true; + bool disallow = false; if (data->control == ASSOC_CTRL_BLOCK) - allow = false; + disallow = true; trace("%s: %s assoc. for bBSS: " MACFMT " [%s]\n", - __func__, allow ? "Allow" : "Disallow", MAC2STR(data->bssid), fh->name); - - ret = wifi_set_backhaul_bss_association_mode(fh->name, allow); + __func__, disallow ? "Disallow" : "Allow", MAC2STR(data->bssid), ap->name); + ret = wifi_set_backhaul_bss_association_mode(ap->name, disallow); + if (!ret) + ap->cfg->disallow_assoc = disallow; return ret; } diff --git a/src/config.h b/src/config.h index 4c15749ff4e237297b4e33139812e306e680bcf4..2cb7c6840e201e4d614ff83d0a3b36dfbe8c52a6 100644 --- a/src/config.h +++ b/src/config.h @@ -110,7 +110,8 @@ struct netif_apcfg { struct list_head list; /* link to next netif_config */ uint8_t multi_ap; /* BSS type, 0x01: backhaul, 0x02: fronthaul, 0x03: combined */ unsigned int vid; /* traffic separation vlan id */ - uint8_t bsta_disallow; /*this option 1 p1 2 p2 3 both disallow*/ + uint8_t bsta_disallow; /* this option 1 p1 2 p2 3 both disallow */ + bool disallow_assoc; /* if true all associations disallowed */ }; struct netif_bkcfg { diff --git a/src/wifi.c b/src/wifi.c index 9d1b4ce52170c7625523dbc5c49bafe3f61b12fa..cdfd1819adb677333efc3d91f448e2ef30b53992 100644 --- a/src/wifi.c +++ b/src/wifi.c @@ -385,12 +385,12 @@ int wifi_ap_stats(const char *ifname, struct wifi_ap_stats *stats) return ret; } -int wifi_set_backhaul_bss_association_mode(const char *ifname, bool allow) +int wifi_set_backhaul_bss_association_mode(const char *ifname, bool disallow) { struct ubus_context *ctx = ubus_connect(NULL); int ret; - ret = wifi_ubus_ap_mbo_disallow_assoc(ctx, ifname, allow); + ret = wifi_ubus_ap_mbo_disallow_assoc(ctx, ifname, disallow); ubus_free(ctx); return ret; diff --git a/src/wifi.h b/src/wifi.h index 491f857b81e52172a7129504467745d918289e90..0fb2cd2fec4ed537a3fe6644fc814ae5a1a89613 100644 --- a/src/wifi.h +++ b/src/wifi.h @@ -164,7 +164,7 @@ int wifi_bsta_status(const char *ifname, struct wifi_bsta_status *bsta_status); int wifi_sta_info(const char *ifname, struct wifi_sta *sta); int wifi_sta_disconnect_ap(const char *ifname, uint32_t reason); -int wifi_set_backhaul_bss_association_mode(const char *ifname, bool allow); +int wifi_set_backhaul_bss_association_mode(const char *ifname, bool disallow); int c2f(int chan); diff --git a/src/wifi_ubus.c b/src/wifi_ubus.c index 57884507fae18ac0ca0ece18340ee47eefeeb478..bd28768831460977f4b9741c5a90987563f89e61 100644 --- a/src/wifi_ubus.c +++ b/src/wifi_ubus.c @@ -2359,7 +2359,7 @@ out: } int wifi_ubus_ap_mbo_disallow_assoc(struct ubus_context *ubus_ctx, - const char *ifname, bool allow) + const char *ifname, bool disallow) { enum { ALLOW = 0, DISALLOW = 2 }; struct blob_buf bb = { 0 }; @@ -2367,7 +2367,7 @@ int wifi_ubus_ap_mbo_disallow_assoc(struct ubus_context *ubus_ctx, uint32_t id; int ret; - trace("[%s] %s %s\n", ifname, __func__, allow ? "ALLOW" : "DISALLOW"); + trace("[%s] %s %s\n", ifname, __func__, disallow ? "DISALLOW" : "ALLOW"); snprintf(name, sizeof(name), "wifi.ap.%s", ifname); ret = ubus_lookup_id(ubus_ctx, name, &id); @@ -2375,7 +2375,7 @@ int wifi_ubus_ap_mbo_disallow_assoc(struct ubus_context *ubus_ctx, goto out; blob_buf_init(&bb, 0); - blobmsg_add_u32(&bb, "reason", allow ? ALLOW : DISALLOW); + blobmsg_add_u32(&bb, "reason", disallow ? DISALLOW : ALLOW); ret = ubus_invoke(ubus_ctx, id, "mbo_disallow_assoc", bb.head, NULL, NULL, 2 * 1000); blob_buf_free(&bb);