From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from atuin.qyliss.net (localhost [IPv6:::1]) by atuin.qyliss.net (Postfix) with ESMTP id B88311467B; Thu, 18 Dec 2025 18:59:33 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id 6CEF0145FB; Thu, 18 Dec 2025 18:59:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on atuin.qyliss.net X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DMARC_MISSING,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=4.0.1 Received: from fout-b6-smtp.messagingengine.com (fout-b6-smtp.messagingengine.com [202.12.124.149]) by atuin.qyliss.net (Postfix) with ESMTPS id 3A19F145F9 for ; Thu, 18 Dec 2025 18:59:26 +0000 (UTC) Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfout.stl.internal (Postfix) with ESMTP id 1B2781D000E9; Thu, 18 Dec 2025 13:59:24 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Thu, 18 Dec 2025 13:59:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alyssa.is; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:message-id:mime-version:reply-to :subject:subject:to:to; s=fm3; t=1766084363; x=1766170763; bh=/O GvSm7pil1MPDMvBSIEtmhB5VXjYByGoI/kN3yrQKs=; b=Mr0lxb0cYEgDo2RcrE EiK88hD0AlCSMKc0+fm5QFakmB06UEugKpdBO/I4tlsN05H4E0tyjIBSFGha/uef JnIjjKf3t4WCNbEh2aAIERhv6HBHHtRNW02pzbNBHIXK+bBQzuVt2qhLW3mTgREB F+ENyt0eItR0nKZ1AA11BxH+qWPh4amscRGqaHHsiZSCsZhg7MPZoMVvzHqcWjhA mB4lW1nEIlDWUp/mqcd8wAiYg3S6+CU2OAfNeIN+s/pHTMwlVe6XyLm6Yaeq5mpn K26Z9xGEYlnWoIs1mahizDxc+jSHxSDkawfaG8m64ZvNOOy4D0rshdkpPuS0Sn5x Vppg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:message-id:mime-version:reply-to:subject :subject:to:to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1766084363; x=1766170763; bh=/OGvSm7pil1MPDMvBSIEtmhB5VXj YByGoI/kN3yrQKs=; b=joDl7TsDqWANc8sXAjI2XmF9O9So4gE9mDz2ozKeTk/X 6FK+vig4JSS+liK6fa1NyVRJpEAWS4Lcofr21wlfvnvQHASah6SeqI55QjX5nMTk SqsVSDK6qoxY+6A0WpM0cGmNmRtN7QX/LbbDPFL5fEIrnf82wzA3ogMy5UDUzFiX AmSfP+3GXMEEyXYGIXfuEp7gKy98v7qumSFUYPkLGbdFmYQo6IkVO8xFgrOKQooE 30LSSlJiKtDjeTyxAwwiktUVFbiqO4bhn6Oqz+ruPqwjScAlcraFvMWquTFEF7XJ Z3heHwdZb5kWUyKJr21gXuHPd+ETOKUAYjrKZJvxCQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdegiedvtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefhvfevufffkffogggtgfesthekredtredtjeenucfhrhhomheptehlhihsshgrucft ohhsshcuoehhihesrghlhihsshgrrdhisheqnecuggftrfgrthhtvghrnhepjeefheffhe ejjefgtdffteektdfgfefgfeejgeffkeejjeegtdevjeelheellefhnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhephhhisegrlhihshhsrgdrih hspdhnsggprhgtphhtthhopedvpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopeih uhhrvghkrgestgihsggvrhgthhgrohhsrdguvghvpdhrtghpthhtohepuggvvhgvlhessh hpvggtthhruhhmqdhoshdrohhrgh X-ME-Proxy: Feedback-ID: i12284293:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 18 Dec 2025 13:59:23 -0500 (EST) Received: by fw12.qyliss.net (Postfix, from userid 1000) id 3D0DA7CD8502; Thu, 18 Dec 2025 19:59:21 +0100 (CET) From: Alyssa Ross To: devel@spectrum-os.org Subject: [PATCH] release/checks/integration: fix race condition Date: Thu, 18 Dec 2025 19:58:30 +0100 Message-ID: <20251218185830.89957-1-hi@alyssa.is> X-Mailer: git-send-email 2.51.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-ID-Hash: ZPUWFDPQMUSW2PT3L2ILGUTTV3ZFXL4J X-Message-ID-Hash: ZPUWFDPQMUSW2PT3L2ILGUTTV3ZFXL4J X-MailFrom: hi@alyssa.is X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-devel.spectrum-os.org-0; header-match-devel.spectrum-os.org-1; header-match-devel.spectrum-os.org-2; header-match-devel.spectrum-os.org-3; header-match-devel.spectrum-os.org-4; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Yureka Lilian X-Mailman-Version: 3.3.9 Precedence: list List-Id: Patches and low-level development discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: By default, IPv6 addresses are in the tentative state and can't be bound to until the kernel has asychronously done Duplicate Address Detection. This was the cause of us needing to retry the bind, and sometimes even that wasn't enough. Since we're in a fresh network namespace, we know there can't be a duplicate address, so we can add the address with the IFA_F_NODAD flag to skip this and make the address available for binding immediately. We can't set that flag using the ioctl interface we were using before, so switch to netlink. This is slightly lazy netlink — we hardcode the index of the loopback address, and don't bother with extended errors — but I think that's fine for a test where readability is the most important thing. I've run the test 100 times with this change and didn't see any bind failures, which is a big improvement over the failure rate I was seeing before. Fixes: cdf1891e ("release/checks/integration: Adapt networking test for ipv6") Signed-off-by: Alyssa Ross --- release/checks/integration/networking.c | 89 +++++++++++++++++++------ 1 file changed, 70 insertions(+), 19 deletions(-) diff --git a/release/checks/integration/networking.c b/release/checks/integration/networking.c index 68f00b98..7d02f557 100644 --- a/release/checks/integration/networking.c +++ b/release/checks/integration/networking.c @@ -12,14 +12,14 @@ #include #include -#include +#include +#include #include +#include static int setup_server(void) { int fd; - struct ifreq ifr; - struct in6_ifreq ifr6; struct sockaddr_in6 addr = { .sin6_family = AF_INET6, @@ -27,30 +27,83 @@ static int setup_server(void) .sin6_addr = { .s6_addr = { 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 } }, }; - sprintf(ifr.ifr_name, "lo"); + struct { + struct nlmsghdr nh; + struct ifaddrmsg ifa; + struct rtattr attr; + struct in6_addr addr; + } newaddr_req = { + { + .nlmsg_len = sizeof newaddr_req, + .nlmsg_type = RTM_NEWADDR, + .nlmsg_flags = NLM_F_ACK | NLM_F_REQUEST, + }, + { + .ifa_family = AF_INET6, + .ifa_prefixlen = 128, + .ifa_flags = IFA_F_NODAD, + .ifa_index = 1, + }, + { + .rta_len = sizeof newaddr_req.attr + sizeof newaddr_req.addr, + .rta_type = IFA_ADDRESS, + }, + addr.sin6_addr, + }; - ifr6.ifr6_ifindex = 1; - ifr6.ifr6_addr = addr.sin6_addr; - ifr6.ifr6_prefixlen = 128; + struct { + struct nlmsghdr nh; + struct ifinfomsg ifi; + } newlink_req = { + { + .nlmsg_len = sizeof newlink_req, + .nlmsg_type = RTM_NEWLINK, + .nlmsg_flags = NLM_F_ACK | NLM_F_REQUEST, + }, + { + .ifi_index = 1, + .ifi_flags = IFF_UP, + .ifi_change = IFF_UP, + }, + }; - if ((fd = socket(AF_INET6, SOCK_STREAM|SOCK_CLOEXEC, 0)) == -1) { + struct { + struct nlmsghdr nh; + struct nlmsgerr err; + } res; + + if ((fd = socket(AF_NETLINK, SOCK_DGRAM|SOCK_CLOEXEC, NETLINK_ROUTE)) == -1) { perror("socket"); exit(EXIT_FAILURE); } - if (ioctl(fd, SIOCGIFFLAGS, &ifr) == -1) { - perror("SIOCGIFFLAGS"); + if (send(fd, &newaddr_req, sizeof newaddr_req, 0) == -1) { + perror("send"); exit(EXIT_FAILURE); } - ifr.ifr_flags |= IFF_UP; - if (ioctl(fd, SIOCSIFFLAGS, &ifr) == -1) { - perror("SIOCSIFFLAGS"); + if (recv(fd, &res, sizeof res, 0) == -1) { + perror("recv"); exit(EXIT_FAILURE); } - if (ioctl(fd, SIOCSIFADDR, &ifr6) == -1) { - perror("SIOCSIFADDR"); + if (res.err.error) { + fprintf(stderr, "RTM_NEWADDR: %s", strerror(-res.err.error)); + exit(EXIT_FAILURE); + } + + if (send(fd, &newlink_req, sizeof newlink_req, 0) == -1) { + perror("send"); + exit(EXIT_FAILURE); + } + + if (recv(fd, &res, sizeof res, 0) == -1) { + perror("recv"); + exit(EXIT_FAILURE); + } + + if (res.err.error) { + fprintf(stderr, "RTM_NEWLINK: %s", strerror(-res.err.error)); exit(EXIT_FAILURE); } @@ -61,11 +114,9 @@ static int setup_server(void) exit(EXIT_FAILURE); } - int tries = 0; - while (bind(fd, &addr, sizeof addr) == -1) { + if (bind(fd, &addr, sizeof addr) == -1) { perror("bind"); - if (tries++ >= 5) - exit(EXIT_FAILURE); + exit(EXIT_FAILURE); } if (listen(fd, 1) == -1) { base-commit: 77f8d28f076b16a64faef83c5cf374995770ff70 -- 2.51.0