From patchwork Tue Jan 30 17:50:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13537812 Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) (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 41D9F1292D2 for ; Tue, 30 Jan 2024 17:50:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706637045; cv=none; b=R0CsWHJWQl3HO5K/yimvLcgXxFyTpdlygHTZcEjqu3F9wesf6cohi53jl1JnQ9z719Z3WSEQcCQpMMU3Hh4BUtIeKawv8VaaEFUO1dALyT1LLXDEW6aEJCbt+JU3ETtEVAGd8T0o+1OVLLQl/WOG2eVbCY8PqM9+Hrsqd8TNJPI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706637045; c=relaxed/simple; bh=ZCsSo3/1h1z/1tTi1VJu8pc+HYN74DSqGYUxQH2I6Kc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Qp4m5twSpD/qmdNWim7AjY5n6VB1Z69LwQdvl1Ky5l+BwSU6ZlVTEhn+j3R+58428uJn4Jhu8ZkO16Yt7nlpZZtUslv1uE/kjwHx37vPXqMfVjMFIsPNoqa4EO4j64NTpUktmfyjah9fJZm7AezbcT5fR2utWJxKNe10cDt98cE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=L+h9ofn0; arc=none smtp.client-ip=209.85.160.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="L+h9ofn0" Received: by mail-qt1-f173.google.com with SMTP id d75a77b69052e-42a99202ae0so281251cf.1 for ; Tue, 30 Jan 2024 09:50:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706637043; x=1707241843; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=5nyonp2lnVFKXz39ljbrpbOlqmN3/o6w0KLDTN9o6c0=; b=L+h9ofn0Sfmfy6ETVcaLRT+lelkFY5SuZstbaqq6cej1Fd+sa9kRT0wVhUt5qc5HsK HBDxxbk5imOViiptqnl7GnmHQsq1YEDxPnCkCxwEipadWE1jG9fxwBEq5KAuHL/glnze tlWQhOyFP1UbW1SxrqOKQnEHzGqw5FDypKDtI9xQFl49EFcl7/WT9Jg9KpXPK+nq4zo9 JUlaCILXD5d04EneuFbx5PAenu4zvOJO11gaNWJceLF+Z700szFMRn5jneh5dJu7nAVD 1SpwGvtpi9f29aPJPPPmWcjDW7KUdPTWXXvSEcg/g89j8ebZmvP86eji5yzlR0DtosJw kZ/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706637043; x=1707241843; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5nyonp2lnVFKXz39ljbrpbOlqmN3/o6w0KLDTN9o6c0=; b=kMpjT6QfbOARRUgpl900GkC2xu83+TIuFqoJR4pNvXLfi4nZ6NWn5dbCzd92j7PjaE atRGTSVqHV2qsb8TyRdTz1/IIoW8R67bpQqJ9LuARMAMSVbMk2Tg72/fxRSHDe3gPp2F 9J6pc3D5n3TaF/nS+siy3D/zmePFXIeaeDVc+T8jVLtg8FAjN8AY57RdSmDlHJNcJVjj jeymJOzuIpQ4wb+qmsIft+4ZzyDtNl5rudqWWsrssrJMQ44WV36+cA6QP+c0Eb6ZxQzH +p7l+buPx4QMdOKcvehc4OTLfsaJ+kwUmrO6p0eQ/YsEYqAoJIpHcNHTSoRoaOR5r3PH SLAQ== X-Gm-Message-State: AOJu0YwmwSHNC8oEyHu/2pGpNXOJk/YDJREuZzjoqB2sU1B+bdAc3XTP nqy2BVtBv/Jjp3dBwttbvHzzZvsWwpW4YaXqIspIaXB7njxcgI2pSQFMkLl1iqw= X-Google-Smtp-Source: AGHT+IHLq8xAOO4N8leCWpOcge/STvbpwa3BLWhUQW7q53idupCNvB3jcgFXUj151D+0um7CpCUKZg== X-Received: by 2002:a05:622a:1451:b0:42b:dfc4:700 with SMTP id v17-20020a05622a145100b0042bdfc40700mr1410609qtx.17.1706637042686; Tue, 30 Jan 2024 09:50:42 -0800 (PST) Received: from LOCLAP699.rst-01.locus ([208.195.13.130]) by smtp.gmail.com with ESMTPSA id cr7-20020a05622a428700b0042a31bc98b9sm4718914qtb.24.2024.01.30.09.50.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 09:50:42 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 1/2] netconfig: limit DHCPv4 attempts to avoid extended netconfig times Date: Tue, 30 Jan 2024 09:50:37 -0800 Message-Id: <20240130175038.77908-1-prestwoj@gmail.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 ELL now has a setting to limit the number of DHCP attempts. This will now be set in IWD and if reached will result in a failure event, and in turn a disconnect. IWD will set a maximum of 4 retries which should keep the maximum DHCP time to ~60 seconds roughly. --- src/netconfig.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/netconfig.c b/src/netconfig.c index 52307025..b31209cf 100644 --- a/src/netconfig.c +++ b/src/netconfig.c @@ -50,6 +50,8 @@ #include "src/netconfig.h" #include "src/sysfs.h" +#define DHCP_ATTEMPTS 4 + /* * Routing priority offset, configurable in main.conf. The route with lower * priority offset is preferred. @@ -696,6 +698,7 @@ struct netconfig *netconfig_new(uint32_t ifindex) int dhcp_priority = L_LOG_INFO; struct l_dhcp6_client *dhcp6; struct l_icmp6_client *icmp6; + struct l_dhcp_client *dhcp; l_debug("Creating netconfig for interface: %d", ifindex); @@ -723,8 +726,8 @@ struct netconfig *netconfig_new(uint32_t ifindex) l_netconfig_set_event_handler(netconfig->nc, netconfig_event_handler, netconfig, NULL); - l_dhcp_client_set_debug(l_netconfig_get_dhcp_client(netconfig->nc), - do_debug, "[DHCPv4] ", NULL, dhcp_priority); + dhcp = l_netconfig_get_dhcp_client(netconfig->nc); + l_dhcp_client_set_max_attempts(dhcp, DHCP_ATTEMPTS); dhcp6 = l_netconfig_get_dhcp6_client(netconfig->nc); l_dhcp6_client_set_lla_randomized(dhcp6, true); @@ -735,6 +738,8 @@ struct netconfig *netconfig_new(uint32_t ifindex) if (debug_level) { l_dhcp6_client_set_debug(dhcp6, do_debug, "[DHCPv6] ", NULL); l_icmp6_client_set_debug(icmp6, do_debug, "[ICMPv6] ", NULL); + l_dhcp_client_set_debug(dhcp, do_debug, "[DHCPv4] ", NULL, + dhcp_priority); } return netconfig; From patchwork Tue Jan 30 17:50:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13537813 Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.174]) (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 3B4C61292E9 for ; Tue, 30 Jan 2024 17:50:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706637046; cv=none; b=CRFskEfdZ4lL+qJ4fcYw1eoVSD2nCAp12tOYzbaaHGMFCvb37kFe3+ThhIOY61avMYWSh65Sph0fmsFcBGekGXI/NrO8nDlavK2Fblp7XoVDDtJwy1WXYXjus2dt5YsLNwrpO1753TnCc3oRN501yqAzmbXZTMP9FnSpiBYF9F8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706637046; c=relaxed/simple; bh=ISd6gY5lxPJNMXnRkokjSnR2o7bVhG4rdwEsdwZ6r4U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iQhLZMCeYCNoBSVrKxasUZHNj5jLQ30y/fk6SMdM0TFFJSjJy7fx7SAWX66JLUh1/fccWvE3mvK3kxs4A86j7vAB0iBCEINhv2lNzxWueqeVZZSD4cSO7YygLyBzj/1YfkkLYCzi/eQ+OLcHnnx8ehs7WhcUCl3BAvxk4JgZumE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=j5Y1z3yp; arc=none smtp.client-ip=209.85.160.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="j5Y1z3yp" Received: by mail-qt1-f174.google.com with SMTP id d75a77b69052e-42a31b90edcso38135351cf.0 for ; Tue, 30 Jan 2024 09:50:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706637044; x=1707241844; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ii8jDIcX/DsDEv7agdvlos1P1vVaKTJYjhbGZ/mMXNQ=; b=j5Y1z3yp7ThvfTyJCPL2zs56geCgUorpi7RR3IvUceGg8kJkw90FDuh1zP1x9nrdyN p91uSKfgcGa0I8fGfzH3LeUsVbfzSRcZtZU2BD3NHnRyYMSLlY86tv2eoH277UdHlxWC WfyrkWRVJG90i7fZNgoM84j3vHFG3E/f7rQBCxgt5fi4vxxep7NZk7oEyL0RCN3oBaHf uHdsD9a8A7C0pJgB3MfMvEAy7lw0P14B++my5k8vYYlIcSHMfLxngGuPalEncGewGewd hnXyqxTl68zGGpRjDConEwSCh0J+yK4rqk6bi4KTUmSl7pBdck75uu8M0oQGUqz6gUVU 4XVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706637044; x=1707241844; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ii8jDIcX/DsDEv7agdvlos1P1vVaKTJYjhbGZ/mMXNQ=; b=MiA1HfcGoMY5amtlVvDEdVmKdXBAmTTA7R1iYuPDvJh2/E1qLvqlmroSKk+Om8dTmU 9uI3MpCPHVdHRWbN4YmHTmpK57CKMo1XubES5/IRnw01dguJXnoE/bQJv1EVbQ+hlq6M s/obHOveT4CXNWDFICvKTgesKOFzm6LY41y+b4blXWkZAtZXbV7mMIKszna4+7/oyD83 G+cUJ3UqroWKzVcO5NGDdHQStWchUZINDKhoukP6S0RWXGzKIez/RTZ50ccwlnBkjW9Z YQPlVWgliuLcJAvyJ7o0cGr2ilhky8JZYi2Mn0tI/wpWsy6OgVS41cGxa6L1YtewEX1f 6YTA== X-Gm-Message-State: AOJu0YzVPhc8eQAi0ONo6Wq8zlE6fDviEs0pFGVExSD46pn0DEbP129s aS/tb7LdOuPKyBijlXCDxWmCWMom9nK87VCaDnqn/cx/D7u7PpEymvokYhW4F9Y= X-Google-Smtp-Source: AGHT+IF0icFwhyKXV2wIAAIoTFi/4HP0H/LhlHWezIQhgBPXz+wOVM3yXYMheoxlZTzekFh0iKtQcA== X-Received: by 2002:a05:622a:138e:b0:42a:a952:69f7 with SMTP id o14-20020a05622a138e00b0042aa95269f7mr4349529qtk.18.1706637043807; Tue, 30 Jan 2024 09:50:43 -0800 (PST) Received: from LOCLAP699.rst-01.locus ([208.195.13.130]) by smtp.gmail.com with ESMTPSA id cr7-20020a05622a428700b0042a31bc98b9sm4718914qtb.24.2024.01.30.09.50.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 09:50:43 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 2/2] auto-t: add netconfig timeout test Date: Tue, 30 Jan 2024 09:50:38 -0800 Message-Id: <20240130175038.77908-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240130175038.77908-1-prestwoj@gmail.com> References: <20240130175038.77908-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Tests that netconfig eventually times out and that IWD disconnects --- autotests/testNetconfig/autoconnect.psk | 2 + autotests/testNetconfig/timeout_test.py | 65 +++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 autotests/testNetconfig/autoconnect.psk create mode 100644 autotests/testNetconfig/timeout_test.py diff --git a/autotests/testNetconfig/autoconnect.psk b/autotests/testNetconfig/autoconnect.psk new file mode 100644 index 00000000..c28936bf --- /dev/null +++ b/autotests/testNetconfig/autoconnect.psk @@ -0,0 +1,2 @@ +[IPv4] +SendHostname=true diff --git a/autotests/testNetconfig/timeout_test.py b/autotests/testNetconfig/timeout_test.py new file mode 100644 index 00000000..a15706e3 --- /dev/null +++ b/autotests/testNetconfig/timeout_test.py @@ -0,0 +1,65 @@ +import unittest +import sys +import os + +sys.path.append('../util') +from iwd import IWD +from iwd import PSKAgent +from iwd import NetworkType + +class Test(unittest.TestCase): + + def test_netconfig_timeout(self): + IWD.copy_to_storage('autoconnect.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) + + ordered_network.network_object.connect() + + condition = 'obj.state == DeviceState.connecting' + wd.wait_for_object_condition(device, condition) + + device.wait_for_event("connecting (netconfig)") + + # Netconfig should fail, and IWD should disconnect + from_condition = 'obj.state == DeviceState.connecting' + to_condition = 'obj.state == DeviceState.disconnecting' + wd.wait_for_object_change(device, from_condition, to_condition, max_wait=60) + + # Autoconnect should then try again + condition = 'obj.state == DeviceState.connecting' + wd.wait_for_object_condition(device, condition) + + device.wait_for_event("connecting (netconfig)") + + device.disconnect() + condition = 'obj.state == DeviceState.disconnected' + wd.wait_for_object_condition(device, condition) + + @classmethod + def setUpClass(cls): + 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() + os.system('rm -rf /tmp/radvd.conf /tmp/resolvconf.log /tmp/test-bin') + os.environ['PATH'] = cls.orig_path + +if __name__ == '__main__': + unittest.main(exit=True)