Skip to contentSkip to conversation

libbpf: Only check mode flags in get_xdp_id

PATCH Applied David Ahern 3 participants 3 messages Apr 20, 2020 – Apr 23, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libbpf: Only check mode flags in get_xdp_id

From: David Ahern <[email protected]>

The commit in the Fixes tag changed get_xdp_id to only return prog_id if flags is 0, but there are other XDP flags than the modes - e.g., XDP_FLAGS_UPDATE_IF_NOEXIST. Since the intention was only to look at MODE flags, clear other ones before checking if flags is 0.

Fixes f07cbad29741 ("libbpf: Fix bpf_get_link_xdp_id flags handling")
Cc Andrey Ignatov <[email protected]>
---
 tools/lib/bpf/netlink.c | 2 ++
 1 file changed, 2 insertions(+)
tools/lib/bpf/netlink.c +2 -0
index 342acacf7cda..692749d87348 100644
@@ -352,6 +352,8 @@ int bpf_get_link_xdp_egress_info(int ifindex, struct xdp_link_info *info,
 
 static __u32 get_xdp_id(struct xdp_link_info *info, __u32 flags)
 {
+	flags &= XDP_FLAGS_MODES;
+
 	if (info->attach_mode != XDP_ATTACHED_MULTI && !flags)
 		return info->prog_id;
 	if (flags & XDP_FLAGS_DRV_MODE)
Signature · 1 line
2.20.1
Acked-by on v1 1/1
#1 lore raw

David Ahern <[email protected]> [Mon, 2020-04-20 09:18 -0700]:

Quoted 10 lines

From: David Ahern <[email protected]>

The commit in the Fixes tag changed get_xdp_id to only return prog_id if flags is 0, but there are other XDP flags than the modes - e.g., XDP_FLAGS_UPDATE_IF_NOEXIST. Since the intention was only to look at MODE flags, clear other ones before checking if flags is 0.

Fixes f07cbad29741 ("libbpf: Fix bpf_get_link_xdp_id flags handling")
Cc Andrey Ignatov <[email protected]>

Makes sense. Thanks.

Quoted 20 lines
---
 tools/lib/bpf/netlink.c | 2 ++
 1 file changed, 2 insertions(+)
tools/lib/bpf/netlink.c +2 -0
index 342acacf7cda..692749d87348 100644
@@ -352,6 +352,8 @@ int bpf_get_link_xdp_egress_info(int ifindex, struct xdp_link_info *info,
 
 static __u32 get_xdp_id(struct xdp_link_info *info, __u32 flags)
 {
+	flags &= XDP_FLAGS_MODES;
+
 	if (info->attach_mode != XDP_ATTACHED_MULTI && !flags)
 		return info->prog_id;
 	if (flags & XDP_FLAGS_DRV_MODE)
Signature · 1 line
2.20.1
Signature · 1 line
Andrey Ignatov
#2 lore raw
Quoted 9 lines · Andrey Ignatov

David Ahern <[email protected]> [Mon, 2020-04-20 09:18 -0700]:

Quoted 7 lines

From: David Ahern <[email protected]>

The commit in the Fixes tag changed get_xdp_id to only return prog_id if flags is 0, but there are other XDP flags than the modes - e.g., XDP_FLAGS_UPDATE_IF_NOEXIST. Since the intention was only to look at MODE flags, clear other ones before checking if flags is 0.

Quoted 7 lines
Quoted 3 lines
Fixes f07cbad29741 ("libbpf: Fix bpf_get_link_xdp_id flags handling")
Cc Andrey Ignatov <[email protected]>

Makes sense. Thanks.

Applied. Thanks