mirror of https://github.com/OpenIPC/firmware.git
34 lines
929 B
Diff
34 lines
929 B
Diff
diff -drupN a/samples/bpf/libbpf.c b/samples/bpf/libbpf.c
|
|
--- a/samples/bpf/libbpf.c 2018-08-06 17:23:04.000000000 +0300
|
|
+++ b/samples/bpf/libbpf.c 2022-06-12 05:28:14.000000000 +0300
|
|
@@ -104,6 +104,29 @@ int bpf_prog_load(enum bpf_prog_type pro
|
|
return syscall(__NR_bpf, BPF_PROG_LOAD, &attr, sizeof(attr));
|
|
}
|
|
|
|
+int bpf_prog_attach(int prog_fd, int target_fd, enum bpf_attach_type type,
|
|
+ unsigned int flags)
|
|
+{
|
|
+ union bpf_attr attr = {
|
|
+ .target_fd = target_fd,
|
|
+ .attach_bpf_fd = prog_fd,
|
|
+ .attach_type = type,
|
|
+ .attach_flags = flags;
|
|
+ };
|
|
+
|
|
+ return syscall(__NR_bpf, BPF_PROG_ATTACH, &attr, sizeof(attr));
|
|
+}
|
|
+
|
|
+int bpf_prog_detach(int target_fd, enum bpf_attach_type type)
|
|
+{
|
|
+ union bpf_attr attr = {
|
|
+ .target_fd = target_fd,
|
|
+ .attach_type = type,
|
|
+ };
|
|
+
|
|
+ return syscall(__NR_bpf, BPF_PROG_DETACH, &attr, sizeof(attr));
|
|
+}
|
|
+
|
|
int bpf_obj_pin(int fd, const char *pathname)
|
|
{
|
|
union bpf_attr attr = {
|