All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/9] build: add ell/acd.{c,h} to makefile
@ 2020-12-10 17:45 James Prestwood
  2020-12-10 17:45 ` [PATCH 2/9] netconfig: add ACD client for static configuration James Prestwood
                   ` (8 more replies)
  0 siblings, 9 replies; 11+ messages in thread
From: James Prestwood @ 2020-12-10 17:45 UTC (permalink / raw)
  To: iwd

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

---
 Makefile.am | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 1f0b0d30..3cd7eaa6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -61,7 +61,8 @@ ell_headers = ell/util.h \
 			ell/time.h \
 			ell/path.h \
 			ell/icmp6.h \
-			ell/dhcp6.h
+			ell/dhcp6.h \
+			ell/acd.h
 
 ell_sources = ell/private.h \
 			ell/missing.h \
@@ -138,7 +139,8 @@ ell_sources = ell/private.h \
 			ell/icmp6.c \
 			ell/icmp6-private.h \
 			ell/dhcp6-lease.c \
-			ell/dhcp6-transport.c
+			ell/dhcp6-transport.c \
+			ell/acd.c
 
 ell_libell_internal_la_SOURCES = $(ell_headers) $(ell_sources)
 endif
-- 
2.26.2

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

* [PATCH 2/9] netconfig: add ACD client for static configuration
  2020-12-10 17:45 [PATCH 1/9] build: add ell/acd.{c,h} to makefile James Prestwood
@ 2020-12-10 17:45 ` James Prestwood
  2020-12-10 20:34   ` Denis Kenzior
  2020-12-10 17:45 ` [PATCH 3/9] test-runner: have start_iwd take a storage dir James Prestwood
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 11+ messages in thread
From: James Prestwood @ 2020-12-10 17:45 UTC (permalink / raw)
  To: iwd

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

When the IP is configured to be static we can now use ACD in
order to check that the IP is available and not already in
use. If a conflict is found netconfig will be reset and no IP
will be set on the interface. The ACD client is left with
the default 'defend once' policy, and probes are not turned
off. This will increase connection time, but for static IP's
it is the best approach.
---
 src/netconfig.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/src/netconfig.c b/src/netconfig.c
index f48a789a..24ad3fff 100644
--- a/src/netconfig.c
+++ b/src/netconfig.c
@@ -64,6 +64,8 @@ struct netconfig {
 	void *user_data;
 
 	struct resolve *resolve;
+
+	struct l_acd *acd;
 };
 
 static struct l_netlink *rtnl;
@@ -804,15 +806,56 @@ static void netconfig_dhcp6_event_handler(struct l_dhcp6_client *client,
 	}
 }
 
+static void netconfig_ipv4_acd_event(enum l_acd_event event, void *user_data)
+{
+	struct netconfig *netconfig = user_data;
+
+	switch (event) {
+	case L_ACD_EVENT_AVAILABLE:
+		L_WARN_ON(!l_rtnl_ifaddr_add(rtnl, netconfig->ifindex,
+					netconfig->v4_address,
+					netconfig_ipv4_ifaddr_add_cmd_cb,
+					netconfig, NULL));
+		return;
+	case L_ACD_EVENT_CONFLICT:
+		l_error("netconfig: statically configured address conflict!");
+		break;
+	case L_ACD_EVENT_LOST:
+		l_error("netconfig: statically configured address was lost");
+		break;
+	}
+
+	netconfig_reset(netconfig);
+}
+
 static void netconfig_ipv4_select_and_install(struct netconfig *netconfig)
 {
 	netconfig->v4_address = netconfig_get_static4_address(netconfig);
 	if (netconfig->v4_address) {
+		char ip[INET6_ADDRSTRLEN];
+
 		netconfig->rtm_protocol = RTPROT_STATIC;
-		L_WARN_ON(!l_rtnl_ifaddr_add(rtnl, netconfig->ifindex,
+		netconfig->acd = l_acd_new(netconfig->ifindex);
+		l_acd_set_event_handler(netconfig->acd,
+					netconfig_ipv4_acd_event, netconfig,
+					NULL);
+		if (getenv("IWD_ACD_DEBUG"))
+			l_acd_set_debug(netconfig->acd, do_debug,
+					"[ACD] ", NULL);
+
+		l_rtnl_address_get_address(netconfig->v4_address, ip);
+
+		if (!l_acd_start(netconfig->acd, ip)) {
+			l_error("failed to start ACD, continuing anyways");
+			l_acd_destroy(netconfig->acd);
+			netconfig->acd = NULL;
+
+			L_WARN_ON(!l_rtnl_ifaddr_add(rtnl, netconfig->ifindex,
 					netconfig->v4_address,
 					netconfig_ipv4_ifaddr_add_cmd_cb,
 					netconfig, NULL));
+		}
+
 		return;
 	}
 
-- 
2.26.2

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

* [PATCH 3/9] test-runner: have start_iwd take a storage dir
  2020-12-10 17:45 [PATCH 1/9] build: add ell/acd.{c,h} to makefile James Prestwood
  2020-12-10 17:45 ` [PATCH 2/9] netconfig: add ACD client for static configuration James Prestwood
