Thread (23 messages) 23 messages, 3 authors, 2020-11-03

Re: [bpf-next PATCH v2 5/5] selftest/bpf: Use global variables instead of maps for test_tcpbpf_kern

From: Andrii Nakryiko <hidden>
Date: 2020-11-03 18:41:05
Also in: bpf

On Sat, Oct 31, 2020 at 11:52 AM Alexander Duyck
[off-list ref] wrote:
From: Alexander Duyck <alexanderduyck@fb.com>

Use global variables instead of global_map and sockopt_results_map to track
test data. Doing this greatly simplifies the code as there is not need to
take the extra steps of updating the maps or looking up elements.

Suggested-by: Martin KaFai Lau <redacted>
Signed-off-by: Alexander Duyck <alexanderduyck@fb.com>
---
 .../testing/selftests/bpf/prog_tests/tcpbpf_user.c |   53 ++++--------
 .../testing/selftests/bpf/progs/test_tcpbpf_kern.c |   86 +++-----------------
 tools/testing/selftests/bpf/test_tcpbpf.h          |    2
 3 files changed, 31 insertions(+), 110 deletions(-)
[...]
-}
-
+struct tcpbpf_globals global = { 0 };
nit: = {0} notation is misleading, just = {}; is equivalent and IMO better.

But don't bother if it's the only change you need to do for the next version.
 int _version SEC("version") = 1;
[...]
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help