All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [RFC PATCH v2 0/6] net/route: Rewrite route{4, 6}-change-{dst, gw} into C
@ 2019-05-10 18:31 Petr Vorel
  2019-05-10 18:31 ` [LTP] [RFC PATCH v2 1/6] net/route: Remove route{4,6}-change-if Petr Vorel
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: Petr Vorel @ 2019-05-10 18:31 UTC (permalink / raw)
  To: ltp

Hi,

another attempt to rewrite route{4,6}-change-{dst,gw}.
I'm not much happy with it.

I was trying to create server side validation over UDP, but failed.
I didn't figure out setup where server could be on single IP address
(there is probably a solution), so I created threads, each thread bind
to single IP (number of threads is the same as number of IP addresses
created in shell). Due limitation of IPv6 routes over gateway (which
must be on rhost, for testsuite changing destination this is not
necessary) I run server on rhost. Testsuite got complicated:
waiting for threads to bind, save port and IP config into files
and load it in client... => unfinished and posted solution without server.
I can see packets sent with tcpdump, but that does not mean it reached
server. With this result it's questionable whether moving into C code is
a benefit, maybe shell code below is just good enough.

Other questionable thing is tst_ipaddr_un() incomplete implementation in C.
Alternatively IP addresses could be passed from shell via getopts, but
that can be hard to debug (too long argument passed).
Originally I wanted to create IP addresses also in C, but that's not
possible due rhost not reachable from C.

Changes from v1:
* Handle also route{4,6}-change-gw
* Use libmnl
* new commits (more comments at the commits):
- net: Move setup_addrinfo() from netstress.c into tst_net.h
- tst_net.sh: Minor code and doc cleanup
- tst_net.sh: Add -a IP and -s options to tst_init_iface()
- net: Introduce TST_GET_UNUSED_PORT() macro into C API
- net/route: Remove route{4,6}-change-if

Draft of alternative implementation in shell:
* route-change-dst
TST_TESTFUNC="do_test"
TST_SETUP="do_setup"
TST_CLEANUP="restore_ipaddr"
TST_NEEDS_CMDS="ip"
TST_CNT=$NS_TIMES

. tst_net_stress.sh

do_setup()
{
	# FIXME: remove duplicity
	mask=$IPV4_LPREFIX
	udp_size=1472
	if [ "$TST_IPV6" ]; then
		mask=$IPV6_LPREFIX
		udp_size=1452
	fi
	netstress_setup
	tst_res TINFO "change IPv$TST_IPVER route destination $NS_TIMES times"
}

do_test()
{
	local iface=$(tst_iface)
	local addr new_rt

	new_rt="$(tst_ipaddr_un $1)/$mask"
	addr="$(tst_ipaddr_un $1 1)"

	tst_res TINFO "testing route '$new_rt'"

	tst_rhost_run -s -c "ip addr add $addr/$mask dev $(tst_iface rhost)"
	ROD ip route add $new_rt dev $iface
	ROD ip neigh replace $addr lladdr $(tst_hwaddr rhost) nud permanent dev $iface

	EXPECT_PASS ns-udpsender -f $TST_IPVER -D $addr -p $1 -o -s $udp_size

	ROD ip neigh del $addr lladdr $(tst_hwaddr rhost) dev $iface
	ROD ip route del $new_rt dev $iface
	tst_rhost_run -c "ip addr del $addr/$mask dev $(tst_iface rhost)"
}

tst_run

* route-change-gw:
TST_TESTFUNC="do_test"
TST_SETUP="do_setup"
TST_CLEANUP="restore_ipaddr"
TST_NEEDS_CMDS="ip"
TST_CNT=$NS_TIMES

. tst_net_stress.sh

do_setup()
{
	mask=$IPV4_LPREFIX
	udp_size=1472
	if [ "$TST_IPV6" ]; then
		mask=$IPV6_LPREFIX
		udp_size=1452
	fi
	netstress_setup
	tst_res TINFO "change IPv$TST_IPVER route gateway $NS_TIMES times"

	rt="$(tst_ipaddr_un 1 0)/$mask"
	addr="$(tst_ipaddr_un 1 1)"
	tst_rhost_run -s -c "ip addr add $addr/$mask dev $(tst_iface rhost)"
}

do_test()
{
	local iface=$(tst_iface)
	local new_gw="$(tst_ipaddr_un 1 $(($1 + 1)))"

	tst_res TINFO "testing gw '$new_gw'"

	ROD ip addr add $new_gw/$mask dev $(tst_iface)
	ROD ip route replace $rt dev $iface via $new_gw
	ROD ip neigh replace $addr lladdr $(tst_hwaddr rhost) nud permanent dev $iface

	EXPECT_PASS ns-udpsender -f $TST_IPVER -D $addr -p $1 -o -s $udp_size

	ROD ip neigh del $addr lladdr $(tst_hwaddr rhost) dev $iface
	ROD ip route del $rt dev $iface via $new_gw
	ROD ip addr del $new_gw/$mask dev $(tst_iface)
}

tst_run
---

Petr Vorel (6):
  net/route: Remove route{4,6}-change-if
  net: Introduce TST_GET_UNUSED_PORT() macro into C API
  tst_net.sh: Add -a IP and -s options to tst_init_iface()
  tst_net.sh: Minor code and doc cleanup
  net: Move setup_addrinfo() from netstress.c into tst_net.h
  net/route: Rewrite route{4,6}-change-{dst,gw} into C

 configure.ac                                  |   1 +
 include/mk/config.mk.default                  |   2 +
 include/mk/config.mk.in                       |   2 +
 include/old/old_safe_net.h                    |   3 +
 include/old/test.h                            |   7 -
 include/safe_net_fn.h                         |  13 +-
 include/tst_net.h                             |  90 +++--
 include/tst_safe_net.h                        |   9 +-
 lib/safe_net.c                                |  66 ++++
 lib/tst_net.c                                 |  89 -----
 m4/ltp-libmnl.m4                              |   7 +
 runtest/net_stress.route                      |  12 +-
 testcases/kernel/syscalls/bind/bind01.c       |   2 +-
 testcases/kernel/syscalls/connect/connect01.c |   2 +-
 testcases/kernel/syscalls/sendmsg/sendmsg01.c |   2 +-
 testcases/lib/tst_net.sh                      | 147 ++++----
 testcases/network/netstress/netstress.c       |  14 +-
 testcases/network/stress/route/.gitignore     |   1 +
 .../network/stress/route/00_Descriptions.txt  |  64 +---
 testcases/network/stress/route/Makefile       |  30 +-
 testcases/network/stress/route/route-change.c | 243 +++++++++++++
 .../network/stress/route/route-change.sh      |  52 +++
 .../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 -----------------
 tools/apicmds/ltpapicmd.c                     |   2 +-
 travis/debian.cross-compile.aarch64.sh        |   6 +-
 travis/debian.cross-compile.ppc64le.sh        |   8 +-
 travis/debian.i386.sh                         |   3 +-
 travis/debian.minimal.sh                      |  28 +-
 travis/debian.sh                              |  55 +--
 travis/fedora.sh                              |   5 +-
 travis/tumbleweed.sh                          |   7 +-
 36 files changed, 626 insertions(+), 2125 deletions(-)
 delete mode 100644 lib/tst_net.c
 create mode 100644 m4/ltp-libmnl.m4
 create mode 100644 testcases/network/stress/route/.gitignore
 create mode 100644 testcases/network/stress/route/route-change.c
 create mode 100755 testcases/network/stress/route/route-change.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.21.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [LTP] [RFC PATCH v2 1/6] net/route: Remove route{4,6}-change-if
  2019-05-10 18:31 [LTP] [RFC PATCH v2 0/6] net/route: Rewrite route{4, 6}-change-{dst, gw} into C Petr Vorel
@ 2019-05-10 18:31 ` Petr Vorel
  2019-05-23 12:46   ` [LTP] [RFC PATCH v2 1/6] net/route: Remove route{4, 6}-change-if Alexey Kodanev
  2019-05-10 18:31 ` [LTP] [RFC PATCH v2 2/6] net: Introduce TST_GET_UNUSED_PORT() macro into C API Petr Vorel
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Petr Vorel @ 2019-05-10 18:31 UTC (permalink / raw)
  To: ltp

These testsuites requires 3 NIC setup, which is not supported by network
namespace setup (single host configuration) and IMHO not common for two
host configuration either.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 runtest/net_stress.route                      |   2 -
 .../network/stress/route/00_Descriptions.txt  |  16 -
 .../network/stress/route/route4-change-if     | 324 ------------------
 .../network/stress/route/route6-change-if     | 323 -----------------
 4 files changed, 665 deletions(-)
 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 266ef0383..c065c5cd1 100644
--- a/runtest/net_stress.route
+++ b/runtest/net_stress.route
@@ -4,12 +4,10 @@
 
 route4-change-dst route4-change-dst
 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-gw route6-change-gw
-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 2a871fdae..91aa01120 100644
--- a/testcases/network/stress/route/00_Descriptions.txt
+++ b/testcases/network/stress/route/00_Descriptions.txt
@@ -14,14 +14,6 @@ route4-change-gw02
 	Verify the kernel is not crashed when the gateway of an IPv4 route is
 	changed frequently by ip command
 
-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
-
 route4-redirect01
 	Verify the kernel is not crashed when the IPv4 route is modified by
 	ICMP Redirects frequently
@@ -51,14 +43,6 @@ 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
-
-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/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.21.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [LTP] [RFC PATCH v2 2/6] net: Introduce TST_GET_UNUSED_PORT() macro into C API
  2019-05-10 18:31 [LTP] [RFC PATCH v2 0/6] net/route: Rewrite route{4, 6}-change-{dst, gw} into C Petr Vorel
  2019-05-10 18:31 ` [LTP] [RFC PATCH v2 1/6] net/route: Remove route{4,6}-change-if Petr Vorel
@ 2019-05-10 18:31 ` Petr Vorel
  2019-05-10 18:31 ` [LTP] [RFC PATCH v2 3/6] tst_net.sh: Add -a IP and -s options to tst_init_iface() Petr Vorel
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: Petr Vorel @ 2019-05-10 18:31 UTC (permalink / raw)
  To: ltp

into both new and legacy API.
Therefore tst_get_unused_port() was ported into new C API.

Adding TST_GET_UNUSED_PORT() was needed to add support for printing
file and line in error messages passed tst_brkm().

+ deleted lib/tst_net.c (net functions for legacy C API).
+ move tst_* function prototypes in headers to the end
(partly sort alphabetically).

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---

TST_GET_UNUSED_PORT() is used in route code, but that's not necessary
("0" would work as well).

 include/old/old_safe_net.h                    |  3 +
 include/old/test.h                            |  7 --
 include/safe_net_fn.h                         | 13 +--
 include/tst_safe_net.h                        |  9 +-
 lib/safe_net.c                                | 66 ++++++++++++++
 lib/tst_net.c                                 | 89 -------------------
 testcases/kernel/syscalls/bind/bind01.c       |  2 +-
 testcases/kernel/syscalls/connect/connect01.c |  2 +-
 testcases/kernel/syscalls/sendmsg/sendmsg01.c |  2 +-
 tools/apicmds/ltpapicmd.c                     |  2 +-
 10 files changed, 87 insertions(+), 108 deletions(-)
 delete mode 100644 lib/tst_net.c

diff --git a/include/old/old_safe_net.h b/include/old/old_safe_net.h
index 609787b32..639094a94 100644
--- a/include/old/old_safe_net.h
+++ b/include/old/old_safe_net.h
@@ -44,4 +44,7 @@
 	safe_getsockname(__FILE__, __LINE__, (cleanup_fn), sockfd, addr, \
 			 addrlen)
 
+#define TST_GET_UNUSED_PORT(cleanup_fn, family, type) \
+	tst_get_unused_port(__FILE__, __LINE__, (cleanup_fn), family, type)
+
 #endif /* OLD_SAFE_NET_H__ */
diff --git a/include/old/test.h b/include/old/test.h
index 0738237e9..604254eea 100644
--- a/include/old/test.h
+++ b/include/old/test.h
@@ -195,13 +195,6 @@ void tst_mkfs_(const char *file, const int lineno, void (cleanup_fn)(void),
 	       const char *dev, const char *fs_type,
 	       const char *const fs_opts[], const char *const extra_opts[]);
 
-/* lib/tst_net.c
- *
- * Return unused port
- */
-unsigned short tst_get_unused_port(void (cleanup_fn)(void),
-	unsigned short family, int type);
-
 /* lib/tst_res.c
  * tst_strsig converts signal's value to corresponding string.
  * tst_strerrno converts errno to corresponding string.
diff --git a/include/safe_net_fn.h b/include/safe_net_fn.h
index 3183b2a1c..fdbb3791c 100644
--- a/include/safe_net_fn.h
+++ b/include/safe_net_fn.h
@@ -25,11 +25,6 @@
 #include <arpa/inet.h>
 #include <sys/un.h>
 
-char *tst_sock_addr(const struct sockaddr *sa, socklen_t salen, char *res,
-		    size_t len);
-
-int tst_getsockport(const char *file, const int lineno, int sockfd);
-
 int safe_socket(const char *file, const int lineno, void (cleanup_fn)(void),
 		int domain, int type, int protocol);
 
@@ -72,4 +67,12 @@ int safe_getsockname(const char *file, const int lineno,
 int safe_gethostname(const char *file, const int lineno,
 		     char *name, size_t size);
 
+int tst_getsockport(const char *file, const int lineno, int sockfd);
+
+unsigned short tst_get_unused_port(const char *file, const int lineno,
+	      void (cleanup_fn)(void), unsigned short family, int type);
+
+char *tst_sock_addr(const struct sockaddr *sa, socklen_t salen, char *res,
+		    size_t len);
+
 #endif /* SAFE_NET_FN_H__ */
diff --git a/include/tst_safe_net.h b/include/tst_safe_net.h
index 83a2f27bf..d49a36073 100644
--- a/include/tst_safe_net.h
+++ b/include/tst_safe_net.h
@@ -26,9 +26,6 @@
 
 #include "safe_net_fn.h"
 
-#define TST_GETSOCKPORT(sockfd) \
-	tst_getsockport(__FILE__, __LINE__, sockfd)
-
 #define SAFE_SOCKET(domain, type, protocol) \
 	safe_socket(__FILE__, __LINE__, NULL, domain, type, protocol)
 
@@ -77,4 +74,10 @@
 #define SAFE_GETHOSTNAME(name, size) \
 	safe_gethostname(__FILE__, __LINE__, name, size)
 
+#define TST_GETSOCKPORT(sockfd) \
+	tst_getsockport(__FILE__, __LINE__, sockfd)
+
+#define TST_GET_UNUSED_PORT(family, type) \
+	tst_get_unused_port(__FILE__, __LINE__, NULL, family, type)
+
 #endif /* TST_SAFE_NET_H__ */
diff --git a/lib/safe_net.c b/lib/safe_net.c
index e849d817a..970a2aba3 100644
--- a/lib/safe_net.c
+++ b/lib/safe_net.c
@@ -372,3 +372,69 @@ int safe_gethostname(const char *file, const int lineno,
 
 	return rval;
 }
+
+unsigned short tst_get_unused_port(const char *file, const int lineno,
+	      void (cleanup_fn)(void), unsigned short family, int type)
+{
+	int sock;
+	socklen_t slen;
+	struct sockaddr_storage _addr;
+	struct sockaddr *addr = (struct sockaddr *)&_addr;
+	struct sockaddr_in *addr4 = (struct sockaddr_in *)addr;
+	struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)addr;
+
+	switch (family) {
+	case AF_INET:
+		addr4->sin_family = AF_INET;
+		addr4->sin_port = 0;
+		addr4->sin_addr.s_addr = INADDR_ANY;
+		slen = sizeof(*addr4);
+		break;
+
+	case AF_INET6:
+		addr6->sin6_family = AF_INET6;
+		addr6->sin6_port = 0;
+		addr6->sin6_addr = in6addr_any;
+		slen = sizeof(*addr6);
+		break;
+
+	default:
+		tst_brkm(TBROK, cleanup_fn,
+			"%s:%d: unknown family", file, lineno);
+		return -1;
+	}
+
+	sock = socket(addr->sa_family, type, 0);
+	if (sock < 0) {
+		tst_brkm(TBROK | TERRNO, cleanup_fn,
+			 "%s:%d: socket failed", file, lineno);
+		return -1;
+	}
+
+	if (bind(sock, addr, slen) < 0) {
+		tst_brkm(TBROK | TERRNO, cleanup_fn,
+			 "%s:%d: bind failed", file, lineno);
+		return -1;
+	}
+
+	if (getsockname(sock, addr, &slen) == -1) {
+		tst_brkm(TBROK | TERRNO, cleanup_fn,
+			 "%s:%d: getsockname failed", file, lineno);
+		return -1;
+	}
+
+	if (close(sock) == -1) {
+		tst_brkm(TBROK | TERRNO, cleanup_fn,
+			 "%s:%d: close failed", file, lineno);
+		return -1;
+	}
+
+	switch (family) {
+	case AF_INET:
+		return addr4->sin_port;
+	case AF_INET6:
+		return addr6->sin6_port;
+	default:
+		return -1;
+	}
+}
diff --git a/lib/tst_net.c b/lib/tst_net.c
deleted file mode 100644
index f842e94a6..000000000
--- a/lib/tst_net.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2014 Linux Test Project, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it
- * is free of the rightful claim of any third person regarding
- * infringement or the like.  Any license provided herein, whether
- * implied or otherwise, applies only to this software file.  Patent
- * licenses, if any, provided herein do not apply to combinations of
- * this program with other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation, Inc.
- */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-
-#include "test.h"
-
-unsigned short tst_get_unused_port(void (cleanup_fn)(void),
-	unsigned short family, int type)
-{
-	int sock;
-	socklen_t slen;
-	struct sockaddr_storage _addr;
-	struct sockaddr *addr = (struct sockaddr *)&_addr;
-	struct sockaddr_in *addr4 = (struct sockaddr_in *)addr;
-	struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)addr;
-
-	switch (family) {
-	case AF_INET:
-		addr4->sin_family = AF_INET;
-		addr4->sin_port = 0;
-		addr4->sin_addr.s_addr = INADDR_ANY;
-		slen = sizeof(*addr4);
-		break;
-
-	case AF_INET6:
-		addr6->sin6_family = AF_INET6;
-		addr6->sin6_port = 0;
-		addr6->sin6_addr = in6addr_any;
-		slen = sizeof(*addr6);
-		break;
-
-	default:
-		tst_brkm(TBROK, cleanup_fn,
-			"tst_get_unused_port unknown family");
-		return -1;
-	}
-
-	sock = socket(addr->sa_family, type, 0);
-	if (sock < 0) {
-		tst_brkm(TBROK | TERRNO, cleanup_fn, "socket failed");
-		return -1;
-	}
-
-	if (bind(sock, addr, slen) < 0) {
-		tst_brkm(TBROK | TERRNO, cleanup_fn, "bind failed");
-		return -1;
-	}
-
-	if (getsockname(sock, addr, &slen) == -1) {
-		tst_brkm(TBROK | TERRNO, cleanup_fn, "getsockname failed");
-		return -1;
-	}
-
-	if (close(sock) == -1) {
-		tst_brkm(TBROK | TERRNO, cleanup_fn, "close failed");
-		return -1;
-	}
-
-	switch (family) {
-	case AF_INET:
-		return addr4->sin_port;
-	case AF_INET6:
-		return addr6->sin6_port;
-	default:
-		return -1;
-	}
-}
diff --git a/testcases/kernel/syscalls/bind/bind01.c b/testcases/kernel/syscalls/bind/bind01.c
index 868749368..d2f50e806 100644
--- a/testcases/kernel/syscalls/bind/bind01.c
+++ b/testcases/kernel/syscalls/bind/bind01.c
@@ -152,7 +152,7 @@ void setup(void)
 	/* initialize sockaddr's */
 	sin1.sin_family = AF_INET;
 	/* this port must be unused! */
-	sin1.sin_port = tst_get_unused_port(NULL, AF_INET, SOCK_STREAM);
+	sin1.sin_port = TST_GET_UNUSED_PORT(NULL, AF_INET, SOCK_STREAM);
 	sin1.sin_addr.s_addr = INADDR_ANY;
 
 	sin2.sin_family = AF_INET;
diff --git a/testcases/kernel/syscalls/connect/connect01.c b/testcases/kernel/syscalls/connect/connect01.c
index 34e260f59..0d7d15a83 100644
--- a/testcases/kernel/syscalls/connect/connect01.c
+++ b/testcases/kernel/syscalls/connect/connect01.c
@@ -184,7 +184,7 @@ void setup(void)
 
 	sin2.sin_family = AF_INET;
 	/* this port must be unused! */
-	sin2.sin_port = tst_get_unused_port(NULL, AF_INET, SOCK_STREAM);
+	sin2.sin_port = TST_GET_UNUSED_PORT(NULL, AF_INET, SOCK_STREAM);
 	sin2.sin_addr.s_addr = INADDR_ANY;
 
 	sin3.sin_family = AF_INET;
diff --git a/testcases/kernel/syscalls/sendmsg/sendmsg01.c b/testcases/kernel/syscalls/sendmsg/sendmsg01.c
index 36f6914ff..cf6e74289 100644
--- a/testcases/kernel/syscalls/sendmsg/sendmsg01.c
+++ b/testcases/kernel/syscalls/sendmsg/sendmsg01.c
@@ -662,7 +662,7 @@ static void setup5(void)
 	 * 5-tuple than already connected
 	 */
 	sin2 = sin1;
-	sin2.sin_port = tst_get_unused_port(cleanup, AF_INET, SOCK_STREAM);
+	sin2.sin_port = TST_GET_UNUSED_PORT(cleanup, AF_INET, SOCK_STREAM);
 }
 
 static void setup6(void)
diff --git a/tools/apicmds/ltpapicmd.c b/tools/apicmds/ltpapicmd.c
index 4b66c4226..d94061242 100644
--- a/tools/apicmds/ltpapicmd.c
+++ b/tools/apicmds/ltpapicmd.c
@@ -213,7 +213,7 @@ unsigned short apicmd_get_unused_port(int argc, char *argv[])
 		if (!p[i]->cmd)
 			goto err;
 	}
-	return  tst_get_unused_port(NULL, p[0]->value, p[1]->value);
+	return  TST_GET_UNUSED_PORT(NULL, p[0]->value, p[1]->value);
 
 err:
 	fprintf(stderr, "Usage: tst_get_unused_port FAMILY TYPE\n"
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [LTP] [RFC PATCH v2 3/6] tst_net.sh: Add -a IP and -s options to tst_init_iface()
  2019-05-10 18:31 [LTP] [RFC PATCH v2 0/6] net/route: Rewrite route{4, 6}-change-{dst, gw} into C Petr Vorel
  2019-05-10 18:31 ` [LTP] [RFC PATCH v2 1/6] net/route: Remove route{4,6}-change-if Petr Vorel
  2019-05-10 18:31 ` [LTP] [RFC PATCH v2 2/6] net: Introduce TST_GET_UNUSED_PORT() macro into C API Petr Vorel
@ 2019-05-10 18:31 ` Petr Vorel
  2019-05-10 18:31 ` [LTP] [RFC PATCH v2 4/6] tst_net.sh: Minor code and doc cleanup Petr Vorel
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: Petr Vorel @ 2019-05-10 18:31 UTC (permalink / raw)
  To: ltp

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/lib/tst_net.sh | 38 +++++++++++++++++++++++++++-----------
 1 file changed, 27 insertions(+), 11 deletions(-)

diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh
index f47a404d0..fb8c49459 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
@@ -446,14 +446,30 @@ 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] [-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
+# -s safe option, if something goes wrong, will exit with TBROK
 tst_add_ipaddr()
 {
+	local addr dad lsafe mask rsafe
+
+	local OPTIND
+	while getopts a:s opt; do
+		case "$opt" in
+		a) addr="$OPTARG" ;;
+		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"
@@ -461,17 +477,17 @@ 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 add $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 add $addr dev $iface $dad"
 }
 
 # tst_restore_ipaddr [TYPE] [LINK]
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [LTP] [RFC PATCH v2 4/6] tst_net.sh: Minor code and doc cleanup
  2019-05-10 18:31 [LTP] [RFC PATCH v2 0/6] net/route: Rewrite route{4, 6}-change-{dst, gw} into C Petr Vorel
                   ` (2 preceding siblings ...)
  2019-05-10 18:31 ` [LTP] [RFC PATCH v2 3/6] tst_net.sh: Add -a IP and -s options to tst_init_iface() Petr Vorel
@ 2019-05-10 18:31 ` Petr Vorel
  2019-05-10 18:31 ` [LTP] [RFC PATCH v2 5/6] net: Move setup_addrinfo() from netstress.c into tst_net.h Petr Vorel
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: Petr Vorel @ 2019-05-10 18:31 UTC (permalink / raw)
  To: ltp

* making OPTIND local instead of setting it 0 before and after test
* remove '=' during variable initialization to empty value
* declare variables with local on single line (there some issues with
  dash when initialize more variables with default values on single local,
  but simple declaration is perfectly safe
* doc: remove dots

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
cleanup of tst_net.sh (new commit, this can be dropped).

 testcases/lib/tst_net.sh | 109 ++++++++++++++++-----------------------
 1 file changed, 44 insertions(+), 65 deletions(-)

diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh
index fb8c49459..8dbd17eb2 100644
--- a/testcases/lib/tst_net.sh
+++ b/testcases/lib/tst_net.sh
@@ -107,7 +107,7 @@ init_ltp_netspace()
 	tst_test_cmds ip
 	tst_require_root_
 
-	local pid=
+	local pid
 
 	if [ ! -f /var/run/netns/ltp_ns -a -z "$LTP_NETNS" ]; then
 		ROD ip li add name ltp_ns_veth1 type veth peer name ltp_ns_veth2
@@ -134,7 +134,7 @@ init_ltp_netspace()
 	tst_restore_ipaddr rhost
 }
 
-# Run command on remote host.
+# Run command on remote host
 # Options:
 # -b run in background
 # -B run in background and save output to $TST_TMPDIR/bg.cmd
@@ -143,16 +143,12 @@ init_ltp_netspace()
 # RETURN: 0 on success, 1 on failure
 tst_rhost_run()
 {
-	local pre_cmd=
 	local post_cmd=' || echo RTERR'
-	local out=
 	local user="root"
-	local cmd=
-	local safe=0
-	local bg=
-
-	OPTIND=0
+	local ret=0
+	local bg cmd out output pre_cmd safe
 
+	local OPTIND
 	while getopts :bBsc:u: opt; do
 		case "$opt" in
 		b|B) [ "$TST_USE_NETNS" ] && pre_cmd= || pre_cmd="nohup"
@@ -167,17 +163,13 @@ tst_rhost_run()
 		esac
 	done
 
-	OPTIND=0
-
 	if [ -z "$cmd" ]; then
-		[ "$safe" -eq 1 ] && \
+		[ "$safe" = 1 ] && \
 			tst_brk_ TBROK "tst_rhost_run: command not defined"
 		tst_res_ TWARN "tst_rhost_run: command not defined"
 		return 1
 	fi
 
-	local output=
-	local ret=0
 	if [ -n "${TST_USE_SSH:-}" ]; then
 		output=`ssh -n -q $user@$RHOST "sh -c \
 			'$pre_cmd $cmd $post_cmd'" $out 2>&1 || echo 'RTERR'`
@@ -191,7 +183,7 @@ tst_rhost_run()
 	echo "$output" | grep -q 'RTERR$' && ret=1
 	if [ $ret -eq 1 ]; then
 		output=$(echo "$output" | sed 's/RTERR//')
-		[ "$safe" -eq 1 ] && \
+		[ "$safe" = 1 ] && \
 			tst_brk_ TBROK "'$cmd' failed on '$RHOST': '$output'"
 	fi
 
@@ -200,8 +192,8 @@ tst_rhost_run()
 	return $ret
 }
 
-# Run command on both lhost and rhost.
-# tst_net_run [-s] [-l LPARAM] [-r RPARAM] [ -q ] CMD [ARG [ARG2]]
+# Run command on both lhost and rhost
+# tst_net_run [-s] [-l LPARAM] [-r RPARAM] [-q] CMD [ARG [ARG2]]
 # Options:
 # -l LPARAM: parameter passed to CMD in lhost
 # -r RPARAM: parameter passed to CMD in rhost
@@ -211,14 +203,7 @@ tst_rhost_run()
 # RETURN: 0 on success, 1 on missing CMD or exit code on lhost or rhost
 tst_net_run()
 {
-	local cmd
-	local lparams
-	local rparams
-	local lsafe
-	local rsafe
-	local lret
-	local rret
-	local quiet
+	local cmd lparams lret lsafe quiet rparams rret rsafe
 
 	local OPTIND
 	while getopts l:qr:s opt; do
@@ -275,9 +260,9 @@ EXPECT_RHOST_FAIL()
 	fi
 }
 
-# Get test interface names for local/remote host.
+# Get test interface names for local/remote host
 # tst_get_ifaces [TYPE]
-# TYPE: { lhost | rhost }; Default value is 'lhost'.
+# TYPE: { lhost | rhost }, default value is 'lhost'
 tst_get_ifaces()
 {
 	local type="${1:-lhost}"
@@ -288,14 +273,13 @@ tst_get_ifaces()
 	fi
 }
 
-# Get HW addresses from defined test interface names.
+# Get HW addresses from defined test interface names
 # tst_get_hwaddrs [TYPE]
-# TYPE: { lhost | rhost }; Default value is 'lhost'.
+# TYPE: { lhost | rhost }, default value is 'lhost'
 tst_get_hwaddrs()
 {
 	local type="${1:-lhost}"
-	local addr=
-	local list=
+	local addr list
 
 	for eth in $(tst_get_ifaces $type); do
 
@@ -311,26 +295,26 @@ tst_get_hwaddrs()
 	echo "$list"
 }
 
-# Get test HW address.
+# Get test HW address
 # tst_hwaddr [TYPE] [LINK]
-# TYPE: { lhost | rhost }; Default value is 'lhost'.
-# LINK: link number starting from 0. Default value is '0'.
+# TYPE: { lhost | rhost }, default value is 'lhost'
+# LINK: link number starting from 0. Default value is '0'
 tst_hwaddr()
 {
 	tst_test_cmds awk
 
 	local type="${1:-lhost}"
 	local link_num="${2:-0}"
-	local hwaddrs=
+	local hwaddrs
 	link_num=$(( $link_num + 1 ))
 	[ "$type" = "lhost" ] && hwaddrs=$LHOST_HWADDRS || hwaddrs=$RHOST_HWADDRS
 	echo "$hwaddrs" | awk '{ print $'"$link_num"' }'
 }
 
-# Get test interface name.
+# Get test interface name
 # tst_iface [TYPE] [LINK]
-# TYPE: { lhost | rhost }; Default value is 'lhost'.
-# LINK: link number starting from 0. Default value is '0'.
+# TYPE: { lhost | rhost }, default value is 'lhost'
+# LINK: link number starting from 0, default value is '0'
 tst_iface()
 {
 	tst_test_cmds awk
@@ -343,7 +327,7 @@ tst_iface()
 
 # Get IP address
 # tst_ipaddr [TYPE]
-# TYPE: { lhost | rhost }; Default value is 'lhost'.
+# TYPE: { lhost | rhost }, default value is 'lhost'
 tst_ipaddr()
 {
 	local type="${1:-lhost}"
@@ -355,13 +339,13 @@ tst_ipaddr()
 }
 
 # Get IP address of unused network, specified either by type and counter
-# or by net and host.
+# 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.
+# 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.
+# 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()
@@ -419,8 +403,8 @@ tst_ipaddr_un()
 }
 
 # tst_init_iface [TYPE] [LINK]
-# TYPE: { lhost | rhost }; Default value is 'lhost'.
-# LINK: link number starting from 0. Default value is '0'.
+# TYPE: { lhost | rhost }, default value is 'lhost'
+# LINK: link number starting from 0, default value is '0'
 tst_init_iface()
 {
 	local type="${1:-lhost}"
@@ -453,6 +437,7 @@ tst_init_iface()
 # -a IP: IP address to be added, default value is
 #   $(tst_ipaddr)/$IPV{4,6}_{L,R}PREFIX
 # -s safe option, if something goes wrong, will exit with TBROK
+# RETURN: 0 on success, 1 on failure
 tst_add_ipaddr()
 {
 	local addr dad lsafe mask rsafe
@@ -492,8 +477,8 @@ tst_add_ipaddr()
 
 # tst_restore_ipaddr [TYPE] [LINK]
 # Restore default ip addresses defined in network.sh
-# TYPE: { lhost | rhost }; Default value is 'lhost'.
-# LINK: link number starting from 0. Default value is '0'.
+# TYPE: { lhost | rhost }, default value is 'lhost'
+# LINK: link number starting from 0, default value is '0'
 tst_restore_ipaddr()
 {
 	tst_test_cmds ip
@@ -517,10 +502,9 @@ tst_restore_ipaddr()
 # wait for IPv6 DAD completion
 tst_wait_ipv6_dad()
 {
-	local ret=
-	local i=
 	local iface_loc=${1:-$(tst_iface)}
 	local iface_rmt=${2:-$(tst_iface rhost)}
+	local i ret
 
 	for i in $(seq 1 50); do
 		ip a sh $iface_loc | grep -q tentative
@@ -549,24 +533,24 @@ tst_netload()
 	local expect_res="pass"
 	local ret=0
 	local type="tcp"
-	local hostopt=
-	local setup_srchost=0
+	local hostopt
+	local setup_srchost
 	# common options for client and server
-	local cs_opts=
+	local cs_opts
 
 	local c_num="$TST_NETLOAD_CLN_NUMBER"
 	local c_requests="$TST_NETLOAD_CLN_REQUESTS"
-	local c_opts=
+	local c_opts
 
 	# number of server replies after which TCP connection is closed
 	local s_replies="${TST_NETLOAD_MAX_SRV_REPLIES:-500000}"
-	local s_opts=
+	local s_opts
 
 	if [ ! "$TST_NEEDS_TMPDIR" = 1 ]; then
 		tst_brk_ TBROK "Using tst_netload requires setting TST_NEEDS_TMPDIR=1"
 	fi
 
-	OPTIND=0
+	local OPTIND
 	while getopts :a:H:d:n:N:r:R:S:b:t:T:fFe:m:A:D: opt; do
 		case "$opt" in
 		a) c_num="$OPTARG" ;;
@@ -592,7 +576,6 @@ tst_netload()
 		*) tst_brk_ TBROK "tst_netload: unknown option: $OPTARG" ;;
 		esac
 	done
-	OPTIND=0
 
 	[ "$setup_srchost" = 1 ] && s_opts="${s_opts}-S $hostopt "
 
@@ -690,11 +673,10 @@ tst_icmp()
 {
 	local timeout=1
 	local msg_sizes=56
-	local opts=
-	local num=
 	local ret=0
+	local num opts
 
-	OPTIND=0
+	local OPTIND
 	while getopts :t:s: opt; do
 		case "$opt" in
 		t) timeout="$OPTARG" ;;
@@ -702,7 +684,6 @@ tst_icmp()
 		*) opts="-$OPTARG $opts" ;;
 		esac
 	done
-	OPTIND=0
 
 	local num=$(echo "$msg_sizes" | wc -w)
 	timeout="$(($timeout / $num))"
@@ -725,15 +706,13 @@ tst_icmp()
 }
 
 # tst_set_sysctl NAME VALUE [safe]
-# It can handle netns case when sysctl not namespaceified.
+# It can handle netns case when sysctl not namespaceified
 tst_set_sysctl()
 {
 	local name="$1"
 	local value="$2"
-	local safe=
+	local rparam safe
 	[ "$3" = "safe" ] && safe="-s"
-
-	local rparam=
 	[ "$TST_USE_NETNS" = "yes" ] && rparam="-r '-e'"
 
 	tst_net_run $safe $rparam "sysctl -q -w $name=$value"
@@ -755,7 +734,7 @@ tst_default_max_pkt()
 [ -z "$RHOST" ] && TST_USE_NETNS="yes"
 export RHOST="$RHOST"
 export PASSWD="${PASSWD:-}"
-# Don't use it in new tests, use tst_rhost_run() from tst_net.sh instead.
+# Don't use it in new tests, use tst_rhost_run() from tst_net.sh instead
 export LTP_RSH="${LTP_RSH:-rsh -n}"
 
 # Test Links
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [LTP] [RFC PATCH v2 5/6] net: Move setup_addrinfo() from netstress.c into tst_net.h
  2019-05-10 18:31 [LTP] [RFC PATCH v2 0/6] net/route: Rewrite route{4, 6}-change-{dst, gw} into C Petr Vorel
                   ` (3 preceding siblings ...)
  2019-05-10 18:31 ` [LTP] [RFC PATCH v2 4/6] tst_net.sh: Minor code and doc cleanup Petr Vorel
@ 2019-05-10 18:31 ` Petr Vorel
  2019-05-10 18:31 ` [LTP] [RFC PATCH v2 6/6] net/route: Rewrite route{4, 6}-change-{dst, gw} into C Petr Vorel
  2019-05-28 12:32 ` [LTP] [RFC PATCH v2 0/6] " Alexey Kodanev
  6 siblings, 0 replies; 14+ messages in thread
