Commit 53792fa4 authored by John Fastabend's avatar John Fastabend Committed by Alexei Starovoitov

bpf, sockmap: Add ingres skb tests that utilize merge skbs

Add a test to check strparser merging skbs is working.
Signed-off-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Acked-by: default avatarMartin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/159312681884.18340.4922800172600252370.stgit@john-XPS-13-9370
parent 8025751d
...@@ -79,7 +79,7 @@ struct { ...@@ -79,7 +79,7 @@ struct {
struct { struct {
__uint(type, BPF_MAP_TYPE_ARRAY); __uint(type, BPF_MAP_TYPE_ARRAY);
__uint(max_entries, 2); __uint(max_entries, 3);
__type(key, int); __type(key, int);
__type(value, int); __type(value, int);
} sock_skb_opts SEC(".maps"); } sock_skb_opts SEC(".maps");
...@@ -94,6 +94,12 @@ struct { ...@@ -94,6 +94,12 @@ struct {
SEC("sk_skb1") SEC("sk_skb1")
int bpf_prog1(struct __sk_buff *skb) int bpf_prog1(struct __sk_buff *skb)
{ {
int *f, two = 2;
f = bpf_map_lookup_elem(&sock_skb_opts, &two);
if (f && *f) {
return *f;
}
return skb->len; return skb->len;
} }
......
...@@ -85,6 +85,7 @@ int txmsg_ktls_skb_drop; ...@@ -85,6 +85,7 @@ int txmsg_ktls_skb_drop;
int txmsg_ktls_skb_redir; int txmsg_ktls_skb_redir;
int ktls; int ktls;
int peek_flag; int peek_flag;
int skb_use_parser;
static const struct option long_options[] = { static const struct option long_options[] = {
{"help", no_argument, NULL, 'h' }, {"help", no_argument, NULL, 'h' },
...@@ -174,6 +175,7 @@ static void test_reset(void) ...@@ -174,6 +175,7 @@ static void test_reset(void)
txmsg_apply = txmsg_cork = 0; txmsg_apply = txmsg_cork = 0;
txmsg_ingress = txmsg_redir_skb = 0; txmsg_ingress = txmsg_redir_skb = 0;
txmsg_ktls_skb = txmsg_ktls_skb_drop = txmsg_ktls_skb_redir = 0; txmsg_ktls_skb = txmsg_ktls_skb_drop = txmsg_ktls_skb_redir = 0;
skb_use_parser = 0;
} }
static int test_start_subtest(const struct _test *t, struct sockmap_options *o) static int test_start_subtest(const struct _test *t, struct sockmap_options *o)
...@@ -1211,6 +1213,11 @@ static int run_options(struct sockmap_options *options, int cg_fd, int test) ...@@ -1211,6 +1213,11 @@ static int run_options(struct sockmap_options *options, int cg_fd, int test)
} }
} }
if (skb_use_parser) {
i = 2;
err = bpf_map_update_elem(map_fd[7], &i, &skb_use_parser, BPF_ANY);
}
if (txmsg_drop) if (txmsg_drop)
options->drop_expected = true; options->drop_expected = true;
...@@ -1650,6 +1657,16 @@ static void test_txmsg_cork(int cgrp, struct sockmap_options *opt) ...@@ -1650,6 +1657,16 @@ static void test_txmsg_cork(int cgrp, struct sockmap_options *opt)
test_send(opt, cgrp); test_send(opt, cgrp);
} }
static void test_txmsg_ingress_parser(int cgrp, struct sockmap_options *opt)
{
txmsg_pass = 1;
skb_use_parser = 512;
opt->iov_length = 256;
opt->iov_count = 1;
opt->rate = 2;
test_exec(cgrp, opt);
}
char *map_names[] = { char *map_names[] = {
"sock_map", "sock_map",
"sock_map_txmsg", "sock_map_txmsg",
...@@ -1748,6 +1765,7 @@ struct _test test[] = { ...@@ -1748,6 +1765,7 @@ struct _test test[] = {
{"txmsg test pull-data", test_txmsg_pull}, {"txmsg test pull-data", test_txmsg_pull},
{"txmsg test pop-data", test_txmsg_pop}, {"txmsg test pop-data", test_txmsg_pop},
{"txmsg test push/pop data", test_txmsg_push_pop}, {"txmsg test push/pop data", test_txmsg_push_pop},
{"txmsg text ingress parser", test_txmsg_ingress_parser},
}; };
static int check_whitelist(struct _test *t, struct sockmap_options *opt) static int check_whitelist(struct _test *t, struct sockmap_options *opt)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment