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

[1.14] Downgrade XDP attachments from Cilium 1.15 #29104

Merged
merged 2 commits into from
Nov 16, 2023

Conversation

ti-mo
Copy link
Contributor

@ti-mo ti-mo commented Nov 10, 2023

Cilium 1.15 will attach XDP programs using bpf_link on supported kernels by default. This patch ensures these attachments can be undone during downgrades so programs can be attached using netlink again.

Also fixes a bug in removing XDP attachments from unused devices.

Support downgrade path for XDP attachments from Cilium 1.15

@ti-mo ti-mo added sig/loader Impacts the loading of BPF programs into the kernel. release-note/bug This PR fixes an issue in a previous release of Cilium. backport/1.14 This PR represents a backport for Cilium 1.14.x of a PR that was merged to main. labels Nov 10, 2023
@ti-mo ti-mo requested a review from a team as a code owner November 10, 2023 13:35
@maintainer-s-little-helper maintainer-s-little-helper bot added the kind/backports This PR provides functionality previously merged into master. label Nov 10, 2023
@ti-mo
Copy link
Contributor Author

ti-mo commented Nov 10, 2023

/test-backport-1.14

rgo3 and others added 2 commits November 10, 2023 14:52
[ upstream commit 0b488fb ]

[ backporter's notes: had to pull in mustXDPProgram() from another commit ]

This commit fixes a bug where Cilium expected the XDP mode flag to be carried
in the netlink.LinkXdp.Flags field, while in reality the XDP mode is actually
contained in the LinkXdp.AttachMode field. Also added a regression test.

Signed-off-by: Robin Gögge <r.goegge@isovalent.com>
[ upstream commit 7a8e3c8 ]

A follow-up commit will introduce attaching XDP programs using bpf_link. Those
attachments cannot be overridden using netlink. If an older version of Cilium
wants to replace an XDP program on a managed interface, it'll need to remove
the bpf_link first.

This commit teaches the agent to remove the (currently) only XDP entrypoint,
cil_xdp_entry, before reattaching it using netlink. Note that this transition
is never seamless, since some time passes between deleting the link and
attaching the new program.

Also note that this downgrade path should seldom be used. If Cilium is upgraded
from a version with only netlink support, the new Cilium version will continue
to use netlink. Only if a fresh node is deployed with a new Cilium version
supporting bpf_link, then downgraded to one supporting only netlink, will the
bpf_link need to be removed.

For adding XDP bpf_link support, a per-device bpffs directory will be created
to pin the device's links, maps, etc. Follow-up commits will put XDP bpf_links
here. Subdirectories will be created for each device, for example:

/sys/fs/bpf/cilium/devices/enp5s0/

Then, following the convention we're already using for cgroup links, another
subdirectory will be created for links, followed by the entrypoint name:

/sys/fs/bpf/cilium/devices/enp5s0/links/cil_xdp_entry

Signed-off-by: Robin Gögge <r.goegge@isovalent.com>
Co-authored-by: Timo Beckers <timo@isovalent.com>
@ti-mo
Copy link
Contributor Author

ti-mo commented Nov 10, 2023

/test-backport-1.14

@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Nov 16, 2023
@julianwiedmann julianwiedmann merged commit 7241195 into cilium:v1.14 Nov 16, 2023
58 checks passed
@ti-mo ti-mo deleted the tb/xdp-bpf-link-1.14 branch December 13, 2023 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/1.14 This PR represents a backport for Cilium 1.14.x of a PR that was merged to main. kind/backports This PR provides functionality previously merged into master. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/bug This PR fixes an issue in a previous release of Cilium. sig/loader Impacts the loading of BPF programs into the kernel.
Projects
No open projects
Status: Released
Development

Successfully merging this pull request may close these issues.

None yet

3 participants