From: David Vernet <void@manifault.com>
To: bpf@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
martin.lau@linux.dev, song@kernel.org, yhs@meta.com,
john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com,
haoluo@google.com, jolsa@kernel.org,
linux-kernel@vger.kernel.org, kernel-team@meta.com,
toke@redhat.com, brouer@redhat.com, corbet@lwn.net,
linux-doc@vger.kernel.org
Subject: [PATCH bpf-next 3/3] selftests/bpf: Add a selftest for the KF_DEPRECATED kfunc flag
Date: Thu, 2 Feb 2023 10:30:56 -0600 [thread overview]
Message-ID: <20230202163056.658641-4-void@manifault.com> (raw)
In-Reply-To: <20230202163056.658641-1-void@manifault.com>
Now that we have KF_DEPRECATED, we should add a selftest for it. This
patch implements that selftest by adding a new test
bpf_kfunc_call_test_deprecated() that includes the KF_DEPRECATED flag,
and adding a kfunc_call_test_deprecated testcase to the kfunc_call_test
suite which verifies that the program is loaded and has the expected
verifier error message.
Signed-off-by: David Vernet <void@manifault.com>
---
net/bpf/test_run.c | 5 +++++
tools/testing/selftests/bpf/prog_tests/kfunc_call.c | 2 ++
tools/testing/selftests/bpf/progs/kfunc_call_test.c | 10 ++++++++++
3 files changed, 17 insertions(+)
diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
index e6f773d12045..945d6f7c1825 100644
--- a/net/bpf/test_run.c
+++ b/net/bpf/test_run.c
@@ -746,6 +746,10 @@ __bpf_kfunc static u32 bpf_kfunc_call_test_static_unused_arg(u32 arg, u32 unused
return arg;
}
+__bpf_kfunc void bpf_kfunc_call_test_deprecated(void)
+{
+}
+
__diag_pop();
BTF_SET8_START(bpf_test_modify_return_ids)
@@ -785,6 +789,7 @@ BTF_ID_FLAGS(func, bpf_kfunc_call_test_mem_len_fail2)
BTF_ID_FLAGS(func, bpf_kfunc_call_test_ref, KF_TRUSTED_ARGS)
BTF_ID_FLAGS(func, bpf_kfunc_call_test_destructive, KF_DESTRUCTIVE)
BTF_ID_FLAGS(func, bpf_kfunc_call_test_static_unused_arg)
+BTF_ID_FLAGS(func, bpf_kfunc_call_test_deprecated, KF_DEPRECATED)
BTF_SET8_END(test_sk_check_kfunc_ids)
static void *bpf_test_init(const union bpf_attr *kattr, u32 user_size,
diff --git a/tools/testing/selftests/bpf/prog_tests/kfunc_call.c b/tools/testing/selftests/bpf/prog_tests/kfunc_call.c
index a543742cd7bd..98398dba5718 100644
--- a/tools/testing/selftests/bpf/prog_tests/kfunc_call.c
+++ b/tools/testing/selftests/bpf/prog_tests/kfunc_call.c
@@ -319,4 +319,6 @@ void test_kfunc_call(void)
if (test__start_subtest("destructive"))
test_destructive();
+
+ RUN_TESTS(kfunc_call_test);
}
diff --git a/tools/testing/selftests/bpf/progs/kfunc_call_test.c b/tools/testing/selftests/bpf/progs/kfunc_call_test.c
index 7daa8f5720b9..b605438e42dd 100644
--- a/tools/testing/selftests/bpf/progs/kfunc_call_test.c
+++ b/tools/testing/selftests/bpf/progs/kfunc_call_test.c
@@ -2,6 +2,7 @@
/* Copyright (c) 2021 Facebook */
#include <vmlinux.h>
#include <bpf/bpf_helpers.h>
+#include "bpf_misc.h"
extern long bpf_kfunc_call_test4(signed char a, short b, int c, long d) __ksym;
extern int bpf_kfunc_call_test2(struct sock *sk, __u32 a, __u32 b) __ksym;
@@ -18,6 +19,7 @@ extern void bpf_kfunc_call_test_mem_len_fail2(__u64 *mem, int len) __ksym;
extern int *bpf_kfunc_call_test_get_rdwr_mem(struct prog_test_ref_kfunc *p, const int rdwr_buf_size) __ksym;
extern int *bpf_kfunc_call_test_get_rdonly_mem(struct prog_test_ref_kfunc *p, const int rdonly_buf_size) __ksym;
extern u32 bpf_kfunc_call_test_static_unused_arg(u32 arg, u32 unused) __ksym;
+extern void bpf_kfunc_call_test_deprecated(void) __ksym;
SEC("tc")
int kfunc_call_test4(struct __sk_buff *skb)
@@ -192,4 +194,12 @@ int kfunc_call_test_static_unused_arg(struct __sk_buff *skb)
return actual != expected ? -1 : 0;
}
+SEC("tc")
+__success __log_level(2) __msg("calling deprecated kfunc bpf_kfunc_call_test_deprecated")
+int kfunc_call_test_deprecated(struct __sk_buff *skb)
+{
+ bpf_kfunc_call_test_deprecated();
+ return 0;
+}
+
char _license[] SEC("license") = "GPL";
--
2.39.0
prev parent reply other threads:[~2023-02-02 16:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-02 16:30 [PATCH bpf-next 0/3] Document kfunc lifecycle / stability expectations David Vernet
2023-02-02 16:30 ` [PATCH bpf-next 1/3] bpf/docs: " David Vernet
2023-02-02 16:30 ` [PATCH bpf-next 2/3] bpf: Add KF_DEPRECATED kfunc flag David Vernet
2023-02-02 21:21 ` Alexei Starovoitov
2023-02-02 21:27 ` David Vernet
2023-02-02 23:11 ` Daniel Borkmann
2023-02-02 23:21 ` Alexei Starovoitov
2023-02-03 0:02 ` Toke Høiland-Jørgensen
2023-02-02 16:30 ` David Vernet [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230202163056.658641-4-void@manifault.com \
--to=void@manifault.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=brouer@redhat.com \
--cc=corbet@lwn.net \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kernel-team@meta.com \
--cc=kpsingh@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=sdf@google.com \
--cc=song@kernel.org \
--cc=toke@redhat.com \
--cc=yhs@meta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).