net/route: Rewrite route{4, 6}-change-{dst, gw} into C
v2 cover net/route: Rewrite route{4, 6}-change-{dst, gw} into C
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
Signature · 1 line
2.21.0
RFC PATCH v2 1/6 net/route: Remove route{4,6}-change-if
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.
--- 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
runtest/net_stress.route +0 -2
@@ -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
testcases/network/stress/route/00_Descriptions.txt +0 -16
@@ -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
testcases/network/stress/route/route4-change-if deleted +0 -324
324 lines not on this page · raw message
testcases/network/stress/route/route6-change-if deleted +0 -323
323 lines not on this page · raw message
Signature · 1 line
2.21.0
RFC PATCH v2 1/6 net/route: Remove route{4, 6}-change-if
Hi Petr,
Quoted 3 lines · Petr Vorel
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.
Quoted 722 lines
Signed-off-by Petr Vorel <[email protected]>--- 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-ifruntest/net_stress.route +0
-2@@ -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-rmmodtestcases/network/stress/route/00_Descriptions.txt +0
-16@@ -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 frequentlytestcases/network/stress/route/route4-change-if deleted +0
-324@@ -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 <[email protected]> -# -# 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 $RCtestcases/network/stress/route/route6-change-if deleted +0
-323@@ -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 <[email protected]> -# -# 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
RFC PATCH v2 1/6 net/route: Remove route{4, 6}-change-if
Hi Alexey,
Quoted 9 lines
Hi Petr,
Quoted 3 lines · Petr Vorel
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?
Quoted 6 lines
For example, by adding macvlan to the test interface:
ip link add ltp_mv0 link $(tst_iface) type macvlan mode bridgeThen, for the test route we can set either
ltp_mv0or $(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
RFC PATCH v2 2/6 net: Introduce TST_GET_UNUSED_PORT() macro into C API
In reply to Petr Vorelinto 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).
---
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
include/old/old_safe_net.h +3 -0
@@ -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__ */
include/old/test.h +0 -7
@@ -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.
include/safe_net_fn.h +8 -5
@@ -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__ */
include/tst_safe_net.h +6 -3
@@ -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__ */
lib/safe_net.c +66 -0
69 lines not on this page · raw message
lib/tst_net.c deleted +0 -89
89 lines not on this page · raw message
testcases/kernel/syscalls/bind/bind01.c +1 -1
@@ -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 ;
testcases/kernel/syscalls/connect/connect01.c +1 -1
@@ -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 ;
testcases/kernel/syscalls/sendmsg/sendmsg01.c +1 -1
@@ -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 )
tools/apicmds/ltpapicmd.c +1 -1
@@ -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"
Signature · 1 line
2.21.0
RFC PATCH v2 3/6 tst_net.sh: Add -a IP and -s options to tst_init_iface()
In reply to Petr Vorel--- testcases/lib/tst_net.sh | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-)
testcases/lib/tst_net.sh +27 -11
@@ -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 <[email protected]> +# Copyright (c) 2016-2019 Petr Vorel <[email protected]> # Author: Alexey Kodanev <[email protected]> [ -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]
Signature · 1 line
2.21.0
RFC PATCH v2 4/6 tst_net.sh: Minor code and doc cleanup
In reply to Petr Vorel* 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
---
cleanup of tst_net.sh (new commit, this can be dropped).
testcases/lib/tst_net.sh | 109 ++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 65 deletions(-)
testcases/lib/tst_net.sh +44 -65
@@ -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
Signature · 1 line
2.21.0
RFC PATCH v2 5/6 net: Move setup_addrinfo() from netstress.c into tst_net.h
In reply to Petr VorelThis allows reusing it in next commit.
Add missing includes into tst_net.h, make functions inline.
---
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(-)
include/tst_net.h +24 -21
@@ -1,22 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* -* Copyright (c) 2017 Petr Vorel <[email protected]> -* -* 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 <[email protected]> */ #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" ); +}
testcases/network/netstress/netstress.c +1 -13
@@ -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 ) {
Signature · 1 line
2.21.0
RFC PATCH v2 6/6 net/route: Rewrite route{4, 6}-change-{dst, gw} into C
In reply to Petr VorelCode:
* 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
--- 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
configure.ac +1 -0
@@ -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
include/mk/config.mk.default +2 -0
@@ -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
include/mk/config.mk.in +2 -0
@@ -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@
include/tst_net.h +45 -0
58 lines not on this page · raw message
m4/ltp-libmnl.m4 new file +7 -0
@@ -0,0 +1,7 @@ +dnl Copyright (c) 2019 Petr Vorel <[email protected]> + +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]) +])
runtest/net_stress.route +4 -6
@@ -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
testcases/network/stress/route/.gitignore new file +1 -0
@@ -0,0 +1 @@ +/route-change
testcases/network/stress/route/00_Descriptions.txt +12 -36
68 lines not on this page · raw message
testcases/network/stress/route/Makefile +8 -22
@@ -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
testcases/network/stress/route/route-change.c new file +243 -0
243 lines not on this page · raw message
testcases/network/stress/route/route-change.sh new file +52 -0
52 lines not on this page · raw message
testcases/network/stress/route/route4-change-dst deleted +0 -276
276 lines not on this page · raw message
testcases/network/stress/route/route4-change-gw deleted +0 -292
292 lines not on this page · raw message
testcases/network/stress/route/route6-change-dst deleted +0 -272
272 lines not on this page · raw message
testcases/network/stress/route/route6-change-gw deleted +0 -292
292 lines not on this page · raw message
travis/debian.cross-compile.aarch64.sh +5 -1
@@ -2,6 +2,10 @@ # Copyright (c) 2018 Petr Vorel <[email protected]> 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
travis/debian.cross-compile.ppc64le.sh +7 -1
@@ -2,6 +2,12 @@ # Copyright (c) 2018 Petr Vorel <[email protected]> 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 \
travis/debian.i386.sh +2 -1
@@ -16,4 +16,5 @@ apt install -y --no-install-recommends \ libkeyutils1:i386 \ libnuma1:i386 \ libssl-dev:i386 \ - libtirpc1:i386 + libtirpc1:i386 \ + pkg-config:i386
travis/debian.minimal.sh +14 -14
@@ -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
travis/debian.sh +29 -26
60 lines not on this page · raw message
travis/fedora.sh +4 -1
@@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (c) 2018 Petr Vorel <[email protected]> +# Copyright (c) 2018-2019 Petr Vorel <[email protected]> set -e yum -y install \
@@ -9,4 +9,7 @@ yum -y install \ clang \ gcc \ findutils \ + libmnl \ + libmnl-devel \ + pkg-config \ redhat-lsb-core
travis/tumbleweed.sh +5 -2
@@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (c) 2018 Petr Vorel <[email protected]> +# Copyright (c) 2018-2019 Petr Vorel <[email protected]> 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
Signature · 1 line
2.21.0
RFC PATCH v2 6/6 net/route: Rewrite route{4, 6}-change-{dst, gw} into C
Quoted 18 lines · Petr Vorel
Code:
* use libmnl and new C API
* reuse code intst_net.h(added in previous commit)
* add shell wrapper (set environment withtst_net.shinstead of using deprecated helpers in testcases/network/stress/ns-tools/)
* Addtst_ipaddr_un()into C API, unlike shell API this implementation does not support -ctst_ipaddr_un[-cCOUNTER] [TYPE] syntax.Travis:
* add libmnl libraries to most of travis jobs
* replace spaces with tabs some travis shell filesCleanup:
* cleanup test description
* other cleanupSigned-off-by Petr Vorel <[email protected]>---
...
Quoted 9 lines
testcases/network/stress/route/route-change.c new file +9
-0+} + +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;
testcases/network/stress/route/route-change.c line 190
Quoted 10 lines
testcases/network/stress/route/route-change.c new file +10
-0+ 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?
testcases/network/stress/route/route-change.c line 192
Quoted 2 lines
testcases/network/stress/route/route-change.c new file +2
-0+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?
Quoted 31 lines
testcases/network/stress/route/route-change.c new file +31
-0+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" ); +} +
v2 cover net/route: Rewrite route{4, 6}-change-{dst, gw} into C
In reply to Petr VorelHi Petr,
Quoted 70 lines · Petr Vorel
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: Movesetup_addrinfo()fromnetstress.cintotst_net.h
-tst_net.sh: Minor code and doc cleanup
-tst_net.sh: Add -a IP and -s options totst_init_iface()
- net: IntroduceTST_GET_UNUSED_PORT()macro into C API
- net/route: Remove route{4,6}-change-ifDraft 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
Quoted 5 lines
Quoted 1 line
EXPECT_PASSns-udpsender -f $TST_IPVER -D $addr -p $1 -o -s $udp_sizeROD 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)"
v2 cover net/route: Rewrite route{4, 6}-change-{dst, gw} into C
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 :).
Quoted 13 lines
Quoted 13 lines
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
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
EXPECT_PASSns-udpsender -f $TST_IPVER -D $addr -p $1 -o -s $udp_sizeROD 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.
Review
Quoted 12 lines
(quoted diff) +0
-0ROD 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 $ifaceROD ip route del $new_rt dev $iface
But with ping and neighbor discovery:
(quoted diff) +0
-0tst_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
v2 cover net/route: Rewrite route{4, 6}-change-{dst, gw} into C
Hi Petr,
Quoted 6 lines · Petr Vorel
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.
Quoted 41 lines
Quoted 13 lines
Quoted 13 lines
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 $ifaceQuoted 7 lines
Quoted 5 lines
Quoted 1 line
EXPECT_PASSns-udpsender -f $TST_IPVER -D $addr -p $1 -o -s $udp_sizeROD 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.
Review
Quoted 12 lines
(quoted diff) +0
-0ROD 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 $ifaceROD ip route del $new_rt dev $iface
But with ping and neighbor discovery:
(quoted diff) +0
-0tst_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
v2 cover net/route: Rewrite route{4, 6}-change-{dst, gw} into C
Hi Alexey,
Quoted 7 lines
Quoted 3 lines
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
Quoted 40 lines
Quoted 40 lines
Quoted 13 lines
Quoted 13 lines
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 $ifaceQuoted 7 lines
Quoted 5 lines
Quoted 1 line
EXPECT_PASSns-udpsender -f $TST_IPVER -D $addr -p $1 -o -s $udp_sizeROD 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.
Review
Quoted 12 lines
(quoted diff) +0
-0ROD 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 $ifaceROD ip route del $new_rt dev $iface
But with ping and neighbor discovery:
(quoted diff) +0
-0tst_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