* [PATCH 02/10] test-runner: make developer mode optional
2022-07-26 17:09 [PATCH 01/10] manager: unregister nl80211 config watch James Prestwood
@ 2022-07-26 17:09 ` James Prestwood
2022-07-26 17:09 ` [PATCH 03/10] auto-t: iwd.py: let IWD class specify developer mode James Prestwood
` (8 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: James Prestwood @ 2022-07-26 17:09 UTC (permalink / raw)
To: iwd; +Cc: James Prestwood
IWD can now be started without -E if needed
---
tools/utils.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tools/utils.py b/tools/utils.py
index 7a182848..a1b3e041 100644
--- a/tools/utils.py
+++ b/tools/utils.py
@@ -411,7 +411,8 @@ class Namespace:
self._bus = dbus.bus.BusConnection(address_or_type=self.dbus_address)
- def start_iwd(self, config_dir = '/tmp', storage_dir = '/tmp/iwd'):
+ def start_iwd(self, config_dir = '/tmp', storage_dir = '/tmp/iwd',
+ developer_mode = True):
args = []
iwd_radios = ','.join([r.name for r in self.radios if r.use == 'iwd'])
@@ -420,7 +421,10 @@ class Namespace:
'--show-leak-kinds=all',
'--log-file=/tmp/valgrind.log.%p'])
- args.extend(['iwd', '-E'])
+ args.append('iwd')
+
+ if developer_mode:
+ args.append('-E')
if iwd_radios != '':
args.extend(['-p', iwd_radios])
--
2.34.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 03/10] auto-t: iwd.py: let IWD class specify developer mode
2022-07-26 17:09 [PATCH 01/10] manager: unregister nl80211 config watch James Prestwood
2022-07-26 17:09 ` [PATCH 02/10] test-runner: make developer mode optional James Prestwood
@ 2022-07-26 17:09 ` James Prestwood
2022-07-26 17:09 ` [PATCH 04/10] wiphy: fix runtime error from bit shift James Prestwood
` (7 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: James Prestwood @ 2022-07-26 17:09 UTC (permalink / raw)
To: iwd; +Cc: James Prestwood
---
autotests/util/iwd.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py
index db91ab8a..b17fe163 100755
--- a/autotests/util/iwd.py
+++ b/autotests/util/iwd.py
@@ -1098,7 +1098,8 @@ class IWD(AsyncOpAbstract):
psk_agents = []
def __init__(self, start_iwd_daemon = False, iwd_config_dir = '/tmp',
- iwd_storage_dir = IWD_STORAGE_DIR, namespace=ctx):
+ iwd_storage_dir = IWD_STORAGE_DIR, namespace=ctx,
+ developer_mode = True):
self.namespace = namespace
self._bus = namespace.get_bus()
@@ -1107,7 +1108,8 @@ class IWD(AsyncOpAbstract):
raise Exception("IWD requested to start but is already running")
self._iwd_proc = self.namespace.start_iwd(iwd_config_dir,
- iwd_storage_dir)
+ iwd_storage_dir,
+ developer_mode)
self._devices = DeviceList(self)
--
2.34.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 04/10] wiphy: fix runtime error from bit shift
2022-07-26 17:09 [PATCH 01/10] manager: unregister nl80211 config watch James Prestwood
2022-07-26 17:09 ` [PATCH 02/10] test-runner: make developer mode optional James Prestwood
2022-07-26 17:09 ` [PATCH 03/10] auto-t: iwd.py: let IWD class specify developer mode James Prestwood
@ 2022-07-26 17:09 ` James Prestwood
2022-07-26 20:57 ` Denis Kenzior
2022-07-26 17:09 ` [PATCH 05/10] scan: make scan_freq_set const in scan_passive James Prestwood
` (6 subsequent siblings)
9 siblings, 1 reply; 13+ messages in thread
From: James Prestwood @ 2022-07-26 17:09 UTC (permalink / raw)
To: iwd; +Cc: James Prestwood
The compiler treated the '1' as an int type which was not big enough
to hold a bit shift of 31:
runtime error: left shift of 1 by 31 places cannot be represented in
type 'int'
Instead of doing the iftype check manually, refactor
wiphy_get_supported_iftypes by adding a subroutine which just parses
out iftypes from a mask into a char** list. This removes the need to
case each iftype into a string.
---
src/wiphy.c | 48 ++++++++++++++----------------------------------
1 file changed, 14 insertions(+), 34 deletions(-)
diff --git a/src/wiphy.c b/src/wiphy.c
index 09b99fb2..98bd3aa4 100644
--- a/src/wiphy.c
+++ b/src/wiphy.c
@@ -707,17 +707,16 @@ bool wiphy_constrain_freq_set(const struct wiphy *wiphy,
return true;
}
-static char **wiphy_get_supported_iftypes(struct wiphy *wiphy, uint16_t mask)
+static char **wiphy_iftype_mask_to_str(uint16_t mask)
{
- uint16_t supported_mask = wiphy->supported_iftypes & mask;
- char **ret = l_new(char *, __builtin_popcount(supported_mask) + 1);
+ char **ret = l_new(char *, __builtin_popcount(mask) + 1);
unsigned int i;
unsigned int j;
- for (j = 0, i = 0; i < sizeof(supported_mask) * 8; i++) {
+ for (j = 0, i = 0; i < sizeof(mask) * 8; i++) {
const char *str;
- if (!(supported_mask & (1 << i)))
+ if (!(mask & (1 << i)))
continue;
str = netdev_iftype_to_string(i + 1);
@@ -728,6 +727,11 @@ static char **wiphy_get_supported_iftypes(struct wiphy *wiphy, uint16_t mask)
return ret;
}
+static char **wiphy_get_supported_iftypes(struct wiphy *wiphy, uint16_t mask)
+{
+ return wiphy_iftype_mask_to_str(wiphy->supported_iftypes & mask);
+}
+
bool wiphy_supports_iftype(struct wiphy *wiphy, uint32_t iftype)
{
if (iftype > sizeof(wiphy->supported_iftypes) * 8)
@@ -951,38 +955,14 @@ static void wiphy_print_mcs_info(const uint8_t *mcs_map,
static void wiphy_print_he_capabilities(struct band *band,
const struct band_he_capabilities *he_cap)
{
- int i;
- char type_buf[128];
- char *s = type_buf;
+ _auto_(l_strv_free) char **iftypes = NULL;
+ _auto_(l_free) char *joined = NULL;
uint8_t width_set = bit_field(he_cap->he_phy_capa[0], 1, 7);
- for (i = 0; i < 32; i++) {
- if (!(he_cap->iftypes & (1 << i)))
- continue;
-
- if (L_WARN_ON(s >= type_buf + sizeof(type_buf)))
- return;
-
- switch (i) {
- case NETDEV_IFTYPE_ADHOC:
- s += sprintf(s, "%s ", "Ad-Hoc");
- break;
- case NETDEV_IFTYPE_STATION:
- s += sprintf(s, "%s ", "Station");
- break;
- case NETDEV_IFTYPE_AP:
- s += sprintf(s, "%s ", "AP");
- break;
- case NETDEV_IFTYPE_P2P_CLIENT:
- s += sprintf(s, "%s ", "P2P Client");
- break;
- case NETDEV_IFTYPE_P2P_GO:
- s += sprintf(s, "%s ", "P2P GO");
- break;
- }
- }
+ iftypes = wiphy_iftype_mask_to_str(he_cap->iftypes);
+ joined = l_strjoinv(iftypes, ' ');
- l_info("\t\t\tInterface Types: %s", type_buf);
+ l_info("\t\t\tInterface Types: %s", joined);
switch (band->freq) {
case BAND_FREQ_2_4_GHZ:
--
2.34.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 04/10] wiphy: fix runtime error from bit shift
2022-07-26 17:09 ` [PATCH 04/10] wiphy: fix runtime error from bit shift James Prestwood
@ 2022-07-26 20:57 ` Denis Kenzior
2022-07-27 16:00 ` James Prestwood
0 siblings, 1 reply; 13+ messages in thread
From: Denis Kenzior @ 2022-07-26 20:57 UTC (permalink / raw)
To: James Prestwood, iwd
Hi James,
On 7/26/22 12:09, James Prestwood wrote:
> The compiler treated the '1' as an int type which was not big enough
> to hold a bit shift of 31:
>
> runtime error: left shift of 1 by 31 places cannot be represented in
> type 'int'
>
> Instead of doing the iftype check manually, refactor
> wiphy_get_supported_iftypes by adding a subroutine which just parses
> out iftypes from a mask into a char** list. This removes the need to
> case each iftype into a string.
> ---
> src/wiphy.c | 48 ++++++++++++++----------------------------------
> 1 file changed, 14 insertions(+), 34 deletions(-)
>
> diff --git a/src/wiphy.c b/src/wiphy.c
> index 09b99fb2..98bd3aa4 100644
> --- a/src/wiphy.c
> +++ b/src/wiphy.c
> @@ -707,17 +707,16 @@ bool wiphy_constrain_freq_set(const struct wiphy *wiphy,
> return true;
> }
>
> -static char **wiphy_get_supported_iftypes(struct wiphy *wiphy, uint16_t mask)
> +static char **wiphy_iftype_mask_to_str(uint16_t mask)
I'm still unsure why you introduce this? Can't you use
wiphy_get_supported_iftypes() as is?
> {
> - uint16_t supported_mask = wiphy->supported_iftypes & mask;
> - char **ret = l_new(char *, __builtin_popcount(supported_mask) + 1);
> + char **ret = l_new(char *, __builtin_popcount(mask) + 1);
> unsigned int i;
> unsigned int j;
>
> - for (j = 0, i = 0; i < sizeof(supported_mask) * 8; i++) {
> + for (j = 0, i = 0; i < sizeof(mask) * 8; i++) {
> const char *str;
>
> - if (!(supported_mask & (1 << i)))
> + if (!(mask & (1 << i)))
> continue;
>
> str = netdev_iftype_to_string(i + 1);
Also note that since valid iftypes start at 1, we actually subtract 1 when
parsing them for the purposes of the mask. So get_iftypes() might need to be
modified to do the same.
Regards,
-Denis
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 04/10] wiphy: fix runtime error from bit shift
2022-07-26 20:57 ` Denis Kenzior
@ 2022-07-27 16:00 ` James Prestwood
0 siblings, 0 replies; 13+ messages in thread
From: James Prestwood @ 2022-07-27 16:00 UTC (permalink / raw)
To: Denis Kenzior, iwd
On Tue, 2022-07-26 at 15:57 -0500, Denis Kenzior wrote:
> Hi James,
>
> On 7/26/22 12:09, James Prestwood wrote:
> > The compiler treated the '1' as an int type which was not big
> > enough
> > to hold a bit shift of 31:
> >
> > runtime error: left shift of 1 by 31 places cannot be represented
> > in
> > type 'int'
> >
> > Instead of doing the iftype check manually, refactor
> > wiphy_get_supported_iftypes by adding a subroutine which just
> > parses
> > out iftypes from a mask into a char** list. This removes the need
> > to
> > case each iftype into a string.
> > ---
> > src/wiphy.c | 48 ++++++++++++++----------------------------------
> > 1 file changed, 14 insertions(+), 34 deletions(-)
> >
> > diff --git a/src/wiphy.c b/src/wiphy.c
> > index 09b99fb2..98bd3aa4 100644
> > --- a/src/wiphy.c
> > +++ b/src/wiphy.c
> > @@ -707,17 +707,16 @@ bool wiphy_constrain_freq_set(const struct
> > wiphy *wiphy,
> > return true;
> > }
> >
> > -static char **wiphy_get_supported_iftypes(struct wiphy *wiphy,
> > uint16_t mask)
> > +static char **wiphy_iftype_mask_to_str(uint16_t mask)
>
> I'm still unsure why you introduce this? Can't you use
> wiphy_get_supported_iftypes() as is?
Only to avoid passing the wiphy pointer to all these print functions.
Otherwise yes, the original could be used as-is.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 05/10] scan: make scan_freq_set const in scan_passive
2022-07-26 17:09 [PATCH 01/10] manager: unregister nl80211 config watch James Prestwood
` (2 preceding siblings ...)
2022-07-26 17:09 ` [PATCH 04/10] wiphy: fix runtime error from bit shift James Prestwood
@ 2022-07-26 17:09 ` James Prestwood
2022-07-26 17:09 ` [PATCH 06/10] util: make scan_freq_set_get_bands const James Prestwood
` (5 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: James Prestwood @ 2022-07-26 17:09 UTC (permalink / raw)
To: iwd; +Cc: James Prestwood
The scan_passive API wasn't using a const struct scan_freq_set as it
should be since it's not modifying the contents. Changing this to
const did require some additional changes like making the scan_parameters
'freqs' member const as well.
After changing scan_parameters, p2p needed updating since it was using
scan_parameters.freqs directly. This was changed to using a separate
scan_freq_set pointer, then setting to scan_parameters.freqs when needed.
---
src/p2p.c | 21 +++++++++++++--------
src/scan.c | 4 ++--
src/scan.h | 4 ++--
3 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/src/p2p.c b/src/p2p.c
index a7207c30..ff3b8e45 100644
--- a/src/p2p.c
+++ b/src/p2p.c
@@ -1977,6 +1977,7 @@ static bool p2p_provision_scan_notify(int err, struct l_queue *bss_list,
static void p2p_provision_scan_start(struct p2p_device *dev)
{
struct scan_parameters params = {};
+ struct scan_freq_set *freqs = NULL;
uint8_t buf[256];
params.flush = true;
@@ -2005,16 +2006,17 @@ static void p2p_provision_scan_start(struct p2p_device *dev)
* contain all of the 2.4 and 5G channels.
*/
if (dev->conn_go_scan_retry < 12) {
- params.freqs = scan_freq_set_new();
- scan_freq_set_add(params.freqs, dev->conn_go_oper_freq);
+ freqs = scan_freq_set_new();
+ scan_freq_set_add(freqs, dev->conn_go_oper_freq);
+ params.freqs = freqs;
}
dev->scan_id = scan_active_full(dev->wdev_id, ¶ms, NULL,
p2p_provision_scan_notify, dev,
p2p_scan_destroy);
- if (params.freqs)
- scan_freq_set_free(params.freqs);
+ if (freqs)
+ scan_freq_set_free(freqs);
}
static void p2p_start_client_provision(struct p2p_device *dev)
@@ -3777,6 +3779,7 @@ schedule:
static bool p2p_device_scan_start(struct p2p_device *dev)
{
struct scan_parameters params = {};
+ struct scan_freq_set *freqs;
uint8_t buf[256];
unsigned int i;
@@ -3812,13 +3815,13 @@ static bool p2p_device_scan_start(struct p2p_device *dev)
* Request frames intended for both P2P Devices and non-P2P Devices."
*/
params.no_cck_rates = true;
- params.freqs = scan_freq_set_new();
+ freqs = scan_freq_set_new();
for (i = 0; i < L_ARRAY_SIZE(channels_social); i++) {
int chan = channels_social[i];
uint32_t freq = band_channel_to_freq(chan, BAND_FREQ_2_4_GHZ);
- scan_freq_set_add(params.freqs, freq);
+ scan_freq_set_add(freqs, freq);
}
/*
@@ -3845,12 +3848,14 @@ static bool p2p_device_scan_start(struct p2p_device *dev)
dev->chans_per_scan = CHANS_PER_SCAN;
}
- scan_freq_set_add(params.freqs, freq);
+ scan_freq_set_add(freqs, freq);
}
+ params.freqs = freqs;
+
dev->scan_id = scan_active_full(dev->wdev_id, ¶ms, NULL,
p2p_scan_notify, dev, p2p_scan_destroy);
- scan_freq_set_free(params.freqs);
+ scan_freq_set_free(freqs);
return dev->scan_id != 0;
}
diff --git a/src/scan.c b/src/scan.c
index 39aef625..03e5b8d9 100644
--- a/src/scan.c
+++ b/src/scan.c
@@ -279,7 +279,7 @@ static void scan_freq_append(uint32_t freq, void *user_data)
}
static void scan_build_attr_scan_frequencies(struct l_genl_msg *msg,
- struct scan_freq_set *freqs)
+ const struct scan_freq_set *freqs)
{
struct scan_freq_append_data append_data = { msg, 0 };
@@ -654,7 +654,7 @@ static uint32_t scan_common(uint64_t wdev_id, bool passive,
priority, &work_ops);
}
-uint32_t scan_passive(uint64_t wdev_id, struct scan_freq_set *freqs,
+uint32_t scan_passive(uint64_t wdev_id, const struct scan_freq_set *freqs,
scan_trigger_func_t trigger, scan_notify_func_t notify,
void *userdata, scan_destroy_func_t destroy)
{
diff --git a/src/scan.h b/src/scan.h
index 79bec605..58b8332b 100644
--- a/src/scan.h
+++ b/src/scan.h
@@ -93,7 +93,7 @@ struct scan_bss {
struct scan_parameters {
const uint8_t *extra_ie;
size_t extra_ie_size;
- struct scan_freq_set *freqs;
+ const struct scan_freq_set *freqs;
uint16_t duration;
bool flush : 1;
bool randomize_mac_addr_hint : 1;
@@ -130,7 +130,7 @@ struct l_genl_msg *scan_build_trigger_scan_bss(uint32_t ifindex,
const uint8_t *ssid,
uint32_t ssid_len);
-uint32_t scan_passive(uint64_t wdev_id, struct scan_freq_set *freqs,
+uint32_t scan_passive(uint64_t wdev_id, const struct scan_freq_set *freqs,
scan_trigger_func_t trigger, scan_notify_func_t notify,
void *userdata, scan_destroy_func_t destroy);
uint32_t scan_passive_full(uint64_t wdev_id,
--
2.34.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 06/10] util: make scan_freq_set_get_bands const
2022-07-26 17:09 [PATCH 01/10] manager: unregister nl80211 config watch James Prestwood
` (3 preceding siblings ...)
2022-07-26 17:09 ` [PATCH 05/10] scan: make scan_freq_set const in scan_passive James Prestwood
@ 2022-07-26 17:09 ` James Prestwood
2022-07-26 17:09 ` [PATCH 07/10] util: add scan_freq_set_subtract James Prestwood
` (4 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: James Prestwood @ 2022-07-26 17:09 UTC (permalink / raw)
To: iwd; +Cc: James Prestwood
---
src/util.c | 2 +-
src/util.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/util.c b/src/util.c
index 2832486d..3c6e2b1b 100644
--- a/src/util.c
+++ b/src/util.c
@@ -378,7 +378,7 @@ bool scan_freq_set_contains(const struct scan_freq_set *freqs, uint32_t freq)
return false;
}
-uint32_t scan_freq_set_get_bands(struct scan_freq_set *freqs)
+uint32_t scan_freq_set_get_bands(const struct scan_freq_set *freqs)
{
uint32_t bands = 0;
uint32_t max;
diff --git a/src/util.h b/src/util.h
index 75c29039..f61e3575 100644
--- a/src/util.h
+++ b/src/util.h
@@ -111,7 +111,7 @@ struct scan_freq_set *scan_freq_set_new(void);
void scan_freq_set_free(struct scan_freq_set *freqs);
bool scan_freq_set_add(struct scan_freq_set *freqs, uint32_t freq);
bool scan_freq_set_contains(const struct scan_freq_set *freqs, uint32_t freq);
-uint32_t scan_freq_set_get_bands(struct scan_freq_set *freqs);
+uint32_t scan_freq_set_get_bands(const struct scan_freq_set *freqs);
void scan_freq_set_foreach(const struct scan_freq_set *freqs,
scan_freq_set_func_t func, void *user_data);
void scan_freq_set_merge(struct scan_freq_set *to,
--
2.34.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 07/10] util: add scan_freq_set_subtract
2022-07-26 17:09 [PATCH 01/10] manager: unregister nl80211 config watch James Prestwood
` (4 preceding siblings ...)
2022-07-26 17:09 ` [PATCH 06/10] util: make scan_freq_set_get_bands const James Prestwood
@ 2022-07-26 17:09 ` James Prestwood
2022-07-26 17:09 ` [PATCH 08/10] wiphy: add disabled_freqs list James Prestwood
` (3 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: James Prestwood @ 2022-07-26 17:09 UTC (permalink / raw)
To: iwd; +Cc: James Prestwood
Removes any frequencies from one set that are found in the other.
---
src/util.c | 22 ++++++++++++++++++++++
src/util.h | 2 ++
2 files changed, 24 insertions(+)
diff --git a/src/util.c b/src/util.c
index 3c6e2b1b..ebaff6a0 100644
--- a/src/util.c
+++ b/src/util.c
@@ -499,6 +499,28 @@ void scan_freq_set_constrain(struct scan_freq_set *set,
set->channels_2ghz &= constraint->channels_2ghz;
}
+void scan_freq_set_subtract(struct scan_freq_set *set,
+ const struct scan_freq_set *subtract)
+{
+ struct l_uintset *sub;
+
+ sub = l_uintset_subtract(set->channels_6ghz, subtract->channels_6ghz);
+ if (L_WARN_ON(!sub))
+ return;
+
+ l_uintset_free(set->channels_6ghz);
+ set->channels_6ghz = sub;
+
+ sub = l_uintset_subtract(set->channels_5ghz, subtract->channels_5ghz);
+ if (L_WARN_ON(!sub))
+ return;
+
+ l_uintset_free(set->channels_5ghz);
+ set->channels_5ghz = sub;
+
+ set->channels_2ghz &= ~subtract->channels_2ghz;
+}
+
static void add_foreach(uint32_t freq, void *user_data)
{
uint32_t **list = user_data;
diff --git a/src/util.h b/src/util.h
index f61e3575..0b7832fb 100644
--- a/src/util.h
+++ b/src/util.h
@@ -118,6 +118,8 @@ void scan_freq_set_merge(struct scan_freq_set *to,
const struct scan_freq_set *from);
void scan_freq_set_constrain(struct scan_freq_set *set,
const struct scan_freq_set *constraint);
+void scan_freq_set_subtract(struct scan_freq_set *set,
+ const struct scan_freq_set *subtract);
bool scan_freq_set_isempty(const struct scan_freq_set *set);
uint32_t *scan_freq_set_to_fixed_array(const struct scan_freq_set *set,
size_t *len_out);
--
2.34.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 08/10] wiphy: add disabled_freqs list
2022-07-26 17:09 [PATCH 01/10] manager: unregister nl80211 config watch James Prestwood
` (5 preceding siblings ...)
2022-07-26 17:09 ` [PATCH 07/10] util: add scan_freq_set_subtract James Prestwood
@ 2022-07-26 17:09 ` James Prestwood
2022-07-26 17:09 ` [PATCH 09/10] wiphy: constrain scan set by disabled frequencies James Prestwood
` (2 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: James Prestwood @ 2022-07-26 17:09 UTC (permalink / raw)
To: iwd; +Cc: James Prestwood
If a frequency is disabled, it should not be added to the supported list which
it previously was. In this case its added to the (new) disabled_freqs list.
---
src/wiphy.c | 26 +++++++++++++++++++++++---
src/wiphy.h | 1 +
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/src/wiphy.c b/src/wiphy.c
index 98bd3aa4..5329e8e4 100644
--- a/src/wiphy.c
+++ b/src/wiphy.c
@@ -104,6 +104,7 @@ struct wiphy {
uint16_t supported_iftypes;
uint16_t supported_ciphers;
struct scan_freq_set *supported_freqs;
+ struct scan_freq_set *disabled_freqs;
struct band *band_2g;
struct band *band_5g;
struct band *band_6g;
@@ -316,6 +317,7 @@ static struct wiphy *wiphy_new(uint32_t id)
wiphy->id = id;
wiphy->supported_freqs = scan_freq_set_new();
+ wiphy->disabled_freqs = scan_freq_set_new();
watchlist_init(&wiphy->state_watches, NULL);
wiphy->extended_capabilities[0] = IE_TYPE_EXTENDED_CAPABILITIES;
wiphy->extended_capabilities[1] = EXT_CAP_LEN;
@@ -357,6 +359,7 @@ static void wiphy_free(void *data)
}
scan_freq_set_free(wiphy->supported_freqs);
+ scan_freq_set_free(wiphy->disabled_freqs);
watchlist_destroy(&wiphy->state_watches);
l_free(wiphy->model_str);
l_free(wiphy->vendor_str);
@@ -454,6 +457,11 @@ const struct scan_freq_set *wiphy_get_supported_freqs(
return wiphy->supported_freqs;
}
+const struct scan_freq_set *wiphy_get_disabled_freqs(const struct wiphy *wiphy)
+{
+ return wiphy->disabled_freqs;
+}
+
bool wiphy_can_transition_disable(struct wiphy *wiphy)
{
/*
@@ -1188,19 +1196,31 @@ static void parse_supported_frequencies(struct wiphy *wiphy,
struct l_genl_attr attr;
while (l_genl_attr_next(freqs, NULL, NULL, NULL)) {
+ uint32_t freq = 0;
+ bool disabled = false;
+
if (!l_genl_attr_recurse(freqs, &attr))
continue;
while (l_genl_attr_next(&attr, &type, &len, &data)) {
- uint32_t u32;
switch (type) {
case NL80211_FREQUENCY_ATTR_FREQ:
- u32 = *((uint32_t *) data);
- scan_freq_set_add(wiphy->supported_freqs, u32);
+ freq = *((uint32_t *) data);
+ break;
+ case NL80211_FREQUENCY_ATTR_DISABLED:
+ disabled = true;
break;
}
}
+
+ if (!freq)
+ continue;
+
+ scan_freq_set_add(wiphy->supported_freqs, freq);
+
+ if (disabled)
+ scan_freq_set_add(wiphy->disabled_freqs, freq);
}
}
diff --git a/src/wiphy.h b/src/wiphy.h
index acc64193..9a3b96f9 100644
--- a/src/wiphy.h
+++ b/src/wiphy.h
@@ -93,6 +93,7 @@ const char *wiphy_get_path(struct wiphy *wiphy);
uint32_t wiphy_get_supported_bands(struct wiphy *wiphy);
const struct scan_freq_set *wiphy_get_supported_freqs(
const struct wiphy *wiphy);
+const struct scan_freq_set *wiphy_get_disabled_freqs(const struct wiphy *wiphy);
bool wiphy_can_transition_disable(struct wiphy *wiphy);
bool wiphy_can_offload(struct wiphy *wiphy);
bool wiphy_supports_cmds_auth_assoc(struct wiphy *wiphy);
--
2.34.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 09/10] wiphy: constrain scan set by disabled frequencies
2022-07-26 17:09 [PATCH 01/10] manager: unregister nl80211 config watch James Prestwood
` (6 preceding siblings ...)
2022-07-26 17:09 ` [PATCH 08/10] wiphy: add disabled_freqs list James Prestwood
@ 2022-07-26 17:09 ` James Prestwood
2022-07-26 17:09 ` [PATCH 10/10] nl80211util: add nested attribute support James Prestwood
2022-07-26 20:52 ` [PATCH 01/10] manager: unregister nl80211 config watch Denis Kenzior
9 siblings, 0 replies; 13+ messages in thread
From: James Prestwood @ 2022-07-26 17:09 UTC (permalink / raw)
To: iwd; +Cc: James Prestwood
With the addition of disabled_freqs, wiphy_constrain_freq_set needs
to also remove any frequencies which are disabled.
---
src/wiphy.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/wiphy.c b/src/wiphy.c
index 5329e8e4..30653b91 100644
--- a/src/wiphy.c
+++ b/src/wiphy.c
@@ -707,6 +707,7 @@ bool wiphy_constrain_freq_set(const struct wiphy *wiphy,
struct scan_freq_set *set)
{
scan_freq_set_constrain(set, wiphy->supported_freqs);
+ scan_freq_set_subtract(set, wiphy->disabled_freqs);
if (!scan_freq_set_get_bands(set))
/* The set is empty. */
--
2.34.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 10/10] nl80211util: add nested attribute support
2022-07-26 17:09 [PATCH 01/10] manager: unregister nl80211 config watch James Prestwood
` (7 preceding siblings ...)
2022-07-26 17:09 ` [PATCH 09/10] wiphy: constrain scan set by disabled frequencies James Prestwood
@ 2022-07-26 17:09 ` James Prestwood
2022-07-26 20:52 ` [PATCH 01/10] manager: unregister nl80211 config watch Denis Kenzior
9 siblings, 0 replies; 13+ messages in thread
From: James Prestwood @ 2022-07-26 17:09 UTC (permalink / raw)
To: iwd; +Cc: James Prestwood
Adds support for nested attributes in nl80211_parse_attrs
---
src/nl80211util.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/src/nl80211util.c b/src/nl80211util.c
index 9cd538ec..9092b204 100644
--- a/src/nl80211util.c
+++ b/src/nl80211util.c
@@ -128,6 +128,16 @@ static bool extract_iovec(const void *data, uint16_t len, void *o)
return true;
}
+static bool extract_nested(const void *data, uint16_t len, void *o)
+{
+ const struct l_genl_attr *outer = data;
+ struct l_genl_attr *nested = o;
+
+ l_genl_attr_recurse(outer, nested);
+
+ return true;
+}
+
static attr_handler handler_for_type(enum nl80211_attrs type)
{
switch (type) {
@@ -157,6 +167,8 @@ static attr_handler handler_for_type(enum nl80211_attrs type)
return extract_uint32;
case NL80211_ATTR_FRAME:
return extract_iovec;
+ case NL80211_ATTR_WIPHY_BANDS:
+ return extract_nested;
default:
break;
}
@@ -222,6 +234,10 @@ int nl80211_parse_attrs(struct l_genl_msg *msg, int tag, ...)
goto done;
}
+ /* For nested attributes use the outer attribute as data */
+ if (entry->handler == extract_nested)
+ data = &attr;
+
if (!entry->handler(data, len, entry->data)) {
ret = -EINVAL;
goto done;
--
2.34.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 01/10] manager: unregister nl80211 config watch
2022-07-26 17:09 [PATCH 01/10] manager: unregister nl80211 config watch James Prestwood
` (8 preceding siblings ...)
2022-07-26 17:09 ` [PATCH 10/10] nl80211util: add nested attribute support James Prestwood
@ 2022-07-26 20:52 ` Denis Kenzior
9 siblings, 0 replies; 13+ messages in thread
From: Denis Kenzior @ 2022-07-26 20:52 UTC (permalink / raw)
To: James Prestwood, iwd
Hi James,
On 7/26/22 12:09, James Prestwood wrote:
> For consistency unregister the config watch when manager exits
> ---
> src/manager.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
All but patch 4 applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 13+ messages in thread