diff options
author | Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp> | 2018-01-22 23:30:44 -0500 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2018-01-23 13:10:09 -0500 |
commit | 783687810e986a15ffbf86c516a1a48ff37f38f7 (patch) | |
tree | 5ab3f5b8418fe372a8cf6e5dfe7ef84ff0627fc7 | |
parent | 8e6875250a1189e0d8db8b05e18abe63c2744521 (diff) |
bpf: test_maps: cleanup sockmaps when test ends
Bug: BPF programs and maps related to sockmaps test exist
in memory even after test_maps ends.
This patch fixes it as a short term workaround (sockmap
kernel side needs real fixing) by empyting sockmaps when
test ends.
Fixes: 6f6d33f3b3d0f ("bpf: selftests add sockmap tests")
Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
[ daniel: Note on workaround. ]
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
-rw-r--r-- | tools/testing/selftests/bpf/test_maps.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/tools/testing/selftests/bpf/test_maps.c b/tools/testing/selftests/bpf/test_maps.c index f0d2f09898a3..436c4c72414f 100644 --- a/tools/testing/selftests/bpf/test_maps.c +++ b/tools/testing/selftests/bpf/test_maps.c | |||
@@ -463,7 +463,7 @@ static void test_devmap(int task, void *data) | |||
463 | #define SOCKMAP_VERDICT_PROG "./sockmap_verdict_prog.o" | 463 | #define SOCKMAP_VERDICT_PROG "./sockmap_verdict_prog.o" |
464 | static void test_sockmap(int tasks, void *data) | 464 | static void test_sockmap(int tasks, void *data) |
465 | { | 465 | { |
466 | int one = 1, map_fd_rx, map_fd_tx, map_fd_break, s, sc, rc; | 466 | int one = 1, map_fd_rx = 0, map_fd_tx = 0, map_fd_break, s, sc, rc; |
467 | struct bpf_map *bpf_map_rx, *bpf_map_tx, *bpf_map_break; | 467 | struct bpf_map *bpf_map_rx, *bpf_map_tx, *bpf_map_break; |
468 | int ports[] = {50200, 50201, 50202, 50204}; | 468 | int ports[] = {50200, 50201, 50202, 50204}; |
469 | int err, i, fd, udp, sfd[6] = {0xdeadbeef}; | 469 | int err, i, fd, udp, sfd[6] = {0xdeadbeef}; |
@@ -868,9 +868,12 @@ static void test_sockmap(int tasks, void *data) | |||
868 | goto out_sockmap; | 868 | goto out_sockmap; |
869 | } | 869 | } |
870 | 870 | ||
871 | /* Test map close sockets */ | 871 | /* Test map close sockets and empty maps */ |
872 | for (i = 0; i < 6; i++) | 872 | for (i = 0; i < 6; i++) { |
873 | bpf_map_delete_elem(map_fd_tx, &i); | ||
874 | bpf_map_delete_elem(map_fd_rx, &i); | ||
873 | close(sfd[i]); | 875 | close(sfd[i]); |
876 | } | ||
874 | close(fd); | 877 | close(fd); |
875 | close(map_fd_rx); | 878 | close(map_fd_rx); |
876 | bpf_object__close(obj); | 879 | bpf_object__close(obj); |
@@ -881,8 +884,13 @@ out: | |||
881 | printf("Failed to create sockmap '%i:%s'!\n", i, strerror(errno)); | 884 | printf("Failed to create sockmap '%i:%s'!\n", i, strerror(errno)); |
882 | exit(1); | 885 | exit(1); |
883 | out_sockmap: | 886 | out_sockmap: |
884 | for (i = 0; i < 6; i++) | 887 | for (i = 0; i < 6; i++) { |
888 | if (map_fd_tx) | ||
889 | bpf_map_delete_elem(map_fd_tx, &i); | ||
890 | if (map_fd_rx) | ||
891 | bpf_map_delete_elem(map_fd_rx, &i); | ||
885 | close(sfd[i]); | 892 | close(sfd[i]); |
893 | } | ||
886 | close(fd); | 894 | close(fd); |
887 | exit(1); | 895 | exit(1); |
888 | } | 896 | } |