All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/11] hwsim: add --no-register option
@ 2020-12-17 19:36 James Prestwood
  2020-12-17 19:36 ` [PATCH 02/11] hwsim: check pending_create_msg before replying James Prestwood
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: James Prestwood @ 2020-12-17 19:36 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 1726 bytes --]

Starts hwsim but does not register to mac80211_hwsim. This is to
allow autotests to disable hwsim, while still having the ability
to create/destroy radios over DBus.
---
 tools/hwsim.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/tools/hwsim.c b/tools/hwsim.c
index 02053fa1..641a6c6f 100644
--- a/tools/hwsim.c
+++ b/tools/hwsim.c
@@ -151,6 +151,7 @@ static enum action {
 
 static bool no_vif_attr;
 static bool p2p_attr;
+static bool no_register = false;
 static const char *radio_name_attr;
 static struct l_dbus *dbus;
 static struct l_queue *rules;
@@ -2347,6 +2348,9 @@ static void get_interface_done_initial(void *user_data)
 {
 	struct l_genl_msg *msg;
 
+	if (no_register)
+		return;
+
 	msg = l_genl_msg_new_sized(HWSIM_CMD_REGISTER, 4);
 	l_genl_family_send(hwsim, msg, register_callback, NULL, NULL);
 }
@@ -2625,6 +2629,7 @@ static const struct option main_options[] = {
 	{ "version",	 no_argument,		NULL, 'v' },
 	{ "iftype-disable", required_argument,	NULL, 't' },
 	{ "cipher-disable", required_argument,	NULL, 'c' },
+	{ "no-register", no_argument,		NULL, 'r' },
 	{ "help",	 no_argument,		NULL, 'h' },
 	{ }
 };
@@ -2636,7 +2641,7 @@ int main(int argc, char *argv[])
 	for (;;) {
 		int opt;
 
-		opt = getopt_long(argc, argv, ":L:CD:kndetc:ipvh", main_options,
+		opt = getopt_long(argc, argv, ":L:CD:kndetrc:ipvh", main_options,
 									NULL);
 		if (opt < 0)
 			break;
@@ -2682,6 +2687,9 @@ int main(int argc, char *argv[])
 		case 'c':
 			hwsim_disable_ciphers(optarg);
 			break;
+		case 'r':
+			no_register = true;
+			break;
 		case 'v':
 			printf("%s\n", VERSION);
 			return EXIT_SUCCESS;
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 02/11] hwsim: check pending_create_msg before replying
  2020-12-17 19:36 [PATCH 01/11] hwsim: add --no-register option James Prestwood
@ 2020-12-17 19:36 ` James Prestwood
  2020-12-17 19:36 ` [PATCH 03/11] auto-t: fix hwsim.py to use Destroy rather than Remove James Prestwood
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: James Prestwood @ 2020-12-17 19:36 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 820 bytes --]

In the NEW_RADIO callback hwsim was assuming that DBus had no
yet replied to the Create() method. In some cases the NEW_RADIO
event fires before the actual callback which will respond to
DBus. This causes a crash in the create callback.
---
 tools/hwsim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/hwsim.c b/tools/hwsim.c
index 641a6c6f..c17792bf 100644
--- a/tools/hwsim.c
+++ b/tools/hwsim.c
@@ -1579,7 +1579,7 @@ static void radio_manager_create_callback(struct l_genl_msg *msg,
 	 */
 	radio = l_queue_find(radio_info, radio_info_match_id,
 				L_UINT_TO_PTR(pending_create_radio_id));
-	if (radio) {
+	if (radio && pending_create_msg) {
 		const char *path = radio_get_path(radio);
 
 		reply = l_dbus_message_new_method_return(pending_create_msg);
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 03/11] auto-t: fix hwsim.py to use Destroy rather than Remove
  2020-12-17 19:36 [PATCH 01/11] hwsim: add --no-register option James Prestwood
  2020-12-17 19:36 ` [PATCH 02/11] hwsim: check pending_create_msg before replying James Prestwood
@ 2020-12-17 19:36 ` James Prestwood
  2020-12-17 19:36 ` [PATCH 04/11] hwsim: change radio Create() to take a dictionary James Prestwood
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: James Prestwood @ 2020-12-17 19:36 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 723 bytes --]

