RENEW was the only flow label action without selftests coverage.

Based on the previously implemented EXCL share test, that demonstrates
that a new flow label with same label can be created after the linger
period, use renew to show that the flow label can last longer and
block a new flow label creation after the previous linger time.

Signed-off-by: Marcelo Mendes Spessoto Junior <[email protected]>
---
 .../selftests/net/ipv6_flowlabel_mgr.c        | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/tools/testing/selftests/net/ipv6_flowlabel_mgr.c 
b/tools/testing/selftests/net/ipv6_flowlabel_mgr.c
index af95b48acea9..cfa7e6270994 100644
--- a/tools/testing/selftests/net/ipv6_flowlabel_mgr.c
+++ b/tools/testing/selftests/net/ipv6_flowlabel_mgr.c
@@ -71,6 +71,17 @@ 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, uint16_t linger)
+{
+       struct in6_flowlabel_req req = {
+               .flr_action = IPV6_FL_A_RENEW,
+               .flr_label = htonl(label),
+               .flr_linger = linger,
+       };
+
+       return setsockopt(fd, SOL_IPV6, IPV6_FLOWLABEL_MGR, &req, sizeof(req));
+}
+
 static void run_tests(int fd)
 {
        int wstatus;
@@ -160,6 +171,18 @@ static void run_tests(int fd)
                error(1, errno, "wait");
        if (!WIFEXITED(wstatus) || WEXITSTATUS(wstatus) != 0)
                error(1, errno, "wait: unexpected child result");
+
+       if (cfg_long_running) {
+               explain("create a new label with FL_MIN_LINGER linger time");
+               expect_pass(flowlabel_get(fd, 5, IPV6_FL_S_EXCL, 
IPV6_FL_F_CREATE));
+               explain("renew the label to increase its linger time and put 
it");
+               expect_pass(flowlabel_renew(fd, 5, 2 * (FL_MIN_LINGER * 2 + 
1)));
+               expect_pass(flowlabel_put(fd, 5));
+               sleep(FL_MIN_LINGER * 2 + 1);
+               explain("The label cannot be created because the new linger 
time is not over yet");
+               expect_fail(flowlabel_get(fd, 5, IPV6_FL_S_ANY, 
IPV6_FL_F_CREATE));
+       }
+
 }
 
 static void parse_opts(int argc, char **argv)
-- 
2.55.0


Reply via email to