From patchwork Tue Sep 20 14:05:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Zaborowski X-Patchwork-Id: 12982223 Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (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 6E2371C34 for ; Tue, 20 Sep 2022 14:05:20 +0000 (UTC) Received: by mail-ed1-f50.google.com with SMTP id z2so4037748edi.1 for ; Tue, 20 Sep 2022 07:05:20 -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=xhaTK1P7R7swiKIojlIx4B/VOmt7XqvmJU5qFBqmW8c=; b=E1xyQiMO0O9DKT+aivYhqu7kyP374LvbrU+cSiL78SZH0sjtNXgPhVDv8bXtBZDWz3 5uzCWJWIlecsrsLVJp3Vh9BjjF3KfVqcL0zt5jvM+Q/HcR0nmaynOqxIsiew17tXw6RV u04HCdNZE7HdLqDmfrOjEcoRyA/1MErqeHGAuTfJ83e7I3/NL0fJyZGc7GC3QO+WmIGP MyN1brfveb6clNN4YhYILkjunVBJzbD38b9RIRZE4KSGMKMwZTCJLPM2nHVV1szk0H2z V8bnXIRAJeRtIKdFs/M6csTiDTlc3UeHUMcyGOcFfpBpOv6pbxntlvxodRXA9RgSmaje rGlQ== X-Gm-Message-State: ACrzQf19ia1iXzB1yuk5u4IhoK6yvDkGB3zuudcb+bMRzjxqcRoaPFa1 SeuBdgHRIxKkbX74uMCjs6WyGe5ZUxdL0iFw X-Google-Smtp-Source: AMsMyM7hDhmrZFSfTM465lcXlaJQ6hHlUKH1dbPV4d61I1Gm1xM9GlQw1rpn9L/S2Sci+Eeu6Xl6Rg== X-Received: by 2002:aa7:d453:0:b0:44e:4b1d:28a with SMTP id q19-20020aa7d453000000b0044e4b1d028amr19661597edr.112.1663682718465; Tue, 20 Sep 2022 07:05:18 -0700 (PDT) Received: from iss.ger.corp.intel.com ([82.213.228.103]) by smtp.gmail.com with ESMTPSA id 8-20020a170906300800b0077d37a5d401sm947561ejz.33.2022.09.20.07.05.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 07:05:14 -0700 (PDT) From: Andrew Zaborowski To: iwd@lists.linux.dev Subject: [PATCH 1/3] netconfig: Drop D-Bus path from debug message Date: Tue, 20 Sep 2022 16:05:07 +0200 Message-Id: <20220920140509.3304422-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 l_dbus_message_get_path(reply) is normally NULL in this callback so don't bother printing it. --- src/netconfig-commit.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/netconfig-commit.c b/src/netconfig-commit.c index 9894ace2..96436c1c 100644 --- a/src/netconfig-commit.c +++ b/src/netconfig-commit.c @@ -373,8 +373,7 @@ static void netconfig_agent_receive_reply(struct l_dbus_message *reply, const char *error, *text; bool success = true; - l_debug("agent reply from %s %s", l_dbus_message_get_sender(reply), - l_dbus_message_get_path(reply)); + l_debug("agent reply from %s", l_dbus_message_get_sender(reply)); data->pending_id[INDEX_FOR_AF(cd->family)] = 0; From patchwork Tue Sep 20 14:05:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Zaborowski X-Patchwork-Id: 12982224 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (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 77D432562 for ; Tue, 20 Sep 2022 14:05:30 +0000 (UTC) Received: by mail-ej1-f54.google.com with SMTP id sb3so6388262ejb.9 for ; Tue, 20 Sep 2022 07:05:30 -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=KJ9Bt9qAxUP0WWIo9JqEWdY3rypdflORQWrqjkw6iN8=; b=UDLm+cup3nY1yk9JViMHhhKwM3eyWm5YNFjFZn1Bjm+ChnEhUPCU+a6aXadb2TAPY6 +WtNhRfDj9jk86QpkvpkmKzb1ayrm281XZ1rn+PqwUY6lqOkw52yb45CBbLJxdH35gOb RIkprH2bwnjYdbh0exvk3mlDrVZkufs2phF0Lel++jdygm1fZg0H6dMHfzKKcw3MHJFe Oc4N+67+zvRrZwpuYcOC+SeYDIRrsAGgs5Q2iR4hiOf3iEV69J9D/tvQ1rQd6VppcJcB nRQCtxv+vpB9N0qWSHq39+9fPg5i2EtTazw0nsnYetX4vYxCTFMeZlyiziV6JtPzytEB Wb9Q== X-Gm-Message-State: ACrzQf3Z5Piuyyhsi7JMQJNORXbZJK90ck3uP176U624UdAvz4EPFxNn gYD+YVfbGoZITPyNiqLCG1SwQ3txRhssrht1 X-Google-Smtp-Source: AMsMyM4Et/g75/bupsHCU1Uhd/YvgTUSxXea/EcrykKfO5M6KL0c/qiKvwXlFez7MOgynacpA5ZajQ== X-Received: by 2002:a17:907:7b87:b0:781:83bd:cae5 with SMTP id ne7-20020a1709077b8700b0078183bdcae5mr5268520ejc.456.1663682728279; Tue, 20 Sep 2022 07:05:28 -0700 (PDT) Received: from iss.ger.corp.intel.com ([82.213.228.103]) by smtp.gmail.com with ESMTPSA id 8-20020a170906300800b0077d37a5d401sm947561ejz.33.2022.09.20.07.05.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 07:05:21 -0700 (PDT) From: Andrew Zaborowski To: iwd@lists.linux.dev Subject: [PATCH 2/3] netconfig: Update l_netconfig API calls Date: Tue, 20 Sep 2022 16:05:08 +0200 Message-Id: <20220920140509.3304422-2-andrew.zaborowski@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920140509.3304422-1-andrew.zaborowski@intel.com> References: <20220920140509.3304422-1-andrew.zaborowski@intel.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Since l_netconfig's DHCPv6 client instance no longer sets parameters on the l_icmp6_client instance, call l_icmp6_client_set_nodelay() and l_icmp6_client_set_debug() directly. Also enable optimistic DAD to speed up IPv6 setup if available. --- src/netconfig.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/netconfig.c b/src/netconfig.c index feb7f87a..c7cc6b1b 100644 --- a/src/netconfig.c +++ b/src/netconfig.c @@ -659,6 +659,7 @@ struct netconfig *netconfig_new(uint32_t ifindex) const char *debug_level = NULL; int dhcp_priority = L_LOG_INFO; struct l_dhcp6_client *dhcp6; + struct l_icmp6_client *icmp6; l_debug("Creating netconfig for interface: %d", ifindex); @@ -691,12 +692,17 @@ struct netconfig *netconfig_new(uint32_t ifindex) dhcp6 = l_netconfig_get_dhcp6_client(netconfig->nc); l_dhcp6_client_set_lla_randomized(dhcp6, true); - l_dhcp6_client_set_nodelay(dhcp6, true); - if (debug_level) + icmp6 = l_netconfig_get_icmp6_client(netconfig->nc); + l_icmp6_client_set_nodelay(icmp6, true); + + if (debug_level) { l_dhcp6_client_set_debug(dhcp6, do_debug, "[DHCPv6] ", NULL); + l_icmp6_client_set_debug(icmp6, do_debug, "[ICMPv6] ", NULL); + } l_netconfig_set_route_priority(netconfig->nc, ROUTE_PRIORITY_OFFSET); + l_netconfig_set_optimistic_dad_enabled(netconfig->nc, true); return netconfig; } From patchwork Tue Sep 20 14:05:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Zaborowski X-Patchwork-Id: 12982225 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (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 B2BCF2562 for ; Tue, 20 Sep 2022 14:05:39 +0000 (UTC) Received: by mail-ej1-f46.google.com with SMTP id a26so6461146ejc.4 for ; Tue, 20 Sep 2022 07:05:39 -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=tenBVMltJIKYeeoj2NljPhqY39VFE9yf2cqRCDhzgyc=; b=JINIU/kF/DmUslTsoBwstalr8h1XXf8FZYK0FB2a8c4VzOlCIKrQI5RKRrlspL/JTd YisppRuxR9qNm7/iVzuq0psXZ43LqLFEPEvwH0XUc4B6q2mAM4B1tTMFk+bzXvFpq2F4 J/sPp6Ob6K9NqIogU2suIte6NmXEgBp2rtpEHjjUPKCdAGAihqXWm6lzXFvRaFx+qioP IqTQbanjcRP2Z7wkB6XrfXNCvDXIq5eU4FK1tOHM/4lHJFr8lZebNmfrY8EB6dlbE6rG ByWTjo6nGdjhp1nU0ev2kWPR9C/Go0OT3R5n5eTQFwrWBBtnjiIWVcr+WM2DM2qMbgjy 5fDA== X-Gm-Message-State: ACrzQf1S279ggqpsplJEK50jkUmkhpmT8CRqoNRgbSDprnhXWHT37lSd IAoa+Fr1ehuSzDdvbj9G8Od2TXapVhNym8PE X-Google-Smtp-Source: AMsMyM6iJhNFK6IeXTrJJN/Gfmi+hynF/JdFUWEG4eILTiu05+egIOZDI6XKz3wO2DVHQ0+1HDSnDw== X-Received: by 2002:a17:907:2d09:b0:781:d793:f51e with SMTP id gs9-20020a1709072d0900b00781d793f51emr1622165ejc.628.1663682737484; Tue, 20 Sep 2022 07:05:37 -0700 (PDT) Received: from iss.ger.corp.intel.com ([82.213.228.103]) by smtp.gmail.com with ESMTPSA id 8-20020a170906300800b0077d37a5d401sm947561ejz.33.2022.09.20.07.05.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 07:05:29 -0700 (PDT) From: Andrew Zaborowski To: iwd@lists.linux.dev Subject: [PATCH 3/3] autotests: Add a SLAAC test Date: Tue, 20 Sep 2022 16:05:09 +0200 Message-Id: <20220920140509.3304422-3-andrew.zaborowski@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920140509.3304422-1-andrew.zaborowski@intel.com> References: <20220920140509.3304422-1-andrew.zaborowski@intel.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- autotests/testNetconfig/slaac_test.py | 154 ++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 autotests/testNetconfig/slaac_test.py diff --git a/autotests/testNetconfig/slaac_test.py b/autotests/testNetconfig/slaac_test.py new file mode 100644 index 00000000..26ae0e46 --- /dev/null +++ b/autotests/testNetconfig/slaac_test.py @@ -0,0 +1,154 @@ +#!/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:200::', 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::10\n', 'nameserver 3ffe:501:ffff:100::50\n', + '-a %s.domain\n' % (ifname,), 'search test1\n', 'search test2\n'] + # Every resolvconf -a run overwrites the previous settings. Check the last seven lines + # of our log since we care about the end result here. + self.assertEqual(expected_rclog, entries[-7:]) + + 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 + 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(['sysctl', + 'net.ipv6.conf.' + cls.hapd.ifname + '.forwarding=1']).wait() + config = open('/tmp/radvd.conf', 'w') + config.write('interface ' + cls.hapd.ifname + ''' { + AdvSendAdvert on; + # Trick radvd to accept MinDelayBetweenRAs values less than 3 seconds. + AdvHomeAgentFlag on; + # Don't throttle so we can test solicited RA reception before link-local addr DAD done. + # radvd may have sent an unsolicited RA just before our RS and would complain -- the + # test should succeed regardless but will take some extra seconds. + MinDelayBetweenRAs 0.05; + AdvManagedFlag off; + # Test that the prefix with longer lifetime is selected. + prefix 3ffe:501:ffff:100::/64 { AdvAutonomous on; }; + prefix 3ffe:501:ffff:200::/64 { AdvAutonomous on; AdvPreferredLifetime infinity; AdvValidLifetime infinity; }; + RDNSS 3ffe:501:ffff:100::10 3ffe:501:ffff:100::50 { AdvRDNSSLifetime 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.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)