There is no Remove() method, but since this code never was used it
remained incorrect for quite some time.
---
 autotests/util/hwsim.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/autotests/util/hwsim.py b/autotests/util/hwsim.py
index 415bfc90..b0e6a089 100755
--- a/autotests/util/hwsim.py
+++ b/autotests/util/hwsim.py
@@ -203,7 +203,7 @@ class Radio(HwsimDBusAbstract):
         return [str(addr) for addr in self._properties['Addresses']]
 
     def remove(self):
-        self._iface.Remove(reply_handler=self._success,
+        self._iface.Destroy(reply_handler=self._success,
                 error_handler=self._failure)
 
         self._wait_for_async_op()
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 04/11] hwsim: change radio Create() to take a dictionary
  2020-12-17 19:36 [PATCH 01/11] hwsim: add --no-register option James Prestwood
  2020-12-17 19:36 ` [PATCH 02/11] hwsim: check pending_create_msg before replying James Prestwood
  2020-12-17 19:36 ` [PATCH 03/11] auto-t: fix hwsim.py to use Destroy rather than Remove James Prestwood
@ 2020-12-17 19:36 ` James Prestwood
  2020-12-17 19:36 ` [PATCH 05/11] auto-t: update hwsim radio create to use dictionary James Prestwood
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: James Prestwood @ 2020-12-17 19:36 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 2455 bytes --]

The Create() API was limited to only taking a Name and boolean
(for p2p enabling). The actual hwsim nl80211 API can take more
attributes than this (which are actually utilized when creating
from the command line). To get the DBus API up to the same
functionality the two arguments in Create were replaced with
a single dictionary. This allows for extending later if more
arguments are needed.
---
 tools/hwsim.c | 35 ++++++++++++++++++++++++++++-------
 1 file changed, 28 insertions(+), 7 deletions(-)

diff --git a/tools/hwsim.c b/tools/hwsim.c
index c17792bf..6a1eb348 100644
--- a/tools/hwsim.c
+++ b/tools/hwsim.c
@@ -1599,20 +1599,38 @@ static struct l_dbus_message *radio_manager_create(struct l_dbus *dbus,
 					void *user_data)
 {
 	struct l_genl_msg *new_msg;
-	const char *name;
-	bool p2p;
+	struct l_dbus_message_iter dict;
+	struct l_dbus_message_iter variant;
+	const char *key;
+	const char *name = NULL;
+	bool p2p = false;
 
 	if (pending_create_msg)
 		return dbus_error_busy(message);
 
-	if (!l_dbus_message_get_arguments(message, "sb", &name, &p2p))
-		return dbus_error_invalid_args(message);
+	if (!l_dbus_message_get_arguments(message, "a{sv}", &dict))
+		goto invalid;
+
+	while (l_dbus_message_iter_next_entry(&dict, &key, &variant)) {
+		bool ret = false;
 
-	new_msg = l_genl_msg_new_sized(HWSIM_CMD_NEW_RADIO, 16 + strlen(name));
+		if (!strcmp(key, "Name"))
+			ret = l_dbus_message_iter_get_variant(&variant,
+								"s", &name);
+		else if (!strcmp(key, "P2P"))
+			ret = l_dbus_message_iter_get_variant(&variant,
+								"b", &p2p);
+
+		if (!ret)
+			goto invalid;
+	}
+
+	new_msg = l_genl_msg_new_sized(HWSIM_CMD_NEW_RADIO,
+					16 + name ? strlen(name) : 0);
 	l_genl_msg_append_attr(new_msg, HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE,
 				0, NULL);
 
-	if (name[0])
+	if (name)
 		l_genl_msg_append_attr(new_msg, HWSIM_ATTR_RADIO_NAME,
 					strlen(name) + 1, name);
 
@@ -1627,12 +1645,15 @@ static struct l_dbus_message *radio_manager_create(struct l_dbus *dbus,
 	pending_create_radio_id = 0;
 
 	return NULL;
+
+invalid:
+	return dbus_error_invalid_args(message);
 }
 
 static void setup_radio_manager_interface(struct l_dbus_interface *interface)
 {
 	l_dbus_interface_method(interface, "CreateRadio", 0,
-				radio_manager_create, "o", "sb",
+				radio_manager_create, "o", "a{sv}",
 				"path", "name", "p2p_device");
 }
 
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 05/11] auto-t: update hwsim radio create to use dictionary
  2020-12-17 19:36 [PATCH 01/11] hwsim: add --no-register option James Prestwood
                   ` (2 preceding siblings ...)
  2020-12-17 19:36 ` [PATCH 04/11] hwsim: change radio Create() to take a dictionary James Prestwood
@ 2020-12-17 19:36 ` James Prestwood
  2020-12-17 19:36 ` [PATCH 06/11] test-runner: add wait_for_dbus_service James Prestwood
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: James Prestwood @ 2020-12-17 19:36 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 888 bytes --]

---
 autotests/util/hwsim.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/autotests/util/hwsim.py b/autotests/util/hwsim.py
index b0e6a089..9ad8ce09 100755
--- a/autotests/util/hwsim.py
+++ b/autotests/util/hwsim.py
@@ -249,8 +249,15 @@ class RadioList(collections.Mapping):
     def _interfaces_removed_handler(self, path, interfaces):
         del _dict[path]
 
-    def create(self, name='', p2p_device=False):
-        path = self._radio_manager.CreateRadio(name, p2p_device)
+    def create(self, name=None, p2p_device=False):
+        args = dbus.Dictionary({
+            'P2P': p2p_device,
+        }, signature='sv')
+
+        if name:
+            args['Name'] = name
+
+        path = self._radio_manager.CreateRadio(args)
         obj = Radio(path)
         self._dict[path] = obj
         return obj
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 06/11] test-runner: add wait_for_dbus_service
  2020-12-17 19:36 [PATCH 01/11] hwsim: add --no-register option James Prestwood
                   ` (3 preceding siblings ...)
  2020-12-17 19:36 ` [PATCH 05/11] auto-t: update hwsim radio create to use dictionary James Prestwood
@ 2020-12-17 19:36 ` James Prestwood
  2020-12-17 19:36 ` [PATCH 07/11] test-runner: start hwsim always (optionally --no-register) James Prestwood
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: James Prestwood @ 2020-12-17 19:36 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 668 bytes --]

Common API to wait for a DBus service to appear on the bus
---
 tools/test-runner | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/test-runner b/tools/test-runner
index bc580a41..d16c8885 100755
--- a/tools/test-runner
+++ b/tools/test-runner
@@ -616,6 +616,15 @@ class Namespace:
 
 		return False
 
+	def wait_for_dbus_service(self, service):
+		tries = 0
+
+		while not self._bus.name_has_owner(service):
+			if tries > 200:
+				raise TimeoutError('DBus service %s did not appear', service)
+			tries += 1
+			sleep(0.1)
+
 	def __str__(self):
 		ret = 'Namespace: %s\n' % self.name
 		ret += 'Processes:\n'
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 07/11] test-runner: start hwsim always (optionally --no-register)
  2020-12-17 19:36 [PATCH 01/11] hwsim: add --no-register option James Prestwood
                   ` (4 preceding siblings ...)
  2020-12-17 19:36 ` [PATCH 06/11] test-runner: add wait_for_dbus_service James Prestwood
@ 2020-12-17 19:36 ` James Prestwood
  2020-12-17 19:36 ` [PATCH 08/11] hwsim: add iftype/cipher disabling through DBus James Prestwood
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: James Prestwood @ 2020-12-17 19:36 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 1178 bytes --]

Always start hwsim but if tests do not need radio rules start
with the --no-register option.
---
 tools/test-runner | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/tools/test-runner b/tools/test-runner
index d16c8885..16628399 100755
--- a/tools/test-runner
+++ b/tools/test-runner
@@ -675,6 +675,14 @@ class TestContext(Namespace):
 	def create_radios(self):
 		setup = self.hw_config['SETUP']
 		nradios = int(setup['num_radios'])
