Skip to content

Conversation

@asbjornst
Copy link

In netdev.h, NETDEV_XDP_ACT_MASK is declared as private, so it should only be used inside the kernel, and according to Jakub Kicinski then "user space should not care about it"[1].

linux$ git grep -B1 NETDEV_XDP_ACT_MASK include/
include/uapi/linux/netdev.h-    /* private: */
include/uapi/linux/netdev.h:    NETDEV_XDP_ACT_MASK = 127,

In this specific case, then this code is buggy. If a new feature flag is added to the uapi header, and hence included in NETDEV_XDP_ACT_MASK, and xdp-tools is not updated, or an older version is re-build in a distro, with newer linux headers, then NETDEV_XDP_ACT_MASK can contain a new feature flag, and if the new flag is observed, then it will neither be checked nor trigger the unknown feature printing.

This patch replaces the use of NETDEV_XDP_ACT_MASK, with a local mask consisting only of the tested flags.

[1] https://lore.kernel.org/netdev/[email protected]/

Copy link
Member

@tohojo tohojo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the patch! It makes sense to stop using the mask, but see below...

In netdev.h, NETDEV_XDP_ACT_MASK is declared as private, so it should
only be used inside the kernel, and according to Jakub Kicinski then
"user space should not care about it"[1].

  linux$ git grep -B1 NETDEV_XDP_ACT_MASK include/
  include/uapi/linux/netdev.h-    /* private: */
  include/uapi/linux/netdev.h:    NETDEV_XDP_ACT_MASK = 127,

In this specific case, then this code is buggy. If a new feature flag
is added to the uapi header, and hence included in NETDEV_XDP_ACT_MASK,
and xdp-tools is not updated, or an older version is re-build in a
distro, with newer linux headers, then NETDEV_XDP_ACT_MASK can contain
a new feature flag, and if the new flag is observed, then it will neither
be checked nor trigger the unknown feature printing.

This patch moves the flags into a constant array, and while looping over
them in iface_print_xdp_features(), it builds a local mask consisting only
of the tested flags. The local mask is used to replace NETDEV_XDP_ACT_MASK.

[1] https://lore.kernel.org/netdev/[email protected]/

Signed-off-by: Asbjørn Sloth Tønnesen <[email protected]>
@asbjornst asbjornst force-pushed the fix-features-printing branch from 5718274 to ebe9169 Compare October 9, 2025 11:12
@asbjornst asbjornst requested a review from tohojo October 9, 2025 13:23
Copy link
Member

@tohojo tohojo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, much better - thanks! :)

@tohojo tohojo merged commit 2074703 into xdp-project:main Oct 10, 2025
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants