diff options
author | Toke Høiland-Jørgensen <toke@redhat.com> | 2020-04-24 15:34:28 +0200 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2020-04-24 17:34:30 -0700 |
commit | 1d8a0af5ee1ad219a9ebd9b43559b165bcb3ff40 (patch) | |
tree | a26ba95e6cff26762f51193696a29df95026b497 /tools/testing/selftests/bpf/progs/freplace_connect4.c | |
parent | bpf: Propagate expected_attach_type when verifying freplace programs (diff) | |
download | wireguard-linux-1d8a0af5ee1ad219a9ebd9b43559b165bcb3ff40.tar.xz wireguard-linux-1d8a0af5ee1ad219a9ebd9b43559b165bcb3ff40.zip |
selftests/bpf: Add test for freplace program with expected_attach_type
This adds a new selftest that tests the ability to attach an freplace
program to a program type that relies on the expected_attach_type of the
target program to pass verification.
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/158773526831.293902.16011743438619684815.stgit@toke.dk
Diffstat (limited to '')
-rw-r--r-- | tools/testing/selftests/bpf/progs/freplace_connect4.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/freplace_connect4.c b/tools/testing/selftests/bpf/progs/freplace_connect4.c new file mode 100644 index 000000000000..a0ae84230699 --- /dev/null +++ b/tools/testing/selftests/bpf/progs/freplace_connect4.c @@ -0,0 +1,18 @@ +#include <linux/stddef.h> +#include <linux/ipv6.h> +#include <linux/bpf.h> +#include <linux/in.h> +#include <sys/socket.h> +#include <bpf/bpf_helpers.h> +#include <bpf/bpf_endian.h> + +SEC("freplace/do_bind") +int new_do_bind(struct bpf_sock_addr *ctx) +{ + struct sockaddr_in sa = {}; + + bpf_bind(ctx, (struct sockaddr *)&sa, sizeof(sa)); + return 0; +} + +char _license[] SEC("license") = "GPL"; |