* [LTP] [PATCH v4 0/7] net/route: rewrite route-change-{dst, gw, if} into new API
@ 2019-09-03 14:16 Petr Vorel
2019-09-03 14:16 ` [LTP] [PATCH v4 1/7] tst_net.sh: enhance tst_add_ipaddr(), add tst_del_ipaddr() Petr Vorel
` (7 more replies)
0 siblings, 8 replies; 15+ messages in thread
From: Petr Vorel @ 2019-09-03 14:16 UTC (permalink / raw)
To: ltp
Hi Alexey,
this version address functionality problems you pointed out.
But yet there might need to be another version as I'm not sure about
tst_ipaddr_un() API changes.
Changes v3-v4:
* enhanced tst_ipaddr_un() with -b, -h -l, -m, -n and -p options (-p was
previous -m)
* use tst_ipaddr_un() options to fix address clash on host_id, net_id clash fix
by adjusting $1 in test (this is really inconsistent, see note at 3/7).
* added tests for tst_ipaddr_un()
* quiet EXPECT_PASS ping$TST_IPV6
Kind regards,
Petr
Petr Vorel (7):
tst_net.sh: enhance tst_add_ipaddr(), add tst_del_ipaddr()
tst_net.sh: Add -p option to return prefix in tst_ipaddr_un()
tst_net.sh: Add (mostly) HOST_ID related options to tst_ipaddr_un
net: Add tst_ipaddr_un.sh test
network/route: Rewrite route{4,6}-change-dst into new shell API
network/route: Rewrite route{4,6}-change-gw into new shell API
network/route: Rewrite route{4,6}-change-if into new API
lib/newlib_tests/net/tst_ipaddr_un.sh | 239 +++++++++++++
runtest/net_stress.route | 15 +-
testcases/lib/tst_net.sh | 196 +++++++++--
.../network/stress/route/00_Descriptions.txt | 54 +--
.../network/stress/route/route-change-dst.sh | 34 ++
.../network/stress/route/route-change-gw.sh | 39 +++
.../network/stress/route/route-change-if.sh | 90 +++++
testcases/network/stress/route/route-lib.sh | 17 +
.../network/stress/route/route4-change-dst | 276 ---------------
.../network/stress/route/route4-change-gw | 292 ----------------
.../network/stress/route/route4-change-if | 324 ------------------
.../network/stress/route/route6-change-dst | 272 ---------------
.../network/stress/route/route6-change-gw | 292 ----------------
.../network/stress/route/route6-change-if | 323 -----------------
14 files changed, 595 insertions(+), 1868 deletions(-)
create mode 100755 lib/newlib_tests/net/tst_ipaddr_un.sh
create mode 100755 testcases/network/stress/route/route-change-dst.sh
create mode 100755 testcases/network/stress/route/route-change-gw.sh
create mode 100755 testcases/network/stress/route/route-change-if.sh
create mode 100644 testcases/network/stress/route/route-lib.sh
delete mode 100644 testcases/network/stress/route/route4-change-dst
delete mode 100644 testcases/network/stress/route/route4-change-gw
delete mode 100644 testcases/network/stress/route/route4-change-if
delete mode 100644 testcases/network/stress/route/route6-change-dst
delete mode 100644 testcases/network/stress/route/route6-change-gw
delete mode 100644 testcases/network/stress/route/route6-change-if
--
2.22.1
^ permalink raw reply [flat|nested] 15+ messages in thread
* [LTP] [PATCH v4 1/7] tst_net.sh: enhance tst_add_ipaddr(), add tst_del_ipaddr()
2019-09-03 14:16 [LTP] [PATCH v4 0/7] net/route: rewrite route-change-{dst, gw, if} into new API Petr Vorel
@ 2019-09-03 14:16 ` Petr Vorel
2019-09-12 12:12 ` Alexey Kodanev
2019-09-03 14:16 ` [LTP] [PATCH v4 2/7] tst_net.sh: Add -p option to return prefix in tst_ipaddr_un() Petr Vorel
` (6 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Petr Vorel @ 2019-09-03 14:16 UTC (permalink / raw)
To: ltp
These changes are intended for easier handling with IP addresses
(not have to calculate dad for IPv6 when adding IP address).
Add -a IP and -s options to tst_add_ipaddr()
tst_del_ipaddr() (which uses internally tst_add_ipaddr()) is defined
mainly for better code readability.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
testcases/lib/tst_net.sh | 48 +++++++++++++++++++++++++++++++---------
1 file changed, 37 insertions(+), 11 deletions(-)
diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh
index 6c3ae708d..83871fe2c 100644
--- a/testcases/lib/tst_net.sh
+++ b/testcases/lib/tst_net.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (c) 2014-2017 Oracle and/or its affiliates. All Rights Reserved.
-# Copyright (c) 2016-2018 Petr Vorel <pvorel@suse.cz>
+# Copyright (c) 2016-2019 Petr Vorel <pvorel@suse.cz>
# Author: Alexey Kodanev <alexey.kodanev@oracle.com>
[ -n "$TST_LIB_NET_LOADED" ] && return 0
@@ -447,14 +447,33 @@ tst_init_iface()
tst_rhost_run -c "ip link set $iface up"
}
-# tst_add_ipaddr [TYPE] [LINK]
-# TYPE: { lhost | rhost }; Default value is 'lhost'.
-# LINK: link number starting from 0. Default value is '0'.
+# tst_add_ipaddr [TYPE] [LINK] [-a IP] [-d] [-s]
+# Options:
+# TYPE: { lhost | rhost }, default value is 'lhost'
+# LINK: link number starting from 0, default value is '0'
+# -a IP: IP address to be added, default value is
+# $(tst_ipaddr)/$IPV{4,6}_{L,R}PREFIX
+# -d: delete address instead of adding
+# -s: safe option, if something goes wrong, will exit with TBROK
tst_add_ipaddr()
{
+ local action="add"
+ local addr dad lsafe mask rsafe
+
+ local OPTIND
+ while getopts a:ds opt; do
+ case "$opt" in
+ a) addr="$OPTARG" ;;
+ d) action="del" ;;
+ s) lsafe="ROD"; rsafe="-s" ;;
+ *) tst_brk TBROK "tst_add_ipaddr: unknown option: $OPTARG" ;;
+ esac
+ done
+ shift $((OPTIND - 1))
+
local type="${1:-lhost}"
local link_num="${2:-0}"
- local mask dad
+ local iface=$(tst_iface $type $link_num)
if [ "$TST_IPV6" ]; then
dad="nodad"
@@ -462,17 +481,24 @@ tst_add_ipaddr()
else
[ "$type" = "lhost" ] && mask=$IPV4_LPREFIX || mask=$IPV4_RPREFIX
fi
-
- local iface=$(tst_iface $type $link_num)
+ [ -n "$addr" ] || addr="$(tst_ipaddr $type)"
+ echo $addr | grep -q / || addr="$addr/$mask"
if [ $type = "lhost" ]; then
- tst_res_ TINFO "set local addr $(tst_ipaddr)/$mask"
- ip addr add $(tst_ipaddr)/$mask dev $iface $dad
+ tst_res_ TINFO "set local addr $addr"
+ $lsafe ip addr $action $addr dev $iface $dad
return $?
fi
- tst_res_ TINFO "set remote addr $(tst_ipaddr rhost)/$mask"
- tst_rhost_run -c "ip addr add $(tst_ipaddr rhost)/$mask dev $iface $dad"
+ tst_res_ TINFO "set remote addr $addr"
+ tst_rhost_run $rsafe -c "ip addr $action $addr dev $iface $dad"
+}
+
+# tst_del_ipaddr [ tst_add_ipaddr options ]
+# Delete IP address
+tst_del_ipaddr()
+{
+ tst_add_ipaddr -d $@
}
# tst_restore_ipaddr [TYPE] [LINK]
--
2.22.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [LTP] [PATCH v4 2/7] tst_net.sh: Add -p option to return prefix in tst_ipaddr_un()
2019-09-03 14:16 [LTP] [PATCH v4 0/7] net/route: rewrite route-change-{dst, gw, if} into new API Petr Vorel
2019-09-03 14:16 ` [LTP] [PATCH v4 1/7] tst_net.sh: enhance tst_add_ipaddr(), add tst_del_ipaddr() Petr Vorel
@ 2019-09-03 14:16 ` Petr Vorel
2019-09-03 14:16 ` [LTP] [PATCH v4 3/7] tst_net.sh: Add (mostly) HOST_ID related options to tst_ipaddr_un Petr Vorel
` (5 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Petr Vorel @ 2019-09-03 14:16 UTC (permalink / raw)
To: ltp
+ reformat docs a bit
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
testcases/lib/tst_net.sh | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh
index 83871fe2c..a4183e013 100644
--- a/testcases/lib/tst_net.sh
+++ b/testcases/lib/tst_net.sh
@@ -357,28 +357,33 @@ tst_ipaddr()
# Get IP address of unused network, specified either by type and counter
# or by net and host.
-# tst_ipaddr_un [-cCOUNTER] [TYPE]
-# tst_ipaddr_un NET_ID [HOST_ID]
-# TYPE: { lhost | rhost }; Default value is 'lhost'.
-# COUNTER: Integer value for counting HOST_ID and NET_ID. Default is 1.
-# NET_ID: Integer or hex value of net. For IPv4 is 3rd octet, for IPv6
-# is 3rd hextet.
-# HOST_ID: Integer or hex value of host. For IPv4 is 4th octet, for
-# IPv6 is the last hextet. Default value is 0.
+# tst_ipaddr_un [-cCOUNTER] [-p] [TYPE]
+# tst_ipaddr_un [-p] NET_ID [HOST_ID]
+#
+# TYPE: { lhost | rhost } (default: 'lhost')
+# NET_ID: integer or hex value of net (IPv4: 3rd octet, IPv6: 3rd hextet)
+# HOST_ID: integer or hex value of host (IPv4: 4th octet, IPv6: the last
+# hextet, default: 0)
+#
+# OPTIONS
+# -c COUNTER: integer value for counting HOST_ID and NET_ID (default: 1)
+# -p: print also prefix
tst_ipaddr_un()
{
- local counter host_id net_id max_host_id max_net_id tmp type
+ local counter host_id max_host_id max_net_id net_id prefix tmp type
local OPTIND
- while getopts "c:" opt; do
+ while getopts "c:p" opt; do
case $opt in
c) counter="$OPTARG";;
+ p) [ "$TST_IPV6" ] && prefix="/64" || prefix="/24";;
esac
done
shift $(($OPTIND - 1))
[ "$TST_IPV6" ] && max_net_id=65535 || max_net_id=255
+ # counter
if [ $# -eq 0 -o "$1" = "lhost" -o "$1" = "rhost" ]; then
[ -z "$counter" ] && counter=1
[ $counter -lt 1 ] && counter=1
@@ -394,7 +399,7 @@ tst_ipaddr_un()
host_id=$max_host_id
net_id=$((net_id - 1))
fi
- else
+ else # net_id & host_id
net_id="$1"
host_id="${2:-0}"
if [ "$TST_IPV6" ]; then
@@ -409,14 +414,14 @@ tst_ipaddr_un()
host_id=$((host_id % max_net_id))
if [ -z "$TST_IPV6" ]; then
- echo "${IPV4_NET16_UNUSED}.${net_id}.${host_id}"
+ echo "${IPV4_NET16_UNUSED}.${net_id}.${host_id}${prefix}"
return
fi
[ $host_id -gt 0 ] && host_id="$(printf %x $host_id)" || host_id=
[ $net_id -gt 0 ] && net_id="$(printf %x $net_id)" || net_id=
[ "$net_id" ] && net_id=":$net_id"
- echo "${IPV6_NET32_UNUSED}${net_id}::${host_id}"
+ echo "${IPV6_NET32_UNUSED}${net_id}::${host_id}${prefix}"
}
# tst_init_iface [TYPE] [LINK]
--
2.22.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [LTP] [PATCH v4 3/7] tst_net.sh: Add (mostly) HOST_ID related options to tst_ipaddr_un
2019-09-03 14:16 [LTP] [PATCH v4 0/7] net/route: rewrite route-change-{dst, gw, if} into new API Petr Vorel
2019-09-03 14:16 ` [LTP] [PATCH v4 1/7] tst_net.sh: enhance tst_add_ipaddr(), add tst_del_ipaddr() Petr Vorel
2019-09-03 14:16 ` [LTP] [PATCH v4 2/7] tst_net.sh: Add -p option to return prefix in tst_ipaddr_un() Petr Vorel
@ 2019-09-03 14:16 ` Petr Vorel
2019-09-12 12:41 ` Alexey Kodanev
2019-09-03 14:16 ` [LTP] [PATCH v4 4/7] net: Add tst_ipaddr_un.sh test Petr Vorel
` (4 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Petr Vorel @ 2019-09-03 14:16 UTC (permalink / raw)
To: ltp
These options are important for looping over max HOST_ID (255 resp.
0xffff for IPv6), when different than the default range.
Added -b, -h -l, -m, -n and -p options:
-b: use also *broadcast* address (HOST_ID: IPv4: 255, IPv6: 0xffff),
equivalent of -m 255 or -m 65535, cannot be combined with -f, -h, -l, -m, -n
-c COUNTER: integer value for counting HOST_ID and NET_ID (default: 1)
-f: use *full* address range (<0,255> resp. <0,65535>), cannot be combined
with -b, -h, -l, -m, -n
-h: use only *host* address range (<1,254> resp. <1,65534>), default for
counter mode, cannot be combined with -b, -f, -l, -m, -n
-l MIN_HOST_ID: specify minimal allowed HOST_ID allowed minimal HOST_ID,
cannot be combined with -b, -f, -h, -n
-m MAX_HOST_ID: specify max allowed HOST_ID (default NET_ID -1), cannot be
combined with -b, -f, -h, -n
-n: use also *network* address (HOST_ID: 0), equivalent of -l 0, cannot be
combined with -b, -f, -h, -l, -m
-p: print also prefix
NOTE: The default range for host_id & net_id changed from <0, 254 resp. 65534> to
<0, 254 resp. 65535>: broadcast bit was added.
For backwards compatibility -n must be used.
But non of the code used host_id & net_id in loop => no change needed.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Hi,
changes make API a bit complex, but affect only HOST_ID, but sometimes
NET_ID changes are needed (route-change-if.sh). Maybe simple
[ -n MIN_NET_ID,MAX_NET_ID ] [ -h MIN_HOST_ID,MAX_HOST_ID ] would be
better. Comments are welcome.
Note: sometimes we call prefix as mask in the code.
Kind regards,
Petr
testcases/lib/tst_net.sh | 123 +++++++++++++++++++++++++++++++++------
1 file changed, 105 insertions(+), 18 deletions(-)
diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh
index a4183e013..baeac6e10 100644
--- a/testcases/lib/tst_net.sh
+++ b/testcases/lib/tst_net.sh
@@ -355,48 +355,135 @@ tst_ipaddr()
fi
}
-# Get IP address of unused network, specified either by type and counter
+# Get IP address of unused network, specified either counter and type
# or by net and host.
-# tst_ipaddr_un [-cCOUNTER] [-p] [TYPE]
-# tst_ipaddr_un [-p] NET_ID [HOST_ID]
+# counter mode:
+# tst_ipaddr_un [-b|-f|-n|[-l MIN_HOST_ID][-m MAX_HOST_ID]] [-p] [-c COUNTER] [TYPE]
+# net & host mode:
+# tst_ipaddr_un [-b|-f|-n|[-l MIN_HOST_ID][-m MAX_HOST_ID]] [-p] NET_ID [HOST_ID]
#
# TYPE: { lhost | rhost } (default: 'lhost')
-# NET_ID: integer or hex value of net (IPv4: 3rd octet, IPv6: 3rd hextet)
-# HOST_ID: integer or hex value of host (IPv4: 4th octet, IPv6: the last
-# hextet, default: 0)
+# NET_ID: integer or hex value of net (IPv4: 3rd octet <0,255>, IPv6: 3rd
+# hextet <0,65535>)
+# HOST_ID: integer or hex value of host (IPv4: 4th octet <0,255>, IPv6: the
+# last hextet <0, 65535>, default: 0)
+#
+# RANGES for HOST_ID
+# |<-------------- -f -------------->|
+# | |<----------- -b -------------->|
+# |<-------------- -n -------->| |
+# | |<----------- -h -------->| |
+# | | |<- -l L -m M ->| | |
+# | | | | | |
+# IPv4: 0 1 L M 254 255
+# IPv6: 0 1 L M 65534 65535
#
# OPTIONS
+# -b: use also *broadcast* address (HOST_ID: IPv4: 255, IPv6: 0xffff),
+# equivalent of -m 255 or -m 65535, cannot be combined with -f, -h, -l, -m, -n
+#
# -c COUNTER: integer value for counting HOST_ID and NET_ID (default: 1)
+#
+# -f: use *full* address range (<0,255> resp. <0,65535>), cannot be combined
+# with -b, -h, -l, -m, -n
+#
+# -h: use only *host* address range (<1,254> resp. <1,65534>), default for
+# counter mode, cannot be combined with -b, -f, -l, -m, -n
+#
+# -l MIN_HOST_ID: specify minimal allowed HOST_ID allowed minimal HOST_ID,
+# cannot be combined with -b, -f, -h, -n
+#
+# -m MAX_HOST_ID: specify max allowed HOST_ID (default NET_ID -1), cannot be
+# combined with -b, -f, -h, -n
+#
+# -n: use also *network* address (HOST_ID: 0), equivalent of -l 0, cannot be
+# combined with -b, -f, -h, -l, -m
+#
# -p: print also prefix
tst_ipaddr_un()
{
- local counter host_id max_host_id max_net_id net_id prefix tmp type
- local OPTIND
+ local counter host_id is_counter max_host_id min_host_id max_net_id net_id prefix tmp type
+ local b_arg f_arg h_arg lm_arg n_arg
- while getopts "c:p" opt; do
+ [ "$TST_IPV6" ] && max_net_id=65535 || max_net_id=255
+
+ local OPTIND
+ while getopts "bc:fhl:m:np" opt; do
case $opt in
+ b)
+ [ "$f_arg" -o "$h_arg" -o "$lm_arg" -o "$n_arg" ] && \
+ tst_brk_ TBROK "tst_ipaddr_un: -b cannot be combined with -f, -h, -l, -m, -n"
+ max_host_id=$max_net_id
+ b_arg=1
+ ;;
c) counter="$OPTARG";;
+ h)
+ [ "$b_arg" -o "$f_arg" -o "$lm_arg" -o "$n_arg" ] && \
+ tst_brk_ TBROK "tst_ipaddr_un: -h cannot be combined with -b -f, -l, -m, -n"
+ min_host_id=1
+ max_host_id=$((max_net_id-1))
+ h_arg=1
+ ;;
+ f)
+ [ "$b_arg" -o "$h_arg" -o "$lm_arg" -o "$n_arg" ] && \
+ tst_brk_ TBROK "tst_ipaddr_un: -f cannot be combined with -b, -h, -l, -m, -n"
+ min_host_id=0
+ max_host_id=$max_net_id
+ f_arg=1
+ ;;
+ l)
+ [ "$b_arg" -o "$f_arg" -o "$h_arg" -o "$n_arg" ] && \
+ tst_brk_ TBROK "tst_ipaddr_un: -l cannot be combined with -b, -f, -h, -n"
+ ! tst_is_int "$OPTARG" || [ $OPTARG -lt 0 ] && \
+ tst_brk TBROK "tst_ipaddr_un: -l must be integer <0,$max_net_id> ($OPTARG)"
+ min_host_id="$OPTARG"
+ lm_arg=1
+ ;;
+ m)
+ [ "$b_arg" -o "$f_arg" -o "$h_arg" -o "$n_arg" ] && \
+ tst_brk_ TBROK "tst_ipaddr_un: -m cannot be combined with -b, -f, -h, -n"
+ ! tst_is_int "$OPTARG" || [ "$OPTARG" -lt 0 ]|| [ "$OPTARG" -gt $max_net_id ] && \
+ tst_brk TBROK "tst_ipaddr_un: -m must be integer <0,$max_net_id> ($OPTARG)"
+ [ "$OPTARG" -gt $max_net_id ] && \
+ tst_brk_ TBROK "tst_ipaddr_un: -m cannot be higher than $max_net_id ($OPTARG)"
+ max_host_id="$OPTARG"
+ lm_arg=1
+ ;;
+ n)
+ [ "$b_arg" -o "$f_arg" -o "$h_arg" -o "$lm_arg" ] && \
+ tst_brk_ TBROK "tst_ipaddr_un: -n cannot be combined with -b, -f, -h, -l, -m"
+ min_host_id=0
+ n_arg=1
+ ;;
p) [ "$TST_IPV6" ] && prefix="/64" || prefix="/24";;
esac
done
shift $(($OPTIND - 1))
+ [ $# -eq 0 -o "$1" = "lhost" -o "$1" = "rhost" ] && is_counter=1
- [ "$TST_IPV6" ] && max_net_id=65535 || max_net_id=255
+ if [ -z "$min_host_id" ]; then
+ [ "$is_counter" ] && min_host_id=1 || min_host_id=0
+ fi
+
+ if [ -z "$max_host_id" ]; then
+ [ "$is_counter" ] && max_host_id=$((max_net_id - 1)) || max_host_id=$max_net_id
+ fi
+
+ [ $min_host_id -gt $max_host_id ] && \
+ tst_brk TBROK "tst_ipaddr_un: max HOST_ID ($max_host_id) must be >= min HOST_ID ($min_host_id)"
# counter
- if [ $# -eq 0 -o "$1" = "lhost" -o "$1" = "rhost" ]; then
+ if [ "$is_counter" ]; then
[ -z "$counter" ] && counter=1
[ $counter -lt 1 ] && counter=1
type="${1:-lhost}"
- max_host_id=$((max_net_id - 1))
tmp=$((counter * 2))
[ "$type" = "rhost" ] && tmp=$((tmp - 1))
-
- host_id=$((tmp % max_host_id))
+ host_id=$((tmp % max_host_id - 1))
net_id=$((tmp / max_host_id))
- if [ $host_id -eq 0 ]; then
- host_id=$max_host_id
+ if [ $host_id -lt 0 ]; then
+ host_id=$((max_host_id-1))
net_id=$((net_id - 1))
fi
else # net_id & host_id
@@ -410,8 +497,8 @@ tst_ipaddr_un()
[ $host_id -lt 0 ] && host_id=1
fi
- net_id=$((net_id % max_net_id))
- host_id=$((host_id % max_net_id))
+ net_id=$((net_id % (max_net_id + 1)))
+ host_id=$((host_id % (max_host_id - min_host_id + 1) + min_host_id)) # orig, but also bad
if [ -z "$TST_IPV6" ]; then
echo "${IPV4_NET16_UNUSED}.${net_id}.${host_id}${prefix}"
--
2.22.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [LTP] [PATCH v4 4/7] net: Add tst_ipaddr_un.sh test
2019-09-03 14:16 [LTP] [PATCH v4 0/7] net/route: rewrite route-change-{dst, gw, if} into new API Petr Vorel
` (2 preceding siblings ...)
2019-09-03 14:16 ` [LTP] [PATCH v4 3/7] tst_net.sh: Add (mostly) HOST_ID related options to tst_ipaddr_un Petr Vorel
@ 2019-09-03 14:16 ` Petr Vorel
2019-09-03 14:16 ` [LTP] [PATCH v4 5/7] network/route: Rewrite route{4, 6}-change-dst into new shell API Petr Vorel
` (3 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Petr Vorel @ 2019-09-03 14:16 UTC (permalink / raw)
To: ltp
Testing tst_ipaddr_un() function from network shell API (tst_net.sh).
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
lib/newlib_tests/net/tst_ipaddr_un.sh | 239 ++++++++++++++++++++++++++
1 file changed, 239 insertions(+)
create mode 100755 lib/newlib_tests/net/tst_ipaddr_un.sh
diff --git a/lib/newlib_tests/net/tst_ipaddr_un.sh b/lib/newlib_tests/net/tst_ipaddr_un.sh
new file mode 100755
index 000000000..3570bd26f
--- /dev/null
+++ b/lib/newlib_tests/net/tst_ipaddr_un.sh
@@ -0,0 +1,239 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2019 Petr Vorel <pvorel@suse.cz>
+
+TST_TESTFUNC=do_test
+TST_CNT=2
+TST_NEEDS_CMDS="cut"
+. tst_net.sh
+
+IPV4_DATA="
+0 0|10.23.0.0
+0 1|10.23.0.1
+1 0|10.23.1.0
+1 1|10.23.1.1
+1 2|10.23.1.2
+2 2|10.23.2.2
+1 3|10.23.1.3
+3 3|10.23.3.3
+1 128|10.23.1.128
+128 128|10.23.128.128
+1 254|10.23.1.254
+254 254|10.23.254.254
+1 255|10.23.1.255
+255 255|10.23.255.255
+1 256|10.23.1.0
+256 256|10.23.0.0
+1 257|10.23.1.1
+257 257|10.23.1.1
+
+-c 0|10.23.0.2
+-c 0 rhost|10.23.0.1
+-c 1|10.23.0.2
+-c 1 rhost|10.23.0.1
+-c 2|10.23.0.4
+-c 2 rhost|10.23.0.3
+-c 127|10.23.0.254
+-c 127 rhost|10.23.0.253
+-c 128|10.23.1.2
+-c 128 rhost|10.23.1.1
+-c 254|10.23.1.254
+-c 254 rhost|10.23.1.253
+-c 255|10.23.2.2
+-c 255 rhost|10.23.2.1
+
+-c 0 -b|10.23.0.2
+-c 0 -b rhost|10.23.0.1
+-c 1 -b|10.23.0.2
+-c 1 -b rhost|10.23.0.1
+-c 127 -b|10.23.0.254
+-c 127 -b rhost|10.23.0.253
+-c 128 -b|10.23.1.1
+-c 128 -b rhost|10.23.0.255
+-c 255 -b|10.23.1.255
+-c 255 -b rhost|10.23.1.254
+-c 256 -b|10.23.2.2
+-c 256 -b rhost|10.23.2.1
+
+-c 0 -f|10.23.0.1
+-c 0 -f rhost|10.23.0.0
+-c 1 -f|10.23.0.1
+-c 1 -f rhost|10.23.0.0
+-c 127 -f|10.23.0.253
+-c 127 -f rhost|10.23.0.252
+-c 128 -f|10.23.1.0
+-c 128 -f rhost|10.23.0.254
+-c 255 -f|10.23.1.254
+-c 255 -f rhost|10.23.1.253
+-c 256 -f|10.23.2.1
+-c 256 -f rhost|10.23.2.0
+
+-c 0 -n|10.23.0.1
+-c 0 -n rhost|10.23.0.0
+-c 1 -n|10.23.0.1
+-c 1 -n rhost|10.23.0.0
+-c 127 -n|10.23.0.253
+-c 127 -n rhost|10.23.0.252
+-c 128 -n|10.23.1.1
+-c 128 -n rhost|10.23.1.0
+-c 255 -n|10.23.2.1
+-c 255 -n rhost|10.23.2.0
+-c 256 -n|10.23.2.3
+-c 256 -n rhost|10.23.2.2
+
+-l 5 -m 253 0 0|10.23.0.5
+-l 5 -m 253 0 0 -c 0|10.23.0.5
+-l 5 -m 253 0 0 -c 0 rhost|10.23.0.5
+-l 5 -m 253 1 1|10.23.1.6
+-l 5 -m 253 1 1 -c 1|10.23.1.6
+-l 5 -m 253 1 1 -c 1 rhost|10.23.1.6
+-l 5 -m 253 248 248|10.23.248.253
+-l 5 -m 253 248 248 -c 248|10.23.248.253
+-l 5 -m 253 248 248 -c 248 rhost|10.23.248.253
+-l 5 -m 253 249 249|10.23.249.5
+-l 5 -m 253 249 249 -c 249|10.23.249.5
+-l 5 -m 253 249 249 -c 249 rhost|10.23.249.5
+
+-c 0 -l 3 -m 6|10.23.0.4
+-c 0 -l 3 -m 6 rhost|10.23.0.3
+-c 1 -l 3 -m 6|10.23.0.4
+-c 1 -l 3 -m 6 rhost|10.23.0.3
+-c 2 -l 3 -m 6|10.23.0.6
+-c 2 -l 3 -m 6 rhost|10.23.0.5
+-c 3 -l 3 -m 6|10.23.0.4
+-c 3 -l 3 -m 6 rhost|10.23.0.3
+-c 255 -l 3 -m 6|10.23.84.4
+-c 255 -l 3 -m 6 rhost|10.23.84.3
+"
+
+IPV6_DATA="
+0 0|fd00:23::
+0 1|fd00:23::1
+1 0|fd00:23:1::
+1 1|fd00:23:1::1
+1 2|fd00:23:1::2
+2 2|fd00:23:2::2
+1 3|fd00:23:1::3
+3 3|fd00:23:3::3
+1 32767|fd00:23:1::7fff
+32767 32767|fd00:23:7fff::7fff
+1 65534|fd00:23:1::fffe
+65534 65534|fd00:23:fffe::fffe
+1 65535|fd00:23:1::ffff
+65535 65535|fd00:23:ffff::ffff
+1 65536|fd00:23:1::
+65536 65536|fd00:23::
+1 65537|fd00:23:1::1
+65537 65537|fd00:23:1::1
+
+-c 0|fd00:23::2
+-c 0 rhost|fd00:23::1
+-c 1|fd00:23::2
+-c 1 rhost|fd00:23::1
+-c 2|fd00:23::4
+-c 2 rhost|fd00:23::3
+-c 32767|fd00:23::fffe
+-c 32767 rhost|fd00:23::fffd
+-c 32768|fd00:23:1::2
+-c 32768 rhost|fd00:23:1::1
+-c 65534|fd00:23:1::fffe
+-c 65534 rhost|fd00:23:1::fffd
+-c 65535|fd00:23:2::2
+-c 65535 rhost|fd00:23:2::1
+
+-c 0 -b|fd00:23::2
+-c 0 -b rhost|fd00:23::1
+-c 1 -b|fd00:23::2
+-c 1 -b rhost|fd00:23::1
+-c 32767 -b|fd00:23::fffe
+-c 32767 -b rhost|fd00:23::fffd
+-c 32768 -b|fd00:23:1::1
+-c 32768 -b rhost|fd00:23::ffff
+-c 65535 -b|fd00:23:1::ffff
+-c 65535 -b rhost|fd00:23:1::fffe
+-c 65536 -b|fd00:23:2::2
+-c 65536 -b rhost|fd00:23:2::1
+
+-c 0 -f|fd00:23::1
+-c 0 -f rhost|fd00:23::
+-c 1 -f|fd00:23::1
+-c 1 -f rhost|fd00:23::
+-c 32767 -f|fd00:23::fffd
+-c 32767 -f rhost|fd00:23::fffc
+-c 32768 -f|fd00:23:1::
+-c 32768 -f rhost|fd00:23::fffe
+-c 65535 -f|fd00:23:1::fffe
+-c 65535 -f rhost|fd00:23:1::fffd
+-c 65536 -f|fd00:23:2::1
+-c 65536 -f rhost|fd00:23:2::
+
+-c 0 -n|fd00:23::1
+-c 0 -n rhost|fd00:23::
+-c 1 -n|fd00:23::1
+-c 1 -n rhost|fd00:23::
+-c 32767 -n|fd00:23::fffd
+-c 32767 -n rhost|fd00:23::fffc
+-c 32768 -n|fd00:23:1::1
+-c 32768 -n rhost|fd00:23:1::
+-c 65535 -n|fd00:23:2::1
+-c 65535 -n rhost|fd00:23:2::
+-c 65536 -n|fd00:23:2::3
+-c 65536 -n rhost|fd00:23:2::2
+
+-l 5 -m 253 0 0|fd00:23::5
+-l 5 -m 253 0 0 -c 0|fd00:23::5
+-l 5 -m 253 0 0 -c 0 rhost|fd00:23::5
+-l 5 -m 253 1 1|fd00:23:1::6
+-l 5 -m 253 1 1 -c 1|fd00:23:1::6
+-l 5 -m 253 1 1 -c 1 rhost|fd00:23:1::6
+-l 5 -m 253 0 0|fd00:23::5
+-l 5 -m 253 0 0 -c 0|fd00:23::5
+-l 5 -m 253 0 0 -c 0 rhost|fd00:23::5
+-l 5 -m 253 1 1|fd00:23:1::6
+-l 5 -m 253 249 249 -c 249|fd00:23:f9::5
+-l 5 -m 253 249 249 -c 249 rhost|fd00:23:f9::5
+
+-c 0 -l 3 -m 6|fd00:23::4
+-c 0 -l 3 -m 6 rhost|fd00:23::3
+-c 1 -l 3 -m 6|fd00:23::4
+-c 1 -l 3 -m 6 rhost|fd00:23::3
+-c 2 -l 3 -m 6|fd00:23::6
+-c 2 -l 3 -m 6 rhost|fd00:23::5
+-c 3 -l 3 -m 6|fd00:23::4
+-c 3 -l 3 -m 6 rhost|fd00:23::3
+-c 65535 -l 3 -m 6|fd00:23:5554::4
+-c 65535 -l 3 -m 6 rhost|fd00:23:5554::3
+"
+
+test_tst_ipaddr_un()
+{
+ local data cmd i result
+ local var="$1"
+
+ tst_res TINFO "Testing for IPv${TST_IPVER}, data: \$$var"
+
+ eval data="\$$var"
+ IFS="
+"
+ for i in $data; do
+ cmd="tst_ipaddr_un $(echo $i | cut -d'|' -f 1)"
+ result="$(echo $i | cut -d'|' -f 2)"
+ tst_res TINFO "testing $cmd"
+ EXPECT_PASS "[ '$(eval $cmd)' = '$result' ]"
+ done
+}
+
+do_test2()
+{
+ test_tst_ipaddr_un "IPV${TST_IPVER}_DATA"
+}
+
+do_test()
+{
+ case $1 in
+ 1) TST_IPV6= TST_IPVER=4 do_test2;;
+ 2) TST_IPV6=6 TST_IPVER=6 do_test2;;
+ esac
+}
+
+tst_run
--
2.22.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [LTP] [PATCH v4 5/7] network/route: Rewrite route{4, 6}-change-dst into new shell API
2019-09-03 14:16 [LTP] [PATCH v4 0/7] net/route: rewrite route-change-{dst, gw, if} into new API Petr Vorel
` (3 preceding siblings ...)
2019-09-03 14:16 ` [LTP] [PATCH v4 4/7] net: Add tst_ipaddr_un.sh test Petr Vorel
@ 2019-09-03 14:16 ` Petr Vorel
2019-09-03 14:16 ` [LTP] [PATCH v4 6/7] network/route: Rewrite route{4, 6}-change-gw " Petr Vorel
` (2 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Petr Vorel @ 2019-09-03 14:16 UTC (permalink / raw)
To: ltp
* Drop route command (use just ip command), support both IPv4 and IPv6
* Add route-lib.sh (will be used in other route-change-*)
* Use unused network range to avoid clash with real network
* Add verification with ping (previous version sent UDP datagram with
ns-udpsender, but didn't verify receiving it on rhost and didn't setup
rhost ip at all)
Suggested-by: Alexey Kodanev <alexey.kodanev@oracle.com>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
runtest/net_stress.route | 7 +-
.../network/stress/route/00_Descriptions.txt | 18 +-
.../network/stress/route/route-change-dst.sh | 34 +++
testcases/network/stress/route/route-lib.sh | 17 ++
.../network/stress/route/route4-change-dst | 276 ------------------
.../network/stress/route/route6-change-dst | 272 -----------------
6 files changed, 56 insertions(+), 568 deletions(-)
create mode 100755 testcases/network/stress/route/route-change-dst.sh
create mode 100644 testcases/network/stress/route/route-lib.sh
delete mode 100644 testcases/network/stress/route/route4-change-dst
delete mode 100644 testcases/network/stress/route/route6-change-dst
diff --git a/runtest/net_stress.route b/runtest/net_stress.route
index 266ef0383..5ffd57b12 100644
--- a/runtest/net_stress.route
+++ b/runtest/net_stress.route
@@ -1,14 +1,11 @@
-#
# Stress test for routing table
-#
-
-route4-change-dst route4-change-dst
+route4-change-dst route-change-dst.sh
route4-change-gw route4-change-gw
route4-change-if route4-change-if
route4-redirect route4-redirect
route4-rmmod route4-rmmod
-route6-change-dst route6-change-dst
+route6-change-dst route-change-dst.sh -6
route6-change-gw route6-change-gw
route6-change-if route6-change-if
route6-redirect route6-redirect
diff --git a/testcases/network/stress/route/00_Descriptions.txt b/testcases/network/stress/route/00_Descriptions.txt
index 2a871fdae..d8a83b327 100644
--- a/testcases/network/stress/route/00_Descriptions.txt
+++ b/testcases/network/stress/route/00_Descriptions.txt
@@ -1,10 +1,6 @@
-route4-change-dst01
- Verify the kernel is not crashed when the destination of an IPv4 route
- is changed frequently by route command
-
-route4-change-dst02
- Verify the kernel is not crashed when the destination of an IPv4 route
- is changed frequently by ip command
+route{4,6}-change-dst
+ Verify the IPv4/IPv6 is not broken when ip command changes route
+ destination many times
route4-change-gw01
Verify the kernel is not crashed when the gateway of an IPv4 route is
@@ -35,14 +31,6 @@ route4-rmmod02
then it is deleted by the removing network driver
-route6-change-dst01
- Verify the kernel is not crashed when the destination of an IPv6 route
- is changed frequently by route command
-
-route6-change-dst02
- Verify the kernel is not crashed when the destination of an IPv6 route
- is changed frequently by ip command
-
route6-change-gw01
Verify the kernel is not crashed when the gateway of an IPv6 route is
changed frequently by route command
diff --git a/testcases/network/stress/route/route-change-dst.sh b/testcases/network/stress/route/route-change-dst.sh
new file mode 100755
index 000000000..beec2dfad
--- /dev/null
+++ b/testcases/network/stress/route/route-change-dst.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2019 Petr Vorel <pvorel@suse.cz>
+# Copyright (c) International Business Machines Corp., 2006
+# Author: Mitsuru Chinen <mitch@jp.ibm.com>
+# Rewrite into new shell API: Petr Vorel
+#
+# Change route destination
+# lhost: 10.0.0.2, rhost: 10.23.x.1
+
+TST_TESTFUNC="test_dst"
+. route-lib.sh
+
+setup()
+{
+ tst_res TINFO "change IPv$TST_IPVER route destination $NS_TIMES times"
+}
+
+test_dst()
+{
+ local iface="$(tst_iface)"
+ local rt="$(tst_ipaddr_un -p $1)"
+ local rhost="$(tst_ipaddr_un $1 1)"
+
+ tst_res TINFO "testing route '$rt'"
+
+ tst_add_ipaddr -s -a $rhost rhost
+ ROD ip route add $rt dev $iface
+ EXPECT_PASS ping$TST_IPV6 -c1 -I $(tst_ipaddr) $rhost \>/dev/null
+ ROD ip route del $rt dev $iface
+ tst_del_ipaddr -s -a $rhost rhost
+}
+
+tst_run
diff --git a/testcases/network/stress/route/route-lib.sh b/testcases/network/stress/route/route-lib.sh
new file mode 100644
index 000000000..4afbe6323
--- /dev/null
+++ b/testcases/network/stress/route/route-lib.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2019 Petr Vorel <pvorel@suse.cz>
+
+TST_NEEDS_ROOT=1
+TST_SETUP="setup"
+TST_CLEANUP="route_cleanup"
+TST_NEEDS_CMDS="ip"
+TST_CNT=$NS_TIMES
+
+. tst_net.sh
+
+route_cleanup()
+{
+ tst_restore_ipaddr
+ tst_restore_ipaddr rhost
+}
diff --git a/testcases/network/stress/route/route4-change-dst b/testcases/network/stress/route/route4-change-dst
deleted file mode 100644
index 8ec606152..000000000
--- a/testcases/network/stress/route/route4-change-dst
+++ /dev/null
@@ -1,276 +0,0 @@
-#!/bin/sh
-
-################################################################################
-## ##
-## Copyright (c) International Business Machines Corp., 2006 ##
-## ##
-## This program is free software; you can redistribute it and#or modify ##
-## it under the terms of the GNU General Public License as published by ##
-## the Free Software Foundation; either version 2 of the License, or ##
-## (at your option) any later version. ##
-## ##
-## This program is distributed in the hope that it will be useful, but ##
-## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
-## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ##
-## for more details. ##
-## ##
-## You should have received a copy of the GNU General Public License ##
-## along with this program; if not, write to the Free Software ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ##
-## ##
-## ##
-################################################################################
-#
-# File:
-# route4-change-dst
-#
-# Description:
-# Verify the kernel is not crashed when the destination of an IPv4 route is
-# changed frequently
-# test01 - by route command
-# test02 - by ip command
-#
-# Setup:
-# See testcases/network/stress/README
-#
-# Author:
-# Mitsuru Chinen <mitch@jp.ibm.com>
-#
-# History:
-# Mar 16 2006 - Created (Mitsuru Chinen)
-#
-#-----------------------------------------------------------------------
-# Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-# Make sure the value of LTPROOT
-LTPROOT=${LTPROOT:-`(cd ../../../../ ; pwd)`}
-export LTPROOT
-
-# Total number of the test case
-TST_TOTAL=2
-export TST_TOTAL
-
-# Default of the test case ID and the test case count
-TCID=route4-change-dst
-TST_COUNT=0
-export TCID
-export TST_COUNT
-
-# Check the environmanet variable
-. check_envval || exit $TST_TOTAL
-
-# The number of times where route is changed
-NS_TIMES=${NS_TIMES:-10000}
-
-# The number of the test link where tests run
-LINK_NUM=${LINK_NUM:-0}
-
-# Network portion of the IPv4 address
-IPV4_NETWORK=${IPV4_NETWORK:-"10.0.0"}
-
-# Netmask of for the tested network
-IPV4_NETMASK="255.255.255.0"
-IPV4_NETMASK_NUM=24
-
-# Broadcast address of the tested network
-IPV4_BROADCAST=${IPV4_NETWORK}.255
-
-# Host portion of the IPv4 address
-LHOST_IPV4_HOST=${LHOST_IPV4_HOST:-"2"} # src
-RHOST_IPV4_HOST=${RHOST_IPV4_HOST:-"1"} # gateway
-
-# The destination network
-DST_NETWORK_PREFIX="10.10" # destination network would be 10.10.n.0/24
-DST_HOST="5"
-DST_PORT="7"
-
-
-#-----------------------------------------------------------------------
-#
-# NAME:
-# do_setup
-#
-# DESCRIPTION:
-# Make a IPv4 connectivity
-#
-# SET VALUES:
-# rhost_ipv4addr - IPv4 Address of the remote host
-# lhost_ifname - Interface name of the local host
-# rhost_ifname - Interface name of the remote host
-#
-#-----------------------------------------------------------------------
-do_setup()
-{
- TCID=route4-change-dst
- TST_COUNT=0
-
- # Initialize the interfaces of the remote host
- initialize_if rhost ${LINK_NUM}
-
- # Set IPv4 address to the interfaces
- set_ipv4addr rhost ${LINK_NUM} ${IPV4_NETWORK} ${RHOST_IPV4_HOST}
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Failed to add an IPv4 address the remote host"
- exit $TST_TOTAL
- fi
-
- # IPv4 address of the remote host (gateway)
- rhost_ipv4addr="${IPV4_NETWORK}.${RHOST_IPV4_HOST}"
-
- # Get the Interface name of local host
- lhost_ifname=`get_ifname lhost ${LINK_NUM}`
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Failed to get the interface name at the local host"
- exit $TST_TOTAL
- fi
-
- # Get the Interface name of remote host
- rhost_ifname=`get_ifname rhost ${LINK_NUM}`
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Failed to get the interface name at the remote host"
- exit $TST_TOTAL
- fi
-}
-
-
-
-#-----------------------------------------------------------------------
-#
-# NAME:
-# do_cleanup
-#
-# DESCRIPTION:
-# Recover the tested interfaces
-#
-#-----------------------------------------------------------------------
-do_cleanup()
-{
- # Initialize the interfaces
- initialize_if lhost ${LINK_NUM}
- initialize_if rhost ${LINK_NUM}
-}
-
-
-#-----------------------------------------------------------------------
-#
-# FUNCTION:
-# test_body
-#
-# DESCRIPTION:
-# main code of the test
-#
-# Arguments:
-# $1: define the test type
-# 1 - route command case
-# 2 - ip command case
-#
-#-----------------------------------------------------------------------
-test_body()
-{
- test_type=$1
-
- TCID=route4-change-dst0${test_type}
- TST_COUNT=$test_type
-
- case $test_type in
- 1)
- test_command="route"
- ;;
- 2)
- test_command="ip"
- ;;
- *)
- tst_resm TBROK "unspecified case"
- return 1
- ;;
- esac
-
- tst_resm TINFO "Verify the kernel is not crashed when the destination of an IPv4 route is changed frequently by $test_command command in $NS_TIMES times"
-
- # Initialize the interface of the local host
- initialize_if lhost ${LINK_NUM}
-
- # Assign IPv4 address to the interface of the local host
- set_ipv4addr lhost ${LINK_NUM} ${IPV4_NETWORK} ${LHOST_IPV4_HOST}
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Failed to assign an IPv4 address at the local host"
- return 1
- fi
- lhost_ipv4addr="${IPV4_NETWORK}.${LHOST_IPV4_HOST}"
-
- # Check the connectivity to the gateway
- check_icmpv4_connectivity $lhost_ifname $rhost_ipv4addr
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Test Link $LINK_NUM is somthing wrong."
- return 1
- fi
-
- # Start the loop
- cnt=0
- while [ $cnt -lt $NS_TIMES ]; do
- # Define the destination IP address
- dst_network_postfix=`expr $cnt % 255`
- dst_addr=${DST_NETWORK_PREFIX}.${dst_network_postfix}.${DST_HOST}
- dst_network=${DST_NETWORK_PREFIX}.${dst_network_postfix}.0
-
- # Add the route
- case $test_type in
- 1)
- route add -net $dst_network netmask 255.255.255.0 gw $rhost_ipv4addr dev $lhost_ifname
- ;;
- 2)
- ip route add ${dst_network}/24 via $rhost_ipv4addr dev $lhost_ifname
- ;;
- esac
- if [ $? -ne 0 ]; then
- tst_resm TFAIL "Failed to add the route to ${dst_network}/24"
- return 1
- fi
-
- # Load the route with UDP datagram
- ns-udpsender -f 4 -D $dst_addr -p $DST_PORT -o -s 1472
- if [ $? -ne 0 ]; then
- tst_resm TFAIL "Failed to run a UDP datagram sender"
- return 1
- fi
-
- # Delete the route
- case $test_type in
- 1)
- route del -net $dst_network netmask 255.255.255.0 gw $rhost_ipv4addr dev $lhost_ifname
- ;;
- 2)
- ip route del ${dst_network}/24 via $rhost_ipv4addr dev $lhost_ifname
- ;;
- esac
- if [ $? -ne 0 ]; then
- tst_resm TFAIL "Cannot delete the route to ${ADDDEL_ROUTE}"
- return 1
- fi
-
- cnt=`expr $cnt + 1`
- done
-
- tst_resm TPASS "Test is finished correctly."
- return 0
-}
-
-
-#-----------------------------------------------------------------------
-#
-# Main
-#
-# Exit Value:
-# The number of the failure
-#
-#-----------------------------------------------------------------------
-
-RC=0
-do_setup
-test_body 1 || RC=`expr $RC + 1` # Case of route command
-test_body 2 || RC=`expr $RC + 1` # Case of ip command
-do_cleanup
-
-exit $RC
diff --git a/testcases/network/stress/route/route6-change-dst b/testcases/network/stress/route/route6-change-dst
deleted file mode 100644
index 2aa953396..000000000
--- a/testcases/network/stress/route/route6-change-dst
+++ /dev/null
@@ -1,272 +0,0 @@
-#!/bin/sh
-
-################################################################################
-## ##
-## Copyright (c) International Business Machines Corp., 2006 ##
-## ##
-## This program is free software; you can redistribute it and#or modify ##
-## it under the terms of the GNU General Public License as published by ##
-## the Free Software Foundation; either version 2 of the License, or ##
-## (at your option) any later version. ##
-## ##
-## This program is distributed in the hope that it will be useful, but ##
-## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
-## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ##
-## for more details. ##
-## ##
-## You should have received a copy of the GNU General Public License ##
-## along with this program; if not, write to the Free Software ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ##
-## ##
-## ##
-################################################################################
-#
-# File:
-# route6-change-dst
-#
-# Description:
-# Verify the kernel is not crashed when the destination of an IPv6 route is
-# changed frequently
-# test01 - by route command
-# test02 - by ip command
-#
-# Setup:
-# See testcases/network/stress/README
-#
-# Author:
-# Mitsuru Chinen <mitch@jp.ibm.com>
-#
-# History:
-# Mar 16 2006 - Created (Mitsuru Chinen)
-#
-#-----------------------------------------------------------------------
-# Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-# Make sure the value of LTPROOT
-LTPROOT=${LTPROOT:-`(cd ../../../../ ; pwd)`}
-export LTPROOT
-
-# Total number of the test case
-TST_TOTAL=2
-export TST_TOTAL
-
-# Default of the test case ID and the test case count
-TCID=route6-change-dst
-TST_COUNT=0
-export TCID
-export TST_COUNT
-
-# Check the environmanet variable
-. check_envval || exit $TST_TOTAL
-
-# The number of times where route is changed
-NS_TIMES=${NS_TIMES:-10000}
-
-# The number of the test link where tests run
-LINK_NUM=${LINK_NUM:-0}
-
-# Network portion of the IPv6 address
-IPV6_NETWORK="fec0:1:1:1"
-
-# Netmask of for the tested network
-IPV6_NETMASK_NUM=64
-
-# Host portion of the IPv6 address
-LHOST_IPV6_HOST=":2" # src
-RHOST_IPV6_HOST=":3" # gateway
-
-# The destination network
-DST_NETWORK_PREFIX="fd00:100:1" # dest network would be fd00:100:1:n:::/64
-DST_HOST="5"
-DST_PORT="7"
-
-
-#-----------------------------------------------------------------------
-#
-# NAME:
-# do_setup
-#
-# DESCRIPTION:
-# Make a IPv6 connectivity
-#
-# SET VALUES:
-# rhost_ipv6addr - IPv6 Address of the remote host
-# lhost_ifname - Interface name of the local host
-# rhost_ifname - Interface name of the remote host
-#
-#-----------------------------------------------------------------------
-do_setup()
-{
- TCID=route6-change-dst
- TST_COUNT=0
-
- # Initialize the interfaces of the remote host
- initialize_if rhost ${LINK_NUM}
-
- # Set IPv6 address to the interfaces
- add_ipv6addr rhost ${LINK_NUM} ${IPV6_NETWORK} ${RHOST_IPV6_HOST}
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Failed to add an IPv6 address the remote host"
- exit $TST_TOTAL
- fi
-
- # IPv6 address of the remote host (gateway)
- rhost_ipv6addr="${IPV6_NETWORK}:${RHOST_IPV6_HOST}"
-
- # Get the Interface name of local host
- lhost_ifname=`get_ifname lhost ${LINK_NUM}`
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Failed to get the interface name at the local host"
- exit $TST_TOTAL
- fi
-
- # Get the Interface name of remote host
- rhost_ifname=`get_ifname rhost ${LINK_NUM}`
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Failed to get the interface name at the remote host"
- exit $TST_TOTAL
- fi
-}
-
-
-#-----------------------------------------------------------------------
-#
-# NAME:
-# do_cleanup
-#
-# DESCRIPTION:
-# Recover the tested interfaces
-#
-#-----------------------------------------------------------------------
-do_cleanup()
-{
- # Initialize the interfaces
- initialize_if lhost ${LINK_NUM}
- initialize_if rhost ${LINK_NUM}
-}
-
-
-#-----------------------------------------------------------------------
-#
-# FUNCTION:
-# test_body
-#
-# DESCRIPTION:
-# main code of the test
-#
-# Arguments:
-# $1: define the test type
-# 1 - route command case
-# 2 - ip command case
-#
-#-----------------------------------------------------------------------
-test_body()
-{
- test_type=$1
-
- TCID=route6-change-dst0${test_type}
- TST_COUNT=$test_type
-
- case $test_type in
- 1)
- test_command="route"
- ;;
- 2)
- test_command="ip"
- ;;
- *)
- tst_resm TBROK "unspecified case"
- return 1
- ;;
- esac
-
- tst_resm TINFO "Verify the kernel is not crashed when the destination of an IPv6 route is changed frequently by $test_command command in $NS_TIMES times"
-
- # Initialize the interface of the local host
- initialize_if lhost ${LINK_NUM}
-
- # Assign IPv6 address to the interface of the local host
- add_ipv6addr lhost ${LINK_NUM} ${IPV6_NETWORK} ${LHOST_IPV6_HOST}
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Failed to assign an IPv6 address at the local host"
- return 1
- fi
- lhost_ipv6addr="${IPV6_NETWORK}:${LHOST_IPV6_HOST}"
-
- # Check the connectivity to the gateway
- check_icmpv6_connectivity $lhost_ifname $rhost_ipv6addr
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Test Link $LINK_NUM is something wrong."
- return 1
- fi
-
- # Start the loop
- cnt=0
- while [ $cnt -lt $NS_TIMES ]; do
- # Define the destination IP address
- tmp_postfix=`expr $cnt % 65535`
- dst_network_postfix=`printf "%x" $tmp_postfix`
- dst_addr=${DST_NETWORK_PREFIX}:${dst_network_postfix}::${DST_HOST}
- dst_network=${DST_NETWORK_PREFIX}:${dst_network_postfix}::
-
- # Add the route
- case $test_type in
- 1)
- route -A inet6 add ${dst_network}/64 gw $rhost_ipv6addr dev $lhost_ifname
- ;;
- 2)
- ip -f inet6 route add ${dst_network}/64 via $rhost_ipv6addr dev $lhost_ifname
- ;;
- esac
- if [ $? -ne 0 ]; then
- tst_resm TFAIL "Failed to add the route to ${dst_network}/64"
- return 1
- fi
-
- # Load the route with UDP datagram
- ns-udpsender -f 6 -D $dst_addr -p $DST_PORT -o -s 1452
- if [ $? -ne 0 ]; then
- tst_resm TFAIL "Failed to run a UDP datagram sender"
- return 1
- fi
-
- # Delete the route
- case $test_type in
- 1)
- route -A inet6 del ${dst_network}/64 gw $rhost_ipv6addr dev $lhost_ifname
- ;;
- 2)
- ip -f inet6 route del ${dst_network}/64 via $rhost_ipv6addr dev $lhost_ifname
- ;;
- esac
- if [ $? -ne 0 ]; then
- tst_resm TFAIL "Cannot delete the route to ${ADDDEL_ROUTE}"
- return 1
- fi
-
- cnt=`expr $cnt + 1`
- done
-
- tst_resm TPASS "Test is finished correctly."
- return 0
-}
-
-
-#-----------------------------------------------------------------------
-#
-# Main
-#
-# Exit Value:
-# The number of the failure
-#
-#-----------------------------------------------------------------------
-
-RC=0
-do_setup
-test_body 1 || RC=`expr $RC + 1` # Case of route command
-test_body 2 || RC=`expr $RC + 1` # Case of ip command
-do_cleanup
-
-exit $RC
--
2.22.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [LTP] [PATCH v4 6/7] network/route: Rewrite route{4, 6}-change-gw into new shell API
2019-09-03 14:16 [LTP] [PATCH v4 0/7] net/route: rewrite route-change-{dst, gw, if} into new API Petr Vorel
` (4 preceding siblings ...)
2019-09-03 14:16 ` [LTP] [PATCH v4 5/7] network/route: Rewrite route{4, 6}-change-dst into new shell API Petr Vorel
@ 2019-09-03 14:16 ` Petr Vorel
2019-09-03 14:16 ` [LTP] [PATCH v4 7/7] network/route: Rewrite route{4, 6}-change-if into new API Petr Vorel
2019-09-12 12:56 ` [LTP] [PATCH v4 0/7] net/route: rewrite route-change-{dst, gw, if} " Alexey Kodanev
7 siblings, 0 replies; 15+ messages in thread
From: Petr Vorel @ 2019-09-03 14:16 UTC (permalink / raw)
To: ltp
* Drop route command (use just ip command), support both IPv4 and IPv6
* Use unused network range to avoid clash with real network
* Add verification with ping (previous version sent UDP datagram with
ns-udpsender, but didn't verify receiving it on rhost and didn't setup
rhost ip at all)
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
runtest/net_stress.route | 4 +-
.../network/stress/route/00_Descriptions.txt | 18 +-
.../network/stress/route/route-change-gw.sh | 39 +++
.../network/stress/route/route4-change-gw | 292 ------------------
.../network/stress/route/route6-change-gw | 292 ------------------
5 files changed, 44 insertions(+), 601 deletions(-)
create mode 100755 testcases/network/stress/route/route-change-gw.sh
delete mode 100644 testcases/network/stress/route/route4-change-gw
delete mode 100644 testcases/network/stress/route/route6-change-gw
diff --git a/runtest/net_stress.route b/runtest/net_stress.route
index 5ffd57b12..cde6d5d11 100644
--- a/runtest/net_stress.route
+++ b/runtest/net_stress.route
@@ -1,12 +1,12 @@
# Stress test for routing table
route4-change-dst route-change-dst.sh
-route4-change-gw route4-change-gw
+route4-change-gw route-change-gw.sh
route4-change-if route4-change-if
route4-redirect route4-redirect
route4-rmmod route4-rmmod
route6-change-dst route-change-dst.sh -6
-route6-change-gw route6-change-gw
+route6-change-gw route-change-gw.sh -6
route6-change-if route6-change-if
route6-redirect route6-redirect
route6-rmmod route6-rmmod
diff --git a/testcases/network/stress/route/00_Descriptions.txt b/testcases/network/stress/route/00_Descriptions.txt
index d8a83b327..bb8f46da6 100644
--- a/testcases/network/stress/route/00_Descriptions.txt
+++ b/testcases/network/stress/route/00_Descriptions.txt
@@ -2,13 +2,9 @@ route{4,6}-change-dst
Verify the IPv4/IPv6 is not broken when ip command changes route
destination many times
-route4-change-gw01
- Verify the kernel is not crashed when the gateway of an IPv4 route is
- changed frequently by route command
-
-route4-change-gw02
- Verify the kernel is not crashed when the gateway of an IPv4 route is
- changed frequently by ip command
+route{4,6}-change-gw
+ Verify the IPv4/IPv6 is not broken when ip command changes route
+ gateway many times
route4-change-if01
Verify the kernel is not crashed when the interface of an IPv4 route is
@@ -31,14 +27,6 @@ route4-rmmod02
then it is deleted by the removing network driver
-route6-change-gw01
- Verify the kernel is not crashed when the gateway of an IPv6 route is
- changed frequently by route command
-
-route6-change-gw02
- Verify the kernel is not crashed when the gateway of an IPv6 route is
- changed frequently by ip command
-
route6-change-if01
Verify the kernel is not crashed when the interface of an IPv6 route is
changed frequently by route command
diff --git a/testcases/network/stress/route/route-change-gw.sh b/testcases/network/stress/route/route-change-gw.sh
new file mode 100755
index 000000000..111227d90
--- /dev/null
+++ b/testcases/network/stress/route/route-change-gw.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2019 Petr Vorel <pvorel@suse.cz>
+# Copyright (c) International Business Machines Corp., 2006
+# Author: Mitsuru Chinen <mitch@jp.ibm.com>
+# Rewrite into new shell API: Petr Vorel
+#
+# Change route gateway
+# lhost: 10.23.x.2, gw (on rhost): 10.23.x.1, rhost: 10.23.0.1
+
+TST_TESTFUNC="test_gw"
+. route-lib.sh
+
+setup()
+{
+ tst_res TINFO "change IPv$TST_IPVER route gateway $NS_TIMES times"
+
+ rt="$(tst_ipaddr_un -p 0 0)"
+ lhost="$(tst_ipaddr_un 1 1)"
+ rhost="$(tst_ipaddr_un 0 1)"
+ tst_add_ipaddr -s -a $lhost
+ tst_add_ipaddr -s -a $rhost rhost
+}
+
+test_gw()
+{
+ local gw="$(tst_ipaddr_un -l 2 -m 254 1 $(($1 + 1)))"
+ local iface="$(tst_iface)"
+
+ tst_res TINFO "testing route over gateway '$gw'"
+
+ tst_add_ipaddr -s -a $gw rhost
+ ROD ip route add $rt dev $iface via $gw
+ EXPECT_PASS ping$TST_IPV6 -c1 -I $lhost $rhost \>/dev/null
+ ROD ip route del $rt dev $iface via $gw
+ tst_del_ipaddr -s -a $gw rhost
+}
+
+tst_run
diff --git a/testcases/network/stress/route/route4-change-gw b/testcases/network/stress/route/route4-change-gw
deleted file mode 100644
index 791f98cc7..000000000
--- a/testcases/network/stress/route/route4-change-gw
+++ /dev/null
@@ -1,292 +0,0 @@
-#!/bin/sh
-
-################################################################################
-## ##
-## Copyright (c) International Business Machines Corp., 2006 ##
-## ##
-## This program is free software; you can redistribute it and#or modify ##
-## it under the terms of the GNU General Public License as published by ##
-## the Free Software Foundation; either version 2 of the License, or ##
-## (at your option) any later version. ##
-## ##
-## This program is distributed in the hope that it will be useful, but ##
-## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
-## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ##
-## for more details. ##
-## ##
-## You should have received a copy of the GNU General Public License ##
-## along with this program; if not, write to the Free Software ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ##
-## ##
-## ##
-################################################################################
-#
-# File:
-# route4-change-gw
-#
-# Description:
-# Verify the kernel is not crashed when the gateway of an IPv4 route is
-# changed frequently
-# test01 - by route command
-# test02 - by ip command
-#
-# Setup:
-# See testcases/network/stress/README
-#
-# Author:
-# Mitsuru Chinen <mitch@jp.ibm.com>
-#
-# History:
-# Mar 16 2006 - Created (Mitsuru Chinen)
-#
-#-----------------------------------------------------------------------
-# Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-# Make sure the value of LTPROOT
-LTPROOT=${LTPROOT:-`(cd ../../../../ ; pwd)`}
-export LTPROOT
-
-# Total number of the test case
-TST_TOTAL=2
-export TST_TOTAL
-
-# Default of the test case ID and the test case count
-TCID=route4-change-gw
-TST_COUNT=0
-export TCID
-export TST_COUNT
-
-# Check the environmanet variable
-. check_envval || exit $TST_TOTAL
-
-# The number of times where route is changed
-NS_TIMES=${NS_TIMES:-10000}
-
-# The number of the test link where tests run
-LINK_NUM=${LINK_NUM:-0}
-
-# Network portion of the IPv4 address
-IPV4_NETWORK=${IPV4_NETWORK:-"10.0.0"}
-
-# Netmask of for the tested network
-IPV4_NETMASK_NUM=24
-
-# Broadcast address of the tested network
-IPV4_BROADCAST=${IPV4_NETWORK}.255
-
-# Host portion of the IPv4 address
-LHOST_IPV4_HOST=${LHOST_IPV4_HOST:-"1"} # src
-RHOST_IPV4_HOST_TOP="10" # gateway
-RHOST_IPV4_HOST_LAST=19
-
-# The destination network
-DST_NETWORK="10.10.0" # destination network would be 10.10.0.0/24
-DST_HOST="5"
-DST_PORT="7"
-
-
-#-----------------------------------------------------------------------
-#
-# NAME:
-# do_setup
-#
-# DESCRIPTION:
-# Make a IPv4 connectivity
-#
-# SET VALUES:
-# rhost_ipv4addr - IPv4 Address of the remote host
-# lhost_ifname - Interface name of the local host
-# rhost_ifname - Interface name of the remote host
-#
-#-----------------------------------------------------------------------
-do_setup()
-{
- TCID=route4-change-gw
- TST_COUNT=0
-
- # Get the Interface name of local host
- lhost_ifname=`get_ifname lhost ${LINK_NUM}`
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Failed to get the interface name at the local host"
- exit $TST_TOTAL
- fi
-
- # Get the Interface name of remote host
- rhost_ifname=`get_ifname rhost ${LINK_NUM}`
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Failed to get the interface name at the remote host"
- exit $TST_TOTAL
- fi
-
- # Initialize the interfaces of the remote host
- initialize_if rhost ${LINK_NUM}
-
- # Set IPv4 address to the interface of the remote host
- rhost_part=$RHOST_IPV4_HOST_TOP
- while [ $rhost_part -le $RHOST_IPV4_HOST_LAST ]; do
- ret=`$LTP_RSH $RHOST '( PATH=/sbin:/usr/sbin:$PATH ; ip addr add '${IPV4_NETWORK}.${rhost_part}/${IPV4_NETMASK_NUM}' broadcast '${IPV4_NETWORK}'.255 dev '$rhost_ifname' ) > /dev/null ; echo $?'`
- if [ $ret -ne 0 ]; then
- tst_resm TBROK "Failed to assign IP address to the interface at the remote host"
- exit $TST_TOTAL
- fi
- rhost_part=`expr $rhost_part + 1`
- done
-}
-
-
-#-----------------------------------------------------------------------
-#
-# NAME:
-# do_cleanup
-#
-# DESCRIPTION:
-# Recover the tested interfaces
-#
-#-----------------------------------------------------------------------
-do_cleanup()
-{
- killall -SIGHUP ns-udpsender >/dev/null 2>&1
-
- # Initialize the interfaces
- initialize_if lhost ${LINK_NUM}
- initialize_if rhost ${LINK_NUM}
-}
-
-
-#-----------------------------------------------------------------------
-#
-# FUNCTION:
-# test_body
-#
-# DESCRIPTION:
-# main code of the test
-#
-# Arguments:
-# $1: define the test type
-# 1 - route command case
-# 2 - ip command case
-#
-#-----------------------------------------------------------------------
-test_body()
-{
- test_type=$1
-
- TCID=route4-change-gw0${test_type}
- TST_COUNT=$test_type
-
- case $test_type in
- 1)
- test_command="route"
- ;;
- 2)
- test_command="ip"
- ;;
- *)
- tst_resm TBROK "unspecified case"
- return 1
- ;;
- esac
-
- tst_resm TINFO "Verify the kernel is not crashed when the gateway of an IPv4 route is changed frequently by $test_command command in $NS_TIMES times"
-
- # Initialize the interface of the local host
- initialize_if lhost ${LINK_NUM}
-
- # Assign IPv4 address to the interface of the local host
- set_ipv4addr lhost ${LINK_NUM} ${IPV4_NETWORK} ${LHOST_IPV4_HOST}
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Failed to assign an IPv4 address at the local host"
- return 1
- fi
-
- # Check the connectivity to the gateway
- rhost_part=$RHOST_IPV4_HOST_TOP
- check_icmpv4_connectivity $lhost_ifname ${IPV4_NETWORK}.${rhost_part}
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Test Link $LINK_NUM is somthing wrong."
- return 1
- fi
-
- # Set the variables regarding the destination host
- dst_addr=${DST_NETWORK}.${DST_HOST}
- dst_network=${DST_NETWORK}.0
-
- # Set the first route
- case $test_type in
- 1)
- route add -net $dst_network netmask 255.255.255.0 gw ${IPV4_NETWORK}.${rhost_part} dev $lhost_ifname
- ;;
- 2)
- ip route add ${dst_network}/24 via ${IPV4_NETWORK}.${rhost_part} dev $lhost_ifname
- ;;
- esac
-
- # Load the route with UDP traffic
- ns-udpsender -f 4 -D $dst_addr -p $DST_PORT -b -s 1472
- if [ $? -ne 0 ]; then
- tst_resm TFAIL "Failed to run a UDP datagram sender"
- return 1
- fi
-
- # Loop for changing the route
- cnt=0
- while [ $cnt -lt $NS_TIMES ]; do
- pre_rhost_part=$rhost_part
- rhost_part=`expr $rhost_part + 1`
- if [ $rhost_part -gt $RHOST_IPV4_HOST_LAST ]; then
- rhost_part=$RHOST_IPV4_HOST_TOP
- fi
-
- case $test_type in
- 1)
- route add -net $dst_network netmask 255.255.255.0 gw ${IPV4_NETWORK}.${rhost_part} dev $lhost_ifname
- route del -net $dst_network netmask 255.255.255.0 gw ${IPV4_NETWORK}.${pre_rhost_part} dev $lhost_ifname
- ;;
- 2)
- ip route change ${dst_network}/24 via ${IPV4_NETWORK}.${rhost_part} dev $lhost_ifname
- ;;
- esac
- if [ $? -ne 0 ]; then
- tst_resm TFAIL "Failed to change the gateway to ${IPV4_NETWORK}.${rhost_part}"
- return 1
- fi
-
- # Rerun if udp datagram sender is dead
- ps auxw | fgrep -v grep | grep ns-udpsender > /dev/null
- if [ $? -ne 0 ]; then
- ns-udpsender -f 4 -D $dst_addr -p $DST_PORT -b -s 1472
- if [ $? -ne 0 ]; then
- tst_resm TFAIL "Failed to run a UDP datagram sender"
- return 1
- fi
- fi
-
- cnt=`expr $cnt + 1`
- done
-
- # Kill the udp datagram sender
- killall -SIGHUP ns-udpsender >/dev/null 2>&1
-
- tst_resm TPASS "Test is finished correctly."
- return 0
-}
-
-
-#-----------------------------------------------------------------------
-#
-# Main
-#
-# Exit Value:
-# The number of the failure
-#
-#-----------------------------------------------------------------------
-
-RC=0
-do_setup
-test_body 1 || RC=`expr $RC + 1` # Case of route command
-test_body 2 || RC=`expr $RC + 1` # Case of ip command
-do_cleanup
-
-exit $RC
diff --git a/testcases/network/stress/route/route6-change-gw b/testcases/network/stress/route/route6-change-gw
deleted file mode 100644
index 05e45b907..000000000
--- a/testcases/network/stress/route/route6-change-gw
+++ /dev/null
@@ -1,292 +0,0 @@
-#!/bin/sh
-################################################################################
-## ##
-## Copyright (c) International Business Machines Corp., 2006 ##
-## ##
-## This program is free software; you can redistribute it and#or modify ##
-## it under the terms of the GNU General Public License as published by ##
-## the Free Software Foundation; either version 2 of the License, or ##
-## (at your option) any later version. ##
-## ##
-## This program is distributed in the hope that it will be useful, but ##
-## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
-## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ##
-## for more details. ##
-## ##
-## You should have received a copy of the GNU General Public License ##
-## along with this program; if not, write to the Free Software ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ##
-## ##
-## ##
-################################################################################
-#
-# File:
-# route6-change-gw
-#
-# Description:
-# Verify the kernel is not crashed when the gateway of an IPv6 route is
-# changed frequently
-# test01 - by route command
-# test02 - by ip command
-#
-# Setup:
-# See testcases/network/stress/README
-#
-# Author:
-# Mitsuru Chinen <mitch@jp.ibm.com>
-#
-# History:
-# Mar 16 2006 - Created (Mitsuru Chinen)
-#
-#-----------------------------------------------------------------------
-# Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-# Make sure the value of LTPROOT
-LTPROOT=${LTPROOT:-`(cd ../../../../ ; pwd)`}
-export LTPROOT
-
-# Total number of the test case
-TST_TOTAL=2
-export TST_TOTAL
-
-# Default of the test case ID and the test case count
-TCID=route6-change-gw
-TST_COUNT=0
-export TCID
-export TST_COUNT
-
-# Check the environmanet variable
-. check_envval || exit $TST_TOTAL
-
-# The number of times where route is changed
-NS_TIMES=${NS_TIMES:-10000}
-
-# The number of the test link where tests run
-LINK_NUM=${LINK_NUM:-0}
-
-# Network portion of the IPv6 address
-IPV6_NETWORK="fec0:1:1:1"
-
-# Netmask of for the tested network
-IPV6_NETMASK_NUM=64
-
-# Host portion of the IPv6 address
-LHOST_IPV6_HOST=":2" # src
-RHOST_IPV6_HOST_TOP="10" # gateway
-RHOST_IPV6_HOST_LAST="19"
-
-# The destination network
-DST_NETWORK="fd00:100:1:1" # dest network would be fd00:100:1:1:::/64
-DST_HOST="5"
-DST_PORT="7"
-
-
-#-----------------------------------------------------------------------
-#
-# NAME:
-# do_setup
-#
-# DESCRIPTION:
-# Make a IPv6 connectivity
-#
-# SET VALUES:
-# rhost_ipv6addr - IPv6 Address of the remote host
-# lhost_ifname - Interface name of the local host
-# rhost_ifname - Interface name of the remote host
-#
-#-----------------------------------------------------------------------
-do_setup()
-{
- TCID=route6-change-gw
- TST_COUNT=0
-
- # Get the Interface name of local host
- lhost_ifname=`get_ifname lhost ${LINK_NUM}`
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Failed to get the interface name at the local host"
- exit $TST_TOTAL
- fi
-
- # Get the Interface name of remote host
- rhost_ifname=`get_ifname rhost ${LINK_NUM}`
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Failed to get the interface name at the remote host"
- exit $TST_TOTAL
- fi
-
- # Initialize the interfaces of the remote host
- initialize_if rhost ${LINK_NUM}
-
- # Set IPv6 address to the interface of the remote host
- rhost_part=$RHOST_IPV6_HOST_TOP
- rhost_part_hex=`printf "%x" $rhost_part`
- while [ $rhost_part -le $RHOST_IPV6_HOST_LAST ]; do
- rhost_part_hex=":`printf "%x" $rhost_part`"
- add_ipv6addr rhost ${LINK_NUM} ${IPV6_NETWORK} ${rhost_part_hex}
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Failed to assign IP address to the interface at the remote host"
- exit $TST_TOTAL
- fi
- rhost_part=`expr $rhost_part + 1`
- done
-}
-
-
-#-----------------------------------------------------------------------
-#
-# NAME:
-# do_cleanup
-#
-# DESCRIPTION:
-# Recover the tested interfaces
-#
-#-----------------------------------------------------------------------
-do_cleanup()
-{
- killall -SIGHUP ns-udpsender >/dev/null 2>&1
-
- # Initialize the interfaces
- initialize_if lhost ${LINK_NUM}
- initialize_if rhost ${LINK_NUM}
-}
-
-
-#-----------------------------------------------------------------------
-#
-# FUNCTION:
-# test_body
-#
-# DESCRIPTION:
-# main code of the test
-#
-# Arguments:
-# $1: define the test type
-# 1 - route command case
-# 2 - ip command case
-#
-#-----------------------------------------------------------------------
-test_body()
-{
- test_type=$1
-
- TCID=route6-change-gw0${test_type}
- TST_COUNT=$test_type
-
- case $test_type in
- 1)
- test_command="route"
- ;;
- 2)
- test_command="ip"
- ;;
- *)
- tst_resm TBROK "unspecified case"
- return 1
- ;;
- esac
-
- tst_resm TINFO "Verify the kernel is not crashed when the gateway of an IPv6 route is changed frequently by $test_command command in $NS_TIMES times"
-
- # Initialize the interface of the local host
- initialize_if lhost ${LINK_NUM}
-
- # Assign IPv6 address to the interface of the local host
- add_ipv6addr lhost ${LINK_NUM} ${IPV6_NETWORK} ${LHOST_IPV6_HOST}
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Failed to assign an IPv6 address at the local host"
- return 1
- fi
-
- # Check the connectivity to the gateway
- rhost_part=$RHOST_IPV6_HOST_TOP
- rhost_part_hex=":`printf "%x" $rhost_part`"
- check_icmpv6_connectivity $lhost_ifname ${IPV6_NETWORK}:${rhost_part_hex}
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Test Link $LINK_NUM is somthing wrong."
- return 1
- fi
-
- # Set the variables regarding the destination host
- dst_addr=${DST_NETWORK}::${DST_HOST}
- dst_network=${DST_NETWORK}::
-
- # Set the first route
- case $test_type in
- 1)
- route -A inet6 add ${dst_network}/64 gw ${IPV6_NETWORK}:${rhost_part_hex} dev $lhost_ifname
- ;;
- 2)
- ip -f inet6 route add ${dst_network}/64 via ${IPV6_NETWORK}:${rhost_part_hex} dev $lhost_ifname
- ;;
- esac
-
- # Load the route with UDP traffic
- ns-udpsender -f 6 -D $dst_addr -p $DST_PORT -b -s 1452
- if [ $? -ne 0 ]; then
- tst_resm TFAIL "Failed to run a UDP datagram sender"
- return 1
- fi
-
- # Loop for changing the route
- cnt=0
- while [ $cnt -lt $NS_TIMES ]; do
- pre_rhost_part_hex=$rhost_part_hex
- rhost_part=`expr $rhost_part + 1`
- if [ $rhost_part -gt $RHOST_IPV6_HOST_LAST ]; then
- rhost_part=$RHOST_IPV6_HOST_TOP
- fi
- rhost_part_hex=":`printf "%x" $rhost_part`"
-
- case $test_type in
- 1)
- route -A inet6 add ${dst_network}/64 gw ${IPV6_NETWORK}:${rhost_part_hex} dev $lhost_ifname
- route -A inet6 del ${dst_network}/64 gw ${IPV6_NETWORK}:${pre_rhost_part_hex} dev $lhost_ifname
- ;;
- 2)
- ip -f inet6 route change ${dst_network}/64 via ${IPV6_NETWORK}:${rhost_part_hex} dev $lhost_ifname
- ;;
- esac
- if [ $? -ne 0 ]; then
- tst_resm TFAIL "Failed to change the gateway to ${IPV6_NETWORK}.${rhost_part}"
- return 1
- fi
-
- # Rerun if udp datagram sender is dead
- ps auxw | fgrep -v grep | grep ns-udpsender > /dev/null
- if [ $? -ne 0 ]; then
- ns-udpsender -f 4 -D $dst_addr -p $DST_PORT -o -s 1472
- if [ $? -ne 0 ]; then
- tst_resm TFAIL "Failed to run a UDP datagram sender"
- return 1
- fi
- fi
-
- cnt=`expr $cnt + 1`
- done
-
- # Kill the udp datagram sender
- killall -SIGHUP ns-udpsender >/dev/null 2>&1
-
- tst_resm TPASS "Test is finished correctly."
- return 0
-}
-
-
-#-----------------------------------------------------------------------
-#
-# Main
-#
-# Exit Value:
-# The number of the failure
-#
-#-----------------------------------------------------------------------
-
-RC=0
-do_setup
-test_body 1 || RC=`expr $RC + 1` # Case of route command
-test_body 2 || RC=`expr $RC + 1` # Case of ip command
-do_cleanup
-
-exit $RC
--
2.22.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [LTP] [PATCH v4 7/7] network/route: Rewrite route{4, 6}-change-if into new API
2019-09-03 14:16 [LTP] [PATCH v4 0/7] net/route: rewrite route-change-{dst, gw, if} into new API Petr Vorel
` (5 preceding siblings ...)
2019-09-03 14:16 ` [LTP] [PATCH v4 6/7] network/route: Rewrite route{4, 6}-change-gw " Petr Vorel
@ 2019-09-03 14:16 ` Petr Vorel
2019-09-12 12:56 ` [LTP] [PATCH v4 0/7] net/route: rewrite route-change-{dst, gw, if} " Alexey Kodanev
7 siblings, 0 replies; 15+ messages in thread
From: Petr Vorel @ 2019-09-03 14:16 UTC (permalink / raw)
To: ltp
* Drop route command (use just ip command), support both IPv4 and IPv6
* Use unused network range to avoid clash with real network
* Add verification with ping (previous version sent UDP datagram with
ns-udpsender, but didn't verify receiving it on rhost and didn't setup
rhost ip at all)
* Add tst_get_ifaces_cnt() into tst_net.sh
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
runtest/net_stress.route | 4 +-
testcases/lib/tst_net.sh | 8 +
.../network/stress/route/00_Descriptions.txt | 18 +-
.../network/stress/route/route-change-if.sh | 90 +++++
.../network/stress/route/route4-change-if | 324 ------------------
.../network/stress/route/route6-change-if | 323 -----------------
6 files changed, 103 insertions(+), 664 deletions(-)
create mode 100755 testcases/network/stress/route/route-change-if.sh
delete mode 100644 testcases/network/stress/route/route4-change-if
delete mode 100644 testcases/network/stress/route/route6-change-if
diff --git a/runtest/net_stress.route b/runtest/net_stress.route
index cde6d5d11..4eff6766a 100644
--- a/runtest/net_stress.route
+++ b/runtest/net_stress.route
@@ -1,12 +1,12 @@
# Stress test for routing table
route4-change-dst route-change-dst.sh
route4-change-gw route-change-gw.sh
-route4-change-if route4-change-if
+route4-change-if route-change-if.sh
route4-redirect route4-redirect
route4-rmmod route4-rmmod
route6-change-dst route-change-dst.sh -6
route6-change-gw route-change-gw.sh -6
-route6-change-if route6-change-if
+route6-change-if route-change-if.sh -6
route6-redirect route6-redirect
route6-rmmod route6-rmmod
diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh
index baeac6e10..16d0995ee 100644
--- a/testcases/lib/tst_net.sh
+++ b/testcases/lib/tst_net.sh
@@ -289,6 +289,14 @@ tst_get_ifaces()
fi
}
+# Get count of test interfaces for local/remote host.
+tst_get_ifaces_cnt()
+{
+ tst_test_cmds awk
+ local type="${1:-lhost}"
+ echo "$(tst_get_ifaces $type)" | awk '{print NF}'
+}
+
# Get HW addresses from defined test interface names.
# tst_get_hwaddrs [TYPE]
# TYPE: { lhost | rhost }; Default value is 'lhost'.
diff --git a/testcases/network/stress/route/00_Descriptions.txt b/testcases/network/stress/route/00_Descriptions.txt
index bb8f46da6..e0e2e42c6 100644
--- a/testcases/network/stress/route/00_Descriptions.txt
+++ b/testcases/network/stress/route/00_Descriptions.txt
@@ -6,13 +6,9 @@ route{4,6}-change-gw
Verify the IPv4/IPv6 is not broken when ip command changes route
gateway many times
-route4-change-if01
- Verify the kernel is not crashed when the interface of an IPv4 route is
- changed frequently by route command
-
-route4-change-if02
- Verify the kernel is not crashed when the interface of an IPv4 route is
- changed frequently by ip command
+route{4,6}-change-if
+ Verify the IPv4/IPv6 is not broken when ip command changes route
+ interface many times
route4-redirect01
Verify the kernel is not crashed when the IPv4 route is modified by
@@ -27,14 +23,6 @@ route4-rmmod02
then it is deleted by the removing network driver
-route6-change-if01
- Verify the kernel is not crashed when the interface of an IPv6 route is
- changed frequently by route command
-
-route6-change-if02
- Verify the kernel is not crashed when the interface of an IPv6 route is
- changed frequently by ip command
-
route6-redirect01
Verify the kernel is not crashed when the IPv6 route is modified by
ICMP Redirects frequently
diff --git a/testcases/network/stress/route/route-change-if.sh b/testcases/network/stress/route/route-change-if.sh
new file mode 100755
index 000000000..f2eda81b5
--- /dev/null
+++ b/testcases/network/stress/route/route-change-if.sh
@@ -0,0 +1,90 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2019 Petr Vorel <pvorel@suse.cz>
+# Copyright (c) International Business Machines Corp., 2006
+# Author: Mitsuru Chinen <mitch@jp.ibm.com>
+#
+# Change route interface
+# lhost: 10.23.x.2, gw (on rhost): 10.23.x.1, rhost: 10.23.0.1, switching ifaces on lhost
+
+TST_TESTFUNC="test_if"
+. route-lib.sh
+TST_CLEANUP="cleanup"
+
+add_macvlan()
+{
+ local action="add"
+ local OPTIND
+ while getopts d opt; do
+ case "$opt" in
+ d) action="del";;
+ esac
+ done
+ shift $((OPTIND - 1))
+
+ local iface="$1"
+ local type="${2:-lhost}"
+
+ cmd="ip link $action $iface link $(tst_iface $type) type macvlan mode bridge"
+ if [ $type = "lhost" ]; then
+ ROD $cmd
+ [ "$action" = "add" ] || return
+ LHOST_IFACES="$LHOST_IFACES $iface"
+ else
+ tst_rhost_run -s -c "$cmd"
+ [ "$action" = "add" ] || return
+ RHOST_IFACES="$RHOST_IFACES $iface"
+ fi
+ tst_init_iface $type 1
+}
+
+setup()
+{
+ tst_res TINFO "change IPv$TST_IPVER route interface $NS_TIMES times"
+
+ rt="$(tst_ipaddr_un -p 0)"
+ rhost="$(tst_ipaddr_un 0 1)"
+ tst_add_ipaddr -s -a $rhost rhost
+
+ if [ $(tst_get_ifaces_cnt) -lt 2 ]; then
+ new_liface="ltp_mv2"
+ tst_res TINFO "2 or more local ifaces required, adding $new_liface"
+ add_macvlan $new_liface
+ fi
+
+ if [ $(tst_get_ifaces_cnt rhost) -lt 2 ]; then
+ new_riface="ltp_mv1"
+ tst_res TINFO "2 or more remote ifaces required, adding $new_riface"
+ add_macvlan $new_riface rhost
+ fi
+}
+
+test_if()
+{
+ local max=253
+ [ "$TST_IPV6" ] && max=65533
+ local net_id=$(($1 % $max + 1))
+ local gw="$(tst_ipaddr_un $net_id 1)"
+ local lhost="$(tst_ipaddr_un $net_id 2)"
+ local link_num="$(($1 % $(tst_get_ifaces_cnt)))"
+ local iface="$(tst_iface lhost $link_num)"
+
+ tst_res TINFO "testing route over interface '$iface' with gateway '$gw'"
+
+ tst_add_ipaddr -s -a $lhost lhost $link_num
+ tst_add_ipaddr -s -a $gw rhost $link_num
+ ROD ip route add $rt dev $iface via $gw
+ EXPECT_PASS ping$TST_IPV6 -c1 -I $lhost $rhost \>/dev/null
+ ROD ip route del $rt dev $iface via $gw
+ tst_del_ipaddr -s -a $lhost lhost $link_num
+ tst_del_ipaddr -s -a $gw rhost $link_num
+}
+
+cleanup()
+{
+ [ "$new_liface" ] && add_macvlan -d $new_liface
+ [ "$new_riface" ] && add_macvlan -d $new_riface rhost
+ route_cleanup
+}
+
+tst_run
diff --git a/testcases/network/stress/route/route4-change-if b/testcases/network/stress/route/route4-change-if
deleted file mode 100644
index 8753203d0..000000000
--- a/testcases/network/stress/route/route4-change-if
+++ /dev/null
@@ -1,324 +0,0 @@
-#!/bin/sh
-
-################################################################################
-## ##
-## Copyright (c) International Business Machines Corp., 2006 ##
-## ##
-## This program is free software; you can redistribute it and#or modify ##
-## it under the terms of the GNU General Public License as published by ##
-## the Free Software Foundation; either version 2 of the License, or ##
-## (at your option) any later version. ##
-## ##
-## This program is distributed in the hope that it will be useful, but ##
-## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
-## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ##
-## for more details. ##
-## ##
-## You should have received a copy of the GNU General Public License ##
-## along with this program; if not, write to the Free Software ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ##
-## ##
-## ##
-################################################################################
-#
-# File:
-# route4-change-if
-#
-# Description:
-# Verify the kernel is not crashed when the interface of an IPv4 route is
-# changed frequently
-# test01 - by route command
-# test02 - by ip command
-#
-# Setup:
-# See testcases/network/stress/README
-#
-# Author:
-# Mitsuru Chinen <mitch@jp.ibm.com>
-#
-# History:
-# Mar 17 2006 - Created (Mitsuru Chinen)
-#
-#-----------------------------------------------------------------------
-# Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-# Make sure the value of LTPROOT
-LTPROOT=${LTPROOT:-`(cd ../../../../ ; pwd)`}
-export LTPROOT
-
-# Total number of the test case
-TST_TOTAL=2
-export TST_TOTAL
-
-# Default of the test case ID and the test case count
-TCID=route4-change-if
-TST_COUNT=0
-export TCID
-export TST_COUNT
-
-# Check the environmanet variable
-. check_envval || exit $TST_TOTAL
-
-# The number of times where route is changed
-NS_TIMES=${NS_TIMES:-10000}
-
-# The first 2 ocnted of the Network portion of the gateway address
-IPV4_NETWORK_PRE=${IPV4_NETWORK_PRE:-"10.0"}
-
-# Netmask of for the gateway
-IPV4_NETMASK_NUM=24
-
-# Host portion of the IPv4 address
-LHOST_IPV4_HOST=${LHOST_IPV4_HOST:-"2"} # src
-RHOST_IPV4_HOST=${RHOST_IPV4_HOST:-"1"} # gateway
-
-# The destination network
-DST_NETWORK="10.10.0" # destination network would be 10.10.0.0/24
-DST_HOST="5"
-DST_PORT="7"
-
-
-#-----------------------------------------------------------------------
-#
-# NAME:
-# do_setup
-#
-# DESCRIPTION:
-# Make a IPv4 connectivity
-#
-# SET VALUES:
-# rhost_ipv4addr - IPv4 Address of the remote host
-# lhost_ifname - Interface name of the local host
-# rhost_ifname - Interface name of the remote host
-#
-#-----------------------------------------------------------------------
-do_setup()
-{
- TCID=route4-change-if
- TST_COUNT=0
-
- # Get the number of the test links
- link_total=`echo $LHOST_HWADDRS | wc -w`
- rhost_link_total=`echo $RHOST_HWADDRS | wc -w`
- if [ $link_total -ne $rhost_link_total ]; then
- tst_resm TBROK "The number of element in LHOST_HWADDRS differs from RHOST_HWADDRS"
- exit $TST_TOTAL
- fi
- if [ $link_total -lt 2 ]; then
- tst_resm TBROK "This test case requires plural Test Links"
- exit $TST_TOTAL
- fi
-
- lhost_ifname_array=""
- rhost_ifname_array=""
- link_num=0
- while [ $link_num -lt $link_total ]; do
- # Get the Interface names of the local host
- lhost_ifname=`get_ifname lhost ${link_num}`
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Failed to get the interface name at the local host"
- exit $TST_TOTAL
- fi
- lhost_ifname_array="$lhost_ifname_array $lhost_ifname"
-
- # Get the Interface names of the remote host
- rhost_ifname=`get_ifname rhost ${link_num}`
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Failed to get the interface name at the remote host"
- exit $TST_TOTAL
- fi
- rhost_ifname_array="$rhost_ifname_array $rhost_ifname"
-
- # Initialize the interfaces of the remote host
- initialize_if rhost ${link_num}
-
- # Set IPv4 address to the interface of the remote host
- set_ipv4addr rhost ${link_num} "${IPV4_NETWORK_PRE}.${link_num}" ${RHOST_IPV4_HOST}
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Failed to assign IP address to the interface $rhost_ifname at the remote host"
- exit $TST_TOTAL
- fi
-
- link_num=`expr $link_num + 1`
- done
-}
-
-
-
-
-#-----------------------------------------------------------------------
-#
-# NAME:
-# do_cleanup
-#
-# DESCRIPTION:
-# Recover the tested interfaces
-#
-#-----------------------------------------------------------------------
-do_cleanup()
-{
- # Make sure to kill the udp datagram sender
- killall -SIGHUP ns-udpsender >/dev/null 2>&1
-
- # Initialize the interfaces
- link_num=0
- while [ $link_num -lt $link_total ]; do
- initialize_if lhost ${link_num}
- initialize_if rhost ${link_num}
- link_num=`expr $link_num + 1`
- done
-}
-
-
-#-----------------------------------------------------------------------
-#
-# FUNCTION:
-# test_body
-#
-# DESCRIPTION:
-# main code of the test
-#
-# Arguments:
-# $1: define the test type
-# 1 - route command case
-# 2 - ip command case
-#
-#-----------------------------------------------------------------------
-test_body()
-{
- test_type=$1
-
- TCID=route4-change-if0${test_type}
- TST_COUNT=$test_type
-
- case $test_type in
- 1)
- test_command="route"
- ;;
- 2)
- test_command="ip"
- ;;
- *)
- tst_resm TBROK "unspecified case"
- return 1
- ;;
- esac
-
- tst_resm TINFO "Verify the kernel is not crashed when the interface of an IPv4 route is changed frequently by $test_command command in $NS_TIMES times"
-
- link_num=0
- while [ $link_num -lt $link_total ]; do
- # Initialize the interface of the local host
- initialize_if lhost ${link_num}
-
- # Assign IPv4 address to the interface of the local host
- set_ipv4addr lhost ${link_num} "${IPV4_NETWORK_PRE}.${link_num}" ${LHOST_IPV4_HOST}
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Failed to assign an IPv4 address at the local host"
- return 1
- fi
-
- # Check the connectivity to the gateway
- field=`expr $link_num + 1`
- lhost_ifname=`echo $lhost_ifname_array | cut -d ' ' -f $field`
- check_icmpv4_connectivity $lhost_ifname "${IPV4_NETWORK_PRE}.${link_num}.${LHOST_IPV4_HOST}"
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Test Link $link_num is somthing wrong."
- return 1
- fi
- link_num=`expr $link_num + 1`
- done
-
- # Set the variables regarding the destination host
- dst_addr=${DST_NETWORK}.${DST_HOST}
- dst_network=${DST_NETWORK}.0
-
- # Set the first route
- link_num=0
- field=`expr $link_num + 1`
- lhost_ifname=`echo $lhost_ifname_array | cut -d ' ' -f $field`
- gateway="${IPV4_NETWORK_PRE}.${link_num}.${RHOST_IPV4_HOST}"
- case $test_type in
- 1)
- route add -net $dst_network netmask 255.255.255.0 gw $gateway dev $lhost_ifname
- ;;
- 2)
- ip route add ${dst_network}/24 via $gateway dev $lhost_ifname
- ;;
- esac
-
- # Load the route with UDP traffic
- ns-udpsender -f 4 -D $dst_addr -p $DST_PORT -b -s 1472
- if [ $? -ne 0 ]; then
- tst_resm TFAIL "Failed to run a UDP datagram sender"
- return 1
- fi
-
- # Loop for changing the route
- cnt=0
- while [ $cnt -lt $NS_TIMES ]; do
- link_num=`expr $link_num + 1`
- if [ $link_num -ge $link_total ]; then
- link_num=0
- fi
-
- pre_lhost_ifname=$lhost_ifname
- pre_gateway=$gateway
-
- field=`expr $link_num + 1`
- lhost_ifname=`echo $lhost_ifname_array | cut -d ' ' -f $field`
- gateway="${IPV4_NETWORK_PRE}.${link_num}.${RHOST_IPV4_HOST}"
-
- case $test_type in
- 1)
- route add -net $dst_network netmask 255.255.255.0 gw $gateway dev $lhost_ifname
- route del -net $dst_network netmask 255.255.255.0 gw $pre_gateway dev $pre_lhost_ifname
- ;;
- 2)
- ip route change ${dst_network}/24 via $gateway dev $lhost_ifname
- ;;
- esac
- if [ $? -ne 0 ]; then
- tst_resm TFAIL "Failed to change the gateway to $gateway"
- return 1
- fi
-
- # Rerun if udp datagram sender is dead
- ps auxw | fgrep -v grep | grep ns-udpsender > /dev/null
- if [ $? -ne 0 ]; then
- ns-udpsender -f 4 -D $dst_addr -p $DST_PORT -b -s 1472
- if [ $? -ne 0 ]; then
- tst_resm TFAIL "Failed to run a UDP datagram sender"
- return 1
- fi
- fi
-
- cnt=`expr $cnt + 1`
- done
-
- # Kill the udp datagram sender
- killall -SIGHUP ns-udpsender
-
- tst_resm TPASS "Test is finished correctly."
- return 0
-}
-
-
-#-----------------------------------------------------------------------
-#
-# Main
-#
-# Exit Value:
-# The number of the failure
-#
-#-----------------------------------------------------------------------
-
-RC=0
-do_setup
-test_body 1 || RC=`expr $RC + 1` # Case of route command
-test_body 2 || RC=`expr $RC + 1` # Case of ip command
-do_cleanup
-
-exit $RC
diff --git a/testcases/network/stress/route/route6-change-if b/testcases/network/stress/route/route6-change-if
deleted file mode 100644
index 051ba8bcc..000000000
--- a/testcases/network/stress/route/route6-change-if
+++ /dev/null
@@ -1,323 +0,0 @@
-#!/bin/sh
-
-################################################################################
-## ##
-## Copyright (c) International Business Machines Corp., 2006 ##
-## ##
-## This program is free software; you can redistribute it and#or modify ##
-## it under the terms of the GNU General Public License as published by ##
-## the Free Software Foundation; either version 2 of the License, or ##
-## (at your option) any later version. ##
-## ##
-## This program is distributed in the hope that it will be useful, but ##
-## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
-## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ##
-## for more details. ##
-## ##
-## You should have received a copy of the GNU General Public License ##
-## along with this program; if not, write to the Free Software ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ##
-## ##
-## ##
-################################################################################
-#
-# File:
-# route6-change-if
-#
-# Description:
-# Verify the kernel is not crashed when the interface of an IPv6 route is
-# changed frequently
-# test01 - by route command
-# test02 - by ip command
-#
-# Setup:
-# See testcases/network/stress/README
-#
-# Author:
-# Mitsuru Chinen <mitch@jp.ibm.com>
-#
-# History:
-# Mar 17 2006 - Created (Mitsuru Chinen)
-#
-#-----------------------------------------------------------------------
-# Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-# Make sure the value of LTPROOT
-LTPROOT=${LTPROOT:-`(cd ../../../../ ; pwd)`}
-export LTPROOT
-
-# Total number of the test case
-TST_TOTAL=2
-export TST_TOTAL
-
-# Default of the test case ID and the test case count
-TCID=route6-change-if
-TST_COUNT=0
-export TCID
-export TST_COUNT
-
-# Check the environmanet variable
-. check_envval || exit $TST_TOTAL
-
-# The number of times where route is changed
-NS_TIMES=${NS_TIMES:-10000}
-
-# The first 2 ocnted of the Network portion of the gateway address
-IPV6_NETWORK_PRE="fec0:1:1"
-
-# Netmask of for the gateway
-IPV6_NETMASK_NUM=64
-
-# Host portion of the IPv6 address
-LHOST_IPV6_HOST=":2" # src
-RHOST_IPV6_HOST=":1" # gateway
-
-# The destination network
-DST_NETWORK="fd00:100:1:1" # dest network would be fd00:100:1:1:::/64
-DST_HOST=":5"
-DST_PORT="7"
-
-
-#-----------------------------------------------------------------------
-#
-# NAME:
-# do_setup
-#
-# DESCRIPTION:
-# Make a IPv6 connectivity
-#
-# SET VALUES:
-# rhost_ipv6addr - IPv6 Address of the remote host
-# lhost_ifname - Interface name of the local host
-# rhost_ifname - Interface name of the remote host
-#
-#-----------------------------------------------------------------------
-do_setup()
-{
- TCID=route6-change-if
- TST_COUNT=0
-
- # Get the number of the test links
- link_total=`echo $LHOST_HWADDRS | wc -w`
- rhost_link_total=`echo $RHOST_HWADDRS | wc -w`
- if [ $link_total -ne $rhost_link_total ]; then
- tst_resm TBROK "The number of element in LHOST_HWADDRS differs from RHOST_HWADDRS"
- exit $TST_TOTAL
- fi
- if [ $link_total -lt 2 ]; then
- tst_resm TBROK "This test case requires plural Test Links"
- exit $TST_TOTAL
- fi
-
- lhost_ifname_array=""
- rhost_ifname_array=""
- link_num=0
- while [ $link_num -lt $link_total ]; do
- # Get the Interface names of the local host
- lhost_ifname=`get_ifname lhost ${link_num}`
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Failed to get the interface name at the local host"
- exit $TST_TOTAL
- fi
- lhost_ifname_array="$lhost_ifname_array $lhost_ifname"
-
- # Get the Interface names of the remote host
- rhost_ifname=`get_ifname rhost ${link_num}`
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Failed to get the interface name at the remote host"
- exit $TST_TOTAL
- fi
- rhost_ifname_array="$rhost_ifname_array $rhost_ifname"
-
- # Initialize the interfaces of the remote host
- initialize_if rhost ${link_num}
-
- # Set IPv6 address to the interface of the remote host
- add_ipv6addr rhost ${link_num} "${IPV6_NETWORK_PRE}:${link_num}" ${RHOST_IPV6_HOST}
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Failed to assign IP address to the interface $rhost_ifname at the remote host"
- exit $TST_TOTAL
- fi
-
- link_num=`expr $link_num + 1`
- done
-}
-
-
-#-----------------------------------------------------------------------
-#
-# NAME:
-# do_cleanup
-#
-# DESCRIPTION:
-# Recover the tested interfaces
-#
-#-----------------------------------------------------------------------
-do_cleanup()
-{
- # Make sure to kill the udp datagram sender
- killall -SIGHUP ns-udpsender >/dev/null 2>&1
-
- # Initialize the interfaces
- link_num=0
- while [ $link_num -lt $link_total ]; do
- initialize_if lhost ${link_num}
- initialize_if rhost ${link_num}
- link_num=`expr $link_num + 1`
- done
-}
-
-
-#-----------------------------------------------------------------------
-#
-# FUNCTION:
-# test_body
-#
-# DESCRIPTION:
-# main code of the test
-#
-# Arguments:
-# $1: define the test type
-# 1 - route command case
-# 2 - ip command case
-#
-#-----------------------------------------------------------------------
-test_body()
-{
- test_type=$1
-
- TCID=route6-change-if0${test_type}
- TST_COUNT=$test_type
-
- case $test_type in
- 1)
- test_command="route"
- ;;
- 2)
- test_command="ip"
- ;;
- *)
- tst_resm TBROK "unspecified case"
- return 1
- ;;
- esac
-
- tst_resm TINFO "Verify the kernel is not crashed when the interface of an IPv6 route is changed frequently by $test_command command in $NS_TIMES times"
-
- link_num=0
- while [ $link_num -lt $link_total ]; do
- # Initialize the interface of the local host
- initialize_if lhost ${link_num}
-
- # Assign IPv6 address to the interface of the local host
- add_ipv6addr lhost ${link_num} "${IPV6_NETWORK_PRE}:${link_num}" ${LHOST_IPV6_HOST}
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Failed to assign an IPv6 address at the local host"
- return 1
- fi
-
- # Check the connectivity to the gateway
- field=`expr $link_num + 1`
- lhost_ifname=`echo $lhost_ifname_array | cut -d ' ' -f $field`
- check_icmpv6_connectivity $lhost_ifname "${IPV6_NETWORK_PRE}:${link_num}:${LHOST_IPV6_HOST}"
- if [ $? -ne 0 ]; then
- tst_resm TBROK "Test Link $link_num is somthing wrong."
- return 1
- fi
- link_num=`expr $link_num + 1`
- done
-
- # Set the variables regarding the destination host
- dst_addr=${DST_NETWORK}:${DST_HOST}
- dst_network=${DST_NETWORK}::
-
- # Set the first route
- link_num=0
- field=`expr $link_num + 1`
- lhost_ifname=`echo $lhost_ifname_array | cut -d ' ' -f $field`
- gateway="${IPV6_NETWORK_PRE}:${link_num}:${RHOST_IPV6_HOST}"
- case $test_type in
- 1)
- route -A inet6 add ${dst_network}/64 gw $gateway dev $lhost_ifname
- ;;
- 2)
- ip -f inet6 route add ${dst_network}/64 via $gateway dev $lhost_ifname
- ;;
- esac
-
- # Load the route with UDP traffic
- ns-udpsender -f 6 -D $dst_addr -p $DST_PORT -b -s 1452
- if [ $? -ne 0 ]; then
- tst_resm TFAIL "Failed to run a UDP datagram sender"
- return 1
- fi
-
- # Loop for changing the route
- cnt=0
- while [ $cnt -lt $NS_TIMES ]; do
- link_num=`expr $link_num + 1`
- if [ $link_num -ge $link_total ]; then
- link_num=0
- fi
-
- pre_lhost_ifname=$lhost_ifname
- pre_gateway=$gateway
-
- field=`expr $link_num + 1`
- lhost_ifname=`echo $lhost_ifname_array | cut -d ' ' -f $field`
- gateway="${IPV6_NETWORK_PRE}:${link_num}:${RHOST_IPV6_HOST}"
-
- case $test_type in
- 1)
- route -A inet6 add ${dst_network}/64 gw $gateway dev $lhost_ifname
- route -A inet6 del ${dst_network}/64 gw $pre_gateway dev $pre_lhost_ifname
- ;;
- 2)
- ip -f inet6 route add ${dst_network}/64 via $gateway dev $lhost_ifname
- ip -f inet6 route del ${dst_network}/64 via $pre_gateway dev $pre_lhost_ifname
- ;;
- esac
- if [ $? -ne 0 ]; then
- tst_resm TFAIL "Failed to change the gateway to $gateway"
- return 1
- fi
-
- # Rerun if udp datagram sender is dead
- ps auxw | fgrep -v grep | grep ns-udpsender > /dev/null
- if [ $? -ne 0 ]; then
- ns-udpsender -f 6 -D $dst_addr -p $DST_PORT -b -s 1452
- if [ $? -ne 0 ]; then
- tst_resm TFAIL "Failed to run a UDP datagram sender"
- return 1
- fi
- fi
-
- cnt=`expr $cnt + 1`
- done
-
- # Kill the udp datagram sender
- killall -SIGHUP ns-udpsender
-
- tst_resm TPASS "Test is finished correctly."
- return 0
-}
-
-
-#-----------------------------------------------------------------------
-#
-# Main
-#
-# Exit Value:
-# The number of the failure
-#
-#-----------------------------------------------------------------------
-
-RC=0
-do_setup
-test_body 1 || RC=`expr $RC + 1` # Case of route command
-test_body 2 || RC=`expr $RC + 1` # Case of ip command
-do_cleanup
-
-exit $RC
--
2.22.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [LTP] [PATCH v4 1/7] tst_net.sh: enhance tst_add_ipaddr(), add tst_del_ipaddr()
2019-09-03 14:16 ` [LTP] [PATCH v4 1/7] tst_net.sh: enhance tst_add_ipaddr(), add tst_del_ipaddr() Petr Vorel
@ 2019-09-12 12:12 ` Alexey Kodanev
2019-09-12 13:26 ` Petr Vorel
0 siblings, 1 reply; 15+ messages in thread
From: Alexey Kodanev @ 2019-09-12 12:12 UTC (permalink / raw)
To: ltp
Hi Petr,
On 03.09.2019 17:16, Petr Vorel wrote:
> These changes are intended for easier handling with IP addresses
> (not have to calculate dad for IPv6 when adding IP address).
> Add -a IP and -s options to tst_add_ipaddr()
>
> tst_del_ipaddr() (which uses internally tst_add_ipaddr()) is defined
> mainly for better code readability.
...
>
> - tst_res_ TINFO "set remote addr $(tst_ipaddr rhost)/$mask"
> - tst_rhost_run -c "ip addr add $(tst_ipaddr rhost)/$mask dev $iface $dad"
> + tst_res_ TINFO "set remote addr $addr"
^
Should be $action here?
> + tst_rhost_run $rsafe -c "ip addr $action $addr dev $iface $dad"
> +}
> +
> +# tst_del_ipaddr [ tst_add_ipaddr options ]
> +# Delete IP address
> +tst_del_ipaddr()
> +{
> + tst_add_ipaddr -d $@
> }
>
> # tst_restore_ipaddr [TYPE] [LINK]
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [LTP] [PATCH v4 3/7] tst_net.sh: Add (mostly) HOST_ID related options to tst_ipaddr_un
2019-09-03 14:16 ` [LTP] [PATCH v4 3/7] tst_net.sh: Add (mostly) HOST_ID related options to tst_ipaddr_un Petr Vorel
@ 2019-09-12 12:41 ` Alexey Kodanev
0 siblings, 0 replies; 15+ messages in thread
From: Alexey Kodanev @ 2019-09-12 12:41 UTC (permalink / raw)
To: ltp
Petr,
On 9/3/19 5:16 PM, Petr Vorel wrote:
> These options are important for looping over max HOST_ID (255 resp.
> 0xffff for IPv6), when different than the default range.
>
> Added -b, -h -l, -m, -n and -p options:
> -b: use also *broadcast* address (HOST_ID: IPv4: 255, IPv6: 0xffff),
> equivalent of -m 255 or -m 65535, cannot be combined with -f, -h, -l, -m, -n
>
> -c COUNTER: integer value for counting HOST_ID and NET_ID (default: 1)
>
> -f: use *full* address range (<0,255> resp. <0,65535>), cannot be combined
> with -b, -h, -l, -m, -n
>
> -h: use only *host* address range (<1,254> resp. <1,65534>), default for
> counter mode, cannot be combined with -b, -f, -l, -m, -n
>
> -l MIN_HOST_ID: specify minimal allowed HOST_ID allowed minimal HOST_ID,
> cannot be combined with -b, -f, -h, -n
>
> -m MAX_HOST_ID: specify max allowed HOST_ID (default NET_ID -1), cannot be
> combined with -b, -f, -h, -n
>
> -n: use also *network* address (HOST_ID: 0), equivalent of -l 0, cannot be
> combined with -b, -f, -h, -l, -m
>
> -p: print also prefix
>
> NOTE: The default range for host_id & net_id changed from <0, 254 resp. 65534> to
> <0, 254 resp. 65535>: broadcast bit was added.
> For backwards compatibility -n must be used.
> But non of the code used host_id & net_id in loop => no change needed.
>
Not sure why extra -b, -f, -n and -h options are needed if there are -l and -m
options can do the same or I missed something?
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> Hi,
>
> changes make API a bit complex, but affect only HOST_ID, but sometimes
> NET_ID changes are needed (route-change-if.sh). Maybe simple
> [ -n MIN_NET_ID,MAX_NET_ID ] [ -h MIN_HOST_ID,MAX_HOST_ID ] would be
> better. Comments are welcome.
>
> Note: sometimes we call prefix as mask in the code.
>
> Kind regards,
> Petr
>
> testcases/lib/tst_net.sh | 123 +++++++++++++++++++++++++++++++++------
> 1 file changed, 105 insertions(+), 18 deletions(-)
>
> diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh
> index a4183e013..baeac6e10 100644
> --- a/testcases/lib/tst_net.sh
> +++ b/testcases/lib/tst_net.sh
> @@ -355,48 +355,135 @@ tst_ipaddr()
> fi
> }
>
> -# Get IP address of unused network, specified either by type and counter
> +# Get IP address of unused network, specified either counter and type
> # or by net and host.
> -# tst_ipaddr_un [-cCOUNTER] [-p] [TYPE]
> -# tst_ipaddr_un [-p] NET_ID [HOST_ID]
> +# counter mode:
> +# tst_ipaddr_un [-b|-f|-n|[-l MIN_HOST_ID][-m MAX_HOST_ID]] [-p] [-c COUNTER] [TYPE]
> +# net & host mode:
> +# tst_ipaddr_un [-b|-f|-n|[-l MIN_HOST_ID][-m MAX_HOST_ID]] [-p] NET_ID [HOST_ID]
> #
> # TYPE: { lhost | rhost } (default: 'lhost')
> -# NET_ID: integer or hex value of net (IPv4: 3rd octet, IPv6: 3rd hextet)
> -# HOST_ID: integer or hex value of host (IPv4: 4th octet, IPv6: the last
> -# hextet, default: 0)
> +# NET_ID: integer or hex value of net (IPv4: 3rd octet <0,255>, IPv6: 3rd
> +# hextet <0,65535>)
> +# HOST_ID: integer or hex value of host (IPv4: 4th octet <0,255>, IPv6: the
> +# last hextet <0, 65535>, default: 0)
> +#
> +# RANGES for HOST_ID
> +# |<-------------- -f -------------->|
> +# | |<----------- -b -------------->|
> +# |<-------------- -n -------->| |
> +# | |<----------- -h -------->| |
> +# | | |<- -l L -m M ->| | |
> +# | | | | | |
> +# IPv4: 0 1 L M 254 255
> +# IPv6: 0 1 L M 65534 65535
> #
> # OPTIONS
> +# -b: use also *broadcast* address (HOST_ID: IPv4: 255, IPv6: 0xffff),
> +# equivalent of -m 255 or -m 65535, cannot be combined with -f, -h, -l, -m, -n
> +#
> # -c COUNTER: integer value for counting HOST_ID and NET_ID (default: 1)
> +#
> +# -f: use *full* address range (<0,255> resp. <0,65535>), cannot be combined
> +# with -b, -h, -l, -m, -n
> +#
> +# -h: use only *host* address range (<1,254> resp. <1,65534>), default for
> +# counter mode, cannot be combined with -b, -f, -l, -m, -n
> +#
> +# -l MIN_HOST_ID: specify minimal allowed HOST_ID allowed minimal HOST_ID,
> +# cannot be combined with -b, -f, -h, -n
> +#
> +# -m MAX_HOST_ID: specify max allowed HOST_ID (default NET_ID -1), cannot be
> +# combined with -b, -f, -h, -n
> +#
> +# -n: use also *network* address (HOST_ID: 0), equivalent of -l 0, cannot be
> +# combined with -b, -f, -h, -l, -m
> +#
> # -p: print also prefix
> tst_ipaddr_un()
> {
> - local counter host_id max_host_id max_net_id net_id prefix tmp type
> - local OPTIND
> + local counter host_id is_counter max_host_id min_host_id max_net_id net_id prefix tmp type
> + local b_arg f_arg h_arg lm_arg n_arg
>
> - while getopts "c:p" opt; do
> + [ "$TST_IPV6" ] && max_net_id=65535 || max_net_id=255
> +
> + local OPTIND
> + while getopts "bc:fhl:m:np" opt; do
> case $opt in
> + b)
> + [ "$f_arg" -o "$h_arg" -o "$lm_arg" -o "$n_arg" ] && \
> + tst_brk_ TBROK "tst_ipaddr_un: -b cannot be combined with -f, -h, -l, -m, -n"
> + max_host_id=$max_net_id
> + b_arg=1
> + ;;
> c) counter="$OPTARG";;
> + h)
> + [ "$b_arg" -o "$f_arg" -o "$lm_arg" -o "$n_arg" ] && \
> + tst_brk_ TBROK "tst_ipaddr_un: -h cannot be combined with -b -f, -l, -m, -n"
> + min_host_id=1
> + max_host_id=$((max_net_id-1))
> + h_arg=1
> + ;;
> + f)
> + [ "$b_arg" -o "$h_arg" -o "$lm_arg" -o "$n_arg" ] && \
> + tst_brk_ TBROK "tst_ipaddr_un: -f cannot be combined with -b, -h, -l, -m, -n"
> + min_host_id=0
> + max_host_id=$max_net_id
> + f_arg=1
> + ;;
> + l)
> + [ "$b_arg" -o "$f_arg" -o "$h_arg" -o "$n_arg" ] && \
> + tst_brk_ TBROK "tst_ipaddr_un: -l cannot be combined with -b, -f, -h, -n"
> + ! tst_is_int "$OPTARG" || [ $OPTARG -lt 0 ] && \
> + tst_brk TBROK "tst_ipaddr_un: -l must be integer <0,$max_net_id> ($OPTARG)"
> + min_host_id="$OPTARG"
> + lm_arg=1
> + ;;
> + m)
> + [ "$b_arg" -o "$f_arg" -o "$h_arg" -o "$n_arg" ] && \
> + tst_brk_ TBROK "tst_ipaddr_un: -m cannot be combined with -b, -f, -h, -n"
> + ! tst_is_int "$OPTARG" || [ "$OPTARG" -lt 0 ]|| [ "$OPTARG" -gt $max_net_id ] && \
> + tst_brk TBROK "tst_ipaddr_un: -m must be integer <0,$max_net_id> ($OPTARG)"
> + [ "$OPTARG" -gt $max_net_id ] && \
> + tst_brk_ TBROK "tst_ipaddr_un: -m cannot be higher than $max_net_id ($OPTARG)"
> + max_host_id="$OPTARG"
> + lm_arg=1
> + ;;
> + n)
> + [ "$b_arg" -o "$f_arg" -o "$h_arg" -o "$lm_arg" ] && \
> + tst_brk_ TBROK "tst_ipaddr_un: -n cannot be combined with -b, -f, -h, -l, -m"
> + min_host_id=0
> + n_arg=1
> + ;;
> p) [ "$TST_IPV6" ] && prefix="/64" || prefix="/24";;
> esac
> done
> shift $(($OPTIND - 1))
> + [ $# -eq 0 -o "$1" = "lhost" -o "$1" = "rhost" ] && is_counter=1
>
> - [ "$TST_IPV6" ] && max_net_id=65535 || max_net_id=255
> + if [ -z "$min_host_id" ]; then
> + [ "$is_counter" ] && min_host_id=1 || min_host_id=0
> + fi
> +
> + if [ -z "$max_host_id" ]; then
> + [ "$is_counter" ] && max_host_id=$((max_net_id - 1)) || max_host_id=$max_net_id
> + fi
> +
> + [ $min_host_id -gt $max_host_id ] && \
> + tst_brk TBROK "tst_ipaddr_un: max HOST_ID ($max_host_id) must be >= min HOST_ID ($min_host_id)"
>
> # counter
> - if [ $# -eq 0 -o "$1" = "lhost" -o "$1" = "rhost" ]; then
> + if [ "$is_counter" ]; then
> [ -z "$counter" ] && counter=1
> [ $counter -lt 1 ] && counter=1
> type="${1:-lhost}"
> - max_host_id=$((max_net_id - 1))
> tmp=$((counter * 2))
> [ "$type" = "rhost" ] && tmp=$((tmp - 1))
> -
> - host_id=$((tmp % max_host_id))
> + host_id=$((tmp % max_host_id - 1))
> net_id=$((tmp / max_host_id))
>
> - if [ $host_id -eq 0 ]; then
> - host_id=$max_host_id
> + if [ $host_id -lt 0 ]; then
> + host_id=$((max_host_id-1))
> net_id=$((net_id - 1))
> fi
> else # net_id & host_id
> @@ -410,8 +497,8 @@ tst_ipaddr_un()
> [ $host_id -lt 0 ] && host_id=1
> fi
>
> - net_id=$((net_id % max_net_id))
> - host_id=$((host_id % max_net_id))
> + net_id=$((net_id % (max_net_id + 1)))
> + host_id=$((host_id % (max_host_id - min_host_id + 1) + min_host_id)) # orig, but also bad
>
> if [ -z "$TST_IPV6" ]; then
> echo "${IPV4_NET16_UNUSED}.${net_id}.${host_id}${prefix}"
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [LTP] [PATCH v4 0/7] net/route: rewrite route-change-{dst, gw, if} into new API
2019-09-03 14:16 [LTP] [PATCH v4 0/7] net/route: rewrite route-change-{dst, gw, if} into new API Petr Vorel
` (6 preceding siblings ...)
2019-09-03 14:16 ` [LTP] [PATCH v4 7/7] network/route: Rewrite route{4, 6}-change-if into new API Petr Vorel
@ 2019-09-12 12:56 ` Alexey Kodanev
2019-09-12 13:48 ` Petr Vorel
7 siblings, 1 reply; 15+ messages in thread
From: Alexey Kodanev @ 2019-09-12 12:56 UTC (permalink / raw)
To: ltp
On 9/3/19 5:16 PM, Petr Vorel wrote:
> Hi Alexey,
>
> this version address functionality problems you pointed out.
> But yet there might need to be another version as I'm not sure about
> tst_ipaddr_un() API changes.
>
> Changes v3-v4:
> * enhanced tst_ipaddr_un() with -b, -h -l, -m, -n and -p options (-p was
> previous -m)
> * use tst_ipaddr_un() options to fix address clash on host_id, net_id clash fix
> by adjusting $1 in test (this is really inconsistent, see note at 3/7).
> * added tests for tst_ipaddr_un()
> * quiet EXPECT_PASS ping$TST_IPV6
>
The patch-set looks good, the only concerns are:
* complicated tst_ipaddr_un(), may be add another high-level function
to use raw tst_ipadd_un(), if -b, -f, -n options are really needed?
* if NS_TIMES is large, there are a lot of messages in a test output
(it seems NS_TIMES * 4), could we minimize the number of them?
^ permalink raw reply [flat|nested] 15+ messages in thread
* [LTP] [PATCH v4 1/7] tst_net.sh: enhance tst_add_ipaddr(), add tst_del_ipaddr()
2019-09-12 12:12 ` Alexey Kodanev
@ 2019-09-12 13:26 ` Petr Vorel
0 siblings, 0 replies; 15+ messages in thread
From: Petr Vorel @ 2019-09-12 13:26 UTC (permalink / raw)
To: ltp
Hi Alexey,
> Hi Petr,
> On 03.09.2019 17:16, Petr Vorel wrote:
> > These changes are intended for easier handling with IP addresses
> > (not have to calculate dad for IPv6 when adding IP address).
> > Add -a IP and -s options to tst_add_ipaddr()
> > tst_del_ipaddr() (which uses internally tst_add_ipaddr()) is defined
> > mainly for better code readability.
> ...
> > - tst_res_ TINFO "set remote addr $(tst_ipaddr rhost)/$mask"
> > - tst_rhost_run -c "ip addr add $(tst_ipaddr rhost)/$mask dev $iface $dad"
> > + tst_res_ TINFO "set remote addr $addr"
> ^
> Should be $action here?
Sure, thanks!
Kind regards,
Petr
^ permalink raw reply [flat|nested] 15+ messages in thread
* [LTP] [PATCH v4 0/7] net/route: rewrite route-change-{dst, gw, if} into new API
2019-09-12 12:56 ` [LTP] [PATCH v4 0/7] net/route: rewrite route-change-{dst, gw, if} " Alexey Kodanev
@ 2019-09-12 13:48 ` Petr Vorel
2019-09-12 14:18 ` Alexey Kodanev
0 siblings, 1 reply; 15+ messages in thread
From: Petr Vorel @ 2019-09-12 13:48 UTC (permalink / raw)
To: ltp
Hi Alexey,
first, thanks for your review.
..
> > this version address functionality problems you pointed out.
> > But yet there might need to be another version as I'm not sure about
> > tst_ipaddr_un() API changes.
> > Changes v3-v4:
> > * enhanced tst_ipaddr_un() with -b, -h -l, -m, -n and -p options (-p was
> > previous -m)
> > * use tst_ipaddr_un() options to fix address clash on host_id, net_id clash fix
> > by adjusting $1 in test (this is really inconsistent, see note at 3/7).
> > * added tests for tst_ipaddr_un()
> > * quiet EXPECT_PASS ping$TST_IPV6
> The patch-set looks good, the only concerns are:
> * complicated tst_ipaddr_un(), may be add another high-level function
> to use raw tst_ipadd_un(), if -b, -f, -n options are really needed?
Sure. I'll keep only -l and -m and drop -b, -f, -n and -h as not needed ATM.
And add them via high-level function only if needed.
In that case I'd like to have -l and -m functionality also for NET_ID (already
needed in route-change-dst.sh). But not sure which options would be for it
(it'd be easy with long opts, but we don't want to depend on /usr/bin/getopt,
nor to parse it manually although of course doable)
Another option is to have single option for adding both MAX and MIN:
-h MIN,MAX # for HOST_ID
-n MIN,MAX # for NET_ID
(e.g. -n5,255 -h1,255)
But it looks to me a bit uncomfortable having to always to add both min and max.
> * if NS_TIMES is large, there are a lot of messages in a test output
> (it seems NS_TIMES * 4), could we minimize the number of them?
I can add -q option to tst_add_ipaddr() which usage will make it NS_TIMES * 2. (1)
If it's still too much I'll drop "testing route over ..." (2)
Other option would be to print only even Nth iteration (I don't think it's a
good idea) or even has only single TPASS/TFAIL.
BTW don't we want end testing on first failure?
Kind regards,
Petr
^ permalink raw reply [flat|nested] 15+ messages in thread
* [LTP] [PATCH v4 0/7] net/route: rewrite route-change-{dst, gw, if} into new API
2019-09-12 13:48 ` Petr Vorel
@ 2019-09-12 14:18 ` Alexey Kodanev
2019-09-12 15:07 ` Petr Vorel
0 siblings, 1 reply; 15+ messages in thread
From: Alexey Kodanev @ 2019-09-12 14:18 UTC (permalink / raw)
To: ltp
On 9/12/19 4:48 PM, Petr Vorel wrote:
> Hi Alexey,
>
> first, thanks for your review.
>
> ..
>>> this version address functionality problems you pointed out.
>>> But yet there might need to be another version as I'm not sure about
>>> tst_ipaddr_un() API changes.
>
>>> Changes v3-v4:
>>> * enhanced tst_ipaddr_un() with -b, -h -l, -m, -n and -p options (-p was
>>> previous -m)
>>> * use tst_ipaddr_un() options to fix address clash on host_id, net_id clash fix
>>> by adjusting $1 in test (this is really inconsistent, see note at 3/7).
>>> * added tests for tst_ipaddr_un()
>>> * quiet EXPECT_PASS ping$TST_IPV6
>
>
>> The patch-set looks good, the only concerns are:
>
>> * complicated tst_ipaddr_un(), may be add another high-level function
>> to use raw tst_ipadd_un(), if -b, -f, -n options are really needed?
> Sure. I'll keep only -l and -m and drop -b, -f, -n and -h as not needed ATM.
> And add them via high-level function only if needed.
>
> In that case I'd like to have -l and -m functionality also for NET_ID (already
> needed in route-change-dst.sh). But not sure which options would be for it
> (it'd be easy with long opts, but we don't want to depend on /usr/bin/getopt,
> nor to parse it manually although of course doable)
>
> Another option is to have single option for adding both MAX and MIN:
>
> -h MIN,MAX # for HOST_ID
> -n MIN,MAX # for NET_ID
>
> (e.g. -n5,255 -h1,255)
>
It can be the best option,
> But it looks to me a bit uncomfortable having to always to add both min and max.
max "-n ,254" or min "-n 2"?
>
>> * if NS_TIMES is large, there are a lot of messages in a test output
>> (it seems NS_TIMES * 4), could we minimize the number of them?
>
> I can add -q option to tst_add_ipaddr() which usage will make it NS_TIMES * 2. (1)
> If it's still too much I'll drop "testing route over ..." (2)
> Other option would be to print only even Nth iteration (I don't think it's a
> good idea) or even has only single TPASS/TFAIL.
>
> BTW don't we want end testing on first failure?
Agree, why not.
>
>
> Kind regards,
> Petr
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [LTP] [PATCH v4 0/7] net/route: rewrite route-change-{dst, gw, if} into new API
2019-09-12 14:18 ` Alexey Kodanev
@ 2019-09-12 15:07 ` Petr Vorel
0 siblings, 0 replies; 15+ messages in thread
From: Petr Vorel @ 2019-09-12 15:07 UTC (permalink / raw)
To: ltp
Hi Alexey,
> > Another option is to have single option for adding both MAX and MIN:
> > -h MIN,MAX # for HOST_ID
> > -n MIN,MAX # for NET_ID
> > (e.g. -n5,255 -h1,255)
> It can be the best option,
> > But it looks to me a bit uncomfortable having to always to add both min and max.
> max "-n ,254" or min "-n 2"?
Great, thanks! How simple and elegant solution :).
> >> * if NS_TIMES is large, there are a lot of messages in a test output
> >> (it seems NS_TIMES * 4), could we minimize the number of them?
> > I can add -q option to tst_add_ipaddr() which usage will make it NS_TIMES * 2. (1)
> > If it's still too much I'll drop "testing route over ..." (2)
> > Other option would be to print only even Nth iteration (I don't think it's a
> > good idea) or even has only single TPASS/TFAIL.
> > BTW don't we want end testing on first failure?
> Agree, why not.
OK, it'll be in v5.
I'd prefer to change EXPECT_{PASS,FAIL} to return exit value so we can detect
the failure, but that would expect tst_res to return exit code as well.
(not sure, if it's a radical change).
Kind regards,
Petr
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2019-09-12 15:07 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-03 14:16 [LTP] [PATCH v4 0/7] net/route: rewrite route-change-{dst, gw, if} into new API Petr Vorel
2019-09-03 14:16 ` [LTP] [PATCH v4 1/7] tst_net.sh: enhance tst_add_ipaddr(), add tst_del_ipaddr() Petr Vorel
2019-09-12 12:12 ` Alexey Kodanev
2019-09-12 13:26 ` Petr Vorel
2019-09-03 14:16 ` [LTP] [PATCH v4 2/7] tst_net.sh: Add -p option to return prefix in tst_ipaddr_un() Petr Vorel
2019-09-03 14:16 ` [LTP] [PATCH v4 3/7] tst_net.sh: Add (mostly) HOST_ID related options to tst_ipaddr_un Petr Vorel
2019-09-12 12:41 ` Alexey Kodanev
2019-09-03 14:16 ` [LTP] [PATCH v4 4/7] net: Add tst_ipaddr_un.sh test Petr Vorel
2019-09-03 14:16 ` [LTP] [PATCH v4 5/7] network/route: Rewrite route{4, 6}-change-dst into new shell API Petr Vorel
2019-09-03 14:16 ` [LTP] [PATCH v4 6/7] network/route: Rewrite route{4, 6}-change-gw " Petr Vorel
2019-09-03 14:16 ` [LTP] [PATCH v4 7/7] network/route: Rewrite route{4, 6}-change-if into new API Petr Vorel
2019-09-12 12:56 ` [LTP] [PATCH v4 0/7] net/route: rewrite route-change-{dst, gw, if} " Alexey Kodanev
2019-09-12 13:48 ` Petr Vorel
2019-09-12 14:18 ` Alexey Kodanev
2019-09-12 15:07 ` Petr Vorel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.