[v3,4/5] network/route: Rewrite route-change-gw into new API
diff mbox series

Message ID 20190725111027.18716-5-pvorel@suse.cz
State New
Headers show
Series
  • net/route: rewrite route-change-{dst, gw, if} into new API
Related show

Commit Message

Petr Vorel July 25, 2019, 11:10 a.m. UTC
* 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      |  38 +++
 .../network/stress/route/route4-change-gw     | 292 ------------------
 .../network/stress/route/route6-change-gw     | 292 ------------------
 5 files changed, 43 insertions(+), 601 deletions(-)
 create mode 100755 testcases/network/stress/route/route-change-gw
 delete mode 100644 testcases/network/stress/route/route4-change-gw
 delete mode 100644 testcases/network/stress/route/route6-change-gw

Comments

Alexey Kodanev Aug. 6, 2019, 1:38 p.m. UTC | #1
Hi Petr,
On 7/25/19 2:10 PM, Petr Vorel wrote:
> * 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      |  38 +++
>  .../network/stress/route/route4-change-gw     | 292 ------------------
>  .../network/stress/route/route6-change-gw     | 292 ------------------
>  5 files changed, 43 insertions(+), 601 deletions(-)
>  create mode 100755 testcases/network/stress/route/route-change-gw
>  delete mode 100644 testcases/network/stress/route/route4-change-gw
>  delete mode 100644 testcases/network/stress/route/route6-change-gw
> 
> ...
> +
> +# 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 -m 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 1 $(($1 + 1)))"

We should keep $(($1 + 1)) within the valid range except already added IP address
($lhost), i.e. for IPv4 the range is 2..254 for host id:

    local gw="$(tst_ipaddr_un 1 $(($1 % 253 + 2)))"

Either we could limit the value here or in the tst_ipaddr_un(). Looks like
route-change-if needs a similar fix for net id?


> +	local iface="$(tst_iface)"
> +
> +	tst_res TINFO "testing route over gateway '$gw'"
> +
> +	tst_add_ipaddr -s -a $gw rhost
> +	ROD ip route replace $rt dev $iface via $gw

May be it would be cleaner to use "add" instead of "replace" since we remove it
and it shouldn't exist before a test start.

> +	EXPECT_PASS ping$TST_IPV6 -c1 -I $lhost $rhost

It is better to redirect stdout to null:

EXPECT_PASS ping$TST_IPV6 -c1 -I $lhost $rhost \>/dev/null

The same for *-if and *-dst.

The rest in the patch-set looks good to me.

> +	ROD ip route del $rt dev $iface via $gw
> +	tst_del_ipaddr -s -a $gw rhost
> +}
> +
> +tst_run
Petr Vorel Aug. 6, 2019, 7:55 p.m. UTC | #2
Hi Alexey,

> Hi Petr,
> On 7/25/19 2:10 PM, Petr Vorel wrote:
> > * 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      |  38 +++
> >  .../network/stress/route/route4-change-gw     | 292 ------------------
> >  .../network/stress/route/route6-change-gw     | 292 ------------------
> >  5 files changed, 43 insertions(+), 601 deletions(-)
> >  create mode 100755 testcases/network/stress/route/route-change-gw
> >  delete mode 100644 testcases/network/stress/route/route4-change-gw
> >  delete mode 100644 testcases/network/stress/route/route6-change-gw

> > ...
> > +
> > +# 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 -m 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 1 $(($1 + 1)))"

> We should keep $(($1 + 1)) within the valid range except already added IP address
> ($lhost), i.e. for IPv4 the range is 2..254 for host id:

>     local gw="$(tst_ipaddr_un 1 $(($1 % 253 + 2)))"

> Either we could limit the value here or in the tst_ipaddr_un(). Looks like
> route-change-if needs a similar fix for net id?
Good point (sorry to keep octet/hextet overflow related errors).
Although it'd be simpler to fix it in the code, I'd prefer to have this support
in tst_ipaddr_un(). Diff below adds -l MIN_HOST_ID (I'll post it as a part of v3),
do we want to lower also max host id?


> > +	local iface="$(tst_iface)"
> > +
> > +	tst_res TINFO "testing route over gateway '$gw'"
> > +
> > +	tst_add_ipaddr -s -a $gw rhost
> > +	ROD ip route replace $rt dev $iface via $gw

> May be it would be cleaner to use "add" instead of "replace" since we remove it
> and it shouldn't exist before a test start.

> > +	EXPECT_PASS ping$TST_IPV6 -c1 -I $lhost $rhost

> It is better to redirect stdout to null:

> EXPECT_PASS ping$TST_IPV6 -c1 -I $lhost $rhost \>/dev/null

> The same for *-if and *-dst.

Agree with all you pointed out.

> The rest in the patch-set looks good to me.


Kind regards,
Petr

commit 3a3ed9bc93c18d899a81b0f592eec4d4402984b1
Author: Petr Vorel <pvorel@suse.cz>
Date:   2019-08-06 16:58:28 +0200

    net/tst_ipaddr_un: Add -l MIN_HOST_ID support
    
    Signed-off-by: Petr Vorel <pvorel@suse.cz>

diff --git testcases/lib/tst_net.sh testcases/lib/tst_net.sh
index 714298797..50d64efca 100644
--- testcases/lib/tst_net.sh
+++ testcases/lib/tst_net.sh
@@ -361,11 +361,13 @@ tst_ipaddr()
 
 # Get IP address of unused network, specified either by type and counter
 # or by net and host.
-# tst_ipaddr_un [-cCOUNTER] [-m] [TYPE]
-# tst_ipaddr_un [-m] NET_ID [HOST_ID]
+# tst_ipaddr_un [-c COUNTER] [-l MIN_HOST_ID] [-m] [TYPE]
+# tst_ipaddr_un [-l MIN_HOST_ID] [-m] NET_ID [HOST_ID]
 #
 # OPTIONS
 # -c COUNTER: integer value for counting HOST_ID and NET_ID (default: 1)
+# -l MIN_HOST_ID: min HOST_ID allowed minimal HOST_ID (useful for loop which
+# overflow max HOST_ID)
 # -m: print also mask
 # TYPE: { lhost | rhost } (default: 'lhost')
 # NET_ID: integer or hex value of net (IPv4: 3rd octet, IPv6: 3rd hextet)
@@ -373,30 +375,39 @@ tst_ipaddr()
 # hextet, default: 0)
 tst_ipaddr_un()
 {
-	local counter host_id lower mask max_host_id max_net_id net_id tmp type
+	local counter host_id mask max_host_id max_net_id min_host_id net_id tmp type
 	local OPTIND
 
-	while getopts "c:m" opt; do
+	[ "$TST_IPV6" ] && max_net_id=65535 || max_net_id=255
+	max_host_id=$((max_net_id - 1))
+
+	while getopts "c:l:m" opt; do
 		case $opt in
 			c) counter="$OPTARG";;
-			l) lower="$OPTARG";;
+			l)
+				min_host_id="$OPTARG"
+				if ! tst_is_int "$min_host_id"; then
+					tst_brk TBROK "tst_ipaddr_un: -l must be integer ($min_host_id)"
+				fi
+				if [ $min_host_id -ge $max_host_id ]; then
+					tst_brk TBROK "tst_ipaddr_un: -l must be >= $max_host_id ($min_host_id)"
+				fi
+				;;
 			m) [ "$TST_IPV6" ] && mask="/64" || mask="/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
 		type="${1:-lhost}"
-		max_host_id=$((max_net_id - 1))
 		tmp=$((counter * 2))
 		[ "$type" = "rhost" ] && tmp=$((tmp - 1))
 
 		host_id=$((tmp % max_host_id))
+
 		net_id=$((tmp / max_host_id))
 
 		if [ $host_id -eq 0 ]; then
@@ -415,7 +426,11 @@ tst_ipaddr_un()
 	fi
 
 	net_id=$((net_id % max_net_id))
+	if [ "$min_host_id" ]; then
+		host_id=$(( host_id % (max_host_id - min_host_id + 1) + min_host_id ))
+	else
 		host_id=$((host_id % max_net_id))
+	fi
 
 	if [ -z "$TST_IPV6" ]; then
 		echo "${IPV4_NET16_UNUSED}.${net_id}.${host_id}${mask}"
Alexey Kodanev Aug. 8, 2019, 11:59 a.m. UTC | #3
Hi Petr,
On 8/6/19 10:55 PM, Petr Vorel wrote:
> Hi Alexey,
> 
>> Hi Petr,
>> On 7/25/19 2:10 PM, Petr Vorel wrote:
>>> * 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      |  38 +++
>>>  .../network/stress/route/route4-change-gw     | 292 ------------------
>>>  .../network/stress/route/route6-change-gw     | 292 ------------------
>>>  5 files changed, 43 insertions(+), 601 deletions(-)
>>>  create mode 100755 testcases/network/stress/route/route-change-gw
>>>  delete mode 100644 testcases/network/stress/route/route4-change-gw
>>>  delete mode 100644 testcases/network/stress/route/route6-change-gw
> 
>>> ...
>>> +
>>> +# 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 -m 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 1 $(($1 + 1)))"
> 
>> We should keep $(($1 + 1)) within the valid range except already added IP address
>> ($lhost), i.e. for IPv4 the range is 2..254 for host id:
> 
>>     local gw="$(tst_ipaddr_un 1 $(($1 % 253 + 2)))"
> 
>> Either we could limit the value here or in the tst_ipaddr_un(). Looks like
>> route-change-if needs a similar fix for net id?
> Good point (sorry to keep octet/hextet overflow related errors).
> Although it'd be simpler to fix it in the code, I'd prefer to have this support
> in tst_ipaddr_un(). Diff below adds -l MIN_HOST_ID (I'll post it as a part of v3),
> do we want to lower also max host id?


It can only be "max host id" option since we already have this variable in the
function, and in the test setup, we could assign "lhost" variable with the max
value:

  lhost="$(tst_ipaddr_un 1 $max_host_id)"


> 
> 
>>> +	local iface="$(tst_iface)"
>>> +
>>> +	tst_res TINFO "testing route over gateway '$gw'"
>>> +
>>> +	tst_add_ipaddr -s -a $gw rhost
>>> +	ROD ip route replace $rt dev $iface via $gw
> 
>> May be it would be cleaner to use "add" instead of "replace" since we remove it
>> and it shouldn't exist before a test start.
> 
>>> +	EXPECT_PASS ping$TST_IPV6 -c1 -I $lhost $rhost
> 
>> It is better to redirect stdout to null:
> 
>> EXPECT_PASS ping$TST_IPV6 -c1 -I $lhost $rhost \>/dev/null
> 
>> The same for *-if and *-dst.
> 
> Agree with all you pointed out.
> 
>> The rest in the patch-set looks good to me.
> 
> 
> Kind regards,
> Petr
> 
> commit 3a3ed9bc93c18d899a81b0f592eec4d4402984b1
> Author: Petr Vorel <pvorel@suse.cz>
> Date:   2019-08-06 16:58:28 +0200
> 
>     net/tst_ipaddr_un: Add -l MIN_HOST_ID support
>     
>     Signed-off-by: Petr Vorel <pvorel@suse.cz>
> 
> diff --git testcases/lib/tst_net.sh testcases/lib/tst_net.sh
> index 714298797..50d64efca 100644
> --- testcases/lib/tst_net.sh
> +++ testcases/lib/tst_net.sh
> @@ -361,11 +361,13 @@ tst_ipaddr()
>  
>  # Get IP address of unused network, specified either by type and counter
>  # or by net and host.
> -# tst_ipaddr_un [-cCOUNTER] [-m] [TYPE]
> -# tst_ipaddr_un [-m] NET_ID [HOST_ID]
> +# tst_ipaddr_un [-c COUNTER] [-l MIN_HOST_ID] [-m] [TYPE]
> +# tst_ipaddr_un [-l MIN_HOST_ID] [-m] NET_ID [HOST_ID]
>  #
>  # OPTIONS
>  # -c COUNTER: integer value for counting HOST_ID and NET_ID (default: 1)
> +# -l MIN_HOST_ID: min HOST_ID allowed minimal HOST_ID (useful for loop which
> +# overflow max HOST_ID)
>  # -m: print also mask
>  # TYPE: { lhost | rhost } (default: 'lhost')
>  # NET_ID: integer or hex value of net (IPv4: 3rd octet, IPv6: 3rd hextet)
> @@ -373,30 +375,39 @@ tst_ipaddr()
>  # hextet, default: 0)
>  tst_ipaddr_un()
>  {
> -	local counter host_id lower mask max_host_id max_net_id net_id tmp type
> +	local counter host_id mask max_host_id max_net_id min_host_id net_id tmp type
>  	local OPTIND
>  
> -	while getopts "c:m" opt; do
> +	[ "$TST_IPV6" ] && max_net_id=65535 || max_net_id=255
> +	max_host_id=$((max_net_id - 1))
> +
> +	while getopts "c:l:m" opt; do
>  		case $opt in
>  			c) counter="$OPTARG";;
> -			l) lower="$OPTARG";;
> +			l)
> +				min_host_id="$OPTARG"
> +				if ! tst_is_int "$min_host_id"; then
> +					tst_brk TBROK "tst_ipaddr_un: -l must be integer ($min_host_id)"
> +				fi
> +				if [ $min_host_id -ge $max_host_id ]; then
> +					tst_brk TBROK "tst_ipaddr_un: -l must be >= $max_host_id ($min_host_id)"
> +				fi
> +				;;
>  			m) [ "$TST_IPV6" ] && mask="/64" || mask="/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
>  		type="${1:-lhost}"
> -		max_host_id=$((max_net_id - 1))
>  		tmp=$((counter * 2))
>  		[ "$type" = "rhost" ] && tmp=$((tmp - 1))
>  
>  		host_id=$((tmp % max_host_id))
> +
>  		net_id=$((tmp / max_host_id))
>  
>  		if [ $host_id -eq 0 ]; then
> @@ -415,7 +426,11 @@ tst_ipaddr_un()
>  	fi
>  
>  	net_id=$((net_id % max_net_id))
> +	if [ "$min_host_id" ]; then
> +		host_id=$(( host_id % (max_host_id - min_host_id + 1) + min_host_id ))
> +	else
>  		host_id=$((host_id % max_net_id))
> +	fi
>  
>  	if [ -z "$TST_IPV6" ]; then
>  		echo "${IPV4_NET16_UNUSED}.${net_id}.${host_id}${mask}"
>
Petr Vorel Aug. 9, 2019, 4:02 p.m. UTC | #4
Hi Alexey,

> >>> +	local gw="$(tst_ipaddr_un 1 $(($1 + 1)))"

> >> We should keep $(($1 + 1)) within the valid range except already added IP address
> >> ($lhost), i.e. for IPv4 the range is 2..254 for host id:

> >>     local gw="$(tst_ipaddr_un 1 $(($1 % 253 + 2)))"

> >> Either we could limit the value here or in the tst_ipaddr_un(). Looks like
> >> route-change-if needs a similar fix for net id?
> > Good point (sorry to keep octet/hextet overflow related errors).
> > Although it'd be simpler to fix it in the code, I'd prefer to have this support
> > in tst_ipaddr_un(). Diff below adds -l MIN_HOST_ID (I'll post it as a part of v3),
> > do we want to lower also max host id?

> It can only be "max host id" option since we already have this variable in the
> function, and in the test setup, we could assign "lhost" variable with the max
> value:

>   lhost="$(tst_ipaddr_un 1 $max_host_id)"

I'll have to implement min value as well, because we have for non-counter mode
(e.g tst_ipaddr_un $net_id $host_id) 0 as well, so it will break for invalid
gateway 10.23.1.0. I wanted to avoid -c mode for these route tests.

I guess <0-254> for max host ID for this mode was good idea, but IMHO it should
be: <0-255> (to allow both network address and broadcast address), and allow to
have minimize both min and max. So for case of valid address it'd would be:
tst_ipaddr_un -l 1 -m 254 $net_id $host_id

Other could be to have range for this mode default suitable for hosts (<1..254>)
as we have it for -c mode. Getting network would be:

tst_ipaddr_un -n $net_id # instead of tst_ipaddr_un $net_id 0

Getting broadcast would be:

tst_ipaddr_un -b $net_id # currently not possible at all with tst_ipaddr_un

This second proposal looks more usable to me, although -b and -n aren't obvious
(long getopts would be better, but I think it's better to avoid them).

+ I'd still keep proposed -m max_host_id, so we could use tst_ipaddr_un $net_id 254
for route and tst_ipaddr_un -m 253 $net_id $1 for hosts.

Kind regards,
Petr

Patch
diff mbox series

diff --git a/runtest/net_stress.route b/runtest/net_stress.route
index b6ea11c2e..0cc033e1a 100644
--- a/runtest/net_stress.route
+++ b/runtest/net_stress.route
@@ -3,13 +3,13 @@ 
 #
 
 route4-change-dst route-change-dst
-route4-change-gw route4-change-gw
+route4-change-gw route-change-gw
 route4-change-if route4-change-if
 route4-redirect route4-redirect
 route4-rmmod route4-rmmod
 
 route6-change-dst route-change-dst -6
-route6-change-gw route6-change-gw
+route6-change-gw route-change-gw -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 518e5ce7f..2a98636ad 100644
--- a/testcases/network/stress/route/00_Descriptions.txt
+++ b/testcases/network/stress/route/00_Descriptions.txt
@@ -2,13 +2,9 @@  route-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-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 b/testcases/network/stress/route/route-change-gw
new file mode 100755
index 000000000..025b5f2c2
--- /dev/null
+++ b/testcases/network/stress/route/route-change-gw
@@ -0,0 +1,38 @@ 
+#!/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 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 -m 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 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 replace $rt dev $iface via $gw
+	EXPECT_PASS ping$TST_IPV6 -c1 -I $lhost $rhost
+	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