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

init.sh: move socket-lb creation to Go package #20739

Closed
ti-mo opened this issue Aug 2, 2022 · 2 comments · Fixed by #23557
Closed

init.sh: move socket-lb creation to Go package #20739

ti-mo opened this issue Aug 2, 2022 · 2 comments · Fixed by #23557
Assignees
Labels
sig/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages. sig/loader Impacts the loading of BPF programs into the kernel.

Comments

@ti-mo
Copy link
Contributor

ti-mo commented Aug 2, 2022

This is a standalone feature that can be moved out of init.sh.

We could potentially create a datapath subpackage for this functionality so it can have a standalone test suite.

@brb Do you have any input on how to design/structure this?

@ti-mo ti-mo added this to the Deprecate init.sh milestone Aug 2, 2022
@ti-mo ti-mo added sig/loader Impacts the loading of BPF programs into the kernel. sig/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages. labels Aug 2, 2022
@ti-mo ti-mo changed the title init.sh: move hostlb creation to Go package init.sh: move host-lb (socket-lb?) creation to Go package Aug 2, 2022
@ti-mo ti-mo assigned rgo3 and unassigned markpash Oct 27, 2022
@ti-mo
Copy link
Contributor Author

ti-mo commented Nov 22, 2022

Something discovered while @rgo3 was doing the initial implementation: link.AttachCgroup() opportunistically uses bpf_link for attaching to cgroups on kernels that support it, which means we need to create a dir layout in /sys/fs/bpf, ideally outside of /sys/fs/bpf/tc/globals. The new socket-lb loader code needs to attempt to pin cgroup links, to open them and manage their lifecycle when there are existing pins when the agent starts up.

Also, the preceding release(s) will need compatibility code in init.sh to handle pinned cgroup links on downgrade.

@borkmann suggested mounting a bpffs just for Cilium, but we'd need to get the host to mount it so it's not bound to the lifecycle of the agent pod.

I'd suggest something like /sys/fs/bpf/cilium/links/cgroup/*.

@ti-mo
Copy link
Contributor Author

ti-mo commented Nov 30, 2022

I looked into removing TestDummyProg(). It seems like it's mostly called from probeKubeProxyReplacementOptions() to detect if certain prog/attachtype combos are supported, as well as calling BPF_PROG_ATTACH as an oracle for CONFIG_CGROUP_BPF. (see abf5366)

Since ebpf-go only falls back to PROG_ATTACH when bpf_link is not available, only probing PROG_ATTACH loses a bit of its value. By moving the socket-lb logic out of init.sh, we can simply try to set up parts of the socklb and bail out when parts of them fail to attach, flipping flags in option.Config on the way out, as is currently done in probeKubeProxyReplacementOptions().

@ti-mo ti-mo changed the title init.sh: move host-lb (socket-lb?) creation to Go package init.sh: move socket-lb creation to Go package Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages. sig/loader Impacts the loading of BPF programs into the kernel.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants