History

selftests: bpf: Fix detach from sockmap tests

Fix sockmap tests which rely on old bpf_prog_dispatch behaviour. In the first case, the tests check that detaching without giving a program succeeds. Since these are not the desired semantics, invert the condition. In the second case, the clean up code doesn't supply the necessary program fds.

Lorenz Bauer committed 6 years ago

Commit f43cb0d1 parent c9a368f1 file · +6 −6Browse files

Unified · Split

tools/testing/selftests/bpf/test_maps.c+6−6
@@ -789,19 +789,19 @@ static void test_sockmap(unsigned int tasks, void *data) · 788 unmodified lines
789789 }
790790
791791 err = bpf_prog_detach(fd, BPF_SK_SKB_STREAM_PARSER);
792− if (err) {
792+ if (!err) {
793793 printf("Failed empty parser prog detach\n");
794794 goto out_sockmap;
795795 }
796796
797797 err = bpf_prog_detach(fd, BPF_SK_SKB_STREAM_VERDICT);
798− if (err) {
798+ if (!err) {
799799 printf("Failed empty verdict prog detach\n");
800800 goto out_sockmap;
801801 }
802802
803803 err = bpf_prog_detach(fd, BPF_SK_MSG_VERDICT);
804− if (err) {
804+ if (!err) {
805805 printf("Failed empty msg verdict prog detach\n");
806806 goto out_sockmap;
807807 }
@@ -1090,19 +1090,19 @@ static void test_sockmap(unsigned int tasks, void *data) · 282 unmodified lines
10901090 assert(status == 0);
10911091 }
10921092
1093− err = bpf_prog_detach(map_fd_rx, __MAX_BPF_ATTACH_TYPE);
1093+ err = bpf_prog_detach2(parse_prog, map_fd_rx, __MAX_BPF_ATTACH_TYPE);
10941094 if (!err) {
10951095 printf("Detached an invalid prog type.\n");
10961096 goto out_sockmap;
10971097 }
10981098
1099− err = bpf_prog_detach(map_fd_rx, BPF_SK_SKB_STREAM_PARSER);
1099+ err = bpf_prog_detach2(parse_prog, map_fd_rx, BPF_SK_SKB_STREAM_PARSER);
11001100 if (err) {
11011101 printf("Failed parser prog detach\n");
11021102 goto out_sockmap;
11031103 }
11041104
1105− err = bpf_prog_detach(map_fd_rx, BPF_SK_SKB_STREAM_VERDICT);
1105+ err = bpf_prog_detach2(verdict_prog, map_fd_rx, BPF_SK_SKB_STREAM_VERDICT);
11061106 if (err) {
11071107 printf("Failed parser prog detach\n");
11081108 goto out_sockmap;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t