-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: Support libbpf v1 compliant section names #228
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,15 @@ | |
|
||
#include <linux/types.h> | ||
|
||
#define XDP_METADATA_SECTION "xdp_metadata" | ||
#define XDP_METADATA_SECTION_ORIG "xdp_metadata" | ||
#define XDP_METADATA_SECTION_NEW ".data.xdp_metadata" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Surely this doesn't need to be renamed since this is not a program section name - therefore libbpf should ignore it. |
||
|
||
#if defined(USE_LIBBPF_V1_SECTION_NAMES) | ||
#define XDP_METADATA_SECTION XDP_METADATA_SECTION_NEW | ||
#else | ||
#define XDP_METADATA_SECTION XDP_METADATA_SECTION_ORIG | ||
#endif | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the dispatcher we should really just define both sections until we can retire the old one; so no need for this ifdef, just define both and duplicate the line adding dispatcher_version in the dispatcher code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicating the dispatcher_version line results in:
So it would also require a different variable name to avoid the collision. That's another protocol change that I guess libxdp can handle, but has consequences for other implementations as well. But I was thinking that the libxdp and dispatcher version on a system would match and would either be old or new, so only need the dispatcher_version declared in 1 section. It's legacy and new programs that we'd need to be able to read old or new metadata from. Or am I missing something? |
||
#define XDP_DISPATCHER_VERSION 1 | ||
/* default retval for dispatcher corresponds to the highest bit in the | ||
* chain_call_actions bitmap; we use this to make sure the dispatcher always | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,17 @@ | |
#ifndef __XDP_HELPERS_H | ||
#define __XDP_HELPERS_H | ||
|
||
#define XDP_RUN_CONFIG_SECTION_ORIG "xdp_run_config" | ||
#define XDP_RUN_CONFIG_SECTION_NEW ".data.xdp_run_config" | ||
|
||
#if defined(USE_LIBBPF_V1_SECTION_NAMES) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This define will be a user-facing API (as this header is meant to be included by user programs), so I guess we should document it somewhere. I'm not too fond of the name, but I can't think of anything better off the top of my head... |
||
#define XDP_RUN_CONFIG_SECTION XDP_RUN_CONFIG_SECTION_NEW | ||
#else | ||
#define XDP_RUN_CONFIG_SECTION XDP_RUN_CONFIG_SECTION_ORIG | ||
#endif | ||
|
||
#define _CONCAT(x,y) x ## y | ||
#define XDP_RUN_CONFIG(f) _CONCAT(_,f) SEC(".xdp_run_config") | ||
#define XDP_RUN_CONFIG(f) _CONCAT(_,f) SEC(XDP_RUN_CONFIG_SECTION) | ||
|
||
#define XDP_DEFAULT_RUN_PRIO 50 | ||
#define XDP_DEFAULT_CHAIN_CALL_ACTIONS (1<<XDP_PASS) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,10 @@ ifeq ($(SYSTEM_LIBBPF),y) | |
DEFINES += -DLIBBPF_DYNAMIC | ||
endif | ||
|
||
ifeq ($(LIBBPF_V1_COMPLIANT),y) | ||
DEFINES += -DUSE_LIBBPF_V1_SECTION_NAMES | ||
endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can just set this unconditionally; this will only affect the BPF programs built as part of xdp-tools, and the assumption here is that those will only be used with the same version of the library (which will then understand the new section names straight away)... |
||
|
||
DEFINES += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 | ||
|
||
CFLAGS += -std=gnu11 -Wextra -Werror $(DEFINES) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure it makes sense to have a configure knob for this? See below, we can just set the define unconditionally...