anqp: print MAC when sending ANQP request
PATCH 1/8 anqp: print MAC when sending ANQP request
--- src/anqp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/anqp.c +1 -1
@@ -248,7 +248,7 @@ uint32_t anqp_request(uint64_t wdev_id, const uint8_t *addr, iov[0 ].iov_len = request->frame_len; iov[1 ].iov_base =NULL ; -l_debug ("Sending ANQP request" ); +l_debug ("Sending ANQP request to " MAC ,MAC_STR (bss->addr)); request->id = frame_xchg_start(request->wdev_id, iov, request->frequency, 0, 300, 0,
Signature · 1 line
2.31.1
PATCH 2/8 hwsim: require enabling rule before use
The hwsim Rule API was structured as properties so once a rule is created it automatically starts being applied to frames. This happens before anything has time to actually define the rule (source, destination etc). This leads to every single frame being matched to the rule until these other properties are added, which can result in unexpected behavior.
To fix this an "Enabled" property has been added and the rule will not be applied until this is true.
--- tools/hwsim.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
tools/hwsim.c +40 -0
@@ -124,6 +124,7 @@ struct hwsim_rule { bool destination_any : 1; bool bidirectional : 1; bool drop : 1; + bool enabled : 1;uint32_t frequency;int priority;int signal;
@@ -1177,6 +1178,9 @@ static void process_rules(const struct radio_info_rec *src_radio, rule_entry = rule_entry->next) {struct hwsim_rule *rule = rule_entry->data; +if (!rule->enabled) +return ; + if (!rule->source_any && !radio_match_addr(src_radio, rule->source) && (!rule->bidirectional ||
@@ -1996,6 +2000,7 @@ static struct l_dbus_message *rule_add(struct l_dbus *dbus, rule->source_any = true; rule->destination_any = true; rule->delay =HWSIM_DELAY_MIN_MS ; + rule->enabled = false;if (!rules) rules =l_queue_new ();
@@ -2369,6 +2374,37 @@ invalid_args:return dbus_error_invalid_args (message); } +static bool rule_property_get_enabled (struct l_dbus *dbus, +struct l_dbus_message *message, +struct l_dbus_message_builder *builder, +void *user_data) +{ +struct hwsim_rule *rule = user_data; +bool bval = rule->enabled; + +l_dbus_message_builder_append_basic (builder,'b' , &bval); + +return true; +} + +static struct l_dbus_message *rule_property_set_enabled ( +struct l_dbus *dbus, +struct l_dbus_message *message, +struct l_dbus_message_iter *new_value, +l_dbus_property_complete_cb_t complete, +void *user_data) +{ +struct hwsim_rule *rule = user_data; +bool bval; + +if (!l_dbus_message_iter_get_variant (new_value,"b" , &bval)) +return dbus_error_invalid_args (message); + + rule->enabled = bval; + +return l_dbus_message_new_method_return (message); +} +static void setup_rule_interface (struct l_dbus_interface *interface) {l_dbus_interface_method (interface,"Remove" ,0 , rule_remove,"" ,"" );
@@ -2409,6 +2445,10 @@ static void setup_rule_interface(struct l_dbus_interface *interface)L_DBUS_PROPERTY_FLAG_AUTO_EMIT ,"ay" , rule_property_get_prefix, rule_property_set_prefix); +l_dbus_interface_property (interface,"Enabled" , +L_DBUS_PROPERTY_FLAG_AUTO_EMIT ,"b" , + rule_property_get_enabled, + rule_property_set_enabled); } static void request_name_callback(struct l_dbus *dbus, bool success,
Signature · 1 line
2.31.1
PATCH 3/8 hwsim: remove unconditional packet delay
In reply to James PrestwoodThis was initially put in to solve an issue that was specific to mac80211_hwsim where the connect callback would get queued and delayed until after the connect event. This caused IWD to get very confused.
Later it was found that "real" drivers can sometimes do this so some code was added to IWD core to handle it.
Now there isn't much point to delay all frames unless a rule specifies so change the behavior back to sending out frames immediately.
--- tools/hwsim.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
tools/hwsim.c +15 -8
@@ -1436,9 +1436,11 @@ static void frame_delay_callback(struct l_timeout *timeout, void *user_data)else send_frame_destroy (send_info); -l_timeout_remove (timeout); +if (timeout) +l_timeout_remove (timeout); } +/* * Process frames in a similar way to how the kernel built-in hwsim medium * does this, with an additional optimization for unicast frames and
@@ -1457,7 +1459,7 @@ static void process_frame(struct hwsim_frame *frame)struct radio_info_rec *radio = entry->data;struct send_frame_info *send_info;bool drop = drop_mcast; -uint32_t delay =HWSIM_DELAY_MIN_MS ; +uint32_t delay =0 ;if (radio == frame->src_radio)continue ;
@@ -1499,11 +1501,16 @@ static void process_frame(struct hwsim_frame *frame) send_info->radio = radio; send_info->frame =hwsim_frame_ref (frame); -if (!l_timeout_create_ms (delay, frame_delay_callback, - send_info,NULL )) { -l_error ("Error delaying frame, frame will be dropped" ); -send_frame_destroy (send_info); - } +if (delay) { +if (!l_timeout_create_ms (delay, frame_delay_callback, + send_info,NULL )) { +l_error ("Error delaying frame %ums, " +"frame will be dropped" , delay); +send_frame_destroy (send_info); + } + }else +frame_delay_callback (NULL , send_info); + }hwsim_frame_unref (frame);
@@ -1999,7 +2006,7 @@ static struct l_dbus_message *rule_add(struct l_dbus *dbus, rule->id = next_rule_id++; rule->source_any = true; rule->destination_any = true; - rule->delay =HWSIM_DELAY_MIN_MS ; + rule->delay =0 ; rule->enabled = false;if (!rules)
Signature · 1 line
2.31.1
PATCH 4/8 auto-t: hwsim.py: add Enabled property
In reply to James Prestwood--- autotests/util/hwsim.py | 10 ++++++++++ 1 file changed, 10 insertions(+)
autotests/util/hwsim.py +10 -0
@@ -142,6 +142,16 @@ class Rule(HwsimDBusAbstract): reply_handler=self._success, error_handler=self._failure) self._wait_for_async_op() + @property + def enabled(self): + return self._properties['Enabled'] + + @enabled.setter + def enabled(self, value): + self._prop_proxy.Set(self._iface_name, 'Enabled', value, + reply_handler=self._success, error_handler=self._failure) + self._wait_for_async_op() + def remove(self): self._iface.Remove(reply_handler=self._success, error_handler=self._failure)
Signature · 1 line
2.31.1
PATCH 5/8 auto-t: hwsim.py: handle Prefix/Enabled in __str__
In reply to James Prestwood--- autotests/util/hwsim.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
autotests/util/hwsim.py +3 -1
@@ -171,7 +171,9 @@ class Rule(HwsimDBusAbstract): prefix + '\tFrequency:\t' + str(self.frequency) + '\n' + \ prefix + '\tApply rssi:\t' + str(self.signal) + '\n' + \ prefix + '\tApply drop:\t' + str(self.drop) + '\n' + \ - prefix + '\tPrefix:\t' + str([hex(b) for b in self.prefix]) + '\n' + prefix + '\tPrefix:\t' + str([hex(b) for b in self.prefix]) + '\n' + \ + prefix + '\tDelay:\t' + str(self.delay) + '\n' + \ + prefix + '\tEnabled:\t' + str(self.enabled) + '\n' class RuleSet(collections.Mapping): def __init__(self, hwsim, objects):
Signature · 1 line
2.31.1
PATCH 6/8 auto-t: combine testBSSBlacklist tests
In reply to James PrestwoodAll 4 tests were combined to reuse hwsim rule code, and improve cleanup between running tests.
--- .../testBSSBlacklist/all_blacklisted_test.py | 97 -------- autotests/testBSSBlacklist/bad_pass_test.py | 90 ------- autotests/testBSSBlacklist/connection_test.py | 220 +++++++++++++++--- .../testBSSBlacklist/temp_blacklist_test.py | 116 --------- 4 files changed, 192 insertions(+), 331 deletions(-) delete mode 100644 autotests/testBSSBlacklist/all_blacklisted_test.py delete mode 100644 autotests/testBSSBlacklist/bad_pass_test.py delete mode 100644 autotests/testBSSBlacklist/temp_blacklist_test.py
autotests/testBSSBlacklist/all_blacklisted_test.py deleted +0 -97
@@ -1,97 +0,0 @@ -#!/usr/bin/python3 - -import unittest -import sys - -sys.path.append('../util') -import iwd -from iwd import IWD -from iwd import PSKAgent -from iwd import NetworkType - -from hostapd import HostapdCLI -from hwsim import Hwsim - -class Test(unittest.TestCase): - - def test_connection_success(self): - hwsim = Hwsim() - - bss_hostapd = [ HostapdCLI(config='ssid1.conf'), - HostapdCLI(config='ssid2.conf'), - HostapdCLI(config='ssid3.conf') ] - bss_radio = [ hwsim.get_radio('rad0'), - hwsim.get_radio('rad1'), - hwsim.get_radio('rad2') ] - - rule0 = hwsim.rules.create() - rule0.source = bss_radio[0].addresses[0] - rule0.bidirectional = True - rule0.signal = -2000 - - rule1 = hwsim.rules.create() - rule1.source = bss_radio[1].addresses[0] - rule1.bidirectional = True - rule1.signal = -8000 - - rule2 = hwsim.rules.create() - rule2.source = bss_radio[2].addresses[0] - rule2.bidirectional = True - rule2.signal = -9000 - - wd = IWD(True) - - psk_agent = PSKAgent(["secret123", 'secret123']) - wd.register_psk_agent(psk_agent) - - devices = wd.list_devices(1) - device = devices[0] - - ordered_network = device.get_ordered_network("TestBlacklist") - - self.assertEqual(ordered_network.type, NetworkType.psk) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - # Have both APs drop all packets, both should get blacklisted - rule0.drop = True - rule1.drop = True - rule2.drop = True - - with self.assertRaises(iwd.FailedEx): - ordered_network.network_object.connect() - - rule0.drop = False - rule1.drop = False - rule2.drop = False - - # Wait for scanning (likely a quick-scan) to finish, otherwise we will - # may not have all BSS's in the list. - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - # This connect should work - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - self.assertIn(device.address, bss_hostapd[0].list_sta()) - - wd.unregister_psk_agent(psk_agent) - - rule0.remove() - rule1.remove() - rule2.remove() - - @classmethod - def setUpClass(cls): - pass - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - -if __name__ == '__main__': - unittest.main(exit=True)
autotests/testBSSBlacklist/bad_pass_test.py deleted +0 -90
90 lines not on this page · raw message
autotests/testBSSBlacklist/connection_test.py +192 -28
250 lines not on this page · raw message
autotests/testBSSBlacklist/temp_blacklist_test.py deleted +0 -116
116 lines not on this page · raw message
Signature · 1 line
2.31.1
PATCH 7/8 auto-t: update tests to enable hwsim rules
In reply to James Prestwood--- autotests/testHT-VHT/connection_test.py | 3 +++ autotests/testOWE/timeout_test.py | 2 ++ autotests/testRSSIAgent/connection_test.py | 1 + autotests/testRoamRetry/fast_retry_test.py | 2 ++ autotests/testRoamRetry/stop_retry_test.py | 2 ++ autotests/testSAE/timeout_test.py | 1 + 6 files changed, 11 insertions(+)
autotests/testHT-VHT/connection_test.py +3 -0
@@ -66,16 +66,19 @@ class Test(unittest.TestCase): rule0.source = vht_radio.addresses[0] rule0.bidirectional = True rule0.signal = -5100 + rule0.enabled = True rule1 = hwsim.rules.create() rule1.source = ht_radio.addresses[0] rule1.bidirectional = True rule1.signal = -5200 + rule1.enabled = True rule2 = hwsim.rules.create() rule2.source = non_ht_radio.addresses[0] rule2.bidirectional = True rule2.signal = -5300 + rule2.enabled = True wd = IWD()
autotests/testOWE/timeout_test.py +2 -0
@@ -39,12 +39,14 @@ class Test(unittest.TestCase): rule0.bidirectional = True rule0.drop = True rule0.prefix = 'b0' + rule0.enabled = True rule1 = hwsim.rules.create() rule1.source = bss_radio1.addresses[0] rule1.bidirectional = True rule1.drop = True rule1.prefix = 'b0' + rule1.enabled = True # Test Authenticate (b0) and Association (00) timeouts
autotests/testRSSIAgent/connection_test.py +1 -0
@@ -20,6 +20,7 @@ class Test(unittest.TestCase): def test_rssi_agent(self): rule = Hwsim().rules.create() rule.signal = -4000 + rule.enabled = True wd = IWD()
autotests/testRoamRetry/fast_retry_test.py +2 -0
@@ -29,10 +29,12 @@ class Test(unittest.TestCase): rule0 = hwsim.rules.create() rule0.source = bss_radio[0].addresses[0] rule0.bidirectional = True + rule0.enabled = True rule1 = hwsim.rules.create() rule1.source = bss_radio[1].addresses[0] rule1.bidirectional = True + rule1.enabled = True # Fill in the neighbor AP tables in both BSSes. By default each # instance knows only about current BSS, even inside one hostapd
autotests/testRoamRetry/stop_retry_test.py +2 -0
@@ -28,10 +28,12 @@ class Test(unittest.TestCase): rule0 = hwsim.rules.create() rule0.source = bss_radio[0].addresses[0] rule0.bidirectional = True + rule0.enabled = True rule1 = hwsim.rules.create() rule1.source = bss_radio[1].addresses[0] rule1.bidirectional = True + rule1.enabled = True # Fill in the neighbor AP tables in both BSSes. By default each # instance knows only about current BSS, even inside one hostapd
autotests/testSAE/timeout_test.py +1 -0
@@ -35,6 +35,7 @@ class Test(unittest.TestCase): rule0.bidirectional = True rule0.drop = True rule0.prefix = 'b0' + rule0.enabled = True wd.wait(1) print(rule0)
Signature · 1 line
2.31.1
PATCH 8/8 auto-t: remove ANQP delay test
In reply to James PrestwoodThe idea of this test is valid but it is extremely timing dependent which simply isn't testable on all machines. Removing this test at least until this can be tested reliably.
--- autotests/testHotspot/anqp_delay_test.py | 106 ----------------------- 1 file changed, 106 deletions(-) delete mode 100644 autotests/testHotspot/anqp_delay_test.py
autotests/testHotspot/anqp_delay_test.py deleted +0 -106
@@ -1,106 +0,0 @@ -#!/usr/bin/python3 - -import unittest -import sys -import os - -sys.path.append('../util') -from iwd import IWD -from iwd import IWD_CONFIG_DIR -from iwd import PSKAgent -from iwd import NetworkType -from hostapd import HostapdCLI -from hwsim import Hwsim -import testutil -from time import sleep - -class Test(unittest.TestCase): - - def test_connection_success(self): - wd = self.wd - hapd = self.hapd - rule0 = self.rule0 - - devices = wd.list_devices(1) - device = devices[0] - device.autoconnect = True - - # We are dependent on a periodic scan here. We want to wait for this - # because this is the first opportunity IWD has to do ANQP. Once ANQP - # has been done once the network is set up and we cannot simulate the - # 'Connect() before ANQP' race condition anymore. - condition = 'obj.scanning' - wd.wait_for_object_condition(device, condition) - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - # If no networks were found we likely had a quick scan. Try again to - # allow the full autoconnect scan to happen. - try: - ordered_network = device.get_ordered_network('Hotspot') - except: - condition = 'obj.scanning' - wd.wait_for_object_condition(device, condition) - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network('Hotspot') - - self.assertEqual(ordered_network.type, NetworkType.eap) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - # Force the case where ANQP does not finish before Connect() comes in - rule0.delay = 100 - rule0.prefix = '0d' - - ordered_network.network_object.connect(wait=False) - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - hapd.wait_for_event('AP-STA-CONNECTED') - - testutil.test_iface_operstate() - testutil.test_ifaces_connected(device.name, hapd.ifname) - - device.disconnect() - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - @classmethod - def setUpClass(cls): - cls.hwsim = Hwsim() - - bss_radio = cls.hwsim.get_radio('rad0') - cls.rule0 = cls.hwsim.rules.create() - cls.rule0.source = bss_radio.addresses[0] - cls.rule0.bidirectional = True - - cls.hapd = HostapdCLI(config='ssidHotspot.conf') - - IWD.copy_to_hotspot('example.conf') - IWD.copy_to_storage('anqp_enabled.conf', storage_dir=IWD_CONFIG_DIR, name='main.conf') - - cls.wd = IWD(True) - cls.psk_agent = PSKAgent('abc', ('domain\\user', 'testpasswd')) - cls.wd.register_psk_agent(cls.psk_agent) - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - - cls.wd.unregister_psk_agent(cls.psk_agent) - cls.psk_agent = None - os.remove('/tmp/main.conf') - - cls.hwsim.rules.remove_all() - cls.hwsim = None - cls.wd = None - -if __name__ == '__main__': - unittest.main(exit=True)
Signature · 1 line
2.31.1
Hi James,
Quoted 4 lines · James Prestwood
--- src/anqp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
All applied, thanks.
Regards,
-Denis