Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bpftool: Refactor xdp attach/detach type judgment

This commit no logical changed, just increases code readability and
facilitates TCX prog expansion, which will be implemented in the next
patch.

Signed-off-by: Tao Chen <chen.dylane@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Quentin Monnet <qmo@kernel.org>
Link: https://lore.kernel.org/bpf/20240721143353.95980-2-chen.dylane@gmail.com
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>

authored by

Tao Chen and committed by
Andrii Nakryiko
b7264f87 81a0b954

+21 -5
+21 -5
tools/bpf/bpftool/net.c
··· 684 684 } 685 685 } 686 686 687 + switch (attach_type) { 687 688 /* attach xdp prog */ 688 - if (is_prefix("xdp", attach_type_strings[attach_type])) 689 - err = do_attach_detach_xdp(progfd, attach_type, ifindex, 690 - overwrite); 689 + case NET_ATTACH_TYPE_XDP: 690 + case NET_ATTACH_TYPE_XDP_GENERIC: 691 + case NET_ATTACH_TYPE_XDP_DRIVER: 692 + case NET_ATTACH_TYPE_XDP_OFFLOAD: 693 + err = do_attach_detach_xdp(progfd, attach_type, ifindex, overwrite); 694 + break; 695 + default: 696 + break; 697 + } 698 + 691 699 if (err) { 692 700 p_err("interface %s attach failed: %s", 693 701 attach_type_strings[attach_type], strerror(-err)); ··· 729 721 if (ifindex < 1) 730 722 return -EINVAL; 731 723 724 + switch (attach_type) { 732 725 /* detach xdp prog */ 733 - progfd = -1; 734 - if (is_prefix("xdp", attach_type_strings[attach_type])) 726 + case NET_ATTACH_TYPE_XDP: 727 + case NET_ATTACH_TYPE_XDP_GENERIC: 728 + case NET_ATTACH_TYPE_XDP_DRIVER: 729 + case NET_ATTACH_TYPE_XDP_OFFLOAD: 730 + progfd = -1; 735 731 err = do_attach_detach_xdp(progfd, attach_type, ifindex, NULL); 732 + break; 733 + default: 734 + break; 735 + } 736 736 737 737 if (err < 0) { 738 738 p_err("interface %s detach failed: %s",