From: Marcelo Mendes Spessoto Junior <marcelomspessoto@gmail.com>
To: "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>, Shuah Khan <shuah@kernel.org>
Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org,
Marcelo Mendes Spessoto Junior <marcelomspessoto@gmail.com>
Subject: [PATCH net-next v3 1/5] selftests: net: test IPV6_FL_A_RENEW
Date: Fri, 7 Aug 2026 19:09:38 -0300 [thread overview]
Message-ID: <20260807220942.421382-2-marcelomspessoto@gmail.com> (raw)
In-Reply-To: <20260807220942.421382-1-marcelomspessoto@gmail.com>
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 <marcelomspessoto@gmail.com>
---
.../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
next prev parent reply other threads:[~2026-08-07 22:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-07 22:09 [PATCH net-next v3 0/5] net: selftests: adjustments to ipv6_flowlabel_mgr Marcelo Mendes Spessoto Junior
2026-08-07 22:09 ` Marcelo Mendes Spessoto Junior [this message]
2026-08-07 22:09 ` [PATCH net-next v3 2/5] selftests: net: test IPV6_FL_F_REMOTE Marcelo Mendes Spessoto Junior
2026-08-07 22:09 ` [PATCH net-next v3 3/5] selftests: net: create own netns in ipv6_flowlabel_mgr Marcelo Mendes Spessoto Junior
2026-08-07 22:09 ` [PATCH net-next v3 4/5] selftests: net: test IPV6_FL_F_REFLECT Marcelo Mendes Spessoto Junior
2026-08-07 22:09 ` [PATCH net-next v3 5/5] selftests: net: adopt harness for flow label mgr Marcelo Mendes Spessoto Junior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260807220942.421382-2-marcelomspessoto@gmail.com \
--to=marcelomspessoto@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox