From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 8F3E345C6F7 for ; Fri, 7 Aug 2026 22:10:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786140602; cv=none; b=P8CS4lp+pCUy+pJp9ZQeBkm+tXx7Lh07OJmi9xZAa5KrJKiQ4TINoUS6DE7PIPSvPdiPuizi4OLE1eXHVxtEFG3aQBecp1Eh99b4tMoWqgKibIV52RU9jgN27EsSqSTtHh5jBUbg7Y0Y3o4T+1Jg0c62+sL+GwgFEeRaGdvGZS4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786140602; c=relaxed/simple; bh=V5PT+zcfv5kwBc3zsPLyOemrZEyr7x51j1JNaZhSLI8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iEjXzJInQbh3vp8B7tQSI5V6mR70ZSDaPPYTQlTgYbY1lPV9TOSmyQEv6/enZHTGILK6j4puAbEwPmA+pZ+DtrRDorpT47XapKOmcxidwalF11SXQWD7zOZLqlJp4UE1Jme4HxQaawM0fcksNfCoJ1Kumgpan/fP45DRxdLnnNo= 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=VXAqTPzL; arc=none smtp.client-ip=209.85.214.180 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="VXAqTPzL" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2caed617615so858935ad.3 for ; Fri, 07 Aug 2026 15:10:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786140600; x=1786745400; 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=kZPO0FvOtEF8M9IFK2RY794kxXwOWSbOPIOTROMX56g=; b=VXAqTPzLDm4AnEFgYVxXKRuKSfYMxynzNJh5wMFTiE6JGFb9gYBebrPBoVsQRmnBtN Ls1LF0g2MSeM29/x3uSw7OVmtXcYvNxtBJ4wpNPYvjBJC7Ze5NJk5bmI0tpN4iHln2yM zPKSz7vnlSvd5gV05lKcQ1UoPsZuvGM2TfKLFRDk8wsuXR6oSMJYS/tQKYfqZG+IHzMX rBFx0+g2FovHppZS7RPTQ6Ewp60TxQ8B4zC119e5s/KNnS9loU/nxYHg/GxXfVgXVH12 7+I35LPx3u7NthrcwR/Tg1lcubbL/mHmpsD5weCBXNV6Zo4vqiPLEagv4eOvcocrvOTO QzBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786140600; x=1786745400; 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=kZPO0FvOtEF8M9IFK2RY794kxXwOWSbOPIOTROMX56g=; b=sQl4m67or7DMmyNJfoEtkohRtBhgRvHZ6GI104Nc4x991pBEKgCob4CT/s8yN64HEm 5b0xYm7OMmSPeVbNAS877Mr+DO+ECy2lQIc0W2YHVjb3nSam18D/cA0iBjDF9PSwkGYo mpjkWv/YCXCNyLRVlm37ozyIZCjK0kD2wfyHOQ7gGL7NxLkkYxcKbTp2nYezuw+S3rov buhopmyeMy/Kn7aAzpavEdmsAXTNgzjSOHST9Xm0k/L6LDWRCh0mBiU/l3tdwXkC5pd7 /sLYZGmATD1cYUrWkMezl3FT5QApSu1UjapIWlrj5dMqH3s1ILHYfIRpzo1/j+jPdZVI +RRQ== X-Forwarded-Encrypted: i=1; AHgh+RpGp0ufWusXX/KWE7ee9S81M+tizO6fKQtj3Fds/T2ideHWW6A3M3AxPJKJXYgBZG7kHcB4aR6Mlszql8A=@vger.kernel.org X-Gm-Message-State: AOJu0Yz+er1ViPMkQpHuKoEFPVSR4bQyo05uBRzEIER8UY5c9QFgpVBs QmQ3c4YI0bHI8KC+o39jWPRZZ2PRe6FtIJRXMcoYm5+vQtKZdK9y/eG6 X-Gm-Gg: AR+sD12YceuKmZNNt6PRLlpJfYNsTf2bj7DdPJEJUyvmHNxMoosZc4UxyOn6yVSBte1 CGwHKce9YQscnpGIp562uMNr2l7gyf0yazOPIlZHoS58sBk8tYvE5uQyR47mP8gQXztfDGhxPSC I43WYkStUTKznM4C/+jBKQ4bNJ3HA0e58zrWzkqTFsRNYbPwPzlEbEKeWxtBYhRwWv0mCVIsu/y 00Y2BOpgfpT1vChPIgeUVAoSptB3oZ5tgiGEbqnjCi56n8JoijjXiCzUwBgBNTi26dQ6d4c5wha Wb2JeGDiuluR/BiZyfbctE7V2R8pxV/6DlIwyg7EkKlAtCggF8+acMLTZ9CJqavLQ0VaAQh/Wkw KEBZy9gaL6ri8YNL6k1ywz+DWNrOdYA4WAwrtOpXTCte6dnJ/+EcylnAQbwSbX9SaReEkrLaq/j z6G3+ynTh2QTix7kZcXQHVYIOgvFxkUSwe4oni7XLtktvDiU0WvA9sfUWBIv80bavUjw== X-Received: by 2002:a05:6a21:3390:b0:3c3:93ce:663 with SMTP id adf61e73a8af0-3cb85f4a26emr28784462637.26.1786140599730; Fri, 07 Aug 2026 15:09:59 -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.09.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2026 15:09:59 -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 1/5] selftests: net: test IPV6_FL_A_RENEW Date: Fri, 7 Aug 2026 19:09:38 -0300 Message-ID: <20260807220942.421382-2-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 RENEW was the only flow label action without selftests coverage. Assert renew returns no error on correct usage and fails for labels that do not exist. This test is based on the previously implemented EXCL share test, which demonstrates that a new flow label with the same value can be created after the linger period. Renew is used here to show that a flow label can last longer and block a new flow label creation after the previous linger time. This test, however, demands sleep during execution, and should be placed as a conditional test under the -l option. The addition of the expect_fail_errno helper is necessary to assert the corresponding error when a function can fail in multiple ways. Signed-off-by: Marcelo Mendes Spessoto Junior --- .../selftests/net/ipv6_flowlabel_mgr.c | 58 ++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/ipv6_flowlabel_mgr.c b/tools/testing/selftests/net/ipv6_flowlabel_mgr.c index af95b48acea9..ec187890a1ed 100644 --- a/tools/testing/selftests/net/ipv6_flowlabel_mgr.c +++ b/tools/testing/selftests/net/ipv6_flowlabel_mgr.c @@ -42,6 +42,23 @@ #define expect_pass(x) __expect(x) #define expect_fail(x) __expect(!(x)) +#define expect_fail_errno(x, e) \ + do { \ + int __exp = (e); \ + int __ret = (x); \ + int __err = errno; \ + if (__ret && __err == __exp) \ + fprintf(stderr, "[OK] " #x "\n"); \ + else if (!__ret) \ + error(1, 0, "[ERR] " #x \ + " (line %d): unexpectedly succeeded", \ + __LINE__); \ + else \ + error(1, 0, "[ERR] " #x \ + " (line %d): expected errno %d, got %d", \ + __LINE__, __exp, __err); \ + } while (0) + static bool cfg_long_running; static bool cfg_verbose; @@ -71,6 +88,19 @@ static int flowlabel_put(int fd, uint32_t label) return setsockopt(fd, SOL_IPV6, IPV6_FLOWLABEL_MGR, &req, sizeof(req)); } +static int flowlabel_renew(int fd, uint32_t label, uint8_t share, + uint16_t linger) +{ + struct in6_flowlabel_req req = { + .flr_action = IPV6_FL_A_RENEW, + .flr_label = htonl(label), + .flr_share = share, + .flr_linger = linger, + }; + + return setsockopt(fd, SOL_IPV6, IPV6_FLOWLABEL_MGR, &req, sizeof(req)); +} + static void run_tests(int fd) { int wstatus; @@ -94,7 +124,7 @@ static void run_tests(int fd) expect_pass(flowlabel_get(fd, 1, IPV6_FL_S_ANY, IPV6_FL_F_CREATE)); explain("cannot get it again with the exclusive (FL_FL_EXCL) flag"); expect_fail(flowlabel_get(fd, 1, IPV6_FL_S_ANY, - IPV6_FL_F_CREATE | IPV6_FL_F_EXCL)); + IPV6_FL_F_CREATE | IPV6_FL_F_EXCL)); explain("can now put exactly three references"); expect_pass(flowlabel_put(fd, 1)); expect_pass(flowlabel_put(fd, 1)); @@ -160,6 +190,32 @@ static void run_tests(int fd) error(1, errno, "wait"); if (!WIFEXITED(wstatus) || WEXITSTATUS(wstatus) != 0) error(1, errno, "wait: unexpected child result"); + + explain("It is not possible to renew a label that does not exist"); + expect_fail_errno(flowlabel_renew(fd, 5, IPV6_FL_S_EXCL, + 2 * (FL_MIN_LINGER * 2 + 1)), + ESRCH); + + explain("Create a label for basic renew validation"); + expect_pass(flowlabel_get(fd, 5, IPV6_FL_S_EXCL, IPV6_FL_F_CREATE)); + explain("renew does not error for an existing, valid label"); + expect_pass(flowlabel_renew(fd, 5, IPV6_FL_S_EXCL, + 2 * (FL_MIN_LINGER * 2 + 1))); + + if (cfg_long_running) { + explain("create a new label with FL_MIN_LINGER linger time"); + expect_pass(flowlabel_get(fd, 6, IPV6_FL_S_EXCL, + IPV6_FL_F_CREATE)); + explain("renew the label to extend linger, then put it"); + expect_pass(flowlabel_renew(fd, 6, IPV6_FL_S_EXCL, + 2 * (FL_MIN_LINGER * 2 + 1))); + expect_pass(flowlabel_put(fd, 6)); + sleep(FL_MIN_LINGER * 2 + 1); + explain("cannot create: new linger time not over yet"); + expect_fail_errno(flowlabel_get(fd, 6, IPV6_FL_S_ANY, + IPV6_FL_F_CREATE), + EPERM); + } } static void parse_opts(int argc, char **argv) -- 2.55.0