+		args = ['hwsim']
+
+		if not self.hw_config['SETUP'].get('hwsim_medium', 'yes') in ['yes', '1', 'true']:
+			# register hwsim as medium
+			args.extend(['--no-register'])
+
+		self.start_process(args)
+		self.wait_for_dbus_service('net.connman.hwsim')
 
 		for i in range(nradios):
 			name = 'rad%u' % i
@@ -690,10 +698,6 @@ class TestContext(Namespace):
 			self.radios.append(VirtualRadio(name, rad_config))
 			self.cur_radio_id += 1
 
-		if self.hw_config['SETUP'].get('hwsim_medium', 'yes') in ['yes', '1', 'true']:
-			# register hwsim as medium
-			self.start_process(['hwsim'])
-
 	def discover_radios(self):
 		phys = []
 		iw = pyroute2.iwutil.IW()
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 08/11] hwsim: add iftype/cipher disabling through DBus
  2020-12-17 19:36 [PATCH 01/11] hwsim: add --no-register option James Prestwood
                   ` (5 preceding siblings ...)
  2020-12-17 19:36 ` [PATCH 07/11] test-runner: start hwsim always (optionally --no-register) James Prestwood
@ 2020-12-17 19:36 ` James Prestwood
  2020-12-17 19:36 ` [PATCH 09/11] auto-t: add iftype/cipher disable to hwsim.py James Prestwood
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: James Prestwood @ 2020-12-17 19:36 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 4746 bytes --]

Update the Dbus API to allow disabling iftypes and ciphers
just as you can with the command line.
---
 tools/hwsim.c | 141 ++++++++++++++++++++++++++++++--------------------
 1 file changed, 84 insertions(+), 57 deletions(-)

diff --git a/tools/hwsim.c b/tools/hwsim.c
index 6a1eb348..62a7d66d 100644
--- a/tools/hwsim.c
+++ b/tools/hwsim.c
@@ -195,6 +195,62 @@ static void do_debug(const char *str, void *user_data)
 	l_info("%s%s", prefix, str);
 }
 
+static void hwsim_disable_support(const char *disable,
+		const struct hwsim_support *map, uint32_t *mask)
+{
+	char **list = l_strsplit(disable, ',');
+	char **iter = list;
+	int i;
+
+	while (*iter) {
+		for (i = 0; map[i].name; i++) {
+			if (!strcmp(map[i].name, *iter))
+				*mask &= ~(map[i].value);
+		}
+
+		iter++;
+	}
+
+	l_strfreev(list);
+}
+
+static bool is_cipher_disabled(const char *args, enum crypto_cipher cipher)
+{
+	char **list = l_strsplit(args, ',');
+	char **iter = list;
+	int i;
+
+	while (*iter) {
+		for (i = 0; cipher_map[i].name; i++) {
+			if (!strcmp(*iter, cipher_map[i].name) &&
+					cipher == cipher_map[i].value) {
+				printf("disable cipher: %s\n", cipher_map[i].name);
+				l_strfreev(list);
+				return true;
+			}
+		}
+
+		iter++;
+	}
+
+	l_strfreev(list);
+
+	return false;
+}
+
+static void hwsim_disable_ciphers(const char *disable)
+{
+	uint8_t i;
+
+	for (i = 0; i < L_ARRAY_SIZE(hwsim_supported_ciphers); i++) {
+		if (is_cipher_disabled(disable, hwsim_supported_ciphers[i]))
+			continue;
+
+		hwsim_ciphers[hwsim_num_ciphers] = hwsim_supported_ciphers[i];
+		hwsim_num_ciphers++;
+	}
+}
+
 static void create_callback(struct l_genl_msg *msg, void *user_data)
 {
 	struct l_genl_attr attr;
@@ -1604,6 +1660,8 @@ static struct l_dbus_message *radio_manager_create(struct l_dbus *dbus,
 	const char *key;
 	const char *name = NULL;
 	bool p2p = false;
+	const char *disabled_iftypes = NULL;
+	const char *disabled_ciphers = NULL;
 
 	if (pending_create_msg)
 		return dbus_error_busy(message);
@@ -1620,7 +1678,12 @@ static struct l_dbus_message *radio_manager_create(struct l_dbus *dbus,
 		else if (!strcmp(key, "P2P"))
 			ret = l_dbus_message_iter_get_variant(&variant,
 								"b", &p2p);
-
+		else if (!strcmp(key, "InterfaceTypeDisable"))
+			ret = l_dbus_message_iter_get_variant(&variant, "s",
+							&disabled_iftypes);
+		else if (!strcmp(key, "CipherTypeDisable"))
+			ret = l_dbus_message_iter_get_variant(&variant, "s",
+							&disabled_ciphers);
 		if (!ret)
 			goto invalid;
 	}
@@ -1638,6 +1701,26 @@ static struct l_dbus_message *radio_manager_create(struct l_dbus *dbus,
 		l_genl_msg_append_attr(new_msg, HWSIM_ATTR_SUPPORT_P2P_DEVICE,
 					0, NULL);
 
+	if (disabled_iftypes) {
+		hwsim_disable_support(disabled_iftypes, iftype_map,
+						&hwsim_iftypes);
+
+		if (hwsim_iftypes != HWSIM_DEFAULT_IFTYPES)
+			l_genl_msg_append_attr(new_msg,
+						HWSIM_ATTR_IFTYPE_SUPPORT,
+						4, &hwsim_iftypes);
+	}
+
+	if (disabled_ciphers) {
+		hwsim_disable_ciphers(disabled_ciphers);
+
+		if (hwsim_num_ciphers)
+			l_genl_msg_append_attr(new_msg, HWSIM_ATTR_CIPHER_SUPPORT,
+					sizeof(uint32_t) * hwsim_num_ciphers,
+					hwsim_ciphers);
+
+	}
+
 	l_genl_family_send(hwsim, new_msg, radio_manager_create_callback,
 				pending_create_msg, NULL);
 
@@ -2525,62 +2608,6 @@ error:
 	l_main_quit();
 }
 
-static void hwsim_disable_support(char *disable,
-		const struct hwsim_support *map, uint32_t *mask)
-{
-	char **list = l_strsplit(disable, ',');
-	char **iter = list;
-	int i;
-
-	while (*iter) {
-		for (i = 0; map[i].name; i++) {
-			if (!strcmp(map[i].name, *iter))
-				*mask &= ~(map[i].value);
-		}
-
-		iter++;
-	}
-
-	l_strfreev(list);
-}
-
-static bool is_cipher_disabled(char *args, enum crypto_cipher cipher)
-{
-	char **list = l_strsplit(args, ',');
-	char **iter = list;
-	int i;
-
-	while (*iter) {
-		for (i = 0; cipher_map[i].name; i++) {
-			if (!strcmp(*iter, cipher_map[i].name) &&
-					cipher == cipher_map[i].value) {
-				printf("disable cipher: %s\n", cipher_map[i].name);
-				l_strfreev(list);
-				return true;
-			}
-		}
-
-		iter++;
-	}
-
-	l_strfreev(list);
-
-	return false;
-}
-
-static void hwsim_disable_ciphers(char *disable)
-{
-	uint8_t i;
-
-	for (i = 0; i < L_ARRAY_SIZE(hwsim_supported_ciphers); i++) {
-		if (is_cipher_disabled(disable, hwsim_supported_ciphers[i]))
-			continue;
-
-		hwsim_ciphers[hwsim_num_ciphers] = hwsim_supported_ciphers[i];
-		hwsim_num_ciphers++;
-	}
-}
-
 static void family_discovered(const struct l_genl_family_info *info,
 							void *user_data)
 {
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 09/11] auto-t: add iftype/cipher disable to hwsim.py
  2020-12-17 19:36 [PATCH 01/11] hwsim: add --no-register option James Prestwood
                   ` (6 preceding siblings ...)
  2020-12-17 19:36 ` [PATCH 08/11] hwsim: add iftype/cipher disabling through DBus James Prestwood
@ 2020-12-17 19:36 ` James Prestwood
  2020-12-17 19:36 ` [PATCH 10/11] test-runner: Use DBus for hwsim radios James Prestwood
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: James Prestwood @ 2020-12-17 19:36 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 1095 bytes --]

---
 autotests/util/hwsim.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/autotests/util/hwsim.py b/autotests/util/hwsim.py
index 9ad8ce09..9aa14cbc 100755
--- a/autotests/util/hwsim.py
+++ b/autotests/util/hwsim.py
@@ -249,7 +249,8 @@ class RadioList(collections.Mapping):
     def _interfaces_removed_handler(self, path, interfaces):
         del _dict[path]
 
-    def create(self, name=None, p2p_device=False):
+    def create(self, name=None, p2p_device=False, iftype_disable=None,
+                cipher_disable=None):
         args = dbus.Dictionary({
             'P2P': p2p_device,
         }, signature='sv')
@@ -257,6 +258,12 @@ class RadioList(collections.Mapping):
         if name:
             args['Name'] = name
 
+        if iftype_disable:
+            args['InterfaceTypeDisable'] = iftype_disable
+
+        if cipher_disable:
+            args['CipherTypeDisable'] = cipher_disable
+
         path = self._radio_manager.CreateRadio(args)
         obj = Radio(path)
         self._dict[path] = obj
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 10/11] test-runner: Use DBus for hwsim radios
  2020-12-17 19:36 [PATCH 01/11] hwsim: add --no-register option James Prestwood
                   ` (7 preceding siblings ...)
  2020-12-17 19:36 ` [PATCH 09/11] auto-t: add iftype/cipher disable to hwsim.py James Prestwood
@ 2020-12-17 19:36 ` James Prestwood
  2020-12-17 19:36 ` [PATCH 11/11] auto-t: fix hwsim.py spoof frame James Prestwood
  2020-12-18  2:15 ` [PATCH 01/11] hwsim: add --no-register option Denis Kenzior
  10 siblings, 0 replies; 12+ messages in thread
From: James Prestwood @ 2020-12-17 19:36 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 1917 bytes --]

Use the hwsim DBus API rather than command line. This both is
faster and more dynamic than doing so with the command line.
This also avoids tracking the radio ID since we can just hang
on to the radio Dbus object directly.
---
 tools/test-runner | 28 +++++++++-------------------
 1 file changed, 9 insertions(+), 19 deletions(-)

diff --git a/tools/test-runner b/tools/test-runner
index 16628399..7bd15a28 100755
--- a/tools/test-runner
+++ b/tools/test-runner
@@ -41,7 +41,6 @@ TIOCSTTY = 0x540E
 
 config = None
 intf_id = 0
-rad_id = 0
 
 TEST_MAX_TIMEOUT = 120
 
@@ -314,35 +313,26 @@ class VirtualRadio(Radio):
 		than the command line.
 	'''
 	def __init__(self, name, config=None):
-		global rad_id
-
-		super().__init__(name)
-
 		self.disable_cipher = None
 		self.disable_iftype = None
 
-		args = ['hwsim', '--create', '--name', self.name, '--nointerface', '--p2p']
+		hwsim = importlib.import_module('hwsim').Hwsim()
 
 		if config:
-			self.disable_iftype = config.get('iftype_disable', False)
-			if self.disable_iftype:
-				args.append('--iftype-disable')
-				args.append(self.disable_iftype)
-
-			self.disable_cipher = config.get('cipher_disable', False)
-			if self.disable_cipher:
-				args.append('--cipher-disable')
-				args.append(self.disable_cipher)
+			self.disable_iftype = config.get('iftype_disable', None)
+			self.disable_cipher = config.get('cipher_disable', None)
 
-		Process(args, wait=True)
+		self._radio = hwsim.radios.create(name, p2p_device=True,
+					iftype_disable=self.disable_iftype,
+					cipher_disable=self.disable_cipher)
 
-		self.id = rad_id
-		rad_id += 1
+		super().__init__(self._radio.name)
 
 	def __del__(self):
 		super().__del__()
 
-		Process(['hwsim', '--destroy=%s' % self.id])
+		self._radio.remove()
+		self._radio = None
 
 	def __str__(self):
 		ret = super().__str__()
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 11/11] auto-t: fix hwsim.py spoof frame
  2020-12-17 19:36 [PATCH 01/11] hwsim: add --no-register option James Prestwood
                   ` (8 preceding siblings ...)
  2020-12-17 19:36 ` [PATCH 10/11] test-runner: Use DBus for hwsim radios James Prestwood
@ 2020-12-17 19:36 ` James Prestwood
  2020-12-18  2:15 ` [PATCH 01/11] hwsim: add --no-register option Denis Kenzior
  10 siblings, 0 replies; 12+ messages in thread
From: James Prestwood @ 2020-12-17 19:36 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 1447 bytes --]

After the change creating radios from DBus the radio address pair
seems to come in mismatch order, meaning the radio address at
index zero may not always be what is expected. Instead of hardcoding
addresses[0] the address is checked in the entire addresses array.
---
 autotests/util/hwsim.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/autotests/util/hwsim.py b/autotests/util/hwsim.py
index 9aa14cbc..818bac1e 100755
--- a/autotests/util/hwsim.py
+++ b/autotests/util/hwsim.py
@@ -330,15 +330,15 @@ class Hwsim(iwd.AsyncOpAbstract):
             obj = objects[path]
             for interface in obj:
                 if interface == HWSIM_INTERFACE_INTERFACE:
-                    if obj[interface]['Address'] == radio.addresses[0]:
+                    if obj[interface]['Address'] in radio.addresses:
                         radio_path = path
                         break
 
         iface = dbus.Interface(self._bus.get_object(HWSIM_SERVICE, radio_path),
                 HWSIM_INTERFACE_INTERFACE)
 
-        iface.SendFrame(bytearray.fromhex(station.replace(':', '')),
-                        freq, -30, bytearray.fromhex(frame))
+        iface.SendFrame(dbus.ByteArray(bytearray.fromhex(station.replace(':', ''))),
+                        freq, -30, dbus.ByteArray(bytearray.fromhex(frame)))
 
     def get_radio(self, name):
         for path in self.radios:
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 01/11] hwsim: add --no-register option
  2020-12-17 19:36 [PATCH 01/11] hwsim: add --no-register option James Prestwood
                   ` (9 preceding siblings ...)
  2020-12-17 19:36 ` [PATCH 11/11] auto-t: fix hwsim.py spoof frame James Prestwood
@ 2020-12-18  2:15 ` Denis Kenzior
  10 siblings, 0 replies; 12+ messages in thread
From: Denis Kenzior @ 2020-12-18  2:15 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 423 bytes --]

Hi James,

On 12/17/20 1:36 PM, James Prestwood wrote:
> Starts hwsim but does not register to mac80211_hwsim. This is to
> allow autotests to disable hwsim, while still having the ability
> to create/destroy radios over DBus.
> ---
>   tools/hwsim.c | 10 +++++++++-
>   1 file changed, 9 insertions(+), 1 deletion(-)
> 

Patch 11 held back per your request...

Patches 1-10 applied thanks.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-12-18  2:15 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-17 19:36 [PATCH 01/11] hwsim: add --no-register option James Prestwood
2020-12-17 19:36 ` [PATCH 02/11] hwsim: check pending_create_msg before replying James Prestwood
2020-12-17 19:36 ` [PATCH 03/11] auto-t: fix hwsim.py to use Destroy rather than Remove James Prestwood
2020-12-17 19:36 ` [PATCH 04/11] hwsim: change radio Create() to take a dictionary James Prestwood
2020-12-17 19:36 ` [PATCH 05/11] auto-t: update hwsim radio create to use dictionary James Prestwood
2020-12-17 19:36 ` [PATCH 06/11] test-runner: add wait_for_dbus_service James Prestwood
2020-12-17 19:36 ` [PATCH 07/11] test-runner: start hwsim always (optionally --no-register) James Prestwood
2020-12-17 19:36 ` [PATCH 08/11] hwsim: add iftype/cipher disabling through DBus James Prestwood
2020-12-17 19:36 ` [PATCH 09/11] auto-t: add iftype/cipher disable to hwsim.py James Prestwood
2020-12-17 19:36 ` [PATCH 10/11] test-runner: Use DBus for hwsim radios James Prestwood
2020-12-17 19:36 ` [PATCH 11/11] auto-t: fix hwsim.py spoof frame James Prestwood
2020-12-18  2:15 ` [PATCH 01/11] hwsim: add --no-register option Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.