fix band steering
added git autocompletion to devcontainer
This commit is contained in:
@@ -23,6 +23,7 @@ RUN apt-get update && apt-get install -y \
|
|||||||
time \
|
time \
|
||||||
sudo \
|
sudo \
|
||||||
locales \
|
locales \
|
||||||
|
bash-completion \
|
||||||
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen
|
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen
|
||||||
@@ -36,6 +37,9 @@ RUN adduser openwrt --disabled-password --gecos "" && \
|
|||||||
USER openwrt
|
USER openwrt
|
||||||
WORKDIR /home/openwrt
|
WORKDIR /home/openwrt
|
||||||
|
|
||||||
|
RUN curl -s https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash \
|
||||||
|
&& printf "\n# Git shell autocomplete\nif [ -f ~/.git-completion.bash ]; then\n . ~/.git-completion.bash\nfi\n" >> ~/.bashrc
|
||||||
|
|
||||||
RUN git clone https://github.com/openwrt/openwrt.git && \
|
RUN git clone https://github.com/openwrt/openwrt.git && \
|
||||||
mkdir -p /home/openwrt/openwrt/package/OpenUniFi
|
mkdir -p /home/openwrt/openwrt/package/OpenUniFi
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ make menuconfig
|
|||||||
On The Accesspoint Run this to install the package:
|
On The Accesspoint Run this to install the package:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
# Install dependencies
|
||||||
|
# replace wpad-basic-mbedtls with wpad-mbedtls
|
||||||
|
apk del wpad-basic-mbedtls && apk add wpad-mbedtls && /etc/init.d/network restart
|
||||||
|
|
||||||
# Remove old installation
|
# Remove old installation
|
||||||
apk -r del openuf
|
apk -r del openuf
|
||||||
|
|
||||||
|
|||||||
+47
-54
@@ -294,42 +294,6 @@ static int radio_uses_ath9k(const char *device_name)
|
|||||||
return strstr(target, "ath9k") != NULL;
|
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. */
|
/* Read a UniFi boolean while accepting names used by controller versions. */
|
||||||
static int json_boolean_any(struct json_object *object,
|
static int json_boolean_any(struct json_object *object,
|
||||||
const char *const *keys, size_t key_count)
|
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. */
|
/* Enable the hostapd capabilities used by steering and 802.11v hints. */
|
||||||
const char *band_steer_keys[] = {
|
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[] = {
|
const char *handoff_keys[] = {
|
||||||
"bss_transition", "bss_transition_enabled",
|
"bss_transition", "bss_transition_enabled",
|
||||||
@@ -934,8 +899,6 @@ static int apply_vap(struct uci_context *ctx,
|
|||||||
sizeof(handoff_keys) / sizeof(handoff_keys[0]));
|
sizeof(handoff_keys) / sizeof(handoff_keys[0]));
|
||||||
int rrm = band_steer || handoff;
|
int rrm = band_steer || handoff;
|
||||||
int bss_transition_requested = 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",
|
UCI_SET_INT(ctx, "wireless", sec_name, "openuf_band_steering",
|
||||||
band_steer);
|
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, "ieee80211k", rrm);
|
||||||
UCI_SET_INT(ctx, "wireless", sec_name, "rrm_neighbor_report", rrm);
|
UCI_SET_INT(ctx, "wireless", sec_name, "rrm_neighbor_report", rrm);
|
||||||
UCI_SET_INT(ctx, "wireless", sec_name, "rrm_beacon_report", rrm);
|
UCI_SET_INT(ctx, "wireless", sec_name, "rrm_beacon_report", rrm);
|
||||||
/*
|
/* Enable 802.11v at runtime after hostapd starts. Putting this option
|
||||||
* The ucode Wi-Fi backend serializes even bss_transition=0. Reduced wpad
|
* in UCI makes builds without CONFIG_WNM_AP reject the entire BSS. */
|
||||||
* rejects the unknown option, so omit it completely unless WNM exists.
|
if (bss_transition_requested)
|
||||||
*/
|
UCI_SET_INT(ctx, "wireless", sec_name,
|
||||||
if (bss_transition)
|
"openuf_bss_transition_requested", 1);
|
||||||
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");
|
|
||||||
|
|
||||||
/* Record the controller VLAN for telemetry and diagnostics. */
|
/* Record the controller VLAN for telemetry and diagnostics. */
|
||||||
if (vid > 0)
|
if (vid > 0)
|
||||||
@@ -1089,7 +1048,7 @@ int wlan_apply_config(struct json_object *config_json,
|
|||||||
disabled_defaults);
|
disabled_defaults);
|
||||||
|
|
||||||
/* 3. Create VAPs and determine whether any WLAN requests steering. */
|
/* 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)) {
|
if (vt_arr && json_object_is_type(vt_arr, json_type_array)) {
|
||||||
int nv = json_object_array_length(vt_arr);
|
int nv = json_object_array_length(vt_arr);
|
||||||
for (int i = 0; i < nv; i++) {
|
for (int i = 0; i < nv; i++) {
|
||||||
@@ -1097,12 +1056,21 @@ int wlan_apply_config(struct json_object *config_json,
|
|||||||
if (!vap) continue;
|
if (!vap) continue;
|
||||||
|
|
||||||
const char *band_steer_keys[] = {
|
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,
|
if (json_boolean_any(vap, band_steer_keys,
|
||||||
sizeof(band_steer_keys) /
|
sizeof(band_steer_keys) /
|
||||||
sizeof(band_steer_keys[0])))
|
sizeof(band_steer_keys[0])) ||
|
||||||
band_steering_enabled = 1;
|
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. */
|
/* A VAP without an explicit band is a model-wide WLAN. */
|
||||||
const char *radio_band = NULL;
|
const char *radio_band = NULL;
|
||||||
@@ -1155,7 +1123,7 @@ int wlan_apply_config(struct json_object *config_json,
|
|||||||
uci_unload(ctx, pkg);
|
uci_unload(ctx, pkg);
|
||||||
uci_free_context(ctx);
|
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");
|
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);
|
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. */
|
/* Restart after hostapd has registered both BSSes on ubus. */
|
||||||
system("/etc/init.d/usteer restart >/dev/null 2>&1");
|
system("/etc/init.d/usteer restart >/dev/null 2>&1");
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1339,7 +1331,8 @@ int wlan_apply_system_cfg(const char *system_cfg,
|
|||||||
json_object_new_boolean(!strcmp(value, "enabled")));
|
json_object_new_boolean(!strcmp(value, "enabled")));
|
||||||
|
|
||||||
const char *band_steer_suffixes[] = {
|
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;
|
for (size_t n = 0;
|
||||||
n < sizeof(band_steer_suffixes) /
|
n < sizeof(band_steer_suffixes) /
|
||||||
|
|||||||
Reference in New Issue
Block a user