selftests/bpf: Wait for receive in cg_storage_multi test
Subsystems (3)
PATCH v2 1/1 selftests/bpf: Wait for receive in cg_storage_multi test
In some cases the loopback latency might be large enough, causing the assertion on invocations to be run before ingress prog getting executed. The assertion would fail and the test would flake.
This can be reliably reproduced by arbitrarily increasing the loopback latency (thanks to [1]):
tc qdisc add dev lo root handle 1: htb default 12
tc class add dev lo parent 1:1 classid 1:12 htb rate 20kbps ceil 20kbps tc qdisc add dev lo parent 1:12 netem delay 100ms
Fix this by waiting on the receive end, instead of instantly returning to the assert. The call to read() will wait for the default SO_RCVTIMEO timeout of 3 seconds provided by start_server().
[1] https://gist.github.com/kstevens715/4598301
---
v1 -> v2:
- Changed from a call to poll() to a call to read() (Martin)
tools/testing/selftests/bpf/prog_tests/cg_storage_multi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/prog_tests/cg_storage_multi.c +6 -2
@@ -56,8 +56,9 @@ static bool assert_storage_noexist(struct bpf_map *map, const void *key)static bool connect_send (const char *cgroup_path) { -bool res = true;int server_fd =-1 , client_fd =-1 ; +char message[] ="message" ; +bool res = true;if (join_cgroup (cgroup_path)) goto out_clean;
@@ -70,7 +71,10 @@ static bool connect_send(const char *cgroup_path)if (client_fd <0 ) goto out_clean; -if (send (client_fd,"message" ,strlen ("message" ),0 ) <0 ) +if (send (client_fd, &message,sizeof (message),0 ) <0 ) + goto out_clean; + +if (read (server_fd, &message,sizeof (message)) <0 ) goto out_clean; res = false;
Signature · 1 line
2.40.0.348.gf938b09366-goog
Martin KaFai Lau
reviewerQuoted 17 lines · YiFei Zhu
In some cases the loopback latency might be large enough, causing the assertion on invocations to be run before ingress prog getting executed. The assertion would fail and the test would flake.
This can be reliably reproduced by arbitrarily increasing the loopback latency (thanks to [1]):
tc qdisc add dev lo root handle 1: htb default 12
tc class add dev lo parent 1:1 classid 1:12 htb rate 20kbps ceil 20kbps tc qdisc add dev lo parent 1:12 netem delay 100msFix this by waiting on the receive end, instead of instantly returning to the assert. The call to
read()will wait for the defaultSO_RCVTIMEOtimeout of 3 seconds provided bystart_server().
Quoted 7 lines
Reported-by Martin KaFai Lau <[email protected]>Fixes 3573f384014f ("selftests/bpf: Test CGROUP_STORAGE behavior on shared egress + ingress")Signed-off-by YiFei Zhu <[email protected]>---
v1 -> v2:
- Changed from a call topoll()to a call toread()(Martin)
Thanks for the fix. Added "Acked-by: Stanislav Fomichev <[email protected]>" and applied.
This patch was applied to bpf/bpf-next.git (master) by Martin KaFai Lau <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Martin KaFai Lau <[email protected]>:
Quoted 11 lines · On Wed, 5 Apr 2023 19:33:54 +0000 you wrote:
In some cases the loopback latency might be large enough, causing the assertion on invocations to be run before ingress prog getting executed. The assertion would fail and the test would flake.
This can be reliably reproduced by arbitrarily increasing the loopback latency (thanks to [1]):
tc qdisc add dev lo root handle 1: htb default 12
tc class add dev lo parent 1:1 classid 1:12 htb rate 20kbps ceil 20kbps tc qdisc add dev lo parent 1:12 netem delay 100ms[...]
Here is the summary with links:
- [v2,bpf] selftests/bpf: Wait for receive in cg_storage_multi test
https://git.kernel.org/bpf/bpf-next/c/5af607a861d4
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html