Skip to contentSkip to conversation

station: add Roam() diagnostics method

PATCH In review James Prestwood 2 participants 6 messages May 5, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/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 | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
src/station.c +35 -0
index d2234e15..62eebfa2 100644
@@ -3721,12 +3721,47 @@ 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);
+
+	l_debug("Attempting roam to BSS "MAC, MAC_STR(mac));
+
+	target = network_bss_find_by_addr(station->connected_network, mac);
+	if (!target || target == station->connected_bss)
+		return dbus_error_invalid_args(message);
+
+	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");
+	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
#1 lore raw

PATCH 2/3 iwd-dbus: deny Roam() method for shipped dbus config

This is not a production method and it is recommended to deny access unless being used for testing.

---
 src/iwd-dbus.conf | 4 ++++
 1 file changed, 4 insertions(+)
src/iwd-dbus.conf +4 -0
index 6b07ba9e..c36401c8 100644
@@ -11,20 +11,24 @@
     <allow own="net.connman.iwd"/>
     <allow send_destination="net.connman.iwd"/>
     <allow send_interface="net.connman.iwd.Agent"/>
+    <deny send_interface="net.connman.iwd.StationDiagnostic" send_member="Roam"/>
   </policy>
 
   <policy group="wheel">
     <allow send_destination="net.connman.iwd"/>
     <allow send_interface="net.connman.iwd.Agent"/>
+    <deny send_interface="net.connman.iwd.StationDiagnostic" send_member="Roam"/>
   </policy>
 
   <policy at_console="true">
     <allow send_destination="net.connman.iwd"/>
     <allow send_interface="net.connman.iwd.Agent"/>
+    <deny send_interface="net.connman.iwd.StationDiagnostic" send_member="Roam"/>
   </policy>
 
   <policy context="default">
     <deny send_destination="net.connman.iwd"/>
+    <deny send_interface="net.connman.iwd.StationDiagnostic" send_member="Roam"/>
   </policy>
 
 </busconfig>
Signature · 1 line
2.26.2
#2 lore raw

Re: [PATCH 2/3] iwd-dbus: deny Roam() method for shipped dbus config

Hi James,

Quoted 34 lines

This is not a production method and it is recommended to deny access unless being used for testing.
---
src/iwd-dbus.conf | 4 ++++

1 file changed, 4 insertions(+)
src/iwd-dbus.conf +4 -0
index 6b07ba9e..c36401c8 100644
@@ -11,20 +11,24 @@
    <allow own="net.connman.iwd"/>
    <allow send_destination="net.connman.iwd"/>
    <allow send_interface="net.connman.iwd.Agent"/>
+    <deny send_interface="net.connman.iwd.StationDiagnostic" send_member="Roam"/>
  </policy>
 
  <policy group="wheel">
    <allow send_destination="net.connman.iwd"/>
    <allow send_interface="net.connman.iwd.Agent"/>
+    <deny send_interface="net.connman.iwd.StationDiagnostic" send_member="Roam"/>
  </policy>
 
  <policy at_console="true">
    <allow send_destination="net.connman.iwd"/>
    <allow send_interface="net.connman.iwd.Agent"/>
+    <deny send_interface="net.connman.iwd.StationDiagnostic" send_member="Roam"/>
  </policy>
 
  <policy context="default">
    <deny send_destination="net.connman.iwd"/>
+    <deny send_interface="net.connman.iwd.StationDiagnostic" send_member="Roam"/>
  </policy>
 
Quoted 1 line

</busconfig>

I actually dislike this. If something that is just for developers, then we should add a switch that starts iwd in developer mode and then these methods are added.

My problem is that even if you add a policy here, the D-Bus introspection will still show the method to everybody.

Regards

Marcel

#3 lore raw

Re: [PATCH 2/3] iwd-dbus: deny Roam() method for shipped dbus config

Hi Marcel,

<snip>

Quoted 4 lines

I actually dislike this. If something that is just for developers, then we should add a switch that starts iwd in developer mode and then these methods are added.

Sure, I'm fine with a hidden main.conf option as well.

Quoted 8 lines

My problem is that even if you add a policy here, the D-Bus introspection will still show the method to everybody.

Regards

Marcel

Thanks,
James

#4 lore raw

Re: [PATCH 2/3] iwd-dbus: deny Roam() method for shipped dbus config

Hi James,

Quoted 5 lines
Quoted 3 lines

I actually dislike this. If something that is just for developers, then we should add a switch that starts iwd in developer mode and then these methods are added.

Sure, I'm fine with a hidden main.conf option as well.

either that or a command line option to iwd.

Regards

Marcel

#5 lore raw

PATCH 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