Skip to contentSkip to conversation

ap: make APRanges optional

PATCH In review James Prestwood 2 participants 5 messages Nov 3, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 ap: make APRanges optional

If EnableNetworkConfiguration was enabled ap.c required that APRanges also be set. This prevents IWD from starting which effects a perfectly valid station configuration. Instead if APRanges is not provided IWD still allows ap_init to pass but DHCP just will not be enabled.

---
 src/ap.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
src/ap.c +7 -2
index bebd7295..4d0d5686 100644
@@ -3028,9 +3028,14 @@ static int ap_init(void)
 
 		ip_prefix = l_settings_get_string(settings, "General",
 							"APRanges");
+		/*
+		 * In this case its assumed the user only cares about station
+		 * netconfig so we let ap_init pass but DHCP will not be
+		 * enabled.
+		 */
 		if (!ip_prefix) {
-			l_error("[General].APRanges must be set for DHCP");
-			return -EINVAL;
+			l_warn("[General].APRanges must be set for DHCP");
+			return 0;
 		}
 
 		if (!ip_pool_create(ip_prefix))
Signature · 1 line
2.26.2
#1 lore raw

PATCH 2/4 auto-t: fix testNetconfig hardcoded interface

If running multiple tests testNetconfig would fail due to the hardcoded wln0 in the dhcpd.conf file. dhcpd can actually start by passing in the interface to the run command rather than inside the config file.

---
 autotests/testNetconfig/connection_test.py | 3 ++-
 autotests/testNetconfig/dhcpd.conf         | 1 -
 2 files changed, 2 insertions(+), 2 deletions(-)
autotests/testNetconfig/connection_test.py +2 -1
index 6818ceff..5fc7a88e 100644
@@ -62,7 +62,8 @@ class Test(unittest.TestCase):
         ctx.start_process(['ifconfig', hapd.ifname, '192.168.1.1', 'netmask', '255.255.255.0'],
                                 wait=True)
         ctx.start_process(['touch', '/tmp/dhcpd.leases'], wait=True)
-        ctx.start_process(['dhcpd', '-cf', '/tmp/dhcpd.conf', '-lf', '/tmp/dhcpd.leases'])
+        ctx.start_process(['dhcpd', '-cf', '/tmp/dhcpd.conf', '-lf', '/tmp/dhcpd.leases',
+                            hapd.ifname])
 
     @classmethod
     def tearDownClass(cls):
autotests/testNetconfig/dhcpd.conf +0 -1
index 77b4da1c..0c4fe9b9 100644
@@ -10,7 +10,6 @@ subnet 192.168.1.0 netmask 255.255.255.0
   option routers 192.168.1.1;
   option subnet-mask 255.255.255.0;
   option domain-name-servers 192.168.1.1;
-  interface wln0;
   range 192.168.1.10 192.168.1.20;
   range 192.168.1.100 192.168.1.200;
  }
Signature · 1 line
2.26.2
#2 lore raw

PATCH 3/4 auto-t: remove /var/lib/iwd references in testKnownNetworks

In reply to James Prestwood
---
 autotests/testKnownNetworks/frequency_test.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
autotests/testKnownNetworks/frequency_test.py +2 -2
index f07074f2..9c523bb2 100644
@@ -67,7 +67,7 @@ class Test(unittest.TestCase):
         hs20_freqs = None
         hs20_uuid = None
         config = ConfigParser()
-        config.read('/var/lib/iwd/.known_network.freq')
+        config.read('/tmp/iwd/.known_network.freq')
         for s in config.sections():
             if os.path.basename(config[s]['name']) == 'ssidCCMP.psk':
                 psk_freqs = config[s]['list']
@@ -116,7 +116,7 @@ class Test(unittest.TestCase):
         psk_uuid2 = None
         hs20_freqs = None
         config = ConfigParser()
-        config.read('/var/lib/iwd/.known_network.freq')
+        config.read('/tmp/iwd/.known_network.freq')
         for s in config.sections():
             self.assertNotEqual(os.path.basename(config[s]['name']),
                                     'example.conf')
Signature · 1 line
2.26.2
#3 lore raw

PATCH 4/4 auto-t: fix agent path timing issue

In reply to James Prestwood

The agent path was generated based on the current time which sometimes yielded duplicate paths if agents were created quickly after one another. Instead a simple iterator removes any chance of a duplicate path.

---
 autotests/util/iwd.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
autotests/util/iwd.py +6 -1
index 7b08c23e..3ffd9f23 100755
@@ -705,17 +705,22 @@ class OrderedNetwork(object):
                         str(self.signal_strength)) + '\n'\
                 '\tObject: \n' + self.network_object.__str__('\t\t')
 
+agent_count = 0
 
 class PSKAgent(dbus.service.Object):
 
     def __init__(self, passphrases=[], users=[]):
+        global agent_count
+
         if type(passphrases) != list:
             passphrases = [passphrases]
         self.passphrases = passphrases
         if type(users) != list:
             users = [users]
         self.users = users
-        self._path = '/test/agent/' + str(int(round(time.time() * 1000)))
+        self._path = '/test/agent/%s' % agent_count
+
+        agent_count += 1
 
         dbus.service.Object.__init__(self, dbus.SystemBus(), self._path)
 
Signature · 1 line
2.26.2
#4 lore raw
In reply to James Prestwood

Hi James,

Quoted 9 lines · James Prestwood

If EnableNetworkConfiguration was enabled ap.c required that APRanges also be set. This prevents IWD from starting which effects a perfectly valid station configuration. Instead if APRanges is not provided IWD still allows ap_init to pass but DHCP just will not be enabled.

---
  src/ap.c | 9 +++++++--
  1 file changed, 7 insertions(+), 2 deletions(-)

All applied, thanks.

Regards,
-Denis