From patchwork Fri Sep 30 14:47:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Zaborowski X-Patchwork-Id: 12995561 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCD594A1C for ; Fri, 30 Sep 2022 14:48:17 +0000 (UTC) Received: by mail-wr1-f48.google.com with SMTP id s14so7250172wro.0 for ; Fri, 30 Sep 2022 07:48:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date; bh=iMaxavfTLXazWmcQtc9nWq4m+GDKGpdc/N+p7UrbKzg=; b=23yxcF83tIDhQMQZvrXds8sjx3xYJQQXy5diB2lfAP1zQOErU9HyYQdPDbnTuGZSSt 1vKUvi4zmt0PPn6QLbCx+2L14Z+KNb+HBtdX5B69uPdtJhhe23U+Fapqmn7rXagacONQ XWp4uYfHd9C1CHM7RtViXuZs0eOJFVlqDfWdLqh5G27uclAOmKyg/Pi+gjPTn/EkB3z9 FvyMrSihNSl85+gFLaBKb5NHO7xxxDDuJNvI4uGD/nNH7S1kIbCf0aVLM6aUGcq1P9u3 xobzm6eAnuyMa7W4urqU7DRLss7E+z9wlwlgraqf7XdLbrsT3xtOb+M67qo6Fm3nccDB TDJA== X-Gm-Message-State: ACrzQf2BmIsrCP+5pVcFLH1/viDOkkn/K1y5LEswJ926G3WFDrELpn+O DbILwOyvDpxRGZuUwE919AgJGNqBJgo= X-Google-Smtp-Source: AMsMyM5CJUSPUVFr+OacAuIkwHGW8Mt94ejYCgdELu6EPW13rV72i6C9HcFRcvyCXE8bDnyOhH/qhQ== X-Received: by 2002:a5d:46d0:0:b0:22c:de2a:23e with SMTP id g16-20020a5d46d0000000b0022cde2a023emr4077238wrs.12.1664549295747; Fri, 30 Sep 2022 07:48:15 -0700 (PDT) Received: from localhost.localdomain ([82.213.228.103]) by smtp.gmail.com with ESMTPSA id v13-20020a05600c214d00b003b505d26776sm6900284wml.5.2022.09.30.07.48.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Sep 2022 07:48:15 -0700 (PDT) From: Andrew Zaborowski To: iwd@lists.linux.dev Subject: [PATCH 1/3] autotests: Add a stateless DHCPv6 test case Date: Fri, 30 Sep 2022 16:47:59 +0200 Message-Id: <20220930144801.548229-1-andrew.zaborowski@intel.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- autotests/testNetconfig/stateless_test.py | 162 ++++++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 autotests/testNetconfig/stateless_test.py diff --git a/autotests/testNetconfig/stateless_test.py b/autotests/testNetconfig/stateless_test.py new file mode 100644 index 00000000..7f01a12a --- /dev/null +++ b/autotests/testNetconfig/stateless_test.py @@ -0,0 +1,162 @@ +#!/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 +import socket + +class Test(unittest.TestCase): + + def test_connection_success(self): + def check_addr(device): + try: + testutil.test_ip_address_match(device.name, '3ffe:501:ffff:100::', 128, 64) + except: + return False + + return True + + def get_ll_addrs6(ns, ifname): + show_ip = ns.start_process(['ip', 'addr', 'show', ifname]) + show_ip.wait() + for l in show_ip.out.split('\n'): + if 'inet6 fe80::' in l: + return socket.inet_pton(socket.AF_INET6, l.split(None, 1)[1].split('/', 1)[0]) + return None + + IWD.copy_to_storage('auto.psk', name='ap-ns1.psk') + wd = IWD(True) + + psk_agent = PSKAgent("secret123") + wd.register_psk_agent(psk_agent) + + devices = wd.list_devices(1) + device = devices[0] + + ordered_network = device.get_ordered_network('ap-ns1') + + self.assertEqual(ordered_network.type, NetworkType.psk) + + condition = 'not obj.connected' + wd.wait_for_object_condition(ordered_network.network_object, condition) + + # Give the AP's interface time to set up addresses so that radvd can + # reply to our Router Solicitation immediately. + ctx.non_block_wait(lambda: False, 3, exception=False) + + ordered_network.network_object.connect() + + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(device, condition) + + testutil.test_iface_operstate() + + ctx.non_block_wait(check_addr, 10, device, + exception=Exception("IPv6 address was not set")) + + # Cannot use test_ifaces_connected() across namespaces (implementation details) + testutil.test_ip_connected(('192.168.1.10', ctx), ('192.168.1.1', self.ns1)) + + ifname = str(device.name) + router_ll_addr = get_ll_addrs6(self.ns1, self.hapd.ifname) + expected_routes6 = { + # Default router + testutil.RouteInfo(gw=router_ll_addr, flags=3, ifname=ifname), + # On-link prefixes + testutil.RouteInfo(dst=socket.inet_pton(socket.AF_INET6, '3ffe:501:ffff:100::'), plen=64, + flags=1, ifname=ifname), + testutil.RouteInfo(dst=socket.inet_pton(socket.AF_INET6, '3ffe:501:ffff:200::'), plen=64, + flags=1, ifname=ifname), + } + self.maxDiff = None + self.assertEqual(expected_routes6, set(testutil.get_routes6(ifname))) + + rclog = open('/tmp/resolvconf.log', 'r') + entries = rclog.readlines() + rclog.close() + expected_rclog = ['-a %s.dns\n' % (ifname,), 'nameserver 192.168.1.2\n', + 'nameserver 3ffe:501:ffff:100::2\n', + '-a %s.domain\n' % (ifname,), 'search test1\n', 'search test2\n'] + # Every resolvconf -a run overwrites the previous settings. Check the last six lines + # of our log since we care about the end result here. + self.assertEqual(expected_rclog, entries[-6:]) + + device.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): + def remove_lease4(): + try: + os.remove('/tmp/dhcpd.leases') + os.remove('/tmp/dhcpd.leases~') + except: + pass + def remove_lease6(): + try: + os.remove('/tmp/dhcpd6.leases') + os.remove('/tmp/dhcpd6.leases~') + except: + pass + + cls.ns1 = ctx.get_namespace('ns1') + cls.hapd = HostapdCLI('ap-ns1.conf') + cls.ns1.start_process(['ip', 'addr','add', '192.168.1.1/17', + 'dev', cls.hapd.ifname]).wait() + cls.ns1.start_process(['touch', '/tmp/dhcpd.leases']).wait() + cls.dhcpd_pid = cls.ns1.start_process(['dhcpd', '-f', '-d', '-cf', '/tmp/dhcpd.conf', + '-lf', '/tmp/dhcpd.leases', + cls.hapd.ifname], cleanup=remove_lease4) + + cls.ns1.start_process(['ip', 'addr', 'add', '3ffe:501:ffff:100::1/72', + 'dev', cls.hapd.ifname]).wait() + cls.ns1.start_process(['touch', '/tmp/dhcpd6.leases']).wait() + cls.dhcpd6_pid = cls.ns1.start_process(['dhcpd', '-6', '-f', '-d', + '-cf', '/tmp/dhcpd-v6.conf', + '-lf', '/tmp/dhcpd6.leases', + cls.hapd.ifname], cleanup=remove_lease6) + cls.ns1.start_process(['sysctl', + 'net.ipv6.conf.' + cls.hapd.ifname + '.forwarding=1']).wait() + config = open('/tmp/radvd.conf', 'w') + config.write('interface ' + cls.hapd.ifname + ''' { + AdvSendAdvert on; + AdvManagedFlag off; + AdvOtherConfigFlag on; + # Test that the prefix with longer lifetime is selected. + prefix 3ffe:501:ffff:100::/64 { AdvAutonomous on; AdvPreferredLifetime 3605; }; + prefix 3ffe:501:ffff:200::/64 { AdvAutonomous on; AdvPreferredLifetime 3600; }; + DNSSL test1 test2 { AdvDNSSLLifetime 3600; }; + };''') + config.close() + cls.radvd_pid = cls.ns1.start_process(['radvd', '-n', '-d5', + '-p', '/tmp/radvd.pid', '-C', '/tmp/radvd.conf']) + + cls.orig_path = os.environ['PATH'] + os.environ['PATH'] = '/tmp/test-bin:' + os.environ['PATH'] + IWD.copy_to_storage('resolvconf', '/tmp/test-bin') + + @classmethod + def tearDownClass(cls): + IWD.clear_storage() + cls.ns1.stop_process(cls.dhcpd_pid) + cls.dhcpd_pid = None + cls.ns1.stop_process(cls.dhcpd6_pid) + cls.dhcpd6_pid = None + cls.ns1.stop_process(cls.radvd_pid) + cls.radvd_pid = None + os.system('rm -rf /tmp/radvd.conf /tmp/test-bin') + os.environ['PATH'] = cls.orig_path + +if __name__ == '__main__': + unittest.main(exit=True) From patchwork Fri Sep 30 14:48:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Zaborowski X-Patchwork-Id: 12995562 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8603E4C63 for ; Fri, 30 Sep 2022 14:48:18 +0000 (UTC) Received: by mail-wr1-f43.google.com with SMTP id c11so7200570wrp.11 for ; Fri, 30 Sep 2022 07:48:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date; bh=qU43tN+gys00gx+PfR1AXIYO2f5fHS6srRN84ZsCt3Q=; b=CSWhFySNdyjUAV3Gawd/MXCsSJWzFIAWsVC0xJO3aWMN7SzpKoR/M8CmOOm27vpZ41 Z8f8nNpFFzLWzg9zc8QeHphOvD197aevqyXKBlM9wAKREh3+ayx5PBo6pq8F0UZgKJ5V G/Wo8yj/hSSkV/j1VJuFtHKeHKLyrXgP8/qINqOGs6Sf89cfQRApTQrl7XcZ0PB3MEaD 7ZROQHEnangVe1PAqPH+vncPi1RKc1FsGpARLW6xz7wqYnxajLx3Xv7xf7NbMm0DXGUc wtO7RTDORTTsFyMruxQDw7orNK0Lq0xlCUFCfWHpu87heMv+inyDaOLifF9w87yUlejM v3Ag== X-Gm-Message-State: ACrzQf3JiNEifxv1pTgrpA7itqnp3XaL0fNmitCUHeXETaCDSVK8cObz OyaVHffz/qOFFulVh9BilVirTF2lrNc= X-Google-Smtp-Source: AMsMyM41TSjYbuJQYm20irRkkvNWrDa9MSHuPN9A3Ml8z3m5oN2OJNwGRGEsML7zK6FcrGH7KMWrqg== X-Received: by 2002:adf:d215:0:b0:228:6293:10ff with SMTP id j21-20020adfd215000000b00228629310ffmr6069275wrh.171.1664549296540; Fri, 30 Sep 2022 07:48:16 -0700 (PDT) Received: from localhost.localdomain ([82.213.228.103]) by smtp.gmail.com with ESMTPSA id v13-20020a05600c214d00b003b505d26776sm6900284wml.5.2022.09.30.07.48.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Sep 2022 07:48:16 -0700 (PDT) From: Andrew Zaborowski To: iwd@lists.linux.dev Subject: [PATCH 2/3] station: Handle NETCONFIG_EVENT_FAILED Date: Fri, 30 Sep 2022 16:48:00 +0200 Message-Id: <20220930144801.548229-2-andrew.zaborowski@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220930144801.548229-1-andrew.zaborowski@intel.com> References: <20220930144801.548229-1-andrew.zaborowski@intel.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If IPv4 setup fails and the netconfig logic gives up, continue as if the connection had failed at earlier stages so that autoconnect can try the next available network. --- src/station.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/station.c b/src/station.c index 6bd66ffc..fdeab7c1 100644 --- a/src/station.c +++ b/src/station.c @@ -2101,6 +2101,30 @@ delayed_retry: station_roam_retry(station); } +static void station_disconnect_on_error_cb(struct netdev *netdev, bool success, + void *user_data) +{ + struct station *station = user_data; + bool continue_autoconnect; + + station_enter_state(station, STATION_STATE_DISCONNECTED); + + continue_autoconnect = station->state == STATION_STATE_CONNECTING_AUTO; + + if (continue_autoconnect) { + if (station_autoconnect_next(station) < 0) { + l_debug("Nothing left on autoconnect list"); + station_enter_state(station, + STATION_STATE_AUTOCONNECT_FULL); + } + + return; + } + + if (station->autoconnect) + station_enter_state(station, STATION_STATE_AUTOCONNECT_QUICK); +} + static void station_netconfig_event_handler(enum netconfig_event event, void *user_data) { @@ -2109,7 +2133,26 @@ static void station_netconfig_event_handler(enum netconfig_event event, switch (event) { case NETCONFIG_EVENT_CONNECTED: station_enter_state(station, STATION_STATE_CONNECTED); + break; + case NETCONFIG_EVENT_FAILED: + if (station->connect_pending) { + struct l_dbus_message *reply = dbus_error_failed( + station->connect_pending); + + dbus_pending_reply(&station->connect_pending, reply); + } + + if (L_IN_SET(station->state, STATION_STATE_CONNECTING, + STATION_STATE_CONNECTING_AUTO)) + network_connect_failed(station->connected_network, + false); + + netdev_disconnect(station->netdev, + station_disconnect_on_error_cb, + station); + station_reset_connection_state(station); + station_enter_state(station, STATION_STATE_DISCONNECTING); break; default: l_error("station: Unsupported netconfig event: %d.", event); From patchwork Fri Sep 30 14:48:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Zaborowski X-Patchwork-Id: 12995563 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 71D0B4C6C for ; Fri, 30 Sep 2022 14:48:19 +0000 (UTC) Received: by mail-wr1-f47.google.com with SMTP id c11so7200627wrp.11 for ; Fri, 30 Sep 2022 07:48:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date; bh=mnat45Sc5bYQRhlem9JJZc+pi34uzJt4baVQ9+vh2gc=; b=rfbMBwDfn8G5zoFz5cTdYewGCQTvf77CAROu7Cn1RnH7YqwHUSxC7koGr+ASypB6Z0 zzMqNp0sttYEiam5np4LiKSP4l6C/ZGkqMqEBLsabp8nMtlUk2RRz6x7MzoG13HHE9YC 8nW/5ARZ2/1ZxDE0JZZbKGgOEuY19TffuOGcjiW9JPYfswqtFOgG6qPzyOCuccPSQshM +84R4C+p8mIsF3a48ueDMxGmUbkHZ9nvq4PaMiEpUBv91RWy6LzzJ39u/OemkyWHhEB3 b1HT34qG9uq3v9M3sJd4ZbeSR3y3XWy9W4MUIWyTl5egIHrf/BrkOpxME1TxLbPPdUmr HPyw== X-Gm-Message-State: ACrzQf3o6THpSNOcK0oyCM0eZiT43jei28qKzsCv/hKdHdTUF6XzioLy nMIXZ5btH389uRIK5behpnRSwwzdwlU= X-Google-Smtp-Source: AMsMyM4rynrabjwcmTAoc0lIcaIH1v1UqCqm/pb+4OzY1SPg+fmsvBbnrbnvNC2BmEF8mtVL3X9c+Q== X-Received: by 2002:a05:6000:1f9b:b0:22e:504:1bb with SMTP id bw27-20020a0560001f9b00b0022e050401bbmr949008wrb.90.1664549297384; Fri, 30 Sep 2022 07:48:17 -0700 (PDT) Received: from localhost.localdomain ([82.213.228.103]) by smtp.gmail.com with ESMTPSA id v13-20020a05600c214d00b003b505d26776sm6900284wml.5.2022.09.30.07.48.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Sep 2022 07:48:17 -0700 (PDT) From: Andrew Zaborowski To: iwd@lists.linux.dev Subject: [PATCH 3/3] doc: Drop proposed and unimplemented API doc Date: Fri, 30 Sep 2022 16:48:01 +0200 Message-Id: <20220930144801.548229-3-andrew.zaborowski@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220930144801.548229-1-andrew.zaborowski@intel.com> References: <20220930144801.548229-1-andrew.zaborowski@intel.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- doc/ip-configuration-api.txt | 47 ------------------------------------ 1 file changed, 47 deletions(-) delete mode 100644 doc/ip-configuration-api.txt diff --git a/doc/ip-configuration-api.txt b/doc/ip-configuration-api.txt deleted file mode 100644 index 58a522de..00000000 --- a/doc/ip-configuration-api.txt +++ /dev/null @@ -1,47 +0,0 @@ -IP Configuration hierarchy -=============================== - -Service net.connman.iwd -Interface net.connman.iwd.IPv4Configuration [Experimental] -Interface net.connman.iwd.IPv6Configuration [Experimental] -Object path /net/connman/iwd/{phy0,phy1,...}/{1,2,...} -Object path /net/connman/iwd/{phy0,phy1,...}/p2p_peers/{aa_bb_cc_dd_ee_ff} - -The interfaces net.connman.iwd.IPv4Configuration and -net.connman.iwd.IPv6Configuration currently have the same sets of methods, -signals and properties. In station mode, when network configuration is -enabled there may be one or both interfaces present on a device object in -connected state depending on if IPv4 and IPv6 addresses have both been -configured. In P2P mode only net.connman.iwd.IPv4Configuration is used. - -Properties string Method [readonly] - - Indicates whether the local address was set - statically (value "static") or obtained automatically - such as through DHCP (value "auto"). Even when the - address was obtained from the remote end some - configuration bits, such as DNS addresses, may have - been overridden locally. - - string Address [readonly] - - Holds the local IP address. - - byte PrefixLength [readonly] - - Holds the prefix-length of the local subnet. For - IPv4 this maps to the netmask. - - string Gateway [readonly, optional] - - Holds the gateway address for the subnet if one - exists. - - array(string) DomainNameServers [readonly, optional] - - Holds the list of domain name server addresses - configured if any. - - array(string) DomainNames [readonly, optional] - - Holds the network's local domain names if any exist.