From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 9BA1C46C825 for ; Fri, 7 Aug 2026 22:10:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786140612; cv=none; b=LUlNr6FXiseT0CU5qSlvqg3lFtFgj6CkbZE+isIoQIbemsOaSKLJDGW7kyFlet6KEtt996eN42AEO/+KHohhL9J/r1OKZyUquZDv1FwLOwzYsfI4FZIXe+vYX1Cgt+WRXHF0O5eDcNd31+ZE20tx0jB8JsCsWoyopCeB6xcE/FY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786140612; c=relaxed/simple; bh=RRCXOWIG7wQhsKY6MWJcWH1ko4HQP18F7eGyDZKZ3Yg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p3aBU0oBCMzwxa1c2NBFKjBvkvLKMooOcfe9er/Fsx2BhBrFSjSrXJEjHEPU/1deN21SrKqtFWqWBt/haMclqeopoyv0A03KDIFXgy+czq9MD4Ceftr+f0M0xr29kc34dBqz58Wpax8MioTM52UevdiAiZC/v4D3mX8CY17ZTCQ= 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=Fvzuz4Cc; arc=none smtp.client-ip=209.85.214.179 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="Fvzuz4Cc" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2ceab75934dso943255ad.2 for ; Fri, 07 Aug 2026 15:10:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786140610; x=1786745410; darn=vger.kernel.org; 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:content-type; bh=eE6hvbuq5iFYO3P8zMcP762X8R9vSoVUqqxZJnu8QhQ=; b=Fvzuz4CcrUyf5sMX3FKYg9wpSuPskQsGjO9/j1j4N1kNV5Q/6cuqg7PK7iV/5Agm0S Bne+IXb9gjzISZrrezC7AiqF3cLCWDQHzmqGrrBtVvjHjxOnTxy3hKuAhB9yMEK+1/QB ELeFmeijBXD8QIoo96S1c6wAKLV+oJjcnjTtjLsCK5pdelzW/YOm5G6GqKE4e9h5vIzx BJ98MdHCPMw0L8XeNfdlKJDXaeIEdTBr8MfC7d6WznP253hEV2UHlGjMsMX1B+b4oHv8 LtEZvPu8PlqyzsKNIef9i27sB/ZQnEPj4m/Aa5iRk6lEwckN/DQO8QaVmnOTRHTgX2uB LYJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786140610; x=1786745410; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=eE6hvbuq5iFYO3P8zMcP762X8R9vSoVUqqxZJnu8QhQ=; b=kIsOBKw6kcPS5z+Xen5yZGj2dau1RVv+1NEhHq3TixP6AkiL8CXIY3FhJKWuDhpAr1 66CsaCiKCtwiccABO5CH+Y9B+CrIRVTEWeH4tI4GmecnkM2tEv8twyBbN/+hP7lokhDD kXPyQWN9hM6bgIUizzTQffCPLBTSkj0CtjsLfPPdUrAMLYiDSKasU3Xc5voNf5vBZelB VL4eKjzCF42qvRHgIOy1kg3asZg/75oHeg2Oe6pwRS4+S08H6mV/yFdnYCJfCDokLliO lHh2LS0tHelnC/2ZVPJcxYxPSueR9XI1lA1D7ybI9BRRLUv6wQJTjGSJHizu65DXx/MO VB9g== X-Forwarded-Encrypted: i=1; AHgh+RqGgDj0uv8tzT723YUb7RCwvH6soidAnkRJ52EppNag6iqgEhCw4G0hDNdjceSLbZWVu2LTCtJldvvdrFc=@vger.kernel.org X-Gm-Message-State: AOJu0Yy2ID/TZykg30DwLottDi0muTbuOfE2UZwuy0x39Vm1a+x5C7lJ G6ZO5h5hgtmhdE9YP20UKvF4nkFy8s4ucSqYIQkzFRP2tR4IIpSy5KKn X-Gm-Gg: AR+sD130jIE1ajXggWRZMp6wPt7uaijI02asZvnNc+2xtcMMWoV+7bWwTeC7HH6iR1G UorzXjOhfJ09AQX0YD9na8FFPllH7n3T52VZl8fnk7snz/ckUn0VRQMQcDQeviRX45OJF6mp/8H 0tymknE07EEJQZ//ifAWQYBuOEQhqu15UpmOQvOiNCAhRaefJUsN/Dc7fYWLzhQiIS1FeUAnI/X Uft6/CwUdgNqM+Ma6rm3hYFq/InSTX5D35gZnkK5XU2muyPCuIiWy0OtTOJBMPgw1bVK8h3u1Lx GFKP+mROjvnJ8A2DmRlPGsM4ppz32g2/T9TIRugPvWAS4YKFDVaMf209VHKuyEDW4eSu9aAzqEL hppvOqLMUYg2NwS5rKNhzhKQVTIM2PiYqnRRMIS+fMxETaEYDuaIRYOb4sMS1f5GUvo+4KWRebT jj34oLnodaCS1qxy2Tp7rK5cOren+4Y0eklIMniApwtsh4TnXve5DrcpqnboyLufdWzQ== X-Received: by 2002:a17:90b:1d8d:b0:38f:5869:387b with SMTP id 98e67ed59e1d1-3903c56c2eamr23722431a91.9.1786140609850; Fri, 07 Aug 2026 15:10:09 -0700 (PDT) Received: from fedora ([2804:1b3:a8c3:8ee5:1c39:64d9:e257:73dc]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-315be568bd3sm11182762eec.0.2026.08.07.15.10.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2026 15:10:09 -0700 (PDT) From: Marcelo Mendes Spessoto Junior To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Shuah Khan Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Marcelo Mendes Spessoto Junior Subject: [PATCH net-next v3 4/5] selftests: net: test IPV6_FL_F_REFLECT Date: Fri, 7 Aug 2026 19:09:41 -0300 Message-ID: <20260807220942.421382-5-marcelomspessoto@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260807220942.421382-1-marcelomspessoto@gmail.com> References: <20260807220942.421382-1-marcelomspessoto@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit According to the source code, flowlabel_consistency must be deactivated for the IPV6_FL_F_REFLECT flag to work. Since ipv6_flowlabel_mgr now runs in its own network namespace, do this directly from the test binary. Attempt to disable net.ipv6.flowlabel_consistency and skip the reflect test if that fails. A disabled flowlabel_consistency does not affect the remaining features being tested on the file, and failing to disable is not fatal and skips the reflect test only. The previously defined tcp_listen and tcp_connect helpers were reused, since the connection flow required for REFLECT validation is very similar to REMOTE. Signed-off-by: Marcelo Mendes Spessoto Junior --- .../selftests/net/ipv6_flowlabel_mgr.c | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/tools/testing/selftests/net/ipv6_flowlabel_mgr.c b/tools/testing/selftests/net/ipv6_flowlabel_mgr.c index f8d8b09b9d86..d32150abd8ff 100644 --- a/tools/testing/selftests/net/ipv6_flowlabel_mgr.c +++ b/tools/testing/selftests/net/ipv6_flowlabel_mgr.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -168,6 +169,23 @@ static void tcp_connect(int listener, uint32_t flowlabel, *accepted = afd; } +static bool disable_flowlabel_consistency(void) +{ + int fd; + + fd = open("/proc/sys/net/ipv6/flowlabel_consistency", O_WRONLY); + if (fd == -1) + return false; + + if (write(fd, "0", 1) != 1) { + close(fd); + return false; + } + close(fd); + + return true; +} + static void run_tests(int fd) { int wstatus; @@ -307,6 +325,54 @@ static void run_tests(int fd) close(remote_cfd); close(remote_listener); } + + if (!disable_flowlabel_consistency()) { + fprintf(stderr, + "[INFO] skip REFLECT: cannot disable net.ipv6.flowlabel_consistency\n"); + } else { + struct in6_flowlabel_req reflect_query = { + .flr_action = IPV6_FL_A_GET, + }; + struct in6_flowlabel_req reflect_off = { + .flr_action = IPV6_FL_A_PUT, + .flr_flags = IPV6_FL_F_REFLECT, + }; + struct in6_flowlabel_req reflect_on = { + .flr_action = IPV6_FL_A_GET, + .flr_flags = IPV6_FL_F_REFLECT, + }; + socklen_t reflect_query_len = sizeof(reflect_query); + int reflect_listener = tcp_listen(); + int reflect_cfd, reflect_afd; + + explain("Enable REFLECT on listener before client connects"); + expect_pass(setsockopt(reflect_listener, SOL_IPV6, + IPV6_FLOWLABEL_MGR, &reflect_on, + sizeof(reflect_on))); + + tcp_connect(reflect_listener, 8, &reflect_cfd, &reflect_afd); + + explain("accepted socket's label should be reflected"); + expect_pass(getsockopt(reflect_afd, SOL_IPV6, + IPV6_FLOWLABEL_MGR, &reflect_query, + &reflect_query_len)); + if (ntohl(reflect_query.flr_label) != 8) + error(1, 0, "unexpected reflected flowlabel %u", + ntohl(reflect_query.flr_label)); + + explain("PUT+REFLECT disables reflection on accepted socket"); + expect_pass(setsockopt(reflect_afd, SOL_IPV6, + IPV6_FLOWLABEL_MGR, &reflect_off, + sizeof(reflect_off))); + explain("cannot disable reflection twice"); + expect_fail(setsockopt(reflect_afd, SOL_IPV6, + IPV6_FLOWLABEL_MGR, &reflect_off, + sizeof(reflect_off))); + + close(reflect_afd); + close(reflect_cfd); + close(reflect_listener); + } } static void setup(void) -- 2.55.0