Netdev List
 help / color / mirror / Atom feed
From: Mahe Tardy <mahe.tardy@gmail.com>
To: bot+bpf-ci@kernel.org
Cc: bpf@vger.kernel.org, andrew+netdev@lunn.ch, andrii@kernel.org,
	ast@kernel.org, daniel@iogearbox.net, davem@davemloft.net,
	eddyz87@gmail.com, edumazet@google.com, john.fastabend@gmail.com,
	kuba@kernel.org, liamwisehart@meta.com, martin.lau@linux.dev,
	pabeni@redhat.com, song@kernel.org, netdev@vger.kernel.org,
	sdf.kernel@gmail.com, ameryhung@gmail.com, kuniyu@google.com,
	memxor@gmail.com, jiayuan.chen@linux.dev, sdf@fomichev.me,
	martin.lau@kernel.org, yonghong.song@linux.dev, clm@meta.com,
	ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf-next v7 3/5] selftests/bpf: Add ksock kfunc test
Date: Fri, 14 Aug 2026 18:59:42 +0200	[thread overview]
Message-ID: <an9JfnuGUFifuQGB@gmail.com> (raw)
In-Reply-To: <b0f93b51174ba64b1ce220ea0ef67b1eced238efdd66ed4a5960f3b2966a70e9@mail.kernel.org>

On Thu, Aug 13, 2026 at 12:13:34PM +0000, bot+bpf-ci@kernel.org wrote:
> > diff --git a/tools/testing/selftests/bpf/prog_tests/ksock.c b/tools/testing/selftests/bpf/prog_tests/ksock.c
> > new file mode 100644
> > index 0000000000000..05d7b7424aee3
> > --- /dev/null
> > +++ b/tools/testing/selftests/bpf/prog_tests/ksock.c
> > @@ -0,0 +1,124 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/* Copyright (c) 2026 Isovalent */
> > +
> > +#include <arpa/inet.h>
> > +
> > +#include "test_progs.h"
> > +#include "network_helpers.h"
> > +#include "ksock_lsm.skel.h"
> > +
> > +#define NS_TEST "ksock_lsm_ns"
> > +#define RECV_PORT 7777
> > +#define RECV_TIMEOUT_SEC 5
> 
> [ ... ]
> 
> > +static bool ksock_test_env_setup(struct ksock_test_env *env)
> > +{
> > +	struct sockaddr_in addr = {
> > +		.sin_family = AF_INET,
> > +		.sin_addr.s_addr = htonl(INADDR_LOOPBACK),
> > +		.sin_port = htons(RECV_PORT),
> > +	};
> > +	struct timeval tv = { .tv_sec = RECV_TIMEOUT_SEC };
> > +	int err;
> > +
> > +	memset(env, 0, sizeof(*env));
> > +	env->rfd = -1;
> > +
> > +	if (!ASSERT_OK(make_netns(NS_TEST), "make_netns"))
> > +		goto fail;
> > +
> > +	env->nstoken = open_netns(NS_TEST);
> > +	if (!ASSERT_OK_PTR(env->nstoken, "open_netns"))
> > +		goto fail;
> > +
> > +	env->rfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
> > +	if (!ASSERT_OK_FD(env->rfd, "receiver socket"))
> > +		goto fail;
> > +
> > +	err = bind(env->rfd, (struct sockaddr *)&addr, sizeof(addr));
> > +	if (!ASSERT_OK(err, "bind receiver"))
> > +		goto fail;
> > +
> > +	err = setsockopt(env->rfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
> > +	if (!ASSERT_OK(err, "set rcvtimeo"))
> > +		goto fail;
> 
> A subsystem pattern flags this socket setup sequence as potentially
> worth simplifying. The network_helpers.h header already provides
> start_server(family, type, addr, port, timeout_ms) which performs
> socket() + bind() + settimeo() for SOCK_DGRAM.
> 
> Other SOCK_DGRAM tests in prog_tests/ use start_server() for this:
> cg_storage_multi.c, connect_force_port.c, cgroup_getset_retval.c,
> sock_destroy.c, and tc_redirect.c. Could this be written as:
> 
>     env->rfd = start_server(AF_INET, SOCK_DGRAM, "127.0.0.1",
>                             RECV_PORT, RECV_TIMEOUT_SEC * 1000);
> 
> to drop the addr and tv locals and use the shared error logging?
> 
> That said, there is also precedent for the hand-rolled form in the same
> directory (cgroup_storage.c, udp_limit.c, xdp_metadata.c, and others),
> so this may just be a style choice.

Yeah unsure it's worth simplifying.

> 
> [ ... ]
> 
> 
> ---
> AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
> See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
> 
> CI run summary: https://github.com/kernel-patches/bpf/actions/runs/31694719067


  reply	other threads:[~2026-08-14 16:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-13 11:05 [PATCH bpf-next v7 0/5] Introduce bpf_ksock Mahe Tardy
2026-08-13 11:05 ` [PATCH bpf-next v7 1/5] net: Add connect_socket() helper Mahe Tardy
2026-08-13 11:05 ` [PATCH bpf-next v7 2/5] bpf: Add ksock kfuncs Mahe Tardy
2026-08-13 11:05 ` [PATCH bpf-next v7 3/5] selftests/bpf: Add ksock kfunc test Mahe Tardy
2026-08-13 12:13   ` bot+bpf-ci
2026-08-14 16:59     ` Mahe Tardy [this message]
2026-08-13 11:05 ` [PATCH bpf-next v7 4/5] selftests/bpf: Test forbidden bpf_ksock_send() LSM attach Mahe Tardy
2026-08-13 11:05 ` [PATCH bpf-next v7 5/5] selftests/bpf: Add ksock test for async callback guard Mahe Tardy
2026-08-13 12:13   ` bot+bpf-ci
2026-08-14 17:02     ` Mahe Tardy

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=an9JfnuGUFifuQGB@gmail.com \
    --to=mahe.tardy@gmail.com \
    --cc=ameryhung@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bot+bpf-ci@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=clm@meta.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=eddyz87@gmail.com \
    --cc=edumazet@google.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=jiayuan.chen@linux.dev \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=liamwisehart@meta.com \
    --cc=martin.lau@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf.kernel@gmail.com \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --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