[RFC PATCH v8 12/20] selftests/bpf: Modify linked_list tests to work with macro-ified removes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since a hidden arguement is added to bpf list remove kfuncs, and
bpf_list_pop_back/front are macrofied, we modify selftests so that it can
be compiled.

Signed-off-by: Amery Hung <amery.hung@xxxxxxxxxxxxx>
---
 .../selftests/bpf/progs/linked_list_fail.c      | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/tools/testing/selftests/bpf/progs/linked_list_fail.c b/tools/testing/selftests/bpf/progs/linked_list_fail.c
index 5f8063ecc448..d260f80ea64d 100644
--- a/tools/testing/selftests/bpf/progs/linked_list_fail.c
+++ b/tools/testing/selftests/bpf/progs/linked_list_fail.c
@@ -49,8 +49,7 @@
 	int test##_missing_lock_##op(void *ctx)             \
 	{                                                   \
 		INIT;                                       \
-		void (*p)(void *) = (void *)&bpf_list_##op; \
-		p(hexpr);                                   \
+		bpf_list_##op(hexpr);                       \
 		return 0;                                   \
 	}
 
@@ -96,9 +95,8 @@ CHECK(inner_map, push_back, &iv->head, &f->node2);
 	int test##_incorrect_lock_##op(void *ctx)           \
 	{                                                   \
 		INIT;                                       \
-		void (*p)(void *) = (void *)&bpf_list_##op; \
 		bpf_spin_lock(lexpr);                       \
-		p(hexpr);                                   \
+		bpf_list_##op(hexpr);                       \
 		return 0;                                   \
 	}
 
@@ -576,7 +574,7 @@ int incorrect_head_off2(void *ctx)
 }
 
 static __always_inline
-int pop_ptr_off(void *(*op)(void *head))
+int pop_ptr_off(bool pop_front)
 {
 	struct {
 		struct bpf_list_head head __contains(foo, node2);
@@ -588,7 +586,10 @@ int pop_ptr_off(void *(*op)(void *head))
 	if (!p)
 		return 0;
 	bpf_spin_lock(&p->lock);
-	n = op(&p->head);
+	if (pop_front)
+		n = bpf_list_pop_front(&p->head);
+	else
+		n = bpf_list_pop_back(&p->head);
 	bpf_spin_unlock(&p->lock);
 
 	if (!n)
@@ -600,13 +601,13 @@ int pop_ptr_off(void *(*op)(void *head))
 SEC("?tc")
 int pop_front_off(void *ctx)
 {
-	return pop_ptr_off((void *)bpf_list_pop_front);
+	return pop_ptr_off(true);
 }
 
 SEC("?tc")
 int pop_back_off(void *ctx)
 {
-	return pop_ptr_off((void *)bpf_list_pop_back);
+	return pop_ptr_off(false);
 }
 
 SEC("?tc")
-- 
2.20.1





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux