summaryrefslogtreecommitdiffstats
path: root/src/shared/bpf-program.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/bpf-program.c')
-rw-r--r--src/shared/bpf-program.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/shared/bpf-program.c b/src/shared/bpf-program.c
index 40bc9645be..93f8db3f34 100644
--- a/src/shared/bpf-program.c
+++ b/src/shared/bpf-program.c
@@ -94,6 +94,25 @@ int bpf_program_load_kernel(BPFProgram *p, char *log_buf, size_t log_size) {
return 0;
}
+int bpf_program_load_from_bpf_fs(BPFProgram *p, const char *path) {
+ union bpf_attr attr;
+
+ assert(p);
+
+ if (p->kernel_fd >= 0) /* don't overwrite an assembled or loaded program */
+ return -EBUSY;
+
+ attr = (union bpf_attr) {
+ .pathname = PTR_TO_UINT64(path),
+ };
+
+ p->kernel_fd = bpf(BPF_OBJ_GET, &attr, sizeof(attr));
+ if (p->kernel_fd < 0)
+ return -errno;
+
+ return 0;
+}
+
int bpf_program_cgroup_attach(BPFProgram *p, int type, const char *path, uint32_t flags) {
_cleanup_free_ char *copy = NULL;
_cleanup_close_ int fd = -1;