summaryrefslogtreecommitdiff
path: root/samples/bpf/test_probe_write_user.bpf.c
diff options
context:
space:
mode:
authorDaniel T. Lee <danieltimlee@gmail.com>2024-10-11 04:48:47 +0000
committerAlexei Starovoitov <ast@kernel.org>2024-10-11 09:51:31 -0700
commit118740b870157eacd974c9120d27c20b5663b47a (patch)
treef8984933bb944d10d52b375612f252f6ae79e1c9 /samples/bpf/test_probe_write_user.bpf.c
parent5ea68f0493d192610fa29fc9a7dcd9038fa8d5ee (diff)
samples/bpf: remove obsolete tracing related tests
The samples/bpf has become outdated and often does not follow up with the latest. This commit removes obsolete tracing-related tests. Specifically, 'test_overhead' is duplicate with selftests (and bench), and 'test_override_return', 'test_probe_write_user' tests are obsolete since they have been replaced by kprobe_multi_override and probe_user from selftests respectively. The following files are removed: - test_overhead: tests the overhead of BPF programs with task_rename, now covered by selftests and benchmark tests (rename-*). [1] - test_override_return: tests the return override functionality, now handled by kprobe_multi_override in selftests. - test_probe_write_user: tests the probe_write_user functionality, now replaced by the probe_user test in selftests. This cleanup will help to streamline the testing framework by removing redundant tests. [1]: https://patchwork.kernel.org/cover/13759916 Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com> Link: https://lore.kernel.org/r/20241011044847.51584-5-danieltimlee@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'samples/bpf/test_probe_write_user.bpf.c')
-rw-r--r--samples/bpf/test_probe_write_user.bpf.c52
1 files changed, 0 insertions, 52 deletions
diff --git a/samples/bpf/test_probe_write_user.bpf.c b/samples/bpf/test_probe_write_user.bpf.c
deleted file mode 100644
index a4f3798b7fb0..000000000000
--- a/samples/bpf/test_probe_write_user.bpf.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/* Copyright (c) 2016 Sargun Dhillon <sargun@sargun.me>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- */
-#include "vmlinux.h"
-#include <string.h>
-#include <linux/version.h>
-#include <bpf/bpf_helpers.h>
-#include <bpf/bpf_tracing.h>
-#include <bpf/bpf_core_read.h>
-
-struct {
- __uint(type, BPF_MAP_TYPE_HASH);
- __type(key, struct sockaddr_in);
- __type(value, struct sockaddr_in);
- __uint(max_entries, 256);
-} dnat_map SEC(".maps");
-
-/* kprobe is NOT a stable ABI
- * kernel functions can be removed, renamed or completely change semantics.
- * Number of arguments and their positions can change, etc.
- * In such case this bpf+kprobe example will no longer be meaningful
- *
- * This example sits on a syscall, and the syscall ABI is relatively stable
- * of course, across platforms, and over time, the ABI may change.
- */
-SEC("ksyscall/connect")
-int BPF_KSYSCALL(bpf_prog1, int fd, struct sockaddr_in *uservaddr,
- int addrlen)
-{
- struct sockaddr_in new_addr, orig_addr = {};
- struct sockaddr_in *mapped_addr;
-
- if (addrlen > sizeof(orig_addr))
- return 0;
-
- if (bpf_probe_read_user(&orig_addr, sizeof(orig_addr), uservaddr) != 0)
- return 0;
-
- mapped_addr = bpf_map_lookup_elem(&dnat_map, &orig_addr);
- if (mapped_addr != NULL) {
- memcpy(&new_addr, mapped_addr, sizeof(new_addr));
- bpf_probe_write_user(uservaddr, &new_addr,
- sizeof(new_addr));
- }
- return 0;
-}
-
-char _license[] SEC("license") = "GPL";
-u32 _version SEC("version") = LINUX_VERSION_CODE;