MPTCP Archive mirror
 help / color / mirror / Atom feed
From: Martin KaFai Lau <martin.lau@linux.dev>
To: Geliang Tang <geliang@kernel.org>
Cc: Geliang Tang <tanggeliang@kylinos.cn>,
	bpf@vger.kernel.org, mptcp@lists.linux.dev,
	Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Mykola Lysenko <mykolal@fb.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
	Jiri Olsa <jolsa@kernel.org>, Shuah Khan <shuah@kernel.org>
Subject: Re: [PATCH bpf-next 1/3] selftests/bpf: Export send_byte helper
Date: Wed, 3 Apr 2024 23:03:09 -0700	[thread overview]
Message-ID: <c3db579d-78d3-4135-8fd8-58a17a4a4382@linux.dev> (raw)
In-Reply-To: <4daa40f84a7b9e506bb21c4dcbccdcf1db8fc750.1712039441.git.tanggeliang@kylinos.cn>

On 4/1/24 11:38 PM, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> The helper send_byte is defined in mptcp.c, sk_lookup.c and tcp_rtt.c.
> It makes sense to export it into network_helpers.h to let it can be
> used for all BPF selftests.
> 
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---
>   tools/testing/selftests/bpf/network_helpers.c      |  9 +++++++++
>   tools/testing/selftests/bpf/network_helpers.h      |  1 +
>   tools/testing/selftests/bpf/prog_tests/mptcp.c     |  7 -------
>   tools/testing/selftests/bpf/prog_tests/sk_lookup.c | 13 -------------
>   tools/testing/selftests/bpf/prog_tests/tcp_rtt.c   |  7 -------
>   5 files changed, 10 insertions(+), 27 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c
> index 6db27a9088e9..f2f8f7388d7c 100644
> --- a/tools/testing/selftests/bpf/network_helpers.c
> +++ b/tools/testing/selftests/bpf/network_helpers.c
> @@ -497,3 +497,12 @@ int get_socket_local_port(int sock_fd)
>   
>   	return -1;
>   }
> +
> +int send_byte(int fd)
> +{
> +	char b = 0x55;
> +
> +	if (!ASSERT_EQ(write(fd, &b, sizeof(b)), 1, "send single byte"))
> +		return -1;
> +	return 0;
> +}

I think it is overkill to have a dedicated helper that only does the error 
checking on the single syscall send/write. I would drop this patch and directly 
use the syscall send/write instead.


  reply	other threads:[~2024-04-04  6:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-02  6:38 [PATCH bpf-next 0/3] export send_byte and send_recv_data Geliang Tang
2024-04-02  6:38 ` [PATCH bpf-next 1/3] selftests/bpf: Export send_byte helper Geliang Tang
2024-04-04  6:03   ` Martin KaFai Lau [this message]
2024-04-02  6:38 ` [PATCH bpf-next 2/3] selftests/bpf: Add struct send_recv_arg Geliang Tang
2024-04-02  6:38 ` [PATCH bpf-next 3/3] selftests/bpf: Export send_recv_data helper Geliang Tang
2024-04-04  5:54   ` Martin KaFai Lau

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=c3db579d-78d3-4135-8fd8-58a17a4a4382@linux.dev \
    --to=martin.lau@linux.dev \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=geliang@kernel.org \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=mykolal@fb.com \
    --cc=sdf@google.com \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=tanggeliang@kylinos.cn \
    --cc=yonghong.song@linux.dev \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).