tools/testing/selftests/net/hsr/hsr_common.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/hsr/hsr_common.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/net/hsr/hsr_common.sh- Extension
.sh- Size
- 1576 bytes
- Lines
- 85
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: tools
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
# SPDX-License-Identifier: GPL-2.0
# Common code for HSR testing scripts
source ../lib.sh
ret=0
ksft_skip=4
# $1: IP address
is_v6()
{
[ -z "${1##*:*}" ]
}
do_ping()
{
local netns="$1"
local connect_addr="$2"
local ping_args="-q -c 2 -i 0.1"
if is_v6 "${connect_addr}"; then
$ipv6 || return 0
ping_args="${ping_args} -6"
fi
ip netns exec ${netns} ping ${ping_args} $connect_addr >/dev/null
if [ $? -ne 0 ] ; then
echo "$netns -> $connect_addr connectivity [ FAIL ]" 1>&2
ret=1
return 1
fi
return 0
}
do_ping_long()
{
local netns="$1"
local connect_addr="$2"
local ping_args="-q -c 10 -i 0.1"
if is_v6 "${connect_addr}"; then
$ipv6 || return 0
ping_args="${ping_args} -6"
fi
OUT="$(LANG=C ip netns exec ${netns} ping ${ping_args} $connect_addr | grep received)"
if [ $? -ne 0 ] ; then
echo "$netns -> $connect_addr ping [ FAIL ]" 1>&2
ret=1
return 1
fi
VAL="$(echo $OUT | cut -d' ' -f1-8)"
SED_VAL="$(echo ${VAL} | sed -r -e 's/([0-9]{2}).*([0-9]{2}).*[[:space:]]([0-9]+%).*/\1 transmitted \2 received \3 loss/')"
if [ "${SED_VAL}" != "10 transmitted 10 received 0% loss" ]
then
echo "$netns -> $connect_addr ping TEST [ FAIL ]"
echo "Expect to send and receive 10 packets and no duplicates."
echo "Full message: ${OUT}."
ret=1
return 1
fi
return 0
}
stop_if_error()
{
local msg="$1"
Annotation
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.