@ 2020-12-10 17:45 ` James Prestwood
  2020-12-10 17:45 ` [PATCH 4/9] auto-t: add storage dir to IWD() constructor James Prestwood
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: James Prestwood @ 2020-12-10 17:45 UTC (permalink / raw)
  To: iwd

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

Allow the storage directory (default /tmp/iwd) to be configured
just like the state directory. This is in order to support multiple
IWD instances which require separate storage directories for network
provisioning files.
---
 tools/test-runner | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/test-runner b/tools/test-runner
index 3a9cfce2..c2ff7eff 100755
--- a/tools/test-runner
+++ b/tools/test-runner
@@ -559,7 +559,7 @@ class Namespace:
 
 		self._bus = dbus.bus.BusConnection(address_or_type=self.dbus_address)
 
-	def start_iwd(self, config_dir = '/tmp'):
+	def start_iwd(self, config_dir = '/tmp', storage_dir = '/tmp/iwd'):
 		args = []
 		iwd_radios = ','.join([r.name for r in self.radios if r.use == 'iwd'])
 
@@ -575,7 +575,7 @@ class Namespace:
 		env = os.environ.copy()
 
 		env['CONFIGURATION_DIRECTORY'] = config_dir
-		env['STATE_DIRECTORY'] = '/tmp/iwd'
+		env['STATE_DIRECTORY'] = storage_dir
 
 		if self.is_verbose('iwd-dhcp'):
 			env['IWD_DHCP_DEBUG'] = '1'
-- 
2.26.2

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

* [PATCH 4/9] auto-t: add storage dir to IWD() constructor
  2020-12-10 17:45 [PATCH 1/9] build: add ell/acd.{c,h} to makefile James Prestwood
  2020-12-10 17:45 ` [PATCH 2/9] netconfig: add ACD client for static configuration James Prestwood
  2020-12-10 17:45 ` [PATCH 3/9] test-runner: have start_iwd take a storage dir James Prestwood
@ 2020-12-10 17:45 ` James Prestwood
  2020-12-10 17:45 ` [PATCH 5/9] auto-t: pass namespace on to other IWD classes James Prestwood
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: James Prestwood @ 2020-12-10 17:45 UTC (permalink / raw)
  To: iwd

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

Add support for setting a custom storage directory.
---
 autotests/util/iwd.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py
index bb4ecefa..844bb0db 100755
--- a/autotests/util/iwd.py
+++ b/autotests/util/iwd.py
@@ -943,7 +943,8 @@ class IWD(AsyncOpAbstract):
     _default_instance = None
     psk_agent = None
 
-    def __init__(self, start_iwd_daemon = False, iwd_config_dir = '/tmp', namespace=ctx):
+    def __init__(self, start_iwd_daemon = False, iwd_config_dir = '/tmp',
+                            iwd_storage_dir = '/tmp/iwd', namespace=ctx):
         self.namespace = namespace
         self._bus = namespace.get_bus()
 
@@ -951,7 +952,8 @@ class IWD(AsyncOpAbstract):
             if self.namespace.is_process_running('iwd'):
                 raise Exception("IWD requested to start but is already running")
 
-            self._iwd_proc = self.namespace.start_iwd(iwd_config_dir)
+            self._iwd_proc = self.namespace.start_iwd(iwd_config_dir,
+                                                        iwd_storage_dir)
 
         tries = 0
         while not self._bus.name_has_owner(IWD_SERVICE):
-- 
2.26.2

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

