Skip to contentSkip to conversation

manager: unregister nl80211 config watch

PATCH In review James Prestwood 2 participants 13 messages Jul 26, 2022 – Jul 27, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/10 manager: unregister nl80211 config watch

For consistency unregister the config watch when manager exits

---
 src/manager.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
src/manager.c +7 -2
index ca29e110..437841b3 100644
@@ -49,6 +49,7 @@ static char **whitelist_filter;
 static char **blacklist_filter;
 static bool randomize;
 static bool use_default;
+static unsigned int config_watch;
 
 struct wiphy_setup_state {
 	uint32_t id;
@@ -820,8 +821,10 @@ static int manager_init(void)
 
 	pending_wiphys = l_queue_new();
 
-	if (!l_genl_family_register(nl80211, "config", manager_config_notify,
-					NULL, NULL)) {
+	config_watch = l_genl_family_register(nl80211, "config",
+						manager_config_notify,
+						NULL, NULL);
+	if (!config_watch) {
 		l_error("Registering for config notifications failed");
 		goto error;
 	}
@@ -880,6 +883,8 @@ static void manager_exit(void)
 	l_strfreev(whitelist_filter);
 	l_strfreev(blacklist_filter);
 
+	l_genl_family_unregister(nl80211, config_watch);
+
 	l_queue_destroy(pending_wiphys, wiphy_setup_state_free);
 	pending_wiphys = NULL;
 
Signature · 1 line
2.34.3
#1 lore raw

PATCH 2/10 test-runner: make developer mode optional

IWD can now be started without -E if needed

---
 tools/utils.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
tools/utils.py +6 -2
index 7a182848..a1b3e041 100644
@@ -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])
Signature · 1 line
2.34.3
#2 lore raw

PATCH 3/10 auto-t: iwd.py: let IWD class specify developer mode

In reply to James Prestwood
---
 autotests/util/iwd.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
autotests/util/iwd.py +4 -2
index db91ab8a..b17fe163 100755
@@ -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)
 
Signature · 1 line
2.34.3
#3 lore raw

PATCH 4/10 wiphy: fix runtime error from bit shift

In reply to 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(-)
src/wiphy.c +14 -34
index 09b99fb2..98bd3aa4 100644
@@ -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:
Signature · 1 line
2.34.3
#4 lore raw

Re: [PATCH 04/10] wiphy: fix runtime error from bit shift

Hi James,

Quoted 19 lines · 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(-)
src/wiphy.c +0 -0
index 09b99fb2..98bd3aa4 100644

src/wiphy.c bool wiphy_constrain_freq_set(const struct wiphy *wiphy, · line 710

Quoted 5 lines
src/wiphy.c +1 -1
@@ -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?

Quoted 6 lines
src/wiphy.c +1 -2
  {
-	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;

src/wiphy.c bool wiphy_constrain_freq_set(const struct wiphy *wiphy, · line 722

Quoted 10 lines
src/wiphy.c +2 -2
 
-	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

#5 lore raw

Re: [PATCH 04/10] wiphy: fix runtime error from bit shift

Quoted 21 lines · Denis Kenzior

Hi James,

Quoted 18 lines · 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(-)
Quoted 15 lines
Quoted 8 lines
src/wiphy.c +0 -0
index 09b99fb2..98bd3aa4 100644
@@ -707,17 +707,16 @@ bool wiphy_constrain_freq_set(const struct
 wiphy *wiphy,
         return true;
   }
Quoted 4 lines


-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.

#6 lore raw

PATCH 5/10 scan: make scan_freq_set const in scan_passive

In reply to 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(-)
src/p2p.c +13 -8
index a7207c30..ff3b8e45 100644
@@ -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, &params, 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, &params, NULL,
 					p2p_scan_notify, dev, p2p_scan_destroy);
-	scan_freq_set_free(params.freqs);
+	scan_freq_set_free(freqs);
 
 	return dev->scan_id != 0;
 }
src/scan.c +2 -2
index 39aef625..03e5b8d9 100644
@@ -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)
 {
src/scan.h +2 -2
index 79bec605..58b8332b 100644
@@ -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,
Signature · 1 line
2.34.3
#7 lore raw

PATCH 6/10 util: make scan_freq_set_get_bands const

In reply to James Prestwood
---
 src/util.c | 2 +-
 src/util.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
src/util.c +1 -1
index 2832486d..3c6e2b1b 100644
@@ -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;
src/util.h +1 -1
index 75c29039..f61e3575 100644
@@ -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,
Signature · 1 line
2.34.3
#8 lore raw

PATCH 7/10 util: add scan_freq_set_subtract

In reply to 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(+)
src/util.c +22 -0
index 3c6e2b1b..ebaff6a0 100644
@@ -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;
src/util.h +2 -0
index f61e3575..0b7832fb 100644
@@ -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);
Signature · 1 line
2.34.3
#9 lore raw

PATCH 8/10 wiphy: add disabled_freqs list

In reply to 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(-)
src/wiphy.c +23 -3
index 98bd3aa4..5329e8e4 100644
@@ -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);
 	}
 }
 
src/wiphy.h +1 -0
index acc64193..9a3b96f9 100644
@@ -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);
Signature · 1 line
2.34.3
#10 lore raw

PATCH 9/10 wiphy: constrain scan set by disabled frequencies

In reply to 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(+)
src/wiphy.c +1 -0
index 5329e8e4..30653b91 100644
@@ -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. */
Signature · 1 line
2.34.3
#11 lore raw

PATCH 10/10 nl80211util: add nested attribute support

In reply to James Prestwood

Adds support for nested attributes in nl80211_parse_attrs

---
 src/nl80211util.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
src/nl80211util.c +16 -0
index 9cd538ec..9092b204 100644
@@ -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;
Signature · 1 line
2.34.3
#12 lore raw
In reply to James Prestwood

Hi James,

Quoted 5 lines · James Prestwood

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