Route tests using netlink API (dst,gw,if)
v6 cover Route tests using netlink API (dst,gw,if)
Hi Alexey, Cyril,
changes v5->v6:
* new commit: Add $ROUTE_CHANGE_IP and $ROUTE_CHANGE_NETLINK variables (increase, but better not affect $NS_TIMES as used by other tests)
* route-change-netlink.c: Better error handling with brk_on_route_error() (Alexey), use global prefix variable in rtnl_route().
Kind regards,
Petr
Petr Vorel (3):
net: Add SAFE_GETADDRINFO()
net/route: Add netlink based route change tests
route: Increase default loop values
configure.ac | 1 + include/mk/config.mk.in | 2 + include/tst_net.h | 9 +- include/tst_private.h | 1 + include/tst_safe_net.h | 6 + lib/tst_net.c | 15 + m4/ltp-libmnl.m4 | 8 + runtest/net_stress.route | 6 + testcases/lib/tst_net.sh | 2 + testcases/network/netstress/netstress.c | 20 +- testcases/network/stress/route/.gitignore | 1 + .../network/stress/route/00_Descriptions.txt | 40 +-- testcases/network/stress/route/Makefile | 30 +- .../network/stress/route/route-change-dst.sh | 7 +- .../network/stress/route/route-change-gw.sh | 14 +- .../network/stress/route/route-change-if.sh | 59 +--- .../stress/route/route-change-netlink-dst.sh | 36 ++ .../stress/route/route-change-netlink-gw.sh | 33 ++ .../stress/route/route-change-netlink-if.sh | 39 +++ .../stress/route/route-change-netlink.c | 327 ++++++++++++++++++ testcases/network/stress/route/route-lib.sh | 103 +++++- travis/debian.cross-compile.sh | 1 + travis/debian.sh | 1 + travis/fedora.sh | 3 + travis/tumbleweed.sh | 1 + 25 files changed, 632 insertions(+), 133 deletions(-) create mode 100644 m4/ltp-libmnl.m4 create mode 100644 testcases/network/stress/route/.gitignore create mode 100755 testcases/network/stress/route/route-change-netlink-dst.sh create mode 100755 testcases/network/stress/route/route-change-netlink-gw.sh create mode 100755 testcases/network/stress/route/route-change-netlink-if.sh create mode 100644 testcases/network/stress/route/route-change-netlink.c
Signature · 1 line
2.26.2
PATCH v6 1/3 net: Add SAFE_GETADDRINFO()
based on setup_addrinfo() from netstress.c.
Added only to new C API, thus code kept in tst_net.c, instead of safe_net.c, which is also for legacy API.
--- include/tst_net.h | 9 +++++++-- include/tst_private.h | 1 + include/tst_safe_net.h | 6 ++++++ lib/tst_net.c | 15 +++++++++++++++ testcases/network/netstress/netstress.c | 20 ++++---------------- 5 files changed, 33 insertions(+), 18 deletions(-)
include/tst_net.h +7 -2
@@ -7,9 +7,10 @@#define TST_NET_H_ #include <arpa/inet.h> -#include <sys/types.h> +#include <netdb.h> #include <netinet/in.h> #include <netinet/ip.h> +#include <sys/types.h> void tst_get_in_addr (const char *ip_str,struct in_addr *ip);void tst_get_in6_addr (const char *ip_str,struct in6_addr *ip6);
@@ -27,4 +28,8 @@ void tst_init_sockaddr_inet_bin(struct sockaddr_in *sa, uint32_t ip_val, uint16_void tst_init_sockaddr_inet6 (struct sockaddr_in6 *sa,const char *ip_str,uint16_t port);void tst_init_sockaddr_inet6_bin (struct sockaddr_in6 *sa,const struct in6_addr *ip_val,uint16_t port); -#endif +void safe_getaddrinfo (const char *file,const int lineno,const char *src_addr, +const char *port,const struct addrinfo *hints, +struct addrinfo **addr_info); + +#endif /* TST_NET_H_ */
include/tst_private.h +1 -0
@@ -10,6 +10,7 @@#define TST_PRIVATE_H_ #include <stdio.h> +#include <netdb.h> #define MAX_IPV4_PREFIX 32#define MAX_IPV6_PREFIX 128
include/tst_safe_net.h +6 -0
@@ -12,6 +12,7 @@#include <sys/un.h> #include "safe_net_fn.h" +#include "tst_net.h" #define SAFE_SOCKET (domain, type, protocol) \ safe_socket(__FILE__, __LINE__, NULL, domain, type, protocol)
@@ -70,4 +71,9 @@#define TST_GET_UNUSED_PORT (family, type) \ tst_get_unused_port(__FILE__, __LINE__, NULL, family, type) +/* new API only */ + +#define SAFE_GETADDRINFO (src_addr, port, hints, addr_info) \ + safe_getaddrinfo(__FILE__, __LINE__, src_addr, port, hints, addr_info) +#endif /* TST_SAFE_NET_H__ */
lib/tst_net.c +15 -0
@@ -5,6 +5,7 @@*/ #include <errno.h> +#include <netdb.h> #include <string.h> #include <stdlib.h>
@@ -204,3 +205,17 @@ void tst_init_sockaddr_inet6_bin(struct sockaddr_in6 *sa, const struct in6_addr sa->sin6_port =htons (port);memcpy (&sa->sin6_addr, ip_val,sizeof (struct in6_addr )); } + +void safe_getaddrinfo (const char *file,const int lineno,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 ,"%s:%d: getaddrinfo failed, %s" , file, lineno, +gai_strerror (err)); + +if (!*addr_info) +tst_brk (TBROK ,"%s:%d: failed to get the address" , file, lineno); +}
testcases/network/netstress/netstress.c +4 -16
@@ -29,6 +29,7 @@#include "tst_safe_stdio.h" #include "tst_safe_pthread.h" #include "tst_test.h" +#include "tst_safe_net.h" static const int max_msg_len = (1 <<16 ) -1 ;static const int min_msg_len =5 ;
@@ -441,19 +442,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 ) {
@@ -471,8 +459,8 @@ static void client_init(void) hints.ai_protocol =0 ;if (source_addr) -setup_addrinfo (source_addr,NULL , &hints, &local_addrinfo); -setup_addrinfo (server_addr, tcp_port, &hints, &remote_addrinfo); +SAFE_GETADDRINFO (source_addr,NULL , &hints, &local_addrinfo); +SAFE_GETADDRINFO (server_addr, tcp_port, &hints, &remote_addrinfo);tst_res (TINFO ,"Running the test over IPv%s" , (remote_addrinfo->ai_family ==AF_INET6 ) ?"6" :"4" );
@@ -667,7 +655,7 @@ static void server_init(void)if (source_addr && !strchr (source_addr,':' ))SAFE_ASPRINTF (&src_addr,"::ffff:%s" , source_addr); -setup_addrinfo (src_addr ? src_addr : source_addr, tcp_port, +SAFE_GETADDRINFO (src_addr ? src_addr : source_addr, tcp_port, &hints, &local_addrinfo);free (src_addr);
Signature · 1 line
2.26.2
PATCH v6 2/3 net/route: Add netlink based route change tests
In reply to Petr Vorelchanging destination, gateway and interface. These tests are inspired by shell tests, but send UDP packets instead of ICMP and there is no receiver of the packets thus no verification. Tests are much faster that shell tests.
lhost address is not used, but NIC is set (required by interface tests).
* use libmnl and new C API, requires pkg-config (and pkg.m4 macro for aclocal) for detection (but that's already needed for TI-RPC tests)
* add shell wrappers
* move common code for changing iface to route-lib.sh
* travis: add libmnl libraries to most of travis jobs
* cleanup test description and Makefile
--- configure.ac | 1 + include/mk/config.mk.in | 2 + m4/ltp-libmnl.m4 | 8 + runtest/net_stress.route | 6 + testcases/network/stress/route/.gitignore | 1 + .../network/stress/route/00_Descriptions.txt | 40 +-- testcases/network/stress/route/Makefile | 30 +- .../network/stress/route/route-change-dst.sh | 5 +- .../network/stress/route/route-change-gw.sh | 16 +- .../network/stress/route/route-change-if.sh | 61 +--- .../stress/route/route-change-netlink-dst.sh | 36 ++ .../stress/route/route-change-netlink-gw.sh | 31 ++ .../stress/route/route-change-netlink-if.sh | 38 ++ .../stress/route/route-change-netlink.c | 327 ++++++++++++++++++ testcases/network/stress/route/route-lib.sh | 107 +++++- travis/debian.cross-compile.sh | 1 + travis/debian.sh | 1 + travis/fedora.sh | 3 + travis/tumbleweed.sh | 1 + 19 files changed, 593 insertions(+), 122 deletions(-) create mode 100644 m4/ltp-libmnl.m4 create mode 100644 testcases/network/stress/route/.gitignore create mode 100755 testcases/network/stress/route/route-change-netlink-dst.sh create mode 100755 testcases/network/stress/route/route-change-netlink-gw.sh create mode 100755 testcases/network/stress/route/route-change-netlink-if.sh create mode 100644 testcases/network/stress/route/route-change-netlink.c
configure.ac +1 -0
@@ -300,6 +300,7 @@ LTP_CHECK_CRYPTO LTP_CHECK_FORTIFY_SOURCE LTP_CHECK_KERNEL_DEVEL LTP_CHECK_KEYUTILS_SUPPORT +LTP_CHECK_LIBMNL LTP_CHECK_LINUX_PTRACE LTP_CHECK_LINUXRANDOM LTP_CHECK_MREMAP_FIXED
include/mk/config.mk.in +2 -0
@@ -43,6 +43,8 @@ TIRPC_CFLAGS := @TIRPC_CFLAGS@ TIRPC_LIBS := @TIRPC_LIBS@ KEYUTILS_LIBS := @KEYUTILS_LIBS@ HAVE_FTS_H := @HAVE_FTS_H@ +LIBMNL_LIBS := @LIBMNL_LIBS@ +LIBMNL_CFLAGS := @LIBMNL_CFLAGS@ prefix := @prefix@
m4/ltp-libmnl.m4 new file +8 -0
@@ -0,0 +1,8 @@ +dnl SPDX-License-Identifier: GPL-2.0-or-later +dnl Copyright (c) 2020 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 library and headers]) + ], [have_libmnl=no]) +])
runtest/net_stress.route +6 -0
@@ -2,11 +2,17 @@ route4-change-dst route-change-dst.sh route4-change-gw route-change-gw.sh route4-change-if route-change-if.sh +route4-change-netlink-dst route-change-netlink-dst.sh +route4-change-netlink-gw route-change-netlink-gw.sh +route4-change-netlink-if route-change-netlink-if.sh route4-redirect route4-redirect route4-rmmod route4-rmmod route6-change-dst route-change-dst.sh -6 route6-change-gw route-change-gw.sh -6 route6-change-if route-change-if.sh -6 +route6-change-netlink-dst route-change-netlink-dst.sh -6 +route6-change-netlink-gw route-change-netlink-gw.sh -6 +route6-change-netlink-if route-change-netlink-if.sh -6 route6-redirect route6-redirect route6-rmmod route6-rmmod
testcases/network/stress/route/.gitignore new file +1 -0
@@ -0,0 +1 @@ +/route-change-netlink
testcases/network/stress/route/00_Descriptions.txt +15 -25
@@ -1,36 +1,26 @@ route{4,6}-change-dst - Verify the IPv4/IPv6 is not broken when ip command changes route - destination many times + Change IPv4/IPv6 route destination by ip command route{4,6}-change-gw - Verify the IPv4/IPv6 is not broken when ip command changes route - gateway many times + Change IPv4/IPv6 route gateway by ip command route{4,6}-change-if - Verify the IPv4/IPv6 is not broken when ip command changes route - interface many times + Change IPv4/IPv6 route interface by ip command -route4-redirect01 - Verify the kernel is not crashed when the IPv4 route is modified by - ICMP Redirects frequently +route{4,6}-change-netlink-dst + Change IPv4/IPv6 route destination by Netlink API via libmnl -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 +route{4,6}-change-netlink-gw + Change IPv4/IPv6 route gateway by Netlink API via libmnl -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 +route{4,6}-change-netlink-if + Change IPv4/IPv6 route interface by Netlink API via libmnl +route{4,6}-redirect01 + Change IPv4/IPv6 route by ICMP Redirects frequently -route6-redirect01 - Verify the kernel is not crashed when the IPv6 route is modified by - ICMP Redirects frequently +route{4,6}-rmmod01 + Add IPv4/IPv6 route by route command then delete it by the removing network driver -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 - -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 +route{4,6}-rmmod02 + Add IPv4/IPv6 route by ip command then delete it by the removing network driver
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-2020 # 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-netlink: CFLAGS += $(LIBMNL_CFLAGS) +route-change-netlink: LDLIBS += $(LIBMNL_LIBS) include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/network/stress/route/route-change-dst.sh +4 -1
@@ -1,6 +1,6 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0-or-later -# Copyright (c) 2019 Petr Vorel <[email protected]> +# Copyright (c) 2019-2020 Petr Vorel <[email protected]> # Copyright (c) International Business Machines Corp., 2006 # Author: Mitsuru Chinen <[email protected]> # Rewrite into new shell API: Petr Vorel
@@ -8,8 +8,11 @@ # Change route destination # lhost: 10.0.0.2, rhost: 10.23.x.1 +TST_SETUP="setup" +TST_CLEANUP="route_cleanup" TST_TESTFUNC="test_dst" . route-lib.sh +TST_CNT=$NS_TIMES setup() {
testcases/network/stress/route/route-change-gw.sh +4 -12
@@ -1,6 +1,6 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0-or-later -# Copyright (c) 2019 Petr Vorel <[email protected]> +# Copyright (c) 2019-2020 Petr Vorel <[email protected]> # Copyright (c) International Business Machines Corp., 2006 # Author: Mitsuru Chinen <[email protected]> # Rewrite into new shell API: Petr Vorel
@@ -8,19 +8,11 @@ # Change route gateway # lhost: 10.23.1.1, gw (on rhost): 10.23.1.x, rhost: 10.23.0.1 +TST_SETUP="setup_gw" +TST_CLEANUP="route_cleanup" TST_TESTFUNC="test_gw" . route-lib.sh - -setup() -{ - tst_res TINFO "change IPv$TST_IPVER route gateway $NS_TIMES times" - - rt="$(tst_ipaddr_un -p 0 0)" - lhost="$(tst_ipaddr_un 1 1)" - rhost="$(tst_ipaddr_un 0 1)" - tst_add_ipaddr -s -q -a $lhost - tst_add_ipaddr -s -q -a $rhost rhost -} +TST_CNT=$NS_TIMES test_gw() {
testcases/network/stress/route/route-change-if.sh +4 -57
78 lines not on this page · raw message
testcases/network/stress/route/route-change-netlink-dst.sh new file +36 -0
@@ -0,0 +1,36 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2020 Petr Vorel <[email protected]> +# +# Change route destination via netlink +# rhost: 10.23.x.1 +# lhost (iface set, but not specified in Netlink API): 10.0.0.2 + +TST_SETUP="setup" +TST_CLEANUP="route_cleanup" +TST_TESTFUNC="test_netlink" +. route-lib.sh + +setup() +{ + tst_res TINFO "change IPv$TST_IPVER route destination $NS_TIMES times" + + local cnt=0 + local gw rhost rhost_all rt + + check_max_ip + + while [ $cnt -lt $ROUTE_MAX_IP ]; do + rt="$(tst_ipaddr_un -p $cnt)" + rhost="$(tst_ipaddr_un $cnt 1)" + rhost_all="$rhost$IP_ADDR_DELIM$rhost_all" + + tst_add_ipaddr -s -q -a $rhost rhost + ROD ip route add $rt dev $(tst_iface) + cnt=$((cnt+1)) + done + + ROUTE_CHANGE_NETLINK_PARAMS="-d $(tst_iface) -r '$rhost_all'" +} + +tst_run
testcases/network/stress/route/route-change-netlink-gw.sh new file +31 -0
@@ -0,0 +1,31 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2020 Petr Vorel <[email protected]> +# +# Change route gateway via netlink +# gw (on rhost): 10.23.1.x, rhost: 10.23.0.1 +# lhost (iface set, but not specified in Netlink API): 10.23.1.1 + +TST_SETUP="setup" +TST_CLEANUP="route_cleanup" +TST_TESTFUNC="test_netlink" +. route-lib.sh + +setup() +{ + local cnt=0 + + check_max_ip + setup_gw + + while [ $cnt -lt $ROUTE_MAX_IP ]; do + gw="$(tst_ipaddr_un -h 2,$max_ip_limit 1 $(($cnt + 1)))" + gw_all="$gw$IP_ADDR_DELIM$gw_all" + tst_add_ipaddr -s -q -a $gw rhost + cnt=$((cnt+1)) + done + + ROUTE_CHANGE_NETLINK_PARAMS="-d $(tst_iface) -g "$gw_all" -r $rhost" +} + +tst_run
testcases/network/stress/route/route-change-netlink-if.sh new file +38 -0
@@ -0,0 +1,38 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2020 Petr Vorel <[email protected]> +# +# Change route interface +# gw (on rhost): 10.23.x.1, rhost: 10.23.0.1, switching ifaces on lhost +# lhost (iface set, but not specified in Netlink API): 10.23.x.2 + +TST_SETUP="setup" +TST_CLEANUP="cleanup_if" +TST_TESTFUNC="test_netlink" +. route-lib.sh + +setup() +{ + local gw gw_all iface iface_all + local cnt=0 + + setup_if + + while [ $cnt -lt $(tst_get_ifaces_cnt) ]; do + gw="$(tst_ipaddr_un -n1 $cnt 1)" + iface="$(tst_iface lhost $cnt)" + lhost="$(tst_ipaddr_un -n1 $cnt 2)" + + tst_add_ipaddr -s -q -a $lhost lhost $cnt + tst_add_ipaddr -s -q -a $gw rhost $cnt + + gw_all="$gw$IP_ADDR_DELIM$gw_all" + iface_all="$iface$IP_ADDR_DELIM$iface_all" + + cnt=$((cnt+1)) + done + + ROUTE_CHANGE_NETLINK_PARAMS="-d '$iface_all' -g '$gw_all' -r $rhost" +} + +tst_run
testcases/network/stress/route/route-change-netlink.c new file +327 -0
327 lines not on this page · raw message
testcases/network/stress/route/route-lib.sh +102 -5
119 lines not on this page · raw message
travis/debian.cross-compile.sh +1 -0
@@ -20,4 +20,5 @@ apt update apt install -y --no-install-recommends \ gcc-${gcc_arch}-linux-gnu \ libc6-dev-${ARCH}-cross \ + libmnl-dev:$ARCH \ libtirpc-dev:$ARCH
travis/debian.sh +1 -0
@@ -28,6 +28,7 @@ apt install -y --no-install-recommends \ libkeyutils-dev \ libkeyutils1 \ libmm-dev \ + libmnl-dev \ libnuma-dev \ libnuma1 \ libselinux1-dev \
travis/fedora.sh +3 -0
@@ -13,3 +13,6 @@ yum -y install \ libtirpc-devel \ pkg-config \ redhat-lsb-core + +# CentOS 8 doesn't have libmnl-devel +yum -y install libmnl-devel || yum -y install libmnl
travis/tumbleweed.sh +1 -0
@@ -15,6 +15,7 @@ zypper --non-interactive install --force-resolution --no-recommends \ libacl-devel \ libaio-devel \ libcap-devel \ + libmnl-devel \ libnuma-devel \ libopenssl-devel \ libselinux-devel \
Signature · 1 line
2.26.2
PATCH v6 3/3 route: Increase default loop values
In reply to Petr Vorelby introducing $ROUTE_CHANGE_IP for shell based tests (only these rewritten into new shell API) and $ROUTE_CHANGE_NETLINK with C Netlink API based tests.
--- testcases/lib/tst_net.sh | 2 ++ testcases/network/stress/route/route-change-dst.sh | 4 ++-- testcases/network/stress/route/route-change-gw.sh | 10 ++++++++-- testcases/network/stress/route/route-change-if.sh | 10 ++++++++-- .../network/stress/route/route-change-netlink-dst.sh | 2 +- .../network/stress/route/route-change-netlink-gw.sh | 2 ++ .../network/stress/route/route-change-netlink-if.sh | 1 + testcases/network/stress/route/route-lib.sh | 8 ++------ 8 files changed, 26 insertions(+), 13 deletions(-)
testcases/lib/tst_net.sh +2 -0
@@ -913,6 +913,8 @@ export UPLOAD_BIGFILESIZE="${UPLOAD_BIGFILESIZE:-2147483647}" export UPLOAD_REGFILESIZE="${UPLOAD_REGFILESIZE:-1024}" export MCASTNUM_NORMAL="${MCASTNUM_NORMAL:-20}" export MCASTNUM_HEAVY="${MCASTNUM_HEAVY:-4000}" +export ROUTE_CHANGE_IP="${ROUTE_CHANGE_IP:-100}" +export ROUTE_CHANGE_NETLINK="${ROUTE_CHANGE_NETLINK:-10000}" # Warning: make sure to set valid interface names and IP addresses below. # Set names for test interfaces, e.g. "eth0 eth1"
testcases/network/stress/route/route-change-dst.sh +2 -2
@@ -12,11 +12,11 @@ TST_SETUP="setup" TST_CLEANUP="route_cleanup" TST_TESTFUNC="test_dst" . route-lib.sh -TST_CNT=$NS_TIMES +TST_CNT=$ROUTE_CHANGE_IP setup() { - tst_res TINFO "change IPv$TST_IPVER route destination $NS_TIMES times" + tst_res TINFO "change IPv$TST_IPVER route destination $ROUTE_CHANGE_IP times" } test_dst()
testcases/network/stress/route/route-change-gw.sh +8 -2
@@ -8,11 +8,17 @@ # Change route gateway # lhost: 10.23.1.1, gw (on rhost): 10.23.1.x, rhost: 10.23.0.1 -TST_SETUP="setup_gw" +TST_SETUP="setup" TST_CLEANUP="route_cleanup" TST_TESTFUNC="test_gw" . route-lib.sh -TST_CNT=$NS_TIMES +TST_CNT=$ROUTE_CHANGE_IP + +setup() +{ + tst_res TINFO "change IPv$TST_IPVER route gateway $ROUTE_CHANGE_IP times" + setup_gw +} test_gw() {
testcases/network/stress/route/route-change-if.sh +8 -2
@@ -8,11 +8,17 @@ # Change route interface # lhost: 10.23.x.2, gw (on rhost): 10.23.x.1, rhost: 10.23.0.1, switching ifaces on lhost -TST_SETUP="setup_if" +TST_SETUP="setup" TST_CLEANUP="cleanup_if" TST_TESTFUNC="test_if" . route-lib.sh -TST_CNT=$NS_TIMES +TST_CNT=$ROUTE_CHANGE_IP + +setup() +{ + tst_res TINFO "change IPv$TST_IPVER route interface $ROUTE_CHANGE_IP times" + setup_if +} test_if() {
testcases/network/stress/route/route-change-netlink-dst.sh +1 -1
@@ -13,7 +13,7 @@ TST_TESTFUNC="test_netlink" setup() { - tst_res TINFO "change IPv$TST_IPVER route destination $NS_TIMES times" + tst_res TINFO "change IPv$TST_IPVER route destination $ROUTE_CHANGE_NETLINK times" local cnt=0 local gw rhost rhost_all rt
testcases/network/stress/route/route-change-netlink-gw.sh +2 -0
@@ -15,6 +15,8 @@ setup() { local cnt=0 + tst_res TINFO "change IPv$TST_IPVER route gateway $ROUTE_CHANGE_NETLINK times" + check_max_ip setup_gw
testcases/network/stress/route/route-change-netlink-if.sh +1 -0
@@ -16,6 +16,7 @@ setup() local gw gw_all iface iface_all local cnt=0 + tst_res TINFO "change IPv$TST_IPVER route interface $ROUTE_CHANGE_NETLINK times" setup_if while [ $cnt -lt $(tst_get_ifaces_cnt) ]; do
testcases/network/stress/route/route-lib.sh +2 -6
@@ -45,7 +45,7 @@ check_max_ip() tst_is_int "$ROUTE_MAX_IP" || tst_brk TBROK "\$ROUTE_MAX_IP not int ($ROUTE_MAX_IP)" [ $ROUTE_MAX_IP -gt $max_ip_limit ] && ROUTE_MAX_IP=$max_ip_limit - [ $ROUTE_MAX_IP -gt $NS_TIMES ] && ROUTE_MAX_IP=$NS_TIMES + [ $ROUTE_MAX_IP -gt $ROUTE_CHANGE_NETLINK ] && ROUTE_MAX_IP=$ROUTE_CHANGE_NETLINK } cleanup_if()
@@ -63,8 +63,6 @@ route_cleanup() setup_gw() { - tst_res TINFO "change IPv$TST_IPVER route gateway $NS_TIMES times" - rt="$(tst_ipaddr_un -p 0 0)" lhost="$(tst_ipaddr_un 1 1)" rhost="$(tst_ipaddr_un 0 1)"
@@ -74,8 +72,6 @@ setup_gw() setup_if() { - tst_res TINFO "change IPv$TST_IPVER route interface $NS_TIMES times" - rt="$(tst_ipaddr_un -p 0)" rhost="$(tst_ipaddr_un 0 1)" tst_add_ipaddr -s -q -a $rhost rhost
@@ -99,7 +95,7 @@ test_netlink() local cmd ip_flag [ "$TST_IPV6" ] && ip_flag="-6" - cmd="route-change-netlink -c $NS_TIMES $ip_flag -p $ROUTE_RHOST_PORT $ROUTE_CHANGE_NETLINK_PARAMS" + cmd="route-change-netlink -c $ROUTE_CHANGE_NETLINK $ip_flag -p $ROUTE_RHOST_PORT $ROUTE_CHANGE_NETLINK_PARAMS" tst_res TINFO "running $cmd" $cmd || ret=$? if [ "$ret" -ne 0 ]; then
Signature · 1 line
2.26.2
PATCH v6 3/3 route: Increase default loop values
Quoted 21 lines · Petr Vorel
by introducing $ROUTE_CHANGE_IP for shell based tests (only these rewritten into new shell API) and $ROUTE_CHANGE_NETLINK with C Netlink API based tests.
Signed-off-by Petr Vorel <[email protected]>--- testcases/lib/tst_net.sh | 2 ++ testcases/network/stress/route/route-change-dst.sh | 4 ++-- testcases/network/stress/route/route-change-gw.sh | 10 ++++++++-- testcases/network/stress/route/route-change-if.sh | 10 ++++++++-- .../network/stress/route/route-change-netlink-dst.sh | 2 +- .../network/stress/route/route-change-netlink-gw.sh | 2 ++ .../network/stress/route/route-change-netlink-if.sh | 1 + testcases/network/stress/route/route-lib.sh | 8 ++------ 8 files changed, 26 insertions(+), 13 deletions(-)testcases/lib/tst_net.sh +0
-0
testcases/lib/tst_net.sh export UPLOAD_BIGFILESIZE="${UPLOAD_BIGFILESIZE:-2147483647}" · line 917
Quoted 5 lines
testcases/lib/tst_net.sh +2
-0@@ -913,6 +913,8 @@ export UPLOAD_BIGFILESIZE="${UPLOAD_BIGFILESIZE:-2147483647}" export UPLOAD_REGFILESIZE="${UPLOAD_REGFILESIZE:-1024}" export MCASTNUM_NORMAL="${MCASTNUM_NORMAL:-20}" export MCASTNUM_HEAVY="${MCASTNUM_HEAVY:-4000}" +export ROUTE_CHANGE_IP="${ROUTE_CHANGE_IP:-100}" +export ROUTE_CHANGE_NETLINK="${ROUTE_CHANGE_NETLINK:-10000}"
Hi Petr,
The changes are fine.
Perhaps for further improvements, ROUTE_CHANGE_NETLINK is limited by "NUM_LOOPS_MAX 65535", it looks unnecessary. Can we limit the setup only and iterate (adding and deleting) from the beginning or use -i option with -c?
Quoted 148 lines
testcases/lib/tst_net.sh +0
-0# Warning: make sure to set valid interface names and IP addresses below. # Set names for test interfaces, e.g. "eth0 eth1"testcases/network/stress/route/route-change-dst.sh +2
-2@@ -12,11 +12,11 @@ TST_SETUP="setup" TST_CLEANUP="route_cleanup" TST_TESTFUNC="test_dst" . route-lib.sh -TST_CNT=$NS_TIMES +TST_CNT=$ROUTE_CHANGE_IP setup() { - tst_res TINFO "change IPv$TST_IPVER route destination $NS_TIMES times" + tst_res TINFO "change IPv$TST_IPVER route destination $ROUTE_CHANGE_IP times" } test_dst()testcases/network/stress/route/route-change-gw.sh +8
-2@@ -8,11 +8,17 @@ # Change route gateway # lhost: 10.23.1.1, gw (on rhost): 10.23.1.x, rhost: 10.23.0.1 -TST_SETUP="setup_gw" +TST_SETUP="setup" TST_CLEANUP="route_cleanup" TST_TESTFUNC="test_gw" . route-lib.sh -TST_CNT=$NS_TIMES +TST_CNT=$ROUTE_CHANGE_IP + +setup() +{ + tst_res TINFO "change IPv$TST_IPVER route gateway $ROUTE_CHANGE_IP times" + setup_gw +} test_gw() {testcases/network/stress/route/route-change-if.sh +8
-2@@ -8,11 +8,17 @@ # Change route interface # lhost: 10.23.x.2, gw (on rhost): 10.23.x.1, rhost: 10.23.0.1, switching ifaces on lhost -TST_SETUP="setup_if" +TST_SETUP="setup" TST_CLEANUP="cleanup_if" TST_TESTFUNC="test_if" . route-lib.sh -TST_CNT=$NS_TIMES +TST_CNT=$ROUTE_CHANGE_IP + +setup() +{ + tst_res TINFO "change IPv$TST_IPVER route interface $ROUTE_CHANGE_IP times" + setup_if +} test_if() {testcases/network/stress/route/route-change-netlink-dst.sh +1
-1@@ -13,7 +13,7 @@ TST_TESTFUNC="test_netlink" setup() { - tst_res TINFO "change IPv$TST_IPVER route destination $NS_TIMES times" + tst_res TINFO "change IPv$TST_IPVER route destination $ROUTE_CHANGE_NETLINK times" local cnt=0 local gw rhost rhost_all rttestcases/network/stress/route/route-change-netlink-gw.sh +2
-0@@ -15,6 +15,8 @@ setup() { local cnt=0 + tst_res TINFO "change IPv$TST_IPVER route gateway $ROUTE_CHANGE_NETLINK times" + check_max_ip setup_gwtestcases/network/stress/route/route-change-netlink-if.sh +1
-0@@ -16,6 +16,7 @@ setup() local gw gw_all iface iface_all local cnt=0 + tst_res TINFO "change IPv$TST_IPVER route interface $ROUTE_CHANGE_NETLINK times" setup_if while [ $cnt -lt $(tst_get_ifaces_cnt) ]; dotestcases/network/stress/route/route-lib.sh +2
-6@@ -45,7 +45,7 @@ check_max_ip() tst_is_int "$ROUTE_MAX_IP" || tst_brk TBROK "\$ROUTE_MAX_IP not int ($ROUTE_MAX_IP)" [ $ROUTE_MAX_IP -gt $max_ip_limit ] && ROUTE_MAX_IP=$max_ip_limit - [ $ROUTE_MAX_IP -gt $NS_TIMES ] && ROUTE_MAX_IP=$NS_TIMES + [ $ROUTE_MAX_IP -gt $ROUTE_CHANGE_NETLINK ] && ROUTE_MAX_IP=$ROUTE_CHANGE_NETLINK } cleanup_if()@@ -63,8 +63,6 @@ route_cleanup() setup_gw() { - tst_res TINFO "change IPv$TST_IPVER route gateway $NS_TIMES times" - rt="$(tst_ipaddr_un -p 0 0)" lhost="$(tst_ipaddr_un 1 1)" rhost="$(tst_ipaddr_un 0 1)"@@ -74,8 +72,6 @@ setup_gw() setup_if() { - tst_res TINFO "change IPv$TST_IPVER route interface $NS_TIMES times" - rt="$(tst_ipaddr_un -p 0)" rhost="$(tst_ipaddr_un 0 1)" tst_add_ipaddr -s -q -a $rhost rhost@@ -99,7 +95,7 @@ test_netlink() local cmd ip_flag [ "$TST_IPV6" ] && ip_flag="-6" - cmd="route-change-netlink -c $NS_TIMES $ip_flag -p $ROUTE_RHOST_PORT $ROUTE_CHANGE_NETLINK_PARAMS" + cmd="route-change-netlink -c $ROUTE_CHANGE_NETLINK $ip_flag -p $ROUTE_RHOST_PORT $ROUTE_CHANGE_NETLINK_PARAMS" tst_res TINFO "running $cmd" $cmd || ret=$? if [ "$ret" -ne 0 ]; then
PATCH v6 3/3 route: Increase default loop values
Hi Alexey,
Quoted 1 line
The changes are fine.
Thanks for your ack.
Quoted 2 lines
Perhaps for further improvements,
ROUTE_CHANGE_NETLINKis limited by "NUM_LOOPS_MAX65535", it looks unnecessary.
Sure, I'll remove this. It fails if -c is bigger than INT_MAX, thus suggest:
+++ testcases/network/stress/route/route-change-netlink.c @@ -20,8 +20,6 @@
#include "tst_safe_net.h"
#include "tst_safe_stdio.h"
-#define NUM_LOOPS_MAX 65535
-
#define IP_ADDR_DELIM ','
#define STR(x) #x
#define CHR2STR(x) STR(x)
@@ -117,8 +115,8 @@ static void setup(void)
if (tst_parse_int(p_opt, &port, 1, 65535))
tst_brk(TBROK, "invalid rhost port '%s'", p_opt);
- if (tst_parse_int(c_opt, &num_loops, 1, NUM_LOOPS_MAX)) {
- num_loops = NUM_LOOPS_MAX;
+ if (tst_parse_int(c_opt, &num_loops, 1, INT_MAX)) {
+ num_loops = INT_MAX;
tst_res(TWARN, "invalid number of loops (-c %s), using: %d",
c_opt, num_loops);
}
---
Or I can use long and LONG_MAX, but IMHO int is OK :)
Quoted 2 lines
Can we limit the setup only and iterate (adding and deleting) from the beginning or use -i option with -c?
I'm sorry, I don't understand you. Isn't it INT_MAX enough?
Kind regards,
Petr
PATCH v6 3/3 route: Increase default loop values
Quoted 32 lines · Petr Vorel
Hi Alexey,
Quoted 1 line
The changes are fine.
Thanks for your ack.
Quoted 2 lines
Perhaps for further improvements,
ROUTE_CHANGE_NETLINKis limited by "NUM_LOOPS_MAX65535", it looks unnecessary.Sure, I'll remove this. It fails if -c is bigger than
INT_MAX, thus suggest:+++
testcases/network/stress/route/route-change-netlink.c(quoted diff) +2
-5@@ -20,8 +20,6 @@ #include "tst_safe_net.h" #include "tst_safe_stdio.h" -#define NUM_LOOPS_MAX 65535 - #define IP_ADDR_DELIM ',' #define STR(x) #x #define CHR2STR(x) STR(x)@@ -117,8 +115,8 @@ static void setup(void) if (tst_parse_int(p_opt, &port, 1, 65535)) tst_brk(TBROK, "invalid rhost port '%s'", p_opt); - if (tst_parse_int(c_opt, &num_loops, 1, NUM_LOOPS_MAX)) { - num_loops = NUM_LOOPS_MAX; + if (tst_parse_int(c_opt, &num_loops, 1, INT_MAX)) { + num_loops = INT_MAX; tst_res(TWARN, "invalid number of loops (-c %s), using: %d", c_opt, num_loops); } ---
Quoted 5 lines
Or I can use long and
LONG_MAX, but IMHO int is OK :)Quoted 2 lines
Can we limit the setup only and iterate (adding and deleting) from the beginning or use -i option with -c?
I'm sorry, I don't understand you. Isn't it
INT_MAXenough?
Yes, it's fine, I just wasn't sure why it was added in the first place, 65535, because of some limitation of the ip address setup (you have added the separate ip max var though) or something else...
Quoted 4 lines
Kind regards,
Petr
PATCH v6 3/3 route: Increase default loop values
Hi Alexey,
Quoted 10 lines
Quoted 5 lines
Or I can use long and
LONG_MAX, but IMHO int is OK :)Quoted 2 lines
Can we limit the setup only and iterate (adding and deleting) from the beginning or use -i option with -c?
I'm sorry, I don't understand you. Isn't it
INT_MAXenough?Yes, it's fine, I just wasn't sure why it was added in the first place, 65535, because of some limitation of the ip address setup (you have added the separate ip max var though) or something else...
OK, finally merging. Thanks a lot for patient review and many tips!
Kind regards,
Petr
PATCH v6 3/3 route: Increase default loop values
Hi Alexey,
Quoted 5 lines
Quoted 3 lines
Yes, it's fine, I just wasn't sure why it was added in the first place, 65535, because of some limitation of the ip address setup (you have added the separate ip max var though) or something else...
OK, finally merging. Thanks a lot for patient review and many tips!
FYI: Merged.
Kind regards,
Petr