diff options
author | Benjamin Tissoires <bentiss@kernel.org> | 2024-07-16 12:27:26 +0200 |
---|---|---|
committer | Benjamin Tissoires <bentiss@kernel.org> | 2024-07-16 12:27:26 +0200 |
commit | 30b866413e7bdd507a79854b5931528d3f6f438f (patch) | |
tree | 59013deb24680a3c0d34fb5163916c442c7b28b1 /samples/hid/hid_mouse.bpf.c | |
parent | e518f368303d35017fe79f21f0fec7860ef71d0b (diff) | |
parent | a67a1deb11d9a692366100d9ba9fb3aeb0c7707b (diff) |
Merge branch 'for-6.11/bpf' into for-linus
- Rewrite of HID-BPF internal implementation to use bpf struct_ops
instead of tracing (Benjamin Tissoires)
- Add new HID-BPF hooks to be able to intercept userspace calls
targetting a HID device and filtering them (Benjamin Tissoires)
- Add support for various new devices through HID-BPF filters (Benjamin
Tissoires)
Diffstat (limited to 'samples/hid/hid_mouse.bpf.c')
-rw-r--r-- | samples/hid/hid_mouse.bpf.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/samples/hid/hid_mouse.bpf.c b/samples/hid/hid_mouse.bpf.c index 7c8b453ccb16..f7f722dcf56d 100644 --- a/samples/hid/hid_mouse.bpf.c +++ b/samples/hid/hid_mouse.bpf.c @@ -5,8 +5,7 @@ #include <bpf/bpf_tracing.h> #include "hid_bpf_helpers.h" -SEC("fmod_ret/hid_bpf_device_event") -int BPF_PROG(hid_y_event, struct hid_bpf_ctx *hctx) +static int hid_y_event(struct hid_bpf_ctx *hctx) { s16 y; __u8 *data = hid_bpf_get_data(hctx, 0 /* offset */, 9 /* size */); @@ -51,8 +50,7 @@ int BPF_PROG(hid_y_event, struct hid_bpf_ctx *hctx) return 0; } -SEC("fmod_ret/hid_bpf_device_event") -int BPF_PROG(hid_x_event, struct hid_bpf_ctx *hctx) +static int hid_x_event(struct hid_bpf_ctx *hctx) { s16 x; __u8 *data = hid_bpf_get_data(hctx, 0 /* offset */, 9 /* size */); @@ -69,7 +67,19 @@ int BPF_PROG(hid_x_event, struct hid_bpf_ctx *hctx) return 0; } -SEC("fmod_ret/hid_bpf_rdesc_fixup") +SEC("struct_ops/hid_device_event") +int BPF_PROG(hid_event, struct hid_bpf_ctx *hctx, enum hid_report_type type) +{ + int ret = hid_y_event(hctx); + + if (ret) + return ret; + + return hid_x_event(hctx); +} + + +SEC("struct_ops/hid_rdesc_fixup") int BPF_PROG(hid_rdesc_fixup, struct hid_bpf_ctx *hctx) { __u8 *data = hid_bpf_get_data(hctx, 0 /* offset */, 4096 /* size */); @@ -109,4 +119,10 @@ int BPF_PROG(hid_rdesc_fixup, struct hid_bpf_ctx *hctx) return 0; } +SEC(".struct_ops.link") +struct hid_bpf_ops mouse_invert = { + .hid_rdesc_fixup = (void *)hid_rdesc_fixup, + .hid_device_event = (void *)hid_event, +}; + char _license[] SEC("license") = "GPL"; |