diff mbox series

[bpf-next] selftests: bpf: use MIN for TCP CC tests

Message ID 4da5ff038c442d4421b95580558fc981bb674e61.1649304888.git.geliang.tang@suse.com (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series [bpf-next] selftests: bpf: use MIN for TCP CC tests | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for bpf-next, async
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 1 maintainers not CCed: netdev@vger.kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 31 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next-VM_Test-1 success Logs for Kernel LATEST on ubuntu-latest + selftests
bpf/vmtest-bpf-next-VM_Test-2 success Logs for Kernel LATEST on z15 + selftests

Commit Message

Geliang Tang April 7, 2022, 4:19 a.m. UTC
Use macro MIN() in sys/param.h for TCP CC tests, instead of defining a
new one.

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
 tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Shuah Khan April 7, 2022, 7:40 p.m. UTC | #1
On 4/6/22 10:19 PM, Geliang Tang wrote:
> Use macro MIN() in sys/param.h for TCP CC tests, instead of defining a
> new one.
> 
> Signed-off-by: Geliang Tang <geliang.tang@suse.com>
> ---
>   tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c
> index 8f7a1cef7d87..ceed369361fc 100644
> --- a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c
> +++ b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c
> @@ -3,6 +3,7 @@
>   
>   #include <linux/err.h>
>   #include <netinet/tcp.h>
> +#include <sys/param.h>
>   #include <test_progs.h>
>   #include "network_helpers.h"
>   #include "bpf_dctcp.skel.h"
> @@ -10,8 +11,6 @@
>   #include "bpf_tcp_nogpl.skel.h"
>   #include "bpf_dctcp_release.skel.h"
>   
> -#define min(a, b) ((a) < (b) ? (a) : (b))
> -

Thank you for cleaning this up. Sanity compile test passed.

Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>

thanks,
-- Shuah
Daniel Borkmann April 7, 2022, 9:05 p.m. UTC | #2
Hi Geliang,

On 4/7/22 6:19 AM, Geliang Tang wrote:
> Use macro MIN() in sys/param.h for TCP CC tests, instead of defining a
> new one.
> 
> Signed-off-by: Geliang Tang <geliang.tang@suse.com>

Thanks for your cleanup; we do seem to have this in a bunch of places:

tools/testing/selftests/bpf/prog_tests/bpf_iter.c:1195:#define min(a, b) ((a) < (b) ? (a) : (b))
tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c:13:#define min(a, b) ((a) < (b) ? (a) : (b))
tools/testing/selftests/bpf/prog_tests/snprintf.c:86:#define min(a, b) ((a) < (b) ? (a) : (b))

Mind sending a v2 which cleans up all at once to reduce too much churn?

Thanks,
Daniel
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c
index 8f7a1cef7d87..ceed369361fc 100644
--- a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c
+++ b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c
@@ -3,6 +3,7 @@ 
 
 #include <linux/err.h>
 #include <netinet/tcp.h>
+#include <sys/param.h>
 #include <test_progs.h>
 #include "network_helpers.h"
 #include "bpf_dctcp.skel.h"
@@ -10,8 +11,6 @@ 
 #include "bpf_tcp_nogpl.skel.h"
 #include "bpf_dctcp_release.skel.h"
 
-#define min(a, b) ((a) < (b) ? (a) : (b))
-
 #ifndef ENOTSUPP
 #define ENOTSUPP 524
 #endif
@@ -53,7 +52,7 @@  static void *server(void *arg)
 
 	while (bytes < total_bytes && !READ_ONCE(stop)) {
 		nr_sent = send(fd, &batch,
-			       min(total_bytes - bytes, sizeof(batch)), 0);
+			       MIN(total_bytes - bytes, sizeof(batch)), 0);
 		if (nr_sent == -1 && errno == EINTR)
 			continue;
 		if (nr_sent == -1) {
@@ -146,7 +145,7 @@  static void do_test(const char *tcp_ca, const struct bpf_map *sk_stg_map)
 	/* recv total_bytes */
 	while (bytes < total_bytes && !READ_ONCE(stop)) {
 		nr_recv = recv(fd, &batch,
-			       min(total_bytes - bytes, sizeof(batch)), 0);
+			       MIN(total_bytes - bytes, sizeof(batch)), 0);
 		if (nr_recv == -1 && errno == EINTR)
 			continue;
 		if (nr_recv == -1)