From: John Fastabend <john.fastabend@gmail.com>
To: lmb@cloudflare.com, jakub@cloudflare.com, daniel@iogearbox.net
Cc: netdev@vger.kernel.org, bpf@vger.kernel.org,
john.fastabend@gmail.com, ast@kernel.org
Subject: [bpf-next PATCH 10/10] bpf: selftests, add ktls tests to test_sockmap
Date: Tue, 05 May 2020 13:52:52 -0700 [thread overview]
Message-ID: <158871197261.7537.5110096753450826009.stgit@john-Precision-5820-Tower> (raw)
In-Reply-To: <158871160668.7537.2576154513696580062.stgit@john-Precision-5820-Tower>
Until now we have only had minimal ktls+sockmap testing when being
used with helpers and different sendmsg/sendpage patterns. Add a
pass with ktls here.
To run just ktls tests,
$ ./test_sockmap --whitelist="ktls"
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
---
tools/testing/selftests/bpf/test_sockmap.c | 70 ++++++++++++++++++----------
1 file changed, 44 insertions(+), 26 deletions(-)
diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c
index 154bcdb..a80ecc4 100644
--- a/tools/testing/selftests/bpf/test_sockmap.c
+++ b/tools/testing/selftests/bpf/test_sockmap.c
@@ -115,6 +115,7 @@ static const struct option long_options[] = {
struct test_env {
const char *type;
const char *subtest;
+ const char *prepend;
int test_num;
int subtest_num;
@@ -126,6 +127,26 @@ struct test_env {
struct test_env env;
+struct sockmap_options {
+ int verbose;
+ bool base;
+ bool sendpage;
+ bool data_test;
+ bool drop_expected;
+ int iov_count;
+ int iov_length;
+ int rate;
+ char *map;
+ char *whitelist;
+ char *blacklist;
+ char *prepend;
+};
+
+struct _test {
+ char *title;
+ void (*tester)(int cg_fd, struct sockmap_options *opt);
+};
+
static void test_start(void)
{
env.subtest_num++;
@@ -151,10 +172,11 @@ static void test_reset(void)
txmsg_ingress = txmsg_skb = 0;
}
-static int test_start_subtest(const char *name, const char *type)
+static int test_start_subtest(const struct _test *t, struct sockmap_options *o)
{
- env.type = type;
- env.subtest = name;
+ env.type = o->map;
+ env.subtest = t->title;
+ env.prepend = o->prepend;
env.test_num++;
env.subtest_num = 0;
env.fail_last = env.fail_cnt;
@@ -170,9 +192,10 @@ static void test_end_subtest(void)
if (!error)
test_pass();
- fprintf(stdout, "#%2d/%2d %8s:%s:%s\n",
+ fprintf(stdout, "#%2d/%2d %8s:%s:%s:%s\n",
env.test_num, env.subtest_num,
!type ? "sockmap" : "sockhash",
+ env.prepend ? : "",
env.subtest, error ? "FAIL" : "OK");
}
@@ -379,20 +402,6 @@ struct msg_stats {
struct timespec end;
};
-struct sockmap_options {
- int verbose;
- bool base;
- bool sendpage;
- bool data_test;
- bool drop_expected;
- int iov_count;
- int iov_length;
- int rate;
- char *map;
- char *whitelist;
- char *blacklist;
-};
-
static int msg_loop_sendpage(int fd, int iov_length, int cnt,
struct msg_stats *s,
struct sockmap_options *opt)
@@ -1606,11 +1615,6 @@ static int populate_progs(char *bpf_file)
return 0;
}
-struct _test {
- char *title;
- void (*tester)(int cg_fd, struct sockmap_options *opt);
-};
-
struct _test test[] = {
{"txmsg test passthrough", test_txmsg_pass},
{"txmsg test redirect", test_txmsg_redir},
@@ -1636,7 +1640,9 @@ static int check_whitelist(struct _test *t, struct sockmap_options *opt)
return -ENOMEM;
entry = strtok(ptr, ",");
while (entry) {
- if (strstr(opt->map, entry) != 0 || strstr(t->title, entry) != 0)
+ if ((opt->prepend && strstr(opt->prepend, entry) != 0) ||
+ strstr(opt->map, entry) != 0 ||
+ strstr(t->title, entry) != 0)
return 0;
entry = strtok(NULL, ",");
}
@@ -1654,7 +1660,9 @@ static int check_blacklist(struct _test *t, struct sockmap_options *opt)
return -ENOMEM;
entry = strtok(ptr, ",");
while (entry) {
- if (strstr(opt->map, entry) != 0 || strstr(t->title, entry) != 0)
+ if ((opt->prepend && strstr(opt->prepend, entry) != 0) ||
+ strstr(opt->map, entry) != 0 ||
+ strstr(t->title, entry) != 0)
return 0;
entry = strtok(NULL, ",");
}
@@ -1680,7 +1688,7 @@ static int __test_selftests(int cg_fd, struct sockmap_options *opt)
if (check_blacklist(&t, opt) == 0)
continue;
- test_start_subtest(t.title, opt->map);
+ test_start_subtest(&t, opt);
t.tester(cg_fd, opt);
test_end_subtest();
}
@@ -1700,11 +1708,21 @@ static void test_selftests_sockhash(int cg_fd, struct sockmap_options *opt)
__test_selftests(cg_fd, opt);
}
+static void test_selftests_ktls(int cg_fd, struct sockmap_options *opt)
+{
+ opt->map = BPF_SOCKHASH_FILENAME;
+ opt->prepend = "ktls";
+ ktls = 1;
+ __test_selftests(cg_fd, opt);
+ ktls = 0;
+}
+
static int test_selftest(int cg_fd, struct sockmap_options *opt)
{
test_selftests_sockmap(cg_fd, opt);
test_selftests_sockhash(cg_fd, opt);
+ test_selftests_ktls(cg_fd, opt);
test_print_results();
return 0;
}
next prev parent reply other threads:[~2020-05-05 20:53 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-05 20:49 [bpf-next PATCH 00/10] bpf: selftests, test_sockmap improvements John Fastabend
2020-05-05 20:49 ` [bpf-next PATCH 01/10] bpf: selftests, move sockmap bpf prog header into progs John Fastabend
2020-05-05 20:50 ` [bpf-next PATCH 02/10] bpf: selftests, remove prints from sockmap tests John Fastabend
2020-05-05 20:50 ` [bpf-next PATCH 03/10] bpf: selftests, sockmap test prog run without setting cgroup John Fastabend
2020-05-07 8:31 ` Jakub Sitnicki
2020-05-07 18:10 ` John Fastabend
2020-05-05 20:50 ` [bpf-next PATCH 04/10] bpf: selftests, print error in test_sockmap error cases John Fastabend
2020-05-05 20:51 ` [bpf-next PATCH 05/10] bpf: selftests, improve test_sockmap total bytes counter John Fastabend
2020-05-07 8:55 ` Jakub Sitnicki
2020-05-05 20:51 ` [bpf-next PATCH 06/10] bpf: selftests, break down test_sockmap into subtests John Fastabend
2020-05-05 20:51 ` [bpf-next PATCH 07/10] bpf: selftests, provide verbose option for selftests execution John Fastabend
2020-05-05 20:52 ` [bpf-next PATCH 08/10] bpf: selftests, add whitelist option to test_sockmap John Fastabend
2020-05-05 20:52 ` [bpf-next PATCH 09/10] bpf: selftests, add blacklist " John Fastabend
2020-05-05 20:52 ` John Fastabend [this message]
2020-05-05 21:04 ` [bpf-next PATCH 00/10] bpf: selftests, test_sockmap improvements John Fastabend
2020-05-07 10:37 ` Jakub Sitnicki
2020-05-07 18:12 ` John Fastabend
2020-05-08 21:34 ` Andrii Nakryiko
2020-05-09 14:55 ` John Fastabend
2020-05-12 3:13 ` Andrii Nakryiko
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=158871197261.7537.5110096753450826009.stgit@john-Precision-5820-Tower \
--to=john.fastabend@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=jakub@cloudflare.com \
--cc=lmb@cloudflare.com \
--cc=netdev@vger.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