* [PATCH 5/9] auto-t: pass namespace on to other IWD classes
  2020-12-10 17:45 [PATCH 1/9] build: add ell/acd.{c,h} to makefile James Prestwood
                   ` (2 preceding siblings ...)
  2020-12-10 17:45 ` [PATCH 4/9] auto-t: add storage dir to IWD() constructor James Prestwood
@ 2020-12-10 17:45 ` James Prestwood
  2020-12-10 17:45 ` [PATCH 6/9] auto-t: support IP match with no IP set James Prestwood
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: James Prestwood @ 2020-12-10 17:45 UTC (permalink / raw)
  To: iwd

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

Certain classes were still using the default namespace. This
didn't matter yet since testAP was the only test using namespaces,
and the AP interface was the only one being used.

For an IWD station on a separate namespace all objects need to
be accessable, so the namespace is passed along to those as needed.
---
 autotests/util/iwd.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py
index 844bb0db..9e653575 100755
--- a/autotests/util/iwd.py
+++ b/autotests/util/iwd.py
@@ -124,6 +124,7 @@ class IWDDBusAbstract(AsyncOpAbstract):
 
     def __init__(self, object_path = None, properties = None, service=IWD_SERVICE, namespace=ctx):
         self._bus = namespace.get_bus()
+        self._namespace = namespace
 
         self._object_path = object_path
         proxy = self._bus.get_object(service, self._object_path)
