fix band steering (#12)
added git autocompletion to devcontainer Reviewed-on: #12
This commit was merged in pull request #12.
This commit is contained in:
+47
-54
@@ -294,42 +294,6 @@ static int radio_uses_ath9k(const char *device_name)
|
||||
return strstr(target, "ath9k") != NULL;
|
||||
}
|
||||
|
||||
/* Detect a full hostapd/wpad package built with 802.11v WNM support. */
|
||||
static int hostapd_supports_bss_transition(void)
|
||||
{
|
||||
static int cached = -1;
|
||||
if (cached >= 0)
|
||||
return cached;
|
||||
|
||||
cached = 0;
|
||||
/*
|
||||
* Do not search binary strings: basic wpad contains the option name in
|
||||
* ancillary code even though its configuration parser rejects it.
|
||||
*/
|
||||
FILE *probe = popen(
|
||||
"(apk info -e wpad >/dev/null 2>&1 || "
|
||||
"apk info -e wpad-mbedtls >/dev/null 2>&1 || "
|
||||
"apk info -e wpad-openssl >/dev/null 2>&1 || "
|
||||
"apk info -e wpad-wolfssl >/dev/null 2>&1 || "
|
||||
"apk info -e hostapd-mbedtls >/dev/null 2>&1 || "
|
||||
"apk info -e hostapd-openssl >/dev/null 2>&1 || "
|
||||
"apk info -e hostapd-wolfssl >/dev/null 2>&1 || "
|
||||
"opkg status wpad 2>/dev/null | grep -q 'install ok installed' || "
|
||||
"opkg status wpad-mbedtls 2>/dev/null | grep -q 'install ok installed' || "
|
||||
"opkg status wpad-openssl 2>/dev/null | grep -q 'install ok installed' || "
|
||||
"opkg status wpad-wolfssl 2>/dev/null | grep -q 'install ok installed') "
|
||||
"&& echo true",
|
||||
"r");
|
||||
if (probe) {
|
||||
char value[16] = {0};
|
||||
if (fgets(value, sizeof(value), probe) &&
|
||||
!strncmp(value, "true", 4))
|
||||
cached = 1;
|
||||
pclose(probe);
|
||||
}
|
||||
return cached;
|
||||
}
|
||||
|
||||
/* Read a UniFi boolean while accepting names used by controller versions. */
|
||||
static int json_boolean_any(struct json_object *object,
|
||||
const char *const *keys, size_t key_count)
|
||||
@@ -919,7 +883,8 @@ static int apply_vap(struct uci_context *ctx,
|
||||
|
||||
/* Enable the hostapd capabilities used by steering and 802.11v hints. */
|
||||
const char *band_steer_keys[] = {
|
||||
"band_steering", "band_steering_enabled", "steering_enabled"
|
||||
"band_steering", "band_steering_enabled", "band_steering_mode",
|
||||
"steering_enabled"
|
||||
};
|
||||
const char *handoff_keys[] = {
|
||||
"bss_transition", "bss_transition_enabled",
|
||||
@@ -934,8 +899,6 @@ static int apply_vap(struct uci_context *ctx,
|
||||
sizeof(handoff_keys) / sizeof(handoff_keys[0]));
|
||||
int rrm = band_steer || handoff;
|
||||
int bss_transition_requested = band_steer || handoff;
|
||||
int bss_transition = bss_transition_requested &&
|
||||
hostapd_supports_bss_transition();
|
||||
|
||||
UCI_SET_INT(ctx, "wireless", sec_name, "openuf_band_steering",
|
||||
band_steer);
|
||||
@@ -944,15 +907,11 @@ static int apply_vap(struct uci_context *ctx,
|
||||
UCI_SET_INT(ctx, "wireless", sec_name, "ieee80211k", rrm);
|
||||
UCI_SET_INT(ctx, "wireless", sec_name, "rrm_neighbor_report", rrm);
|
||||
UCI_SET_INT(ctx, "wireless", sec_name, "rrm_beacon_report", rrm);
|
||||
/*
|
||||
* The ucode Wi-Fi backend serializes even bss_transition=0. Reduced wpad
|
||||
* rejects the unknown option, so omit it completely unless WNM exists.
|
||||
*/
|
||||
if (bss_transition)
|
||||
UCI_SET_INT(ctx, "wireless", sec_name, "bss_transition", 1);
|
||||
if (bss_transition_requested && !bss_transition)
|
||||
printf("[openuf] Handoff Suggestions requested, but installed "
|
||||
"hostapd lacks 802.11v WNM support; install wpad-mbedtls\n");
|
||||
/* Enable 802.11v at runtime after hostapd starts. Putting this option
|
||||
* in UCI makes builds without CONFIG_WNM_AP reject the entire BSS. */
|
||||
if (bss_transition_requested)
|
||||
UCI_SET_INT(ctx, "wireless", sec_name,
|
||||
"openuf_bss_transition_requested", 1);
|
||||
|
||||
/* Record the controller VLAN for telemetry and diagnostics. */
|
||||
if (vid > 0)
|
||||
@@ -1089,7 +1048,7 @@ int wlan_apply_config(struct json_object *config_json,
|
||||
disabled_defaults);
|
||||
|
||||
/* 3. Create VAPs and determine whether any WLAN requests steering. */
|
||||
int band_steering_enabled = 0;
|
||||
int steering_policy_enabled = 0;
|
||||
if (vt_arr && json_object_is_type(vt_arr, json_type_array)) {
|
||||
int nv = json_object_array_length(vt_arr);
|
||||
for (int i = 0; i < nv; i++) {
|
||||
@@ -1097,12 +1056,21 @@ int wlan_apply_config(struct json_object *config_json,
|
||||
if (!vap) continue;
|
||||
|
||||
const char *band_steer_keys[] = {
|
||||
"band_steering", "band_steering_enabled", "steering_enabled"
|
||||
"band_steering", "band_steering_enabled",
|
||||
"band_steering_mode", "steering_enabled"
|
||||
};
|
||||
const char *handoff_keys[] = {
|
||||
"bss_transition", "bss_transition_enabled",
|
||||
"bss_transition_management", "handoff_suggestions",
|
||||
"handoff_suggestions_enabled", "ieee80211v"
|
||||
};
|
||||
if (json_boolean_any(vap, band_steer_keys,
|
||||
sizeof(band_steer_keys) /
|
||||
sizeof(band_steer_keys[0])))
|
||||
band_steering_enabled = 1;
|
||||
sizeof(band_steer_keys[0])) ||
|
||||
json_boolean_any(vap, handoff_keys,
|
||||
sizeof(handoff_keys) /
|
||||
sizeof(handoff_keys[0])))
|
||||
steering_policy_enabled = 1;
|
||||
|
||||
/* A VAP without an explicit band is a model-wide WLAN. */
|
||||
const char *radio_band = NULL;
|
||||
@@ -1155,7 +1123,7 @@ int wlan_apply_config(struct json_object *config_json,
|
||||
uci_unload(ctx, pkg);
|
||||
uci_free_context(ctx);
|
||||
|
||||
if (configure_band_steering(band_steering_enabled) != 0)
|
||||
if (configure_band_steering(steering_policy_enabled) != 0)
|
||||
printf("[openuf] Failed to configure the band steering policy\n");
|
||||
|
||||
/*
|
||||
@@ -1215,6 +1183,30 @@ int wlan_apply_config(struct json_object *config_json,
|
||||
printf("[openuf] %s failed after 2 start attempts\n", device);
|
||||
}
|
||||
|
||||
/* Enable management features only after hostapd has registered each BSS.
|
||||
* Unsupported WNM methods fail harmlessly without preventing AP startup. */
|
||||
if (steering_policy_enabled) {
|
||||
for (int i = 0; i < model->radio_map_len; i++) {
|
||||
const char *device = wlan_device_for_band(
|
||||
model, model->radio_map[i].band);
|
||||
int phy_index = -1;
|
||||
if (!device || sscanf(device, "radio%d", &phy_index) != 1)
|
||||
continue;
|
||||
|
||||
char command[256];
|
||||
snprintf(command, sizeof(command),
|
||||
"ubus -S call hostapd.phy%d-ap0 bss_mgmt_enable "
|
||||
"%c{ \"neighbor_report\": true, "
|
||||
"\"beacon_report\": true, "
|
||||
"\"bss_transition\": true }%c >/dev/null 2>&1",
|
||||
phy_index, 39, 39);
|
||||
if (system(command) != 0)
|
||||
printf("[openuf] hostapd on phy%d lacks runtime 802.11v "
|
||||
"support; continuing without BSS Transition\n",
|
||||
phy_index);
|
||||
}
|
||||
}
|
||||
|
||||
/* Restart after hostapd has registered both BSSes on ubus. */
|
||||
system("/etc/init.d/usteer restart >/dev/null 2>&1");
|
||||
return 0;
|
||||
@@ -1339,7 +1331,8 @@ int wlan_apply_system_cfg(const char *system_cfg,
|
||||
json_object_new_boolean(!strcmp(value, "enabled")));
|
||||
|
||||
const char *band_steer_suffixes[] = {
|
||||
"band_steering", "band_steering_enabled", "steering"
|
||||
"band_steering", "band_steering_enabled", "band_steering_mode",
|
||||
"steering"
|
||||
};
|
||||
for (size_t n = 0;
|
||||
n < sizeof(band_steer_suffixes) /
|
||||
|
||||
Reference in New Issue
Block a user