]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: Fix bpf_get_link_xdp_id flags handling
authorAndrey Ignatov <rdna@fb.com>
Tue, 7 Apr 2020 05:09:45 +0000 (22:09 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 7 Apr 2020 22:57:35 +0000 (00:57 +0200)
commit472167107e4959686b8f3959dd9e4d1c301e790c
treebe1940ed74a8e8b53c45cf3e58168c9e6de2dc5a
parente9fdddf4ec82744728baad20c79333889b6829c6
libbpf: Fix bpf_get_link_xdp_id flags handling

Currently if one of XDP_FLAGS_{DRV,HW,SKB}_MODE flags is passed to
bpf_get_link_xdp_id() and there is a single XDP program attached to
ifindex, that program's id will be returned by bpf_get_link_xdp_id() in
prog_id argument no matter what mode the program is attached in, i.e.
flags argument is not taken into account.

For example, if there is a single program attached with
XDP_FLAGS_SKB_MODE but user calls bpf_get_link_xdp_id() with flags =
XDP_FLAGS_DRV_MODE, that skb program will be returned.

Fix it by returning info->prog_id only if user didn't specify flags. If
flags is specified then return corresponding mode-specific-field from
struct xdp_link_info.

The initial error was introduced in commit 32e779a4a781 ("libbpf: Add a
support for getting xdp prog id on ifindex") and then refactored in
3de67f253960 so 3de67f253960 is used in the Fixes tag.

Fixes: 3de67f253960 ("libbpf: Add bpf_get_link_xdp_info() function to get more XDP information")
Signed-off-by: Andrey Ignatov <rdna@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
Link: https://lore.kernel.org/bpf/0e9e30490b44b447bb2bebc69c7135e7fe7e4e40.1586236080.git.rdna@fb.com
tools/lib/bpf/netlink.c