From: John Fastabend <john.fastabend@gmail.com>
To: bpf@vger.kernel.org, vincent.whitchurch@datadoghq.com
Cc: daniel@iogearbox.net, john.fastabend@gmail.com
Subject: [PATCH bpf 2/2] bpf: sockmap, add test for ingress through strparser
Date: Tue, 25 Jun 2024 13:16:32 -0700 [thread overview]
Message-ID: <20240625201632.49024-3-john.fastabend@gmail.com> (raw)
In-Reply-To: <20240625201632.49024-1-john.fastabend@gmail.com>
Add an option to always return SK_PASS in the verdict callback
instead of redirecting the skb. This allows testing cases
which are not covered by the test program as of now.
Signed-off-by: Vincent Whitchurch <vincent.whitchurch@datadoghq.com>
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
---
tools/testing/selftests/bpf/test_sockmap.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c
index 9cba4ec844a5..cc3e4d96c8ac 100644
--- a/tools/testing/selftests/bpf/test_sockmap.c
+++ b/tools/testing/selftests/bpf/test_sockmap.c
@@ -78,6 +78,7 @@ int txmsg_end_push;
int txmsg_start_pop;
int txmsg_pop;
int txmsg_ingress;
+int txmsg_pass_skb;
int txmsg_redir_skb;
int txmsg_ktls_skb;
int txmsg_ktls_skb_drop;
@@ -108,6 +109,7 @@ static const struct option long_options[] = {
{"txmsg_start_pop", required_argument, NULL, 'w'},
{"txmsg_pop", required_argument, NULL, 'x'},
{"txmsg_ingress", no_argument, &txmsg_ingress, 1 },
+ {"txmsg_pass_skb", no_argument, &txmsg_pass_skb, 1 },
{"txmsg_redir_skb", no_argument, &txmsg_redir_skb, 1 },
{"ktls", no_argument, &ktls, 1 },
{"peek", no_argument, &peek_flag, 1 },
@@ -177,6 +179,7 @@ static void test_reset(void)
txmsg_pass = txmsg_drop = txmsg_redir = 0;
txmsg_apply = txmsg_cork = 0;
txmsg_ingress = txmsg_redir_skb = 0;
+ txmsg_pass_skb = 0;
txmsg_ktls_skb = txmsg_ktls_skb_drop = txmsg_ktls_skb_redir = 0;
txmsg_omit_skb_parser = 0;
skb_use_parser = 0;
@@ -956,6 +959,7 @@ static int run_options(struct sockmap_options *options, int cg_fd, int test)
{
int i, key, next_key, err, zero = 0;
struct bpf_program *tx_prog;
+ struct bpf_program *skb_verdict_prog;
/* If base test skip BPF setup */
if (test == BASE || test == BASE_SENDPAGE)
@@ -972,7 +976,12 @@ static int run_options(struct sockmap_options *options, int cg_fd, int test)
}
}
- links[1] = bpf_program__attach_sockmap(progs[1], map_fd[0]);
+ if (txmsg_pass_skb)
+ skb_verdict_prog = progs[2];
+ else
+ skb_verdict_prog = progs[1];
+
+ links[1] = bpf_program__attach_sockmap(skb_verdict_prog, map_fd[0]);
if (!links[1]) {
fprintf(stderr, "ERROR: bpf_program__attach_sockmap (sockmap): (%s)\n",
strerror(errno));
@@ -1361,6 +1370,8 @@ static void test_options(char *options)
}
if (txmsg_ingress)
append_str(options, "ingress,", OPTSTRING);
+ if (txmsg_pass_skb)
+ append_str(options, "pass_skb,", OPTSTRING);
if (txmsg_redir_skb)
append_str(options, "redir_skb,", OPTSTRING);
if (txmsg_ktls_skb)
--
2.33.0
prev parent reply other threads:[~2024-06-25 20:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-25 20:16 [PATCH bpf 0/2] Fix reported sockmap splat John Fastabend
2024-06-25 20:16 ` [PATCH bpf 1/2] bpf: sockmap, fix introduced strparser recursive lock John Fastabend
2024-06-29 15:34 ` Jakub Sitnicki
2024-07-03 1:12 ` John Fastabend
2024-06-25 20:16 ` John Fastabend [this message]
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=20240625201632.49024-3-john.fastabend@gmail.com \
--to=john.fastabend@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=vincent.whitchurch@datadoghq.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.