@@ -391,7 +392,7 @@ class Device(IWDDBusAbstract):
         '''
         ordered_networks = []
         for bus_obj in self._station.GetOrderedNetworks():
-            ordered_network = OrderedNetwork(bus_obj, self._bus)
+            ordered_network = OrderedNetwork(bus_obj, self._bus, self._namespace)
             ordered_networks.append(ordered_network)
 
         if len(ordered_networks) > 0:
@@ -407,7 +408,7 @@ class Device(IWDDBusAbstract):
         IWD._wait_for_object_condition(self, condition)
 
         for bus_obj in self._station.GetOrderedNetworks():
-            ordered_network = OrderedNetwork(bus_obj, self._bus)
+            ordered_network = OrderedNetwork(bus_obj, self._bus, self._namespace)
             ordered_networks.append(ordered_network)
 
         if len(ordered_networks) > 0:
@@ -643,9 +644,9 @@ class KnownNetwork(IWDDBusAbstract):
 class OrderedNetwork(object):
     '''Represents a network found in the scan'''
 
-    def __init__(self, o_n_tuple, bus):
+    def __init__(self, o_n_tuple, bus, namespace=ctx):
         self._bus = bus
-        self._network_object = Network(o_n_tuple[0])
+        self._network_object = Network(o_n_tuple[0], namespace=namespace)
         self._network_proxy = dbus.Interface(self._bus.get_object(IWD_SERVICE,
                                         o_n_tuple[0]),
                                         DBUS_PROPERTIES)
-- 
2.26.2

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

* [PATCH 6/9] auto-t: support IP match with no IP set
  2020-12-10 17:45 [PATCH 1/9] build: add ell/acd.{c,h} to makefile James Prestwood
                   ` (3 preceding siblings ...)
  2020-12-10 17:45 ` [PATCH 5/9] auto-t: pass namespace on to other IWD classes James Prestwood
@ 2020-12-10 17:45 ` James Prestwood
  2020-12-10 17:45 ` [PATCH 7/9] auto-t: add static netconfig test James Prestwood
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: James Prestwood @ 2020-12-10 17:45 UTC (permalink / raw)
  To: iwd

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

This allows an interface with no IP set to be checked for
by passing None in as the address. This will generate an
exception by ioctl which we catch.
---
 autotests/util/testutil.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/autotests/util/testutil.py b/autotests/util/testutil.py
index 94f8ef32..f50223b1 100644
--- a/autotests/util/testutil.py
+++ b/autotests/util/testutil.py
@@ -146,9 +146,15 @@ def test_iface_operstate(intf=None):
         sock.close()
 
 def test_ip_address_match(intf, ip):
-    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
-    addr = fcntl.ioctl(s.fileno(), SIOCGIFADDR, struct.pack('256s', intf.encode('utf-8')))
-    addr = socket.inet_ntoa(addr[20:24])
+    try:
+        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+        addr = fcntl.ioctl(s.fileno(), SIOCGIFADDR, struct.pack('256s', intf.encode('utf-8')))
+        addr = socket.inet_ntoa(addr[20:24])
+    except OSError as e:
+        if e.errno != 99 or ip != None:
+            raise Exception('SIOCGIFADDR failed with %d' % e.errno)
+
+        return
 
     if ip != addr:
         raise Exception('IP for %s did not match %s (was %s)' % (intf, ip, addr))
-- 
2.26.2

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

* [PATCH 7/9] auto-t: add static netconfig test
  2020-12-10 17:45 [PATCH 1/9] build: add ell/acd.{c,h} to makefile James Prestwood
                   ` (4 preceding siblings ...)
  2020-12-10 17:45 ` [PATCH 6/9] auto-t: support IP match with no IP set James Prestwood
@ 2020-12-10 17:45 ` James Prestwood
  2020-12-10 17:45 ` [PATCH 8/9] test-runner: add iwd-acd to verbose options James Prestwood
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: James Prestwood @ 2020-12-10 17:45 UTC (permalink / raw)
  To: iwd

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

Tests netconfig with a static configuration, as well as tests ACD
functionality.

The test has two IWD radios which will eventually use the same IP.
One is configured statically, one will receive the IP via DHCP.
The static client sets its IP first and begins using it. Then the
DHCP client is started. Since ACD in a DHCP client is configured
to use its address indefinitely, the static client *should* give
up its address.
---
 autotests/testNetconfig/connection_test.py   |  10 +-
 autotests/testNetconfig/hw.conf              |   7 +-
 autotests/testNetconfig/static_test.py       | 105 +++++++++++++++++++
 autotests/testNetconfig/storage/ssidTKIP.psk |   3 +
 4 files changed, 121 insertions(+), 4 deletions(-)
 create mode 100644 autotests/testNetconfig/static_test.py
 create mode 100644 autotests/testNetconfig/storage/ssidTKIP.psk

diff --git a/autotests/testNetconfig/connection_test.py b/autotests/testNetconfig/connection_test.py
index 5fc7a88e..caab090c 100644
--- a/autotests/testNetconfig/connection_test.py
+++ b/autotests/testNetconfig/connection_test.py
@@ -11,11 +11,12 @@ from iwd import NetworkType
 from hostapd import HostapdCLI
 import testutil
 from config import ctx
+import os
 
 class Test(unittest.TestCase):
 
     def test_connection_success(self):
-        wd = IWD()
+        wd = IWD(True)
 
         psk_agent = PSKAgent("secret123")
         wd.register_psk_agent(psk_agent)
@@ -62,12 +63,15 @@ 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',
-                            hapd.ifname])
+        cls.dhcpd_pid = ctx.start_process(['dhcpd', '-f', '-cf', '/tmp/dhcpd.conf',
+                                            '-lf', '/tmp/dhcpd.leases',
+                                            hapd.ifname])
 
     @classmethod
     def tearDownClass(cls):
         IWD.clear_storage()
+        cls.dhcpd_pid.kill()
+        os.system('rm -rf /tmp/dhcpd.leases')
 
 if __name__ == '__main__':
     unittest.main(exit=True)
diff --git a/autotests/testNetconfig/hw.conf b/autotests/testNetconfig/hw.conf
index 75c5ac6e..323f1fb2 100644
--- a/autotests/testNetconfig/hw.conf
+++ b/autotests/testNetconfig/hw.conf
@@ -1,6 +1,11 @@
 [SETUP]
-num_radios=2
+num_radios=3
 max_test_exec_interval_sec=40
+start_iwd=0
+hwsim_medium=no
 
 [HOSTAPD]
 rad0=ssidTKIP.conf
+
+[NameSpaces]
+ns0=rad2
diff --git a/autotests/testNetconfig/static_test.py b/autotests/testNetconfig/static_test.py
new file mode 100644
index 00000000..b304f06d
--- /dev/null
+++ b/autotests/testNetconfig/static_test.py
@@ -0,0 +1,105 @@
+#!/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
+import testutil
+from config import ctx
+import os
+
+class Test(unittest.TestCase):
+
+    def test_connection_success(self):
+        wd = IWD(True, iwd_storage_dir='/tmp/storage')
+
+        ns0 = ctx.get_namespace('ns0')
+
+        wd_ns0 = IWD(True, namespace=ns0)
+
+        psk_agent = PSKAgent("secret123")
+        psk_agent_ns0 = PSKAgent("secret123", namespace=ns0)
+        wd.register_psk_agent(psk_agent)
+        wd_ns0.register_psk_agent(psk_agent_ns0)
+
+        dev1 = wd.list_devices(1)[0]
+        dev2 = wd_ns0.list_devices(1)[0]
+
+        condition = 'not obj.scanning'
+        wd.wait_for_object_condition(dev1, condition)
+
+        dev1.scan()
+
+        condition = 'not obj.scanning'
+        wd.wait_for_object_condition(dev1, condition)
+
+        ordered_network = dev1.get_ordered_network('ssidTKIP')
+
+        self.assertEqual(ordered_network.type, NetworkType.psk)
+
+        condition = 'not obj.connected'
+        wd.wait_for_object_condition(ordered_network.network_object, condition)
+
+        ordered_network.network_object.connect()
+
+        condition = 'obj.state == DeviceState.connected'
+        wd.wait_for_object_condition(dev1, condition)
+
+        testutil.test_iface_operstate()
+        testutil.test_ifaces_connected()
+
+        testutil.test_ip_address_match(dev1.name, '192.168.1.10')
+
+        dev2.scan()
+
+        condition = 'not obj.scanning'
+        wd_ns0.wait_for_object_condition(dev2, condition)
+
+        ordered_network = dev2.get_ordered_network('ssidTKIP', scan_if_needed=True)
+
+        condition = 'not obj.connected'
+        wd_ns0.wait_for_object_condition(ordered_network.network_object, condition)
+
+        ordered_network.network_object.connect()
+
+        condition = 'obj.state == DeviceState.connected'
+        wd_ns0.wait_for_object_condition(dev2, condition)
+
+        wd.wait(1)
+        testutil.test_ip_address_match(dev1.name, None)
+
+        dev1.disconnect()
+        dev2.disconnect()
+
+        condition = 'not obj.connected'
+        wd.wait_for_object_condition(ordered_network.network_object, condition)
+
+        wd.unregister_psk_agent(psk_agent)
+
+    @classmethod
+    def setUpClass(cls):
+        hapd = HostapdCLI()
+        # TODO: This could be moved into test-runner itself if other tests ever
+        #       require this functionality (p2p, FILS, etc.). Since its simple
+        #       enough it can stay here for now.
+        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)
+        cls.dhcpd_pid = ctx.start_process(['dhcpd', '-f', '-cf', '/tmp/dhcpd.conf',
+                                            '-lf', '/tmp/dhcpd.leases',
+                                            hapd.ifname])
+        IWD.copy_to_storage('ssidTKIP.psk', '/tmp/storage')
+
+    @classmethod
+    def tearDownClass(cls):
+        IWD.clear_storage()
+        cls.dhcpd_pid.kill()
+        os.system('rm -rf /tmp/dhcpd.leases')
+
+if __name__ == '__main__':
+    unittest.main(exit=True)
diff --git a/autotests/testNetconfig/storage/ssidTKIP.psk b/autotests/testNetconfig/storage/ssidTKIP.psk
new file mode 100644
index 00000000..f15724a3
--- /dev/null
+++ b/autotests/testNetconfig/storage/ssidTKIP.psk
@@ -0,0 +1,3 @@
+[IPv4]
+Address=192.168.1.10
+Gateway=192.168.1.1
-- 
2.26.2

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

* [PATCH 8/9] test-runner: add iwd-acd to verbose options
  2020-12-10 17:45 [PATCH 1/9] build: add ell/acd.{c,h} to makefile James Prestwood
                   ` (5 preceding siblings ...)
  2020-12-10 17:45 ` [PATCH 7/9] auto-t: add static netconfig test James Prestwood
@ 2020-12-10 17:45 ` James Prestwood
  2020-12-10 17:45 ` [PATCH 9/9] test-runner: set processor count for VM James Prestwood
  2020-12-10 20:37 ` [PATCH 1/9] build: add ell/acd.{c,h} to makefile Denis Kenzior
  8 siblings, 0 replies; 11+ messages in thread
From: James Prestwood @ 2020-12-10 17:45 UTC (permalink / raw)
  To: iwd

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

This will turn on IWD_ACD_DEBUG
---
 tools/test-runner | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/test-runner b/tools/test-runner
index c2ff7eff..3628e45e 100755
--- a/tools/test-runner
+++ b/tools/test-runner
@@ -586,6 +586,9 @@ class Namespace:
 		if self.is_verbose('iwd-genl'):
 			env['IWD_GENL_DEBUG'] = '1'
 
+		if self.is_verbose('iwd-acd'):
+			env['IWD_ACD_DEBUG'] = '1'
+
 		pid = self.start_process(args, env=env)
 		return pid
 
-- 
2.26.2

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

* [PATCH 9/9] test-runner: set processor count for VM
  2020-12-10 17:45 [PATCH 1/9] build: add ell/acd.{c,h} to makefile James Prestwood
                   ` (6 preceding siblings ...)
  2020-12-10 17:45 ` [PATCH 8/9] test-runner: add iwd-acd to verbose options James Prestwood
@ 2020-12-10 17:45 ` James Prestwood
  2020-12-10 20:37 ` [PATCH 1/9] build: add ell/acd.{c,h} to makefile Denis Kenzior
  8 siblings, 0 replies; 11+ messages in thread
From: James Prestwood @ 2020-12-10 17:45 UTC (permalink / raw)
  To: iwd

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

For better reliability the processor count is now set to qemu.
In cases of low CPU count (< 2) hosts the processor count is
limited to 1. Otherwise half of the host cores will be used for
the VM.
---
 tools/test-runner | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/tools/test-runner b/tools/test-runner
index 3628e45e..bc580a41 100755
--- a/tools/test-runner
+++ b/tools/test-runner
@@ -1405,6 +1405,19 @@ class Main:
 			'kernel'
 		]
 
+		nproc = multiprocessing.cpu_count()
+
+		#
+		# Specially handle CPU systems with minimal cores, otherwise
+		# use half the host cores.
+		#
+		if nproc < 2:
+			smp = 1
+		else:
+			smp = int(nproc / 2)
+
+		print("Using %d cores for VM" % smp)
+
 		#
 		# This passes through most of the command line options to
 		# the kernel command line. Some are not relevant (e.g. qemu)
@@ -1443,7 +1456,7 @@ class Main:
 				rootflags=trans=virtio,version=9p2000.u \
 				acpi=off pci=noacpi %s ro \
 				mac80211_hwsim.radios=0 %s' % (kern_log, options),
-			'-cpu', 'host'
+			'-cpu', 'host', '-smp', str(smp)
 		]
 
 		# Add two ethernet devices for testing EAD
-- 
2.26.2

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

* Re: [PATCH 2/9] netconfig: add ACD client for static configuration
  2020-12-10 17:45 ` [PATCH 2/9] netconfig: add ACD client for static configuration James Prestwood
@ 2020-12-10 20:34   ` Denis Kenzior
  0 siblings, 0 replies; 11+ messages in thread
From: Denis Kenzior @ 2020-12-10 20:34 UTC (permalink / raw)
  To: iwd

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

Hi James,

On 12/10/20 11:45 AM, James Prestwood wrote:
> When the IP is configured to be static we can now use ACD in
> order to check that the IP is available and not already in
> use. If a conflict is found netconfig will be reset and no IP
> will be set on the interface. The ACD client is left with
> the default 'defend once' policy, and probes are not turned
> off. This will increase connection time, but for static IP's
> it is the best approach.
> ---
>   src/netconfig.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-
>   1 file changed, 44 insertions(+), 1 deletion(-)
> 
> diff --git a/src/netconfig.c b/src/netconfig.c
> index f48a789a..24ad3fff 100644
> --- a/src/netconfig.c
> +++ b/src/netconfig.c
> @@ -64,6 +64,8 @@ struct netconfig {
>   	void *user_data;
>   
>   	struct resolve *resolve;
> +
> +	struct l_acd *acd;
>   };
>   
>   static struct l_netlink *rtnl;
> @@ -804,15 +806,56 @@ static void netconfig_dhcp6_event_handler(struct l_dhcp6_client *client,
>   	}
>   }
>   
> +static void netconfig_ipv4_acd_event(enum l_acd_event event, void *user_data)
> +{
> +	struct netconfig *netconfig = user_data;
> +
> +	switch (event) {
> +	case L_ACD_EVENT_AVAILABLE:
> +		L_WARN_ON(!l_rtnl_ifaddr_add(rtnl, netconfig->ifindex,
> +					netconfig->v4_address,
> +					netconfig_ipv4_ifaddr_add_cmd_cb,
> +					netconfig, NULL));
> +		return;
> +	case L_ACD_EVENT_CONFLICT:
> +		l_error("netconfig: statically configured address conflict!");
> +		break;
> +	case L_ACD_EVENT_LOST:
> +		l_error("netconfig: statically configured address was lost");
> +		break;
> +	}
> +
> +	netconfig_reset(netconfig);

That might be a bit harsh.  We may still have ipv6 connectivity.

> +}
> +
>   static void netconfig_ipv4_select_and_install(struct netconfig *netconfig)
>   {
>   	netconfig->v4_address = netconfig_get_static4_address(netconfig);
>   	if (netconfig->v4_address) {

Hmm, right now the assumption is that if v4_address is set, then we attempted to 
set it in the kernel and it is most likely set.  So on ACD failure we'd try to 
reset an address that doesn't exist.  Harmless, but might be nicer not to do 
unnecessary stuff.

> +		char ip[INET6_ADDRSTRLEN];
> +
>   		netconfig->rtm_protocol = RTPROT_STATIC;
> -		L_WARN_ON(!l_rtnl_ifaddr_add(rtnl, netconfig->ifindex,
> +		netconfig->acd = l_acd_new(netconfig->ifindex);
> +		l_acd_set_event_handler(netconfig->acd,
> +					netconfig_ipv4_acd_event, netconfig,
> +					NULL);
> +		if (getenv("IWD_ACD_DEBUG"))
> +			l_acd_set_debug(netconfig->acd, do_debug,
> +					"[ACD] ", NULL);
> +
> +		l_rtnl_address_get_address(netconfig->v4_address, ip);
> +
> +		if (!l_acd_start(netconfig->acd, ip)) {
> +			l_error("failed to start ACD, continuing anyways");
> +			l_acd_destroy(netconfig->acd);
> +			netconfig->acd = NULL;
> +
> +			L_WARN_ON(!l_rtnl_ifaddr_add(rtnl, netconfig->ifindex,
>   					netconfig->v4_address,
>   					netconfig_ipv4_ifaddr_add_cmd_cb,
>   					netconfig, NULL));
> +		}
> +
>   		return;
>   	}
>   
> 

Regards,
-Denis

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

* Re: [PATCH 1/9] build: add ell/acd.{c,h} to makefile
  2020-12-10 17:45 [PATCH 1/9] build: add ell/acd.{c,h} to makefile James Prestwood
                   ` (7 preceding siblings ...)
  2020-12-10 17:45 ` [PATCH 9/9] test-runner: set processor count for VM James Prestwood
@ 2020-12-10 20:37 ` Denis Kenzior
  8 siblings, 0 replies; 11+ messages in thread
From: Denis Kenzior @ 2020-12-10 20:37 UTC (permalink / raw)
  To: iwd

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

Hi James,

On 12/10/20 11:45 AM, James Prestwood wrote:
> ---
>   Makefile.am | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 

Patches 1, 3, 4, 5, 6, 8 and 9 applied, thanks.

Regards,
-Denis

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

end of thread, other threads:[~2020-12-10 20:37 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-10 17:45 [PATCH 1/9] build: add ell/acd.{c,h} to makefile James Prestwood
2020-12-10 17:45 ` [PATCH 2/9] netconfig: add ACD client for static configuration James Prestwood
2020-12-10 20:34   ` Denis Kenzior
2020-12-10 17:45 ` [PATCH 3/9] test-runner: have start_iwd take a storage dir James Prestwood
2020-12-10 17:45 ` [PATCH 4/9] auto-t: add storage dir to IWD() constructor James Prestwood
2020-12-10 17:45 ` [PATCH 5/9] auto-t: pass namespace on to other IWD classes James Prestwood
2020-12-10 17:45 ` [PATCH 6/9] auto-t: support IP match with no IP set James Prestwood
2020-12-10 17:45 ` [PATCH 7/9] auto-t: add static netconfig test James Prestwood
2020-12-10 17:45 ` [PATCH 8/9] test-runner: add iwd-acd to verbose options James Prestwood
2020-12-10 17:45 ` [PATCH 9/9] test-runner: set processor count for VM James Prestwood
2020-12-10 20:37 ` [PATCH 1/9] build: add ell/acd.{c,h} to makefile 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.