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.
Unified · Split
| @@ -789,19 +789,19 @@ static void test_sockmap(unsigned int tasks, void *data) · 788 unmodified lines | |||
| 789 | } | 789 | } |
| 790 | 790 | ||
| 791 | err = bpf_prog_detach(fd, BPF_SK_SKB_STREAM_PARSER); | 791 | err = bpf_prog_detach(fd, BPF_SK_SKB_STREAM_PARSER); |
| 792 | if (err) { | 792 | if (!err) { |
| 793 | printf("Failed empty parser prog detach\n"); | 793 | printf("Failed empty parser prog detach\n"); |
| 794 | goto out_sockmap; | 794 | goto out_sockmap; |
| 795 | } | 795 | } |
| 796 | 796 | ||
| 797 | err = bpf_prog_detach(fd, BPF_SK_SKB_STREAM_VERDICT); | 797 | err = bpf_prog_detach(fd, BPF_SK_SKB_STREAM_VERDICT); |
| 798 | if (err) { | 798 | if (!err) { |
| 799 | printf("Failed empty verdict prog detach\n"); | 799 | printf("Failed empty verdict prog detach\n"); |
| 800 | goto out_sockmap; | 800 | goto out_sockmap; |
| 801 | } | 801 | } |
| 802 | 802 | ||
| 803 | err = bpf_prog_detach(fd, BPF_SK_MSG_VERDICT); | 803 | err = bpf_prog_detach(fd, BPF_SK_MSG_VERDICT); |
| 804 | if (err) { | 804 | if (!err) { |
| 805 | printf("Failed empty msg verdict prog detach\n"); | 805 | printf("Failed empty msg verdict prog detach\n"); |
| 806 | goto out_sockmap; | 806 | goto out_sockmap; |
| 807 | } | 807 | } |
| @@ -1090,19 +1090,19 @@ static void test_sockmap(unsigned int tasks, void *data) · 282 unmodified lines | |||
| 1090 | assert(status == 0); | 1090 | assert(status == 0); |
| 1091 | } | 1091 | } |
| 1092 | 1092 | ||
| 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); |
| 1094 | if (!err) { | 1094 | if (!err) { |
| 1095 | printf("Detached an invalid prog type.\n"); | 1095 | printf("Detached an invalid prog type.\n"); |
| 1096 | goto out_sockmap; | 1096 | goto out_sockmap; |
| 1097 | } | 1097 | } |
| 1098 | 1098 | ||
| 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); |
| 1100 | if (err) { | 1100 | if (err) { |
| 1101 | printf("Failed parser prog detach\n"); | 1101 | printf("Failed parser prog detach\n"); |
| 1102 | goto out_sockmap; | 1102 | goto out_sockmap; |
| 1103 | } | 1103 | } |
| 1104 | 1104 | ||
| 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); |
| 1106 | if (err) { | 1106 | if (err) { |
| 1107 | printf("Failed parser prog detach\n"); | 1107 | printf("Failed parser prog detach\n"); |
| 1108 | goto out_sockmap; | 1108 | goto out_sockmap; |