Skip to content
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

elf_reader: Add support for XDP frags #1037

Merged
merged 1 commit into from
May 17, 2023
Merged

Conversation

ptzianos
Copy link
Contributor

implements #1036

Since v5.18 of the Linux kernel, it is possible for an XDP program to process packets larger than the physical page of the system. This feature is called XDP frags.

In order for an XDP program to signal that it can process packets with large MTUs, it needs to have the "xdp.frags" annotation instead of "xdp". This new annotation causes the BPF_F_XDP_HAS_FRAGS to be added to the annotated program section of the ELF. This flag in turn causes the verifier to apply extra checks to the code. The commit along with some documentation about the feature can be seen here:
torvalds/linux@c2f2cdb

This commit allows the code to parse the "xdp.frags" annotation and adds the appropriate flag to the program section, along with unit tests for this behaviour. It replicated the functionality of this code: https://elixir.bootlin.com/linux/v6.0/source/tools/lib/bpf/libbpf.c#L6626

@@ -35,6 +35,7 @@ const (
BPF_F_RDONLY_PROG = linux.BPF_F_RDONLY_PROG
BPF_F_WRONLY_PROG = linux.BPF_F_WRONLY_PROG
BPF_F_SLEEPABLE = linux.BPF_F_SLEEPABLE
BPF_F_XDP_HAS_FRAGS = linux.BPF_F_XDP_HAS_FRAGS
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add a dummy entry to types_other.go please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry about that, forgot to commit the change. fixed now

Since v5.18 of the Linux kernel, it is possible for an XDP program to
process packets larger than the physical page of the system. This
feature is called XDP frags.

In order for an XDP program to signal that it can process packets with
large MTUs, it needs to have the "xdp.frags" annotation instead of
"xdp". This new annotation causes the BPF_F_XDP_HAS_FRAGS to be added to
the annotated program section of the ELF. This flag in turn causes the
verifier to apply extra checks to the code. The commit along with some
documentation about the feature can be seen here:
torvalds/linux@c2f2cdb

This commit allows the code to parse the "xdp.frags" annotation and adds
the appropriate flag to the program section, along with unit tests for
this behaviour. It follows the functionality of this code:
https://elixir.bootlin.com/linux/v6.0/source/tools/lib/bpf/libbpf.c#L6626

Signed-off-by: Pavlos Tzianos <pavlos@cloudflare.com>
Copy link
Collaborator

@lmb lmb left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for your contribution :)

@lmb lmb merged commit 5c58a6a into cilium:master May 17, 2023
2 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.

None yet

2 participants