mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: bot+bpf-ci@kernel.org
To: alexis.lothore@bootlin.com,ast@kernel.org,daniel@iogearbox.net,andrii@kernel.org,eddyz87@gmail.com,memxor@gmail.com,martin.lau@linux.dev,song@kernel.org,yonghong.song@linux.dev,jolsa@kernel.org,emil@etsalapatis.com,shuah@kernel.org
Cc: ebpf@linuxfoundation.org,bastien.curutchet@bootlin.com,thomas.petazzoni@bootlin.com,bpf@vger.kernel.org,linux-kselftest@vger.kernel.org,linux-kernel@vger.kernel.org,alexis.lothore@bootlin.com,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,clm@meta.com,ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf v2] selftests/bpf: keep polling connection that is still in progress
Date: Mon,  3 Aug 2026 08:35:25 +0000 (UTC)	[thread overview]
Message-ID: <eac3adb0094cfdbbd998c459ddecd92179c0fa252a44878ea5c69eb991c1a11a@mail.kernel.org> (raw)
In-Reply-To: <20260803-tc_tunnel_flaky-v2-1-657b287dfa75@bootlin.com>

[-- Attachment #1: Type: text/plain, Size: 3985 bytes --]

> diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c
> index b82f572641b7..2f2719a28f02 100644
> --- a/tools/testing/selftests/bpf/network_helpers.c
> +++ b/tools/testing/selftests/bpf/network_helpers.c

[ ... ]

> @@ -40,6 +41,8 @@
>  #define IPPROTO_MPTCP 262
>  #endif
>
> +#define CONNECTION_IN_PROGRESS_TIMEOUT_MS	3000
> +
>  #define clean_errno() (errno == 0 ? "None" : strerror(errno))
>  #define log_err(MSG, ...) ({						\
>  			int __save = errno;				\

[ ... ]

> @@ -294,7 +297,8 @@ int client_socket(int family, int type,
>  int connect_to_addr(int type, const struct sockaddr_storage *addr, socklen_t addrlen,
>  		    const struct network_helper_opts *opts)
>  {
> -	int fd;
> +	socklen_t errlen;
> +	int fd, err;
>
>  	if (!opts)
>  		opts = &default_opts;
> @@ -305,13 +309,42 @@ int connect_to_addr(int type, const struct sockaddr_storage *addr, socklen_t add
>  		return -1;
>  	}
>
> -	if (connect(fd, (const struct sockaddr *)addr, addrlen)) {
> +	err = connect(fd, (const struct sockaddr *)addr, addrlen);
> +	if (err && errno == EINPROGRESS) {
> +		struct pollfd pfd = { .fd = fd, .events = POLLOUT };
> +
> +		err = poll(&pfd, 1, CONNECTION_IN_PROGRESS_TIMEOUT_MS);

Does the fixed 3000 ms timeout override opts->timeout_ms correctly?

client_socket() in this file passes opts->timeout_ms to settimeo(), which
converts it into SO_RCVTIMEO and SO_SNDTIMEO:

tools/testing/selftests/bpf/network_helpers.c:settimeo() {
	...
	if (timeout_ms > 0) {
		timeout.tv_sec = timeout_ms / 1000;
		timeout.tv_usec = (timeout_ms % 1000) * 1000;
	} else {
		timeout.tv_sec = 3;
		timeout.tv_usec = 0;
	}
	...
}

tools/testing/selftests/bpf/network_helpers.c:client_socket() {
	...
	if (settimeo(fd, opts->timeout_ms))
		goto error_close;
	...
}

That opts->timeout_ms is the caller's requested timeout contract. But the
new poll() discards it and uses CONNECTION_IN_PROGRESS_TIMEOUT_MS instead,
which is always 3000.

This changes observable timing for callers in both directions:

Callers that request a SHORT timeout now wait longer than they asked for.
prog_tests/assign_reuse.c calls connect_to_fd(fd_sv, 100) at lines 42 and
66, requesting a 100 ms budget. A stalled connect now blocks for 100 ms
(SO_SNDTIMEO) plus 3000 ms in poll() - a 30x overrun.
prog_tests/test_tc_tunnel.c sets .timeout_ms = 1000 at line 171.

The commit message explicitly argues against lengthening timeouts:
"increasing the timeout value would increase overall test execution
duration again", yet the patch lengthens these callers' timeouts from
their requested values.

Callers that request a LONG timeout get a shorter window than they asked
for. prog_tests/tc_redirect.c uses TIMEOUT_MILLIS (10000) at lines 428,
561, and 658. prog_tests/xdp_synproxy.c uses 10000 at line 135. On a
loaded runner the connect is now abandoned at SO_SNDTIMEO + 3 s rather
than the requested 10 s.

Would deriving the poll timeout from opts->timeout_ms preserve the single
timeout contract that callers already use?

>
> +		if (err <= 0) {
> +			if (err == 0) {
> +				log_err("Connection timeout");
> +				errno = ETIMEDOUT;
> +			} else {
> +				log_err("Failed to poll connection status");
> +			}
> +			goto close;
> +		}
> +
> +		errlen = sizeof(err);
> +		if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &err, &errlen) < 0) {
> +			log_err("Failed to getsockopt");
> +			goto close;
> +		}
> +
> +		if (err) {
> +			log_err("Eventually failed to connect to server");
> +			errno = err;
> +			goto close;
> +		}
> +	} else if (err) {
>  		log_err("Failed to connect to server");
> -		save_errno_close(fd);
> -		return -1;
> +		goto close;
>  	}
>
>  	return fd;
> +close:
> +	save_errno_close(fd);
> +	return -1;
>  }


---
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/30795380743

  reply	other threads:[~2026-08-03  8:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-03  7:36 Alexis Lothoré (eBPF Foundation)
2026-08-03  8:35 ` bot+bpf-ci [this message]
2026-08-06 18:56 ` Ihor Solodrai

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=eac3adb0094cfdbbd998c459ddecd92179c0fa252a44878ea5c69eb991c1a11a@mail.kernel.org \
    --to=bot+bpf-ci@kernel.org \
    --cc=alexis.lothore@bootlin.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bastien.curutchet@bootlin.com \
    --cc=bpf@vger.kernel.org \
    --cc=clm@meta.com \
    --cc=daniel@iogearbox.net \
    --cc=ebpf@linuxfoundation.org \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    --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

all inboxes | Powered by JetHome®