diff options
author | John Fastabend <john.fastabend@gmail.com> | 2017-08-28 07:12:41 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-08-28 11:13:22 -0700 |
commit | 3f0d6a16989da252d4014c3fb7334369c891f91e (patch) | |
tree | ac84f615484f1685127b0b717187e222f31d076e /tools/testing | |
parent | 08848246639218ae58acdf3321bc7b693062f31c (diff) | |
download | linux-3f0d6a16989da252d4014c3fb7334369c891f91e.tar.bz2 |
bpf: test_maps add sockmap stress test
Sockmap is a bit different than normal stress tests that can run
in parallel as is. We need to reuse the same socket pool and map
pool to get good stress test cases.
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/testing')
-rw-r--r-- | tools/testing/selftests/bpf/test_maps.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/tools/testing/selftests/bpf/test_maps.c b/tools/testing/selftests/bpf/test_maps.c index 0c4b56d1b822..7059bb315a10 100644 --- a/tools/testing/selftests/bpf/test_maps.c +++ b/tools/testing/selftests/bpf/test_maps.c @@ -461,7 +461,7 @@ static void test_devmap(int task, void *data) #include <linux/err.h> #define SOCKMAP_PARSE_PROG "./sockmap_parse_prog.o" #define SOCKMAP_VERDICT_PROG "./sockmap_verdict_prog.o" -static void test_sockmap(int task, void *data) +static void test_sockmap(int tasks, void *data) { int one = 1, map_fd_rx, map_fd_tx, map_fd_break, s, sc, rc; struct bpf_map *bpf_map_rx, *bpf_map_tx, *bpf_map_break; @@ -473,6 +473,7 @@ static void test_sockmap(int task, void *data) struct bpf_object *obj; struct timeval to; __u32 key, value; + pid_t pid[tasks]; fd_set w; /* Create some sockets to use with sockmap */ @@ -782,6 +783,32 @@ static void test_sockmap(int task, void *data) } } + /* Test tasks number of forked operations */ + for (i = 0; i < tasks; i++) { + pid[i] = fork(); + if (pid[i] == 0) { + for (i = 0; i < 6; i++) { + bpf_map_delete_elem(map_fd_tx, &i); + bpf_map_delete_elem(map_fd_rx, &i); + bpf_map_update_elem(map_fd_tx, &i, + &sfd[i], BPF_ANY); + bpf_map_update_elem(map_fd_rx, &i, + &sfd[i], BPF_ANY); + } + exit(0); + } else if (pid[i] == -1) { + printf("Couldn't spawn #%d process!\n", i); + exit(1); + } + } + + for (i = 0; i < tasks; i++) { + int status; + + assert(waitpid(pid[i], &status, 0) == pid[i]); + assert(status == 0); + } + /* Test map close sockets */ for (i = 0; i < 6; i++) close(sfd[i]); |