mirror of
https://git.FreeBSD.org/src.git
synced 2026-06-02 11:24:32 +00:00
ping: fix test timestamp_origin when tstamprepl is disabled
The timestamp_origin test sends an ICMP Timestamp Request (ping -Mt) and parses the tso/tsr fields out of the reply. When the sysctl net.inet.icmp.tstamprepl is 0, the kernel silently drops the request, ping receives no reply, and the sed extraction yields an empty $tso. The test then fails inside atf_check test -n "$tso" with the unhelpful message Approved by: maxim Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D57287
This commit is contained in:
@@ -253,14 +253,22 @@ inject_reply_cleanup()
|
||||
ifconfig `cat tun.txt` destroy
|
||||
}
|
||||
|
||||
atf_test_case timestamp_origin
|
||||
atf_test_case timestamp_origin cleanup
|
||||
timestamp_origin_head()
|
||||
{
|
||||
atf_set "descr" "ICMP Originate Timestamp"
|
||||
atf_set "require.user" "root"
|
||||
atf_set "require.config" "allow_sysctl_side_effects"
|
||||
}
|
||||
timestamp_origin_body()
|
||||
{
|
||||
require_ipv4
|
||||
# The kernel only replies to ICMP timestamp requests when
|
||||
# net.inet.icmp.tstamprepl is enabled. Save the current value
|
||||
# so the cleanup hook can restore it, then enable replies.
|
||||
sysctl -n net.inet.icmp.tstamprepl > tstamprepl.txt
|
||||
sysctl net.inet.icmp.tstamprepl=1
|
||||
|
||||
# Run ping timestamp
|
||||
out=$(ping -Mt -c1 127.0.0.1)
|
||||
|
||||
@@ -286,6 +294,12 @@ timestamp_origin_body()
|
||||
atf_fail "tso ($tso) differs from tsr ($tsr) by $diff seconds"
|
||||
fi
|
||||
}
|
||||
timestamp_origin_cleanup()
|
||||
{
|
||||
if [ -f tstamprepl.txt ]; then
|
||||
sysctl net.inet.icmp.tstamprepl=`cat tstamprepl.txt`
|
||||
fi
|
||||
}
|
||||
|
||||
atf_init_test_cases()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user