On Mon, Feb 08, 2021 at 05:47:50PM +0800, Yu Chuan wrote:
[Why] In physical machine, there will be a delay between the start of network card and the availability of the network.
So we add a test ping condition to network_ok.
Signed-off-by: Yu Chuan 13186087857@163.com
lib/bootstrap.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/lib/bootstrap.sh b/lib/bootstrap.sh index 06aa09bf65b2..38965ff60755 100755 --- a/lib/bootstrap.sh +++ b/lib/bootstrap.sh @@ -85,14 +85,19 @@ net_devices_link() done }
+test_ping() +{
- ping -c 1 -W 1 $LKP_SERVER > /dev/null || return 1
This looks not necessary:
|| return 1
-w seems somehow better than -W, since the man page explicitly discussed it:
If ping does not receive any reply packets at all it will exit with code 1. If a packet count and deadline are both specified, and fewer than count packets are received by the time the deadline has arrived, it will also exit with code 1. On other error it exits with code 2. Otherwise it exits with code 0. => This makes it possible to use the exit code to see if a host is => alive or not.
Thanks, Fengguang
+}
network_ok() { local i for i in /sys/class/net/*/ do [ "${i#*/lo/}" != "$i" ] && continue
[ "$(cat $i/operstate)" = 'up' ] && return 0
[ "$(cat $i/carrier 2>/dev/null)" = '1' ] && return 0
[ "$(cat $i/operstate)" = 'up' ] && test_ping && return 0
[ "$(cat $i/carrier 2>/dev/null)" = '1' ] && test_ping && return 0
done
is_clearlinux && {
-- 2.23.0