Skip to contentSkip to conversation

tcp_cmds/ping/ping02: Make it compatible with Busybox

PATCH Superseded Kory Maincent 2 participants 4 messages Nov 6, 2020 – Nov 9, 2020

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tcp_cmds/ping/ping02: Make it compatible with Busybox

The ping from busybox does not have -f parameter, use -i parameter instead. BusyBox does not accept pattern longer than 2 bytes.

---
 testcases/network/tcp_cmds/ping/ping02.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
testcases/network/tcp_cmds/ping/ping02.sh +2 -2
index e0a63c5f6..2784c8160 100755
@@ -20,7 +20,7 @@ do_setup()
 
 do_test()
 {
-	local pat="000102030405060708090a0b0c0d0e0f"
+	local pat="aa"
 
 	tst_res TINFO "flood $PING: ICMP packets filled with pattern '$pat'"
 
@@ -28,7 +28,7 @@ do_test()
 	local s
 
 	for s in $PACKETSIZES; do
-		EXPECT_PASS $PING -c $COUNT -f -s $s $ipaddr -p "$pat" \>/dev/null
+		EXPECT_PASS $PING -c $COUNT -i 0.001 -s $s $ipaddr -p "$pat" \>/dev/null
 	done
 }
 
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/1 tcp_cmds/ping/ping02: Make it compatible with Busybox

Quoted 13 lines · Kory Maincent

The ping from busybox does not have -f parameter, use -i parameter instead. BusyBox does not accept pattern longer than 2 bytes.

---
 testcases/network/tcp_cmds/ping/ping02.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
testcases/network/tcp_cmds/ping/ping02.sh +0 -0
index e0a63c5f6..2784c8160 100755

testcases/network/tcp_cmds/ping/ping02.sh do_setup() · line 24

Quoted 6 lines
testcases/network/tcp_cmds/ping/ping02.sh +1 -1
@@ -20,7 +20,7 @@ do_setup()
 
 do_test()
 {
-	local pat="000102030405060708090a0b0c0d0e0f"
+	local pat="aa"
 

Hi Kory,

I think we should replace the options only if ping doesn't support '-f', i.e. something like in the first version and this patch:

local ping_opts="-f -p 000102030405060708090a0b0c0d0e0f" local ipaddr=$(tst_ipaddr rhost)
local s

$PING -h 2>&1 | grep -q '[-]f' || ping_opts="-i 0.01 -p aa"

for s in $PACKETSIZES; do
EXPECT_PASS $PING -c $COUNT -s $s $ipaddr $ping_opts \>/dev/null
done

Quoted 12 lines
testcases/network/tcp_cmds/ping/ping02.sh +1 -1
 	tst_res TINFO "flood $PING: ICMP packets filled with pattern '$pat'"
 
@@ -28,7 +28,7 @@ do_test()
 	local s
 
 	for s in $PACKETSIZES; do
-		EXPECT_PASS $PING -c $COUNT -f -s $s $ipaddr -p "$pat" \>/dev/null
+		EXPECT_PASS $PING -c $COUNT -i 0.001 -s $s $ipaddr -p "$pat" \>/dev/null
 	done
 }
 
#2 lore raw

PATCH v2 1/1 tcp_cmds/ping/ping02: Make it compatible with Busybox

Hello Alexey,

Thank for your feedback.

Quoted 23 lines · On Mon, 9 Nov 2020 14:09:24 +0300 Alexey Kodanev <[email protected]>…
Quoted 13 lines · Kory Maincent

The ping from busybox does not have -f parameter, use -i parameter instead. BusyBox does not accept pattern longer than 2 bytes.

---
 testcases/network/tcp_cmds/ping/ping02.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/testcases/network/tcp_cmds/ping/ping02.sh index e0a63c5f6..2784c8160 100755 --- a/testcases/network/tcp_cmds/ping/ping02.sh
+++ b/testcases/network/tcp_cmds/ping/ping02.sh

testcases/network/tcp_cmds/ping/ping02.sh do_setup() · line 24

Quoted 6 lines
testcases/network/tcp_cmds/ping/ping02.sh +1 -1
@@ -20,7 +20,7 @@ do_setup()
 
 do_test()
 {
-	local pat="000102030405060708090a0b0c0d0e0f"
+	local pat="aa"
 

Hi Kory,

Quoted 8 lines

I think we should replace the options only if ping doesn't support '-f', i.e. something like in the first version and this patch:

local ping_opts="-f -p 000102030405060708090a0b0c0d0e0f" local ipaddr=$(tst_ipaddr rhost)
local s

$PING -h 2>&1 | grep -q '[-]f' || ping_opts="-i 0.01 -p aa"

The grep in parameter is not working for all cases.
For example the ping usage of my Ubuntu laptop is:
Usage: ping [-aAbBdDfhLnOqrRUvV64] [-c count] [-i interval] [-I interface]
[-m mark] [-M pmtudisc_option] [-l preload] [-p pattern] [-Q tos] [-s packetsize] [-S sndbuf] [-t ttl] [-T timestamp_option] [-w deadline] [-W timeout] [hop1 ...] destination

I may use test like this:
$PING -c 1 -f $ipaddr >/dev/null 2>&1 || ping_opts="-i 0.01 -p aa"

What do you think?

Regards,

Quoted 20 lines

for s in $PACKETSIZES; do
EXPECT_PASS $PING -c $COUNT -s $s $ipaddr $ping_opts \>/dev/null
done

Quoted 13 lines
(quoted diff) +0 -0
 	tst_res TINFO "flood $PING: ICMP packets filled with pattern

'$pat'"

testcases/network/tcp_cmds/ping/ping02.sh +0 -1
@@ -28,7 +28,7 @@ do_test()
 	local s
 
 	for s in $PACKETSIZES; do
-		EXPECT_PASS $PING -c $COUNT -f -s $s $ipaddr -p "$pat"

\>/dev/null

(quoted diff) +1 -0
+		EXPECT_PASS $PING -c $COUNT -i 0.001 -s $s $ipaddr -p

"$pat" \>/dev/null done
}

Signature · 3 lines
K?ry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
#3 lore raw

PATCH v2 1/1 tcp_cmds/ping/ping02: Make it compatible with Busybox

Quoted 11 lines · K?ry Maincent
Quoted 2 lines

$PING -h 2>&1 | grep -q '[-]f' || ping_opts="-i 0.01 -p aa"

The grep in parameter is not working for all cases.
For example the ping usage of my Ubuntu laptop is:
Usage: ping [-aAbBdDfhLnOqrRUvV64] [-c count] [-i interval] [-I interface]
[-m mark] [-M pmtudisc_option] [-l preload] [-p pattern] [-Q tos] [-s packetsize] [-S sndbuf] [-t ttl] [-T timestamp_option] [-w deadline] [-W timeout] [hop1 ...] destination

Quoted 5 lines

I may use test like this:
$PING -c 1 -f $ipaddr >/dev/null 2>&1 || ping_opts="-i 0.01 -p aa"

What do you think?

Agree, in that case it's better to try ping with the option.