bpf_tc_hook_destroy() deletes qdisc only if hook.attach_point is set to BPF_TC_INGRESS | BPF_TC_EGRESS, but it is impossible to do from C++ code because hook.attach_point is enum, but it is prohibited to set struct enum member to non-enum value in C++. This patch introduces new enum value BPF_TC_BOTH = BPF_TC_INGRESS | BPF_TC_EGRESS This value allows to delete qdisc from C++ code. An example of program compatible with C but incompatible with C++: \#include <bpf/libbpf.h> int main() { struct bpf_tc_hook hook; hook.attach_point = BPF_TC_INGRESS | BPF_TC_EGRESS; } 'clang program.c' is OK, but 'clang++ program.cpp' fails: program.cpp:4:40: error: assigning to 'enum bpf_tc_attach_point' from incompatible type 'int' 4 | hook.attach_point = BPF_TC_INGRESS | BPF_TC_EGRESS; | ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~ 1 error generated. The same issue with g++. Signed-off-by: Sergey V. Lobanov <sergey@xxxxxxxxxx> --- tools/lib/bpf/libbpf.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h index 64a6a3d32..494f99152 100644 --- a/tools/lib/bpf/libbpf.h +++ b/tools/lib/bpf/libbpf.h @@ -1257,6 +1257,7 @@ LIBBPF_API int bpf_xdp_query_id(int ifindex, int flags, __u32 *prog_id); enum bpf_tc_attach_point { BPF_TC_INGRESS = 1 << 0, BPF_TC_EGRESS = 1 << 1, + BPF_TC_BOTH = BPF_TC_INGRESS | BPF_TC_EGRESS, BPF_TC_CUSTOM = 1 << 2, }; -- 2.34.1