eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

commit b1b45f55092fe915edd0a1058accc3541ffcddde
parent 6065d86fa7f62e064f9ea664936498e655d8c040
Author: James Prestwood <prestwoj@gmail.com>
Date:   Thu, 15 Jun 2023 12:24:10 -0700

wiphy: allow for user-defined driver flags

The driver_infos list in wiphy.c is hard coded and, naturally,
not configurable from a user perspective. As drivers are updated
or added users may be left with their system being broken until the
driver is added, IWD released, and packaged.

This adds the ability to define driver flags inside main.conf under
the "DriverQuirks" group. Keys in this group correspond to values in
enum driver_flag and values are a list of glob matches for specific
drivers:

[DriverQuirks]
DefaultInterface=rtl81*,rtl87*,rtl88*,rtw_*,brcmfmac,bcmsdh_sdmmc
ForcePae=buggy_pae_*

Diffstat:
Msrc/wiphy.c | 31+++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+), 0 deletions(-)

diff --git a/src/wiphy.c b/src/wiphy.c @@ -73,6 +73,11 @@ enum driver_flag { FORCE_PAE = 0x2, }; +struct driver_flag_name { + const char *name; + enum driver_flag flag; +}; + struct driver_info { const char *prefix; unsigned int flags; @@ -93,6 +98,11 @@ static const struct driver_info driver_infos[] = { { "bcmsdh_sdmmc", DEFAULT_IF }, }; +static const struct driver_flag_name driver_flag_names[] = { + { "DefaultInterface", DEFAULT_IF }, + { "ForcePae", FORCE_PAE }, +}; + struct wiphy { uint32_t id; char name[20]; @@ -1868,6 +1878,9 @@ static bool wiphy_get_driver_name(struct wiphy *wiphy) char driver_path[256]; ssize_t len; unsigned int i; + unsigned int j; + const struct l_settings *config = iwd_get_config(); + char **flag_list; driver_link = l_strdup_printf("/sys/class/ieee80211/%s/device/driver", wiphy->name); @@ -1885,6 +1898,24 @@ static bool wiphy_get_driver_name(struct wiphy *wiphy) if (!fnmatch(driver_infos[i].prefix, wiphy->driver_str, 0)) wiphy->driver_flags |= driver_infos[i].flags; + /* Check for any user-defined driver flags */ + if (!l_settings_has_group(config, "DriverQuirks")) + return true; + + for (i = 0; i < L_ARRAY_SIZE(driver_flag_names); i++) { + flag_list = l_settings_get_string_list(config, "DriverQuirks", + driver_flag_names[i].name, ','); + if (!flag_list) + continue; + + for (j = 0; flag_list[j]; j++) + if (!fnmatch(flag_list[j], wiphy->driver_str, 0)) + wiphy->driver_flags |= + driver_flag_names[i].flag; + + l_strv_free(flag_list); + } + return true; }