* [PATCH net] selftests: net: make busywait timeout clock portable
@ 2026-06-26 14:49 Nirmoy Das
2026-06-30 10:11 ` Paolo Abeni
0 siblings, 1 reply; 3+ messages in thread
From: Nirmoy Das @ 2026-06-26 14:49 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Shuah Khan
Cc: netdev, linux-kselftest, stable
loopy_wait() expects millisecond timestamps. However, Ubuntu Resolute
can use uutils date, where `date -u +%s%3N` returns seconds plus full
nanoseconds instead of a 3-digit millisecond field. This makes
busywait expire too early and can make vlan_bridge_binding.sh read a
stale operstate.
Fixes: 25ae948b4478 ("selftests/net: add lib.sh")
Cc: stable@vger.kernel.org # 6.8+
Link: https://github.com/uutils/coreutils/issues/11658
Signed-off-by: Nirmoy Das <nirmoyd@nvidia.com>
---
tools/testing/selftests/net/lib.sh | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/net/lib.sh
index b40694573f4c7..fcaec058be6d0 100644
--- a/tools/testing/selftests/net/lib.sh
+++ b/tools/testing/selftests/net/lib.sh
@@ -70,12 +70,27 @@ ksft_exit_status_merge()
$ksft_xfail $ksft_pass $ksft_skip $ksft_fail
}
+timestamp_ms()
+{
+ local now=$(date -u +%s:%N)
+ local seconds=${now%:*}
+ local nanoseconds=${now#*:}
+
+ if [[ $nanoseconds =~ ^[0-9]+$ ]]; then
+ nanoseconds=${nanoseconds:0:9}
+ else
+ nanoseconds=0
+ fi
+
+ echo $((seconds * 1000 + 10#$nanoseconds / 1000000))
+}
+
loopy_wait()
{
local sleep_cmd=$1; shift
local timeout_ms=$1; shift
- local start_time="$(date -u +%s%3N)"
+ local start_time=$(timestamp_ms)
while true
do
local out
@@ -84,7 +99,7 @@ loopy_wait()
return 0
fi
- local current_time="$(date -u +%s%3N)"
+ local current_time=$(timestamp_ms)
if ((current_time - start_time > timeout_ms)); then
echo -n "$out"
return 1
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net] selftests: net: make busywait timeout clock portable
2026-06-26 14:49 [PATCH net] selftests: net: make busywait timeout clock portable Nirmoy Das
@ 2026-06-30 10:11 ` Paolo Abeni
2026-06-30 16:52 ` Nirmoy Das
0 siblings, 1 reply; 3+ messages in thread
From: Paolo Abeni @ 2026-06-30 10:11 UTC (permalink / raw)
To: Nirmoy Das, David S. Miller, Eric Dumazet, Jakub Kicinski,
Shuah Khan
Cc: netdev, linux-kselftest, stable
On 6/26/26 4:49 PM, Nirmoy Das wrote:
> loopy_wait() expects millisecond timestamps. However, Ubuntu Resolute
> can use uutils date, where `date -u +%s%3N` returns seconds plus full
> nanoseconds instead of a 3-digit millisecond field. This makes
> busywait expire too early and can make vlan_bridge_binding.sh read a
> stale operstate.
>
> Fixes: 25ae948b4478 ("selftests/net: add lib.sh")
> Cc: stable@vger.kernel.org # 6.8+
> Link: https://github.com/uutils/coreutils/issues/11658
> Signed-off-by: Nirmoy Das <nirmoyd@nvidia.com>
> ---
> tools/testing/selftests/net/lib.sh | 19 +++++++++++++++++--
> 1 file changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/net/lib.sh
> index b40694573f4c7..fcaec058be6d0 100644
> --- a/tools/testing/selftests/net/lib.sh
> +++ b/tools/testing/selftests/net/lib.sh
> @@ -70,12 +70,27 @@ ksft_exit_status_merge()
> $ksft_xfail $ksft_pass $ksft_skip $ksft_fail
> }
>
> +timestamp_ms()
> +{
> + local now=$(date -u +%s:%N)
shellcheck says:
^-^ SC2155 (warning): Declare and assign separately to avoid masking
return values.
/P
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net] selftests: net: make busywait timeout clock portable
2026-06-30 10:11 ` Paolo Abeni
@ 2026-06-30 16:52 ` Nirmoy Das
0 siblings, 0 replies; 3+ messages in thread
From: Nirmoy Das @ 2026-06-30 16:52 UTC (permalink / raw)
To: Paolo Abeni, David S. Miller, Eric Dumazet, Jakub Kicinski,
Shuah Khan
Cc: netdev, linux-kselftest, stable
On 30.06.26 13:11, Paolo Abeni wrote:
> On 6/26/26 4:49 PM, Nirmoy Das wrote:
>> loopy_wait() expects millisecond timestamps. However, Ubuntu Resolute
>> can use uutils date, where `date -u +%s%3N` returns seconds plus full
>> nanoseconds instead of a 3-digit millisecond field. This makes
>> busywait expire too early and can make vlan_bridge_binding.sh read a
>> stale operstate.
>>
>> Fixes: 25ae948b4478 ("selftests/net: add lib.sh")
>> Cc: stable@vger.kernel.org # 6.8+
>> Link: https://github.com/uutils/coreutils/issues/11658
>> Signed-off-by: Nirmoy Das <nirmoyd@nvidia.com>
>> ---
>> tools/testing/selftests/net/lib.sh | 19 +++++++++++++++++--
>> 1 file changed, 17 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/net/lib.sh
>> index b40694573f4c7..fcaec058be6d0 100644
>> --- a/tools/testing/selftests/net/lib.sh
>> +++ b/tools/testing/selftests/net/lib.sh
>> @@ -70,12 +70,27 @@ ksft_exit_status_merge()
>> $ksft_xfail $ksft_pass $ksft_skip $ksft_fail
>> }
>>
>> +timestamp_ms()
>> +{
>> + local now=$(date -u +%s:%N)
> shellcheck says:
>
> ^-^ SC2155 (warning): Declare and assign separately to avoid masking
> return values.
Thanks a lot. Sent a v2 with that fixed.
> /P
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-06-30 16:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-26 14:49 [PATCH net] selftests: net: make busywait timeout clock portable Nirmoy Das
2026-06-30 10:11 ` Paolo Abeni
2026-06-30 16:52 ` Nirmoy Das
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox