Skip to contentSkip to conversation

main: add a --developer,-E option

PATCH In review James Prestwood 2 participants 4 messages May 5, 2021 – May 7, 2021

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/3 main: add a --developer,-E option

This will enable developer features to be used. Currently the only user of this will be StationDiagnostics.Roam() method which should only be exposed in this mode.

---
 src/iwd.h  |  1 +
 src/main.c | 12 +++++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

v2:
* Added this patch to replace the dbus config changes

src/iwd.h +1 -0
index 51548cbb..1be20df3 100644
@@ -41,3 +41,4 @@ const char *iwd_get_iface_blacklist(void);
 
 const char *iwd_get_phy_whitelist(void);
 const char *iwd_get_phy_blacklist(void);
+bool iwd_is_developer_mode(void);
src/main.c +11 -1
index 2ee6188c..8e965341 100644
@@ -54,6 +54,7 @@ static const char *nointerfaces;
 static const char *phys;
 static const char *nophys;
 static const char *debugopt;
+static bool developeropt;
 static bool terminating;
 static bool nl80211_complete;
 
@@ -126,6 +127,11 @@ const char *iwd_get_phy_blacklist(void)
 	return nophys;
 }
 
+bool iwd_is_developer_mode(void)
+{
+	return developeropt;
+}
+
 static void usage(void)
 {
 	printf("iwd - Wireless daemon\n"
@@ -143,6 +149,7 @@ static void usage(void)
 }
 
 static const struct option main_options[] = {
+	{ "developer",    no_argument,       NULL, 'E' },
 	{ "dbus-debug",   no_argument,       NULL, 'B' },
 	{ "version",      no_argument,       NULL, 'v' },
 	{ "interfaces",   required_argument, NULL, 'i' },
@@ -363,7 +370,7 @@ int main(int argc, char *argv[])
 	for (;;) {
 		int opt;
 
-		opt = getopt_long(argc, argv, "Bi:I:p:P:d::vh",
+		opt = getopt_long(argc, argv, "EBi:I:p:P:d::vh",
 							main_options, NULL);
 		if (opt < 0)
 			break;
@@ -372,6 +379,9 @@ int main(int argc, char *argv[])
 		case 'B':
 			enable_dbus_debug = true;
 			break;
+		case 'E':
+			developeropt = true;
+			break;
 		case 'i':
 			interfaces = optarg;
 			break;
Signature · 1 line
2.26.2
#1 lore raw

PATCH v2 2/3 station: add Roam() diagnostics method

This is being added as a developer method and should not be used in production. For testing purposes though, it is quite useful as it forces IWD to roam to a provided BSS and bypasses IWD's roaming and ranking logic for choosing a roam candidate.

To use this a BSSID is provided as the only parameter. If this BSS is not in IWD's current scan results -EINVAL will be returned. If IWD knows about the BSS it will attempt to roam to it whether that is via FT, FT-over-DS, or Reassociation. These details are still sorted out in IWDs station_transition_start() logic.

---
 src/station.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

v2:
* Check developer mode before adding Roam method

src/station.c +37 -0
index d2234e15..479f81f5 100644
@@ -3721,12 +3721,49 @@ static struct l_dbus_message *station_get_diagnostics(struct l_dbus *dbus,
 	return NULL;
 }
 
+static struct l_dbus_message *station_force_roam(struct l_dbus *dbus,
+						struct l_dbus_message *message,
+						void *user_data)
+{
+	struct station *station = user_data;
+	struct scan_bss *target;
+	struct l_dbus_message_iter iter;
+	uint8_t *mac;
+	uint32_t mac_len;
+
+	if (!l_dbus_message_get_arguments(message, "ay", &iter))
+		goto invalid_args;
+
+	if (!l_dbus_message_iter_get_fixed_array(&iter, &mac, &mac_len))
+		goto invalid_args;
+
+	if (mac_len != 6)
+		return dbus_error_invalid_args(message);
+
+	target = network_bss_find_by_addr(station->connected_network, mac);
+	if (!target || target == station->connected_bss)
+		return dbus_error_invalid_args(message);
+
+	l_debug("Attempting forced roam to BSS "MAC, MAC_STR(mac));
+
+	station_transition_start(station, target);
+
+	return l_dbus_message_new_method_return(message);
+
+invalid_args:
+	return dbus_error_invalid_args(message);
+}
+
 static void station_setup_diagnostic_interface(
 					struct l_dbus_interface *interface)
 {
 	l_dbus_interface_method(interface, "GetDiagnostics", 0,
 				station_get_diagnostics, "a{sv}", "",
 				"diagnostics");
+
+	if (iwd_is_developer_mode())
+		l_dbus_interface_method(interface, "Roam", 0,
+					station_force_roam, "", "ay", "mac");
 }
 
 static void station_destroy_diagnostic_interface(void *user_data)
Signature · 1 line
2.26.2
#2 lore raw

PATCH v2 3/3 test: add test utility for Roam() method

In reply to James Prestwood
---
 test/force-roam | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100755 test/force-roam
test/force-roam new file +16 -0
new file mode 100755
index 00000000..b590c84a
@@ -0,0 +1,16 @@
+#!/usr/bin/python3
+
+import sys
+import dbus
+
+if (len(sys.argv) != 3):
+    print("Usage: %s <device> <mac>" % (sys.argv[0]))
+    sys.exit(1)
+
+bus = dbus.SystemBus()
+device = dbus.Interface(bus.get_object("net.connman.iwd", sys.argv[1]),
+                                    "net.connman.iwd.StationDiagnostic")
+
+mac = sys.argv[2].replace(':', '')
+
+device.Roam(dbus.ByteArray.fromhex(mac))
Signature · 1 line
2.26.2
#3 lore raw
In reply to James Prestwood

Hi James,

Quoted 11 lines · James Prestwood

This will enable developer features to be used. Currently the only user of this will be StationDiagnostics.Roam() method which should only be exposed in this mode.

---
  src/iwd.h  |  1 +
  src/main.c | 12 +++++++++++-
  2 files changed, 12 insertions(+), 1 deletion(-)

v2:
* Added this patch to replace the dbus config changes

All applied, thanks.

Regards,
-Denis