From: Petr Vorel @ 2019-05-10 18:31 UTC (permalink / raw)
  To: ltp

This allows reusing it in next commit.

Add missing includes into tst_net.h, make functions inline.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Maybe tst_net.c would be better than inline functions.
tst_net.h requires tst_test.h be loaded first.

 include/tst_net.h                       | 45 +++++++++++++------------
 testcases/network/netstress/netstress.c | 14 +-------
 2 files changed, 25 insertions(+), 34 deletions(-)

diff --git a/include/tst_net.h b/include/tst_net.h
index cb97b7b61..ad067d8c6 100644
--- a/include/tst_net.h
+++ b/include/tst_net.h
@@ -1,22 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
- * Copyright (c) 2017 Petr Vorel <pvorel@suse.cz>
- *
- * 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, see <http://www.gnu.org/licenses/>.
+ * Copyright (c) 2017-2019 Petr Vorel <pvorel@suse.cz>
  */
 
 #include <arpa/inet.h>
 #include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
 
 #define MAX_IPV4_PREFIX 32
 #define MAX_IPV6_PREFIX 128
@@ -45,7 +35,7 @@ static inline void print_svar_change(const char *name, const char *val)
 /*
  * Function bit_count is from ipcalc project, ipcalc.c.
  */
-static int bit_count(uint32_t i)
+static inline int bit_count(uint32_t i)
 {
 	int c = 0;
 	unsigned int seen_one = 0;
@@ -67,7 +57,7 @@ static int bit_count(uint32_t i)
 /*
  * Function mask2prefix is from ipcalc project, ipcalc.c.
  */
-static int mask2prefix(struct in_addr mask)
+static inline int mask2prefix(struct in_addr mask)
 {
 	return bit_count(ntohl(mask.s_addr));
 }
@@ -75,7 +65,7 @@ static int mask2prefix(struct in_addr mask)
 /*
  * Function ipv4_mask_to_int is from ipcalc project, ipcalc.c.
  */
-static int ipv4_mask_to_int(const char *prefix)
+static inline int ipv4_mask_to_int(const char *prefix)
 {
 	int ret;
 	struct in_addr in;
@@ -90,7 +80,7 @@ static int ipv4_mask_to_int(const char *prefix)
 /*
  * Function safe_atoi is from ipcalc project, ipcalc.c.
  */
-static int safe_atoi(const char *s, int *ret_i)
+static inline int safe_atoi(const char *s, int *ret_i)
 {
 	char *x = NULL;
 	long l;
@@ -112,7 +102,7 @@ static int safe_atoi(const char *s, int *ret_i)
 /*
  * Function get_prefix use code from ipcalc project, str_to_prefix/ipcalc.c.
  */
-static int get_prefix(const char *ip_str, int is_ipv6)
+static inline int get_prefix(const char *ip_str, int is_ipv6)
 {
 	char *prefix_str = NULL;
 	int prefix = -1, r;
@@ -140,14 +130,27 @@ static int get_prefix(const char *ip_str, int is_ipv6)
 	return prefix;
 }
 
-static void get_in_addr(const char *ip_str, struct in_addr *ip)
+static inline void get_in_addr(const char *ip_str, struct in_addr *ip)
 {
 	if (inet_pton(AF_INET, ip_str, ip) <= 0)
 		tst_brk_comment("bad IPv4 address: '%s'", ip_str);
 }
 
-static void get_in6_addr(const char *ip_str, struct in6_addr *ip6)
+static inline void get_in6_addr(const char *ip_str, struct in6_addr *ip6)
 {
 	if (inet_pton(AF_INET6, ip_str, ip6) <= 0)
 		tst_brk_comment("bad IPv6 address: '%s'", ip_str);
 }
+
+static inline void setup_addrinfo(const char *src_addr, const char *port,
+			   const struct addrinfo *hints,
+			   struct addrinfo **addr_info)
+{
+	int err = getaddrinfo(src_addr, port, hints, addr_info);
+
+	if (err)
+		tst_brk(TBROK, "getaddrinfo failed, %s", gai_strerror(err));
+
+	if (!*addr_info)
+		tst_brk(TBROK, "failed to get the address");
+}
diff --git a/testcases/network/netstress/netstress.c b/testcases/network/netstress/netstress.c
index 06882b1b3..5001f206a 100644
--- a/testcases/network/netstress/netstress.c
+++ b/testcases/network/netstress/netstress.c
@@ -43,6 +43,7 @@
 #include "tst_safe_stdio.h"
 #include "tst_safe_pthread.h"
 #include "tst_test.h"
+#include "tst_net.h"
 
 static const int max_msg_len = (1 << 16) - 1;
 static const int min_msg_len = 5;
@@ -455,19 +456,6 @@ static int parse_client_request(const char *msg)
 static struct timespec tv_client_start;
 static struct timespec tv_client_end;
 
-static void setup_addrinfo(const char *src_addr, const char *port,
-			   const struct addrinfo *hints,
-			   struct addrinfo **addr_info)
-{
-	int err = getaddrinfo(src_addr, port, hints, addr_info);
-
-	if (err)
-		tst_brk(TBROK, "getaddrinfo failed, %s", gai_strerror(err));
-
-	if (!*addr_info)
-		tst_brk(TBROK, "failed to get the address");
-}
-
 static void client_init(void)
 {
 	if (clients_num >= MAX_THREADS) {
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [LTP] [RFC PATCH v2 6/6] net/route: Rewrite route{4, 6}-change-{dst, gw} into C
  2019-05-10 18:31 [LTP] [RFC PATCH v2 0/6] net/route: Rewrite route{4, 6}-change-{dst, gw} into C Petr Vorel
                   ` (4 preceding siblings ...)
  2019-05-10 18:31 ` [LTP] [RFC PATCH v2 5/6] net: Move setup_addrinfo() from netstress.c into tst_net.h Petr Vorel
@ 2019-05-10 18:31 ` Petr Vorel
  2019-06-14 11:59   ` Alexey Kodanev
  2019-05-28 12:32 ` [LTP] [RFC PATCH v2 0/6] " Alexey Kodanev
  6 siblings, 1 reply; 14+ messages in thread
From: Petr Vorel @ 2019-05-10 18:31 UTC (permalink / raw)
  To: ltp

Code:
* use libmnl and new C API
* reuse code in tst_net.h (added in previous commit)
* add shell wrapper (set environment with tst_net.sh instead of using
  deprecated helpers in testcases/network/stress/ns-tools/)
* Add tst_ipaddr_un() into C API, unlike shell API this implementation
  does not support -c tst_ipaddr_un [-cCOUNTER] [TYPE] syntax.

Travis:
* add libmnl libraries to most of travis jobs
* replace spaces with tabs some travis shell files

Cleanup:
* cleanup test description
* other cleanup

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 configure.ac                                  |   1 +
 include/mk/config.mk.default                  |   2 +
 include/mk/config.mk.in                       |   2 +
 include/tst_net.h                             |  45 +++
 m4/ltp-libmnl.m4                              |   7 +
 runtest/net_stress.route                      |  10 +-
 testcases/network/stress/route/.gitignore     |   1 +
 .../network/stress/route/00_Descriptions.txt  |  48 +--
 testcases/network/stress/route/Makefile       |  30 +-
 testcases/network/stress/route/route-change.c | 243 +++++++++++++++
 .../network/stress/route/route-change.sh      |  52 ++++
 .../network/stress/route/route4-change-dst    | 276 -----------------
 .../network/stress/route/route4-change-gw     | 292 ------------------
 .../network/stress/route/route6-change-dst    | 272 ----------------
 .../network/stress/route/route6-change-gw     | 292 ------------------
 travis/debian.cross-compile.aarch64.sh        |   6 +-
 travis/debian.cross-compile.ppc64le.sh        |   8 +-
 travis/debian.i386.sh                         |   3 +-
 travis/debian.minimal.sh                      |  28 +-
 travis/debian.sh                              |  55 ++--
 travis/fedora.sh                              |   5 +-
 travis/tumbleweed.sh                          |   7 +-
 22 files changed, 443 insertions(+), 1242 deletions(-)
 create mode 100644 m4/ltp-libmnl.m4
 create mode 100644 testcases/network/stress/route/.gitignore
 create mode 100644 testcases/network/stress/route/route-change.c
 create mode 100755 testcases/network/stress/route/route-change.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/route6-change-dst
 delete mode 100644 testcases/network/stress/route/route6-change-gw

diff --git a/configure.ac b/configure.ac
index fad8f8396..0ea6ed531 100644
--- a/configure.ac
+++ b/configure.ac
@@ -207,6 +207,7 @@ LTP_CHECK_IOVEC
 LTP_CHECK_KCMP_TYPE
 LTP_CHECK_KERNEL_DEVEL
 LTP_CHECK_KEYUTILS_SUPPORT
+LTP_CHECK_LIBMNL
 LTP_CHECK_LINUX_PTRACE
 LTP_CHECK_LINUXRANDOM
 LTP_CHECK_MADVISE
diff --git a/include/mk/config.mk.default b/include/mk/config.mk.default
index 0934d9453..d55ca888d 100644
--- a/include/mk/config.mk.default
+++ b/include/mk/config.mk.default
@@ -43,6 +43,8 @@ YACC			:= bison -y
 #SELINUX_LIBS		:= -lselinux
 #TIRPC_CPPFLAGS		:= -I/usr/include/tirpc
 #TIRPC_LIBS		:= -ltirpc
+#LIBMNL_LIBS		:= -lmnl
+#LIBMNL_CFLAGS		:= -I/usr/include/libmnl
 
 prefix			:= /opt/ltp
 
diff --git a/include/mk/config.mk.in b/include/mk/config.mk.in
index d55fe9602..ee442f718 100644
--- a/include/mk/config.mk.in
+++ b/include/mk/config.mk.in
@@ -47,6 +47,8 @@ TIRPC_CPPFLAGS		:= @TIRPC_CPPFLAGS@
 TIRPC_LIBS		:= @TIRPC_LIBS@
 KEYUTILS_LIBS		:= @KEYUTILS_LIBS@
 HAVE_FTS_H		:= @HAVE_FTS_H@
+LIBMNL_LIBS		:= @LIBMNL_LIBS@
+LIBMNL_CFLAGS		:= @LIBMNL_CFLAGS@
 
 prefix			:= @prefix@
 
diff --git a/include/tst_net.h b/include/tst_net.h
index ad067d8c6..404595241 100644
--- a/include/tst_net.h
+++ b/include/tst_net.h
@@ -7,10 +7,14 @@
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include "tst_safe_stdio.h"
 
 #define MAX_IPV4_PREFIX 32
 #define MAX_IPV6_PREFIX 128
 
+#define MAX_IPV4_NET_ID 255
+#define MAX_IPV6_NET_ID 65535
+
 #define tst_res_comment(...) { \
 	fprintf(stderr, "# "); \
 	tst_res(__VA_ARGS__); } \
@@ -154,3 +158,44 @@ static inline void setup_addrinfo(const char *src_addr, const char *port,
 	if (!*addr_info)
 		tst_brk(TBROK, "failed to get the address");
 }
+
+/*
+ * NOTE: unlike shell implementation this support only:
+ * tst_ipaddr_un NET_ID HOST_ID
+ */
+static inline char *tst_ipaddr_un(int ai_family, unsigned int net, unsigned int host)
+{
+	char *env = "IPV4_NET16_UNUSED";
+	unsigned int max = MAX_IPV4_NET_ID;
+	char *addr, *unused;
+
+	if (ai_family != AF_INET && ai_family != AF_INET6)
+		tst_brk(TCONF, "ai_family must be AF_INET or AF_INET6 (%d)", ai_family);
+
+	if (ai_family == AF_INET6) {
+		env = "IPV6_NET32_UNUSED";
+		max = MAX_IPV6_NET_ID;
+	}
+
+	unused = getenv(env);
+	if (!unused)
+		tst_brk(TCONF, "%s not set (set it with tst_net.sh)", env);
+
+	net %= max;
+	host %= max;
+
+	if (ai_family == AF_INET6) {
+		if (host > 0 && net > 0)
+			SAFE_ASPRINTF(&addr, "%s:%x::%x", unused, net, host);
+		else if (host > 0 && net == 0)
+			SAFE_ASPRINTF(&addr, "%s::%x", unused, host);
+		else if (net > 0 && host == 0)
+			SAFE_ASPRINTF(&addr, "%s:%x::", unused, net);
+		else
+			SAFE_ASPRINTF(&addr, "%s::", unused);
+	} else {
+		SAFE_ASPRINTF(&addr, "%s.%d.%d", unused, net, host);
+	}
+
+	return strdup(addr);
+}
diff --git a/m4/ltp-libmnl.m4 b/m4/ltp-libmnl.m4
new file mode 100644
index 000000000..56adaba6e
--- /dev/null
+++ b/m4/ltp-libmnl.m4
@@ -0,0 +1,7 @@
+dnl Copyright (c) 2019 Petr Vorel <pvorel@suse.cz>
+
+AC_DEFUN([LTP_CHECK_LIBMNL], [
+    PKG_CHECK_MODULES([LIBMNL], [libmnl], [
+        AC_DEFINE([HAVE_LIBMNL], [1], [Define to 1 if you have libmnl libraries and headers])
+	], [have_libmnl=no])
+])
diff --git a/runtest/net_stress.route b/runtest/net_stress.route
index c065c5cd1..0a72c4eee 100644
--- a/runtest/net_stress.route
+++ b/runtest/net_stress.route
@@ -1,13 +1,11 @@
-#
 # Stress test for routing table
-#
 
-route4-change-dst route4-change-dst
-route4-change-gw route4-change-gw
+route4-change-dst route-change.sh
+route4-change-gw route-change.sh -g
 route4-redirect route4-redirect
 route4-rmmod route4-rmmod
 
-route6-change-dst route6-change-dst
-route6-change-gw route6-change-gw
+route6-change-dst route-change.sh -6
+route6-change-gw route-change.sh -6 -g
 route6-redirect route6-redirect
 route6-rmmod route6-rmmod
diff --git a/testcases/network/stress/route/.gitignore b/testcases/network/stress/route/.gitignore
new file mode 100644
index 000000000..53d3c16d1
--- /dev/null
+++ b/testcases/network/stress/route/.gitignore
@@ -0,0 +1 @@
+/route-change
diff --git a/testcases/network/stress/route/00_Descriptions.txt b/testcases/network/stress/route/00_Descriptions.txt
index 91aa01120..e31f5918b 100644
--- a/testcases/network/stress/route/00_Descriptions.txt
+++ b/testcases/network/stress/route/00_Descriptions.txt
@@ -1,56 +1,32 @@
-route4-change-dst01
-	Verify the kernel is not crashed when the destination of an IPv4 route
-	is changed frequently by route command
+route4-change-dst
+	Change IPv4 route destination by libmnl API
 
-route4-change-dst02
-	Verify the kernel is not crashed when the destination of an IPv4 route
-	is changed frequently by ip command
-
-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
+route4-change-gw
+	Change IPv4 route gateway by libmnl API
 
 route4-redirect01
 	Verify the kernel is not crashed when the IPv4 route is modified by
 	ICMP Redirects frequently
 
 route4-rmmod01
-	Verify the kernel is not crashed when IPv4 route is add by route command
-	then it is deleted by the removing network driver
+	Add IPv4 route by route command then delete it by the removing network driver
 
 route4-rmmod02
-	Verify the kernel is not crashed when IPv4 route is add by ip command
-	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
+	Add IPv4 route by ip command then delete it by the removing network driver
 
-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
+route6-change-dst
+	Change IPv6 route destination by libmnl API
 
-route6-change-gw02
-	Verify the kernel is not crashed when the gateway of an IPv6 route is
-	changed frequently by ip command
+route6-change-gw
+	Change IPv6 route gateway by libmnl API
 
 route6-redirect01
 	Verify the kernel is not crashed when the IPv6 route is modified by
 	ICMP Redirects frequently
 
 route6-rmmod01
-	Verify the kernel is not crashed when IPv6 route is add by route command
-	then it is deleted by the removing network driver
+	Add IPv6 route by route command then delete it by the removing network driver
 
 route6-rmmod02
-	Verify the kernel is not crashed when IPv6 route is add by ip command
-	then it is deleted by the removing network driver
+	Add IPv6 route by ip command then delete it by the removing network driver
diff --git a/testcases/network/stress/route/Makefile b/testcases/network/stress/route/Makefile
index 2e5eaa2f2..49247e4d8 100644
--- a/testcases/network/stress/route/Makefile
+++ b/testcases/network/stress/route/Makefile
@@ -1,29 +1,15 @@
-#
-#    network/stress/route test suite Makefile.
-#
-#    Copyright (C) 2009, Cisco Systems Inc.
-#
-#    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.
-#
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (C) 2009, Cisco Systems Inc.
+# Copyright (c) Linux Test Project, 2006-2019
 # Ngie Cooper, October 2009
-#
 
 top_srcdir		?= ../../../..
 
-include $(top_srcdir)/include/mk/env_pre.mk
+include $(top_srcdir)/include/mk/testcases.mk
 
-INSTALL_TARGETS		:= route*
+INSTALL_TARGETS		+= route[4-6]-* *.sh
+
+route-change: CFLAGS += $(LIBMNL_CFLAGS)
+route-change: LDLIBS += $(LIBMNL_LIBS)
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/stress/route/route-change.c b/testcases/network/stress/route/route-change.c
new file mode 100644
index 000000000..d694a0f65
--- /dev/null
+++ b/testcases/network/stress/route/route-change.c
@@ -0,0 +1,243 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2019 Petr Vorel <pvorel@suse.cz>
+ */
+
+#include "config.h"
+#include "tst_test.h"
+
+#ifdef HAVE_LIBMNL
+
+#include <string.h>
+
+#include <libmnl/libmnl.h>
+#include <linux/rtnetlink.h>
+#include <net/if.h>
+#include <netdb.h>
+
+#include "tst_net.h"
+#include "tst_safe_net.h"
+#include "tst_safe_stdio.h"
+
+#define NS_TIMES_MAX 255
+#define MAX_IP 255
+
+static char *c_opt, *d_opt, *g_opt, *ipv6_opt, *l_opt, *m_opt, *r_opt;
+static int family = AF_INET;
+static int num_loops = 10000;
+static int iface, is_ipv6, gwhost, lhost, max_ip = MAX_IP, rhost;
+static unsigned int prefix;
+static struct mnl_socket *nl;
+static struct addrinfo *local_addrinfo;
+static struct addrinfo *remote_addrinfo;
+static int fd;
+
+struct in_addr ip;
+struct in6_addr ip6;
+
+union {
+	in_addr_t ip;
+	struct in6_addr ip6;
+} dst;
+
+static void setup(void)
+{
+	prefix = 24;
+	if (ipv6_opt) {
+		family = AF_INET6;
+		is_ipv6 = 1;
+		prefix = 64;
+	}
+
+	if (tst_parse_int(c_opt, &num_loops, 1, INT_MAX))
+		tst_brk(TBROK, "Invalid number of loops: '%s'", c_opt);
+
+	if (!d_opt)
+		tst_brk(TBROK, "Missing iface, specify it with -d");
+
+	iface = if_nametoindex(d_opt);
+	if (!iface)
+		tst_brk(TBROK, "if_nametoindex failed");
+
+	if (g_opt  && tst_parse_int(g_opt, &gwhost, 1, NS_TIMES_MAX))
+		tst_brk(TBROK, "Invalid gateway host id: '%s'", g_opt);
+
+	if (!l_opt)
+		tst_brk(TBROK, "Missing local host id, specify it with -l");
+
+	if (m_opt && tst_parse_int(m_opt, &max_ip, 1, MAX_IP))
+		tst_brk(TBROK, "Invalid max IP: '%s'", m_opt);
+
+	if (tst_parse_int(l_opt, &lhost, 1, NS_TIMES_MAX))
+		tst_brk(TBROK, "Invalid local host id: '%s'", l_opt);
+
+	if (!r_opt)
+		tst_brk(TBROK, "Missing remote host id, specify it with -r");
+
+	if (tst_parse_int(r_opt, &rhost, 1, NS_TIMES_MAX))
+		tst_brk(TBROK, "Invalid remote host id: '%s'", r_opt);
+
+	if (lhost == gwhost || lhost == rhost || rhost == gwhost)
+		tst_brk(TBROK, "-g, -l and -r params must be different: %d, %d, %d",
+				gwhost, rhost, lhost);
+}
+
+static void cleanup(void)
+{
+	if (fd > 0)
+		close(fd);
+
+	if (nl)
+		mnl_socket_close(nl);
+
+	if (remote_addrinfo)
+		freeaddrinfo(remote_addrinfo);
+}
+
+static void rtnl_route(int iface, char *destination, uint32_t prefix, char *gateway, int type)
+{
+	union {
+		in_addr_t ip;
+		struct in6_addr ip6;
+	} dst;
+	union {
+		in_addr_t ip;
+		struct in6_addr ip6;
+	} gw;
+
+	struct mnl_socket *nl;
+	char buf[MNL_SOCKET_BUFFER_SIZE];
+	struct nlmsghdr *nlh;
+	struct rtmsg *rtm;
+	uint32_t seq, portid;
+	int ret;
+
+	if (!inet_pton(family, destination, &dst))
+		tst_brk(TBROK, "inet_pton failed ('%s', errno=%d): %s", destination, errno, strerror(errno));
+
+	if (gateway && !inet_pton(family, gateway, &gw))
+		tst_brk(TBROK, "inet_pton failed ('%s', errno=%d): %s", gateway, errno, strerror(errno));
+
+	nlh = mnl_nlmsg_put_header(buf);
+	nlh->nlmsg_type	= type;
+	nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_ACK;
+	nlh->nlmsg_seq = seq = time(NULL);
+
+	rtm = mnl_nlmsg_put_extra_header(nlh, sizeof(struct rtmsg));
+	rtm->rtm_family = family;
+	rtm->rtm_dst_len = prefix;
+	rtm->rtm_src_len = 0;
+	rtm->rtm_tos = 0;
+	rtm->rtm_protocol = RTPROT_STATIC;
+	rtm->rtm_table = RT_TABLE_MAIN;
+	rtm->rtm_type = RTN_UNICAST;
+	rtm->rtm_scope = (gateway) ? RT_SCOPE_UNIVERSE : RT_SCOPE_LINK;
+	rtm->rtm_flags = 0;
+
+	if (is_ipv6)
+		mnl_attr_put(nlh, RTA_DST, sizeof(struct in6_addr), &dst);
+	else
+		mnl_attr_put_u32(nlh, RTA_DST, dst.ip);
+
+	mnl_attr_put_u32(nlh, RTA_OIF, iface);
+	if (gateway) {
+		if (is_ipv6)
+			mnl_attr_put(nlh, RTA_GATEWAY, sizeof(struct in6_addr),
+					&gw.ip6);
+		else
+			mnl_attr_put_u32(nlh, RTA_GATEWAY, gw.ip);
+	}
+
+	nl = mnl_socket_open(NETLINK_ROUTE);
+	if (nl == NULL)
+		tst_brk(TBROK, "mnl_socket_open failed (errno=%d): %s", errno, strerror(errno));
+
+	if (mnl_socket_bind(nl, 0, MNL_SOCKET_AUTOPID) < 0)
+		tst_brk(TBROK, "mnl_socket_bind failed (errno=%d): %s", errno, strerror(errno));
+
+	portid = mnl_socket_get_portid(nl);
+
+	if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0)
+		tst_brk(TBROK, "mnl_socket_sendto failed (errno=%d): %s", errno, strerror(errno));
+
+	ret = mnl_socket_recvfrom(nl, buf, sizeof(buf));
+	if (ret < 0)
+		tst_brk(TBROK, "mnl_socket_recvfrom failed (ret=%d, errno=%d): %s", ret, errno, strerror(errno));
+
+	ret = mnl_cb_run(buf, ret, seq, portid, NULL, NULL);
+	if (ret < 0)
+		tst_brk(TBROK, "mnl_cb_run failed (ret=%d, errno=%d): %s", ret, errno, strerror(errno));
+
+	mnl_socket_close(nl);
+}
+
+static void send_udp(char *local, char *remote)
+{
+	fd = SAFE_SOCKET(family, SOCK_DGRAM, IPPROTO_UDP);
+
+	struct addrinfo hints;
+	memset(&hints, 0, sizeof(struct addrinfo));
+	hints.ai_family = family;
+	hints.ai_socktype = SOCK_DGRAM;
+	hints.ai_flags = 0;
+	hints.ai_protocol = 0;
+	hints.ai_addr = INADDR_ANY;
+	setup_addrinfo(local, NULL, &hints, &local_addrinfo);
+	char *port;
+	int _port = TST_GET_UNUSED_PORT(family, SOCK_DGRAM);
+	SAFE_ASPRINTF(&port, "%d", _port);
+	setup_addrinfo(remote, port, &hints, &remote_addrinfo);
+
+	SAFE_BIND(fd, local_addrinfo->ai_addr, local_addrinfo->ai_addrlen);
+
+	SAFE_SENDTO(1, fd, remote, strlen(remote), MSG_CONFIRM,
+		remote_addrinfo->ai_addr, remote_addrinfo->ai_addrlen);
+
+	close(fd);
+}
+
+static void run(void)
+{
+	int i, j;
+	char *destination, *gateway = NULL, *local, *remote;
+
+	tst_res(TINFO, "Adding and deleting route with different destination %d times", num_loops);
+	for (i = 0; i < num_loops; i++) {
+		j = i % max_ip;
+		local = tst_ipaddr_un(family, j, lhost);
+		remote = tst_ipaddr_un(family, j, rhost);
+		if (g_opt) {
+			destination = tst_ipaddr_un(family, 0, 0);
+			gateway = tst_ipaddr_un(family, j, gwhost);
+		} else {
+			destination = tst_ipaddr_un(family, j, 0);
+		}
+
+		rtnl_route(iface, destination, prefix, gateway, RTM_NEWROUTE);
+		send_udp(local, remote);
+		rtnl_route(iface, destination, prefix, gateway, RTM_DELROUTE);
+	}
+
+	tst_res(TPASS, "Routes created and deleted");
+}
+
+static struct tst_option options[] = {
+	{"6", &ipv6_opt, "-6       Use IPv6 (default is IPv4)"},
+	{"c:", &c_opt, "-c x     Number of loops"},
+	{"d:", &d_opt, "-d IFACE Interface to work on"},
+	{"g:", &g_opt, "-g x     Change gateway instead of destination, x: Host id of gateway"},
+	{"l:", &l_opt, "-l x     Local host id"},
+	{"m:", &m_opt, "-m x     Max IP addresses, this modulos -c"},
+	{"r:", &r_opt, "-r x     Remote host id"},
+	{NULL, NULL, NULL}
+};
+static struct tst_test test = {
+	.test_all = run,
+	.needs_root = 1,
+	.setup = setup,
+	.cleanup = cleanup,
+	.options = options,
+};
+#else
+	TST_TEST_TCONF("netlink libraries and headers are required");
+#endif /* HAVE_LIBNL_CLI3 */
diff --git a/testcases/network/stress/route/route-change.sh b/testcases/network/stress/route/route-change.sh
new file mode 100755
index 000000000..35b23a15f
--- /dev/null
+++ b/testcases/network/stress/route/route-change.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2019 Petr Vorel <pvorel@suse.cz>
+
+TST_TESTFUNC="do_test"
+TST_OPTS="g"
+TST_PARSE_ARGS="route_change_parse_args"
+TST_SETUP="setup"
+TST_CLEANUP="cleanup"
+TST_NEEDS_TMPDIR=1
+. tst_net.sh
+
+GATEWAY=1
+LHOST=2
+RHOST=3
+
+MAX_IP=${MAX_IP:-255}
+NS_TIMES=${NS_TIMES:-10000}
+
+route_change_parse_args()
+{
+	case "$1" in
+	g) g_opt="-g $GATEWAY" ;;
+	esac
+}
+
+setup()
+{
+	local cnt=0
+
+	while [ $cnt -lt $NS_TIMES -a $cnt -lt $MAX_IP ]; do
+		tst_add_ipaddr -s -a $(tst_ipaddr_un $cnt $LHOST)
+		tst_add_ipaddr -s -a $(tst_ipaddr_un $cnt $RHOST) rhost
+		cnt=$((cnt+1))
+	done
+}
+
+cleanup()
+{
+	tst_restore_ipaddr
+	tst_restore_ipaddr rhost
+}
+
+do_test()
+{
+	local ip_flag port
+	[ "$TST_IPV6" ] && ip_flag="-6"
+
+	EXPECT_PASS route-change -d $(tst_iface) -c $NS_TIMES $ip_flag $g_opt -l $LHOST -m $MAX_IP -r $RHOST
+}
+
+tst_run
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/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-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
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
diff --git a/travis/debian.cross-compile.aarch64.sh b/travis/debian.cross-compile.aarch64.sh
index 4b07f186f..be1e52ccf 100755
--- a/travis/debian.cross-compile.aarch64.sh
+++ b/travis/debian.cross-compile.aarch64.sh
@@ -2,6 +2,10 @@
 # Copyright (c) 2018 Petr Vorel <pvorel@suse.cz>
 set -e
 
+dpkg --add-architecture arm64
+apt update
+
 apt install -y --no-install-recommends \
 	gcc-aarch64-linux-gnu \
-	libc6-dev-arm64-cross
+	libc6-dev-arm64-cross \
+	pkg-config:arm64
diff --git a/travis/debian.cross-compile.ppc64le.sh b/travis/debian.cross-compile.ppc64le.sh
index d8431bd52..340acf22d 100755
--- a/travis/debian.cross-compile.ppc64le.sh
+++ b/travis/debian.cross-compile.ppc64le.sh
@@ -2,6 +2,12 @@
 # Copyright (c) 2018 Petr Vorel <pvorel@suse.cz>
 set -e
 
+dpkg --add-architecture ppc64el
+apt update
+
 apt install -y --no-install-recommends \
 	gcc-powerpc64le-linux-gnu \
-	libc6-dev-ppc64el-cross
+	libc6-dev-ppc64el-cross \
+	pkg-config:ppc64el \
+	libmnl0:ppc64el \
+	libmnl-dev:ppc64el \
diff --git a/travis/debian.i386.sh b/travis/debian.i386.sh
index 250d53b0d..c9ac3a9eb 100755
--- a/travis/debian.i386.sh
+++ b/travis/debian.i386.sh
@@ -16,4 +16,5 @@ apt install -y --no-install-recommends \
 	libkeyutils1:i386 \
 	libnuma1:i386 \
 	libssl-dev:i386 \
-	libtirpc1:i386
+	libtirpc1:i386 \
+	pkg-config:i386
diff --git a/travis/debian.minimal.sh b/travis/debian.minimal.sh
index 8e8bb6249..856b4002d 100755
--- a/travis/debian.minimal.sh
+++ b/travis/debian.minimal.sh
@@ -3,17 +3,17 @@
 set -e
 
 apt remove -y \
-    libacl1-dev \
-    libaio-dev \
-    libaio1 \
-    libcap-dev \
-    libcap2 \
-    libkeyutils-dev \
-    libkeyutils1 \
-    libmm-dev \
-    libnuma-dev \
-    libnuma1 \
-    libselinux1-dev \
-    libsepol1-dev \
-    libssl-dev \
-    libtirpc1
+	libacl1-dev \
+	libaio-dev \
+	libaio1 \
+	libcap-dev \
+	libcap2 \
+	libkeyutils-dev \
+	libkeyutils1 \
+	libmm-dev \
+	libnuma-dev \
+	libnuma1 \
+	libselinux1-dev \
+	libsepol1-dev \
+	libssl-dev \
+	libtirpc1
diff --git a/travis/debian.sh b/travis/debian.sh
index 56c8a08be..b8a345dbb 100755
--- a/travis/debian.sh
+++ b/travis/debian.sh
@@ -9,31 +9,34 @@ grep -v oldstable-updates /etc/apt/sources.list > /tmp/sources.list && mv /tmp/s
 apt update
 
 apt install -y --no-install-recommends \
-    acl-dev \
-    autoconf \
-    automake \
-    build-essential \
-    debhelper \
-    devscripts \
-    clang \
-    gcc \
-    libacl1 \
-    libacl1-dev \
-    libaio-dev \
-    libaio1 \
-    libcap-dev \
-    libcap2 \
-    libc6 \
-    libc6-dev \
-    libkeyutils-dev \
-    libkeyutils1 \
-    libmm-dev \
-    libnuma-dev \
-    libnuma1 \
-    libselinux1-dev \
-    libsepol1-dev \
-    libssl-dev \
-    linux-libc-dev \
-    lsb-release
+	acl-dev \
+	autoconf \
+	automake \
+	build-essential \
+	debhelper \
+	devscripts \
+	clang \
+	gcc \
+	libacl1 \
+	libacl1-dev \
+	libaio-dev \
+	libaio1 \
+	libcap-dev \
+	libcap2 \
+	libc6 \
+	libc6-dev \
+	libkeyutils-dev \
+	libkeyutils1 \
+	libmm-dev \
+	libmnl0 \
+	libmnl-dev \
+	libnuma-dev \
+	libnuma1 \
+	libselinux1-dev \
+	libsepol1-dev \
+	libssl-dev \
+	linux-libc-dev \
+	lsb-release \
+	pkg-config
 
 apt install libtirpc1 libtirpc3 || true
diff --git a/travis/fedora.sh b/travis/fedora.sh
index a4633333e..196336563 100755
--- a/travis/fedora.sh
+++ b/travis/fedora.sh
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright (c) 2018 Petr Vorel <pvorel@suse.cz>
+# Copyright (c) 2018-2019 Petr Vorel <pvorel@suse.cz>
 set -e
 
 yum -y install \
@@ -9,4 +9,7 @@ yum -y install \
 	clang \
 	gcc \
 	findutils \
+	libmnl \
+	libmnl-devel \
+	pkg-config \
 	redhat-lsb-core
diff --git a/travis/tumbleweed.sh b/travis/tumbleweed.sh
index c57257120..969767ca6 100755
--- a/travis/tumbleweed.sh
+++ b/travis/tumbleweed.sh
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright (c) 2018 Petr Vorel <pvorel@suse.cz>
+# Copyright (c) 2018-2019 Petr Vorel <pvorel@suse.cz>
 set -e
 
 zypper --non-interactive install --no-recommends \
@@ -14,9 +14,12 @@ zypper --non-interactive install --no-recommends \
 	libacl-devel \
 	libaio-devel \
 	libcap-devel \
+	libmnl0 \
+	libmnl-devel \
 	libnuma-devel \
 	libopenssl-devel \
 	libselinux-devel \
 	libtirpc-devel \
 	linux-glibc-devel \
-	lsb-release
+	lsb-release \
+	pkg-config
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [LTP] [RFC PATCH v2 1/6] net/route: Remove route{4, 6}-change-if
  2019-05-10 18:31 ` [LTP] [RFC PATCH v2 1/6] net/route: Remove route{4,6}-change-if Petr Vorel
@ 2019-05-23 12:46   ` Alexey Kodanev
  2019-05-23 13:05     ` Petr Vorel
  0 siblings, 1 reply; 14+ messages in thread
From: Alexey Kodanev @ 2019-05-23 12:46 UTC (permalink / raw)
  To: ltp

Hi Petr,
On 5/10/19 9:31 PM, Petr Vorel wrote:
> These testsuites requires 3 NIC setup, which is not supported by network
> namespace setup (single host configuration) and IMHO not common for two
> host configuration either.

I guess, the third interface can be easily created during the setup, on the
lhost... this is what's required, right?

For example, by adding macvlan to the test interface:

  ip link add ltp_mv0 link $(tst_iface) type macvlan mode bridge


Then, for the test route we can set either ltp_mv0 or $(tst_iface) interface.

> 
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
>  runtest/net_stress.route                      |   2 -
>  .../network/stress/route/00_Descriptions.txt  |  16 -
>  .../network/stress/route/route4-change-if     | 324 ------------------
>  .../network/stress/route/route6-change-if     | 323 -----------------
>  4 files changed, 665 deletions(-)
>  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 266ef0383..c065c5cd1 100644
> --- a/runtest/net_stress.route
> +++ b/runtest/net_stress.route
> @@ -4,12 +4,10 @@
>  
>  route4-change-dst route4-change-dst
>  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-gw route6-change-gw
> -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 2a871fdae..91aa01120 100644
> --- a/testcases/network/stress/route/00_Descriptions.txt
> +++ b/testcases/network/stress/route/00_Descriptions.txt
> @@ -14,14 +14,6 @@ route4-change-gw02
>  	Verify the kernel is not crashed when the gateway of an IPv4 route is
>  	changed frequently by ip command
>  
> -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
> -
>  route4-redirect01
>  	Verify the kernel is not crashed when the IPv4 route is modified by
>  	ICMP Redirects frequently
> @@ -51,14 +43,6 @@ 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
> -
> -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/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
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [LTP] [RFC PATCH v2 1/6] net/route: Remove route{4, 6}-change-if
  2019-05-23 12:46   ` [LTP] [RFC PATCH v2 1/6] net/route: Remove route{4, 6}-change-if Alexey Kodanev
@ 2019-05-23 13:05     ` Petr Vorel
  0 siblings, 0 replies; 14+ messages in thread
From: Petr Vorel @ 2019-05-23 13:05 UTC (permalink / raw)
  To: ltp

Hi Alexey,

> Hi Petr,
> On 5/10/19 9:31 PM, Petr Vorel wrote:
> > These testsuites requires 3 NIC setup, which is not supported by network
> > namespace setup (single host configuration) and IMHO not common for two
> > host configuration either.

> I guess, the third interface can be easily created during the setup, on the
> lhost... this is what's required, right?

> For example, by adding macvlan to the test interface:

>   ip link add ltp_mv0 link $(tst_iface) type macvlan mode bridge


> Then, for the test route we can set either ltp_mv0 or $(tst_iface) interface.

Thanks for review. I'd prefer to have this support in tst_net.sh as it can be
needed for some tests in the future, so why reinvent a wheel? Probably via some
variable (e.g.: TST_NET_EXTRA_NETNS_IFACES=2 => would add 2 more interfaces).
But maybe not every single thing must be in the library...

Much more important thing is how to solve validation when route-change-dst
on IPv6 requires using rhost and whether using C brings a benefit (next
patches in this patch-set).
First I wanted to use it because speed: faster changes stress system more
efficiently, but validation might slows it down anyway.
Validation: I give up because server app using threads (each binded to it's own
IP) was too slow and with client waiting for server to be up looked to me that
validation complicates the test a lot. But maybe instead of threading running
just several single thread instances would be faster.

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [LTP] [RFC PATCH v2 0/6] net/route: Rewrite route{4, 6}-change-{dst, gw} into C
  2019-05-10 18:31 [LTP] [RFC PATCH v2 0/6] net/route: Rewrite route{4, 6}-change-{dst, gw} into C Petr Vorel
                   ` (5 preceding siblings ...)
  2019-05-10 18:31 ` [LTP] [RFC PATCH v2 6/6] net/route: Rewrite route{4, 6}-change-{dst, gw} into C Petr Vorel
@ 2019-05-28 12:32 ` Alexey Kodanev
  2019-06-03  7:26   ` Petr Vorel
  6 siblings, 1 reply; 14+ messages in thread
From: Alexey Kodanev @ 2019-05-28 12:32 UTC (permalink / raw)
  To: ltp

Hi Petr,

On 5/10/19 9:31 PM, Petr Vorel wrote:
> Hi,
> 
> another attempt to rewrite route{4,6}-change-{dst,gw}.
> I'm not much happy with it.
> 
> I was trying to create server side validation over UDP, but failed.
> I didn't figure out setup where server could be on single IP address
> (there is probably a solution), so I created threads, each thread bind
> to single IP (number of threads is the same as number of IP addresses
> created in shell). Due limitation of IPv6 routes over gateway (which
> must be on rhost, for testsuite changing destination this is not
> necessary) I run server on rhost. Testsuite got complicated:
> waiting for threads to bind, save port and IP config into files
> and load it in client... => unfinished and posted solution without server.
> I can see packets sent with tcpdump, but that does not mean it reached
> server. With this result it's questionable whether moving into C code is
> a benefit, maybe shell code below is just good enough.
> 
> Other questionable thing is tst_ipaddr_un() incomplete implementation in C.
> Alternatively IP addresses could be passed from shell via getopts, but
> that can be hard to debug (too long argument passed).
> Originally I wanted to create IP addresses also in C, but that's not
> possible due rhost not reachable from C.
> 
> Changes from v1:
> * Handle also route{4,6}-change-gw
> * Use libmnl
> * new commits (more comments at the commits):
> - net: Move setup_addrinfo() from netstress.c into tst_net.h
> - tst_net.sh: Minor code and doc cleanup
> - tst_net.sh: Add -a IP and -s options to tst_init_iface()
> - net: Introduce TST_GET_UNUSED_PORT() macro into C API
> - net/route: Remove route{4,6}-change-if
> 
> Draft of alternative implementation in shell:
> * route-change-dst
> TST_TESTFUNC="do_test"
> TST_SETUP="do_setup"
> TST_CLEANUP="restore_ipaddr"
> TST_NEEDS_CMDS="ip"
> TST_CNT=$NS_TIMES
> 
> . tst_net_stress.sh
> 
> do_setup()
> {
> 	# FIXME: remove duplicity
> 	mask=$IPV4_LPREFIX
> 	udp_size=1472
> 	if [ "$TST_IPV6" ]; then
> 		mask=$IPV6_LPREFIX
> 		udp_size=1452
> 	fi
> 	netstress_setup
> 	tst_res TINFO "change IPv$TST_IPVER route destination $NS_TIMES times"
> }
> 
> do_test()
> {
> 	local iface=$(tst_iface)
> 	local addr new_rt
> 
> 	new_rt="$(tst_ipaddr_un $1)/$mask"
> 	addr="$(tst_ipaddr_un $1 1)"
> 
> 	tst_res TINFO "testing route '$new_rt'"
> 
> 	tst_rhost_run -s -c "ip addr add $addr/$mask dev $(tst_iface rhost)"
> 	ROD ip route add $new_rt dev $iface
> 	ROD ip neigh replace $addr lladdr $(tst_hwaddr rhost) nud permanent dev $iface
> > 	EXPECT_PASS ns-udpsender -f $TST_IPVER -D $addr -p $1 -o -s $udp_size
> 
> 	ROD ip neigh del $addr lladdr $(tst_hwaddr rhost) dev $iface
> 	ROD ip route del $new_rt dev $iface
> 	tst_rhost_run -c "ip addr del $addr/$mask dev $(tst_iface rhost)"

With ns-udpsender, I think it can be without setting ip addresses:
 	ROD ip route add $new_rt dev $iface
 	ROD ip neigh replace $addr lladdr $(tst_hwaddr rhost) nud permanent dev $iface
 	EXPECT_PASS ns-udpsender -f $TST_IPVER -D $addr -p $1 -o -s $udp_size> 
	ROD ip neigh del $addr lladdr $(tst_hwaddr rhost) dev $iface
 	ROD ip route del $new_rt dev $iface

But with ping and neighbor discovery:
 	tst_rhost_run -s -c "ip addr add $addr/$mask dev $(tst_iface rhost)"
 	ROD ip route add $new_rt dev $iface
 	EXPECT_PASS ping$TST_IPVER ...
 	ROD ip route del $new_rt dev $iface
 	tst_rhost_run -c "ip addr del $addr/$mask dev $(tst_iface rhost)"

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [LTP] [RFC PATCH v2 0/6] net/route: Rewrite route{4, 6}-change-{dst, gw} into C
  2019-05-28 12:32 ` [LTP] [RFC PATCH v2 0/6] " Alexey Kodanev
@ 2019-06-03  7:26   ` Petr Vorel
  2019-06-14 11:43     ` Alexey Kodanev
  0 siblings, 1 reply; 14+ messages in thread
From: Petr Vorel @ 2019-06-03  7:26 UTC (permalink / raw)
  To: ltp

Hi Alexey,

thanks for your comments. I suppose you don't see much point of rewriting tests
into C (and depending on libmnl). The original idea was to change it fast enough
with C to really stress it. OK, let's leave it :).

> > do_test()
> > {
> > 	local iface=$(tst_iface)
> > 	local addr new_rt

> > 	new_rt="$(tst_ipaddr_un $1)/$mask"
> > 	addr="$(tst_ipaddr_un $1 1)"

> > 	tst_res TINFO "testing route '$new_rt'"

> > 	tst_rhost_run -s -c "ip addr add $addr/$mask dev $(tst_iface rhost)"
> > 	ROD ip route add $new_rt dev $iface
> > 	ROD ip neigh replace $addr lladdr $(tst_hwaddr rhost) nud permanent dev $iface
> > > 	EXPECT_PASS ns-udpsender -f $TST_IPVER -D $addr -p $1 -o -s $udp_size

> > 	ROD ip neigh del $addr lladdr $(tst_hwaddr rhost) dev $iface
> > 	ROD ip route del $new_rt dev $iface
> > 	tst_rhost_run -c "ip addr del $addr/$mask dev $(tst_iface rhost)"

> With ns-udpsender, I think it can be without setting ip addresses:
Route over gateway requires (on IPv6) gateway on rhost, which is requires to
create this IP address first.

>  	ROD ip route add $new_rt dev $iface
>  	ROD ip neigh replace $addr lladdr $(tst_hwaddr rhost) nud permanent dev $iface
>  	EXPECT_PASS ns-udpsender -f $TST_IPVER -D $addr -p $1 -o -s $udp_size> 
> 	ROD ip neigh del $addr lladdr $(tst_hwaddr rhost) dev $iface
>  	ROD ip route del $new_rt dev $iface

> But with ping and neighbor discovery:
>  	tst_rhost_run -s -c "ip addr add $addr/$mask dev $(tst_iface rhost)"
>  	ROD ip route add $new_rt dev $iface
>  	EXPECT_PASS ping$TST_IPVER ...
>  	ROD ip route del $new_rt dev $iface
>  	tst_rhost_run -c "ip addr del $addr/$mask dev $(tst_iface rhost)"
I prefer using ping and neighbor discovery. I suppose these are both equivalent
(if not it'd be good to run them both).

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [LTP] [RFC PATCH v2 0/6] net/route: Rewrite route{4, 6}-change-{dst, gw} into C
  2019-06-03  7:26   ` Petr Vorel
@ 2019-06-14 11:43     ` Alexey Kodanev
  2019-06-14 12:47       ` Petr Vorel
  0 siblings, 1 reply; 14+ messages in thread
From: Alexey Kodanev @ 2019-06-14 11:43 UTC (permalink / raw)
  To: ltp

Hi Petr,
On 03.06.2019 10:26, Petr Vorel wrote:
> Hi Alexey,
> 
> thanks for your comments. I suppose you don't see much point of rewriting tests
> into C (and depending on libmnl). The original idea was to change it fast enough
> with C to really stress it. OK, let's leave it :).
> 

Sorry for the delay, it would be good to have a shell variant with the ping (so we
can verify the route) and also keep the libmnl test-case to stress the creation/deletion.

>>> do_test()
>>> {
>>> 	local iface=$(tst_iface)
>>> 	local addr new_rt
> 
>>> 	new_rt="$(tst_ipaddr_un $1)/$mask"
>>> 	addr="$(tst_ipaddr_un $1 1)"
> 
>>> 	tst_res TINFO "testing route '$new_rt'"
> 
>>> 	tst_rhost_run -s -c "ip addr add $addr/$mask dev $(tst_iface rhost)"
>>> 	ROD ip route add $new_rt dev $iface
>>> 	ROD ip neigh replace $addr lladdr $(tst_hwaddr rhost) nud permanent dev $iface
>>>> 	EXPECT_PASS ns-udpsender -f $TST_IPVER -D $addr -p $1 -o -s $udp_size
> 
>>> 	ROD ip neigh del $addr lladdr $(tst_hwaddr rhost) dev $iface
>>> 	ROD ip route del $new_rt dev $iface
>>> 	tst_rhost_run -c "ip addr del $addr/$mask dev $(tst_iface rhost)"
> 
>> With ns-udpsender, I think it can be without setting ip addresses:
> Route over gateway requires (on IPv6) gateway on rhost, which is requires to
> create this IP address first.
> 
>>  	ROD ip route add $new_rt dev $iface
>>  	ROD ip neigh replace $addr lladdr $(tst_hwaddr rhost) nud permanent dev $iface
>>  	EXPECT_PASS ns-udpsender -f $TST_IPVER -D $addr -p $1 -o -s $udp_size> 
>> 	ROD ip neigh del $addr lladdr $(tst_hwaddr rhost) dev $iface
>>  	ROD ip route del $new_rt dev $iface
> 
>> But with ping and neighbor discovery:
>>  	tst_rhost_run -s -c "ip addr add $addr/$mask dev $(tst_iface rhost)"
>>  	ROD ip route add $new_rt dev $iface
>>  	EXPECT_PASS ping$TST_IPVER ...
>>  	ROD ip route del $new_rt dev $iface
>>  	tst_rhost_run -c "ip addr del $addr/$mask dev $(tst_iface rhost)"
> I prefer using ping and neighbor discovery. I suppose these are both equivalent
> (if not it'd be good to run them both).
> 
> Kind regards,
> Petr
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [LTP] [RFC PATCH v2 6/6] net/route: Rewrite route{4, 6}-change-{dst, gw} into C
  2019-05-10 18:31 ` [LTP] [RFC PATCH v2 6/6] net/route: Rewrite route{4, 6}-change-{dst, gw} into C Petr Vorel
@ 2019-06-14 11:59   ` Alexey Kodanev
  0 siblings, 0 replies; 14+ messages in thread
From: Alexey Kodanev @ 2019-06-14 11:59 UTC (permalink / raw)
  To: ltp

On 10.05.2019 21:31, Petr Vorel wrote:
> Code:
> * use libmnl and new C API
> * reuse code in tst_net.h (added in previous commit)
> * add shell wrapper (set environment with tst_net.sh instead of using
>   deprecated helpers in testcases/network/stress/ns-tools/)
> * Add tst_ipaddr_un() into C API, unlike shell API this implementation
>   does not support -c tst_ipaddr_un [-cCOUNTER] [TYPE] syntax.
> 
> Travis:
> * add libmnl libraries to most of travis jobs
> * replace spaces with tabs some travis shell files
> 
> Cleanup:
> * cleanup test description
> * other cleanup
> 
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
...
> +}
> +
> +static void send_udp(char *local, char *remote)
> +{
> +	fd = SAFE_SOCKET(family, SOCK_DGRAM, IPPROTO_UDP);
> +
> +	struct addrinfo hints;
> +	memset(&hints, 0, sizeof(struct addrinfo));
> +	hints.ai_family = family;
> +	hints.ai_socktype = SOCK_DGRAM;
> +	hints.ai_flags = 0;
> +	hints.ai_protocol = 0;
> +	hints.ai_addr = INADDR_ANY;
> +	setup_addrinfo(local, NULL, &hints, &local_addrinfo);
> +	char *port;
> +	int _port = TST_GET_UNUSED_PORT(family, SOCK_DGRAM);
> +	SAFE_ASPRINTF(&port, "%d", _port);
> +	setup_addrinfo(remote, port, &hints, &remote_addrinfo);
> +

Getting local unused port and using as a remote port?


> +	SAFE_BIND(fd, local_addrinfo->ai_addr, local_addrinfo->ai_addrlen);
> +

TST_GET_UNUSED_PORT and SAFE_BIND look redundant, what is the purpose to use
them here?

> +	SAFE_SENDTO(1, fd, remote, strlen(remote), MSG_CONFIRM,
> +		remote_addrinfo->ai_addr, remote_addrinfo->ai_addrlen);
> +
> +	close(fd);
> +}
> +
> +static void run(void)
> +{
> +	int i, j;
> +	char *destination, *gateway = NULL, *local, *remote;
> +
> +	tst_res(TINFO, "Adding and deleting route with different destination %d times", num_loops);
> +	for (i = 0; i < num_loops; i++) {
> +		j = i % max_ip;
> +		local = tst_ipaddr_un(family, j, lhost);
> +		remote = tst_ipaddr_un(family, j, rhost);
> +		if (g_opt) {
> +			destination = tst_ipaddr_un(family, 0, 0);
> +			gateway = tst_ipaddr_un(family, j, gwhost);
> +		} else {
> +			destination = tst_ipaddr_un(family, j, 0);
> +		}
> +
> +		rtnl_route(iface, destination, prefix, gateway, RTM_NEWROUTE);
> +		send_udp(local, remote);
> +		rtnl_route(iface, destination, prefix, gateway, RTM_DELROUTE);
> +	}
> +
> +	tst_res(TPASS, "Routes created and deleted");
> +}
> +

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [LTP] [RFC PATCH v2 0/6] net/route: Rewrite route{4, 6}-change-{dst, gw} into C
  2019-06-14 11:43     ` Alexey Kodanev
@ 2019-06-14 12:47       ` Petr Vorel
  0 siblings, 0 replies; 14+ messages in thread
From: Petr Vorel @ 2019-06-14 12:47 UTC (permalink / raw)
  To: ltp

Hi Alexey,

> > thanks for your comments. I suppose you don't see much point of rewriting tests
> > into C (and depending on libmnl). The original idea was to change it fast enough
> > with C to really stress it. OK, let's leave it :).


> Sorry for the delay, it would be good to have a shell variant with the ping (so we
> can verify the route) and also keep the libmnl test-case to stress the creation/deletion.

Thanks for your opinion. It's actually good idea to have both instead of trying
to kill two birds with one stone in C (speed and validation) :).
I'll send ping and neighbor discovery variant and fixed C variant.

Kind regards,
Petr

> >>> do_test()
> >>> {
> >>> 	local iface=$(tst_iface)
> >>> 	local addr new_rt

> >>> 	new_rt="$(tst_ipaddr_un $1)/$mask"
> >>> 	addr="$(tst_ipaddr_un $1 1)"

> >>> 	tst_res TINFO "testing route '$new_rt'"

> >>> 	tst_rhost_run -s -c "ip addr add $addr/$mask dev $(tst_iface rhost)"
> >>> 	ROD ip route add $new_rt dev $iface
> >>> 	ROD ip neigh replace $addr lladdr $(tst_hwaddr rhost) nud permanent dev $iface
> >>>> 	EXPECT_PASS ns-udpsender -f $TST_IPVER -D $addr -p $1 -o -s $udp_size

> >>> 	ROD ip neigh del $addr lladdr $(tst_hwaddr rhost) dev $iface
> >>> 	ROD ip route del $new_rt dev $iface
> >>> 	tst_rhost_run -c "ip addr del $addr/$mask dev $(tst_iface rhost)"

> >> With ns-udpsender, I think it can be without setting ip addresses:
> > Route over gateway requires (on IPv6) gateway on rhost, which is requires to
> > create this IP address first.

> >>  	ROD ip route add $new_rt dev $iface
> >>  	ROD ip neigh replace $addr lladdr $(tst_hwaddr rhost) nud permanent dev $iface
> >>  	EXPECT_PASS ns-udpsender -f $TST_IPVER -D $addr -p $1 -o -s $udp_size> 
> >> 	ROD ip neigh del $addr lladdr $(tst_hwaddr rhost) dev $iface
> >>  	ROD ip route del $new_rt dev $iface

> >> But with ping and neighbor discovery:
> >>  	tst_rhost_run -s -c "ip addr add $addr/$mask dev $(tst_iface rhost)"
> >>  	ROD ip route add $new_rt dev $iface
> >>  	EXPECT_PASS ping$TST_IPVER ...
> >>  	ROD ip route del $new_rt dev $iface
> >>  	tst_rhost_run -c "ip addr del $addr/$mask dev $(tst_iface rhost)"
> > I prefer using ping and neighbor discovery. I suppose these are both equivalent
> > (if not it'd be good to run them both).

> > Kind regards,
> > Petr



^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2019-06-14 12:47 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-10 18:31 [LTP] [RFC PATCH v2 0/6] net/route: Rewrite route{4, 6}-change-{dst, gw} into C Petr Vorel
2019-05-10 18:31 ` [LTP] [RFC PATCH v2 1/6] net/route: Remove route{4,6}-change-if Petr Vorel
2019-05-23 12:46   ` [LTP] [RFC PATCH v2 1/6] net/route: Remove route{4, 6}-change-if Alexey Kodanev
2019-05-23 13:05     ` Petr Vorel
2019-05-10 18:31 ` [LTP] [RFC PATCH v2 2/6] net: Introduce TST_GET_UNUSED_PORT() macro into C API Petr Vorel
2019-05-10 18:31 ` [LTP] [RFC PATCH v2 3/6] tst_net.sh: Add -a IP and -s options to tst_init_iface() Petr Vorel
2019-05-10 18:31 ` [LTP] [RFC PATCH v2 4/6] tst_net.sh: Minor code and doc cleanup Petr Vorel
2019-05-10 18:31 ` [LTP] [RFC PATCH v2 5/6] net: Move setup_addrinfo() from netstress.c into tst_net.h Petr Vorel
2019-05-10 18:31 ` [LTP] [RFC PATCH v2 6/6] net/route: Rewrite route{4, 6}-change-{dst, gw} into C Petr Vorel
2019-06-14 11:59   ` Alexey Kodanev
2019-05-28 12:32 ` [LTP] [RFC PATCH v2 0/6] " Alexey Kodanev
2019-06-03  7:26   ` Petr Vorel
2019-06-14 11:43     ` Alexey Kodanev
2019-06-14 12:47       ` 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.