All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@mellanox.com>
To: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org
Cc: davem@davemloft.net, shuah@kernel.org, jiri@mellanox.com,
	dsahern@gmail.com, roopa@cumulusnetworks.com,
	nikolay@cumulusnetworks.com, andrew@lunn.ch,
	f.fainelli@gmail.com, vivien.didelot@savoirfairelinux.com,
	mlxsw@mellanox.com, Ido Schimmel <idosch@mellanox.com>
Subject: [PATCH net-next v2 06/14] selftests: forwarding: Test IPv4 weighted nexthops
Date: Wed, 28 Feb 2018 12:25:11 +0200	[thread overview]
Message-ID: <20180228102519.4156-7-idosch@mellanox.com> (raw)
In-Reply-To: <20180228102519.4156-1-idosch@mellanox.com>

Use different weights for the multipath route configured on the first
router and check that the different flows generated by the first host
are distributed according to the provided weights.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 tools/testing/selftests/net/forwarding/lib.sh      | 14 ++++
 .../selftests/net/forwarding/router_multipath.sh   | 77 ++++++++++++++++++++++
 2 files changed, 91 insertions(+)

diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index 962153b7181b..6866f4a4bc4e 100644
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -113,6 +113,13 @@ log_test()
 	return 0
 }
 
+log_info()
+{
+	local msg=$1
+
+	echo "INFO: $msg"
+}
+
 setup_wait()
 {
 	for i in $(eval echo {1..$NUM_NETIFS}); do
@@ -256,6 +263,13 @@ master_name_get()
 	ip -j link show dev $if_name | jq -r '.[]["master"]'
 }
 
+link_stats_tx_packets_get()
+{
+       local if_name=$1
+
+       ip -j -s link show dev $if_name | jq '.[]["stats64"]["tx"]["packets"]'
+}
+
 bridge_ageing_time_get()
 {
 	local bridge=$1
diff --git a/tools/testing/selftests/net/forwarding/router_multipath.sh b/tools/testing/selftests/net/forwarding/router_multipath.sh
index 86d189b42e9b..5b425dffb5d0 100755
--- a/tools/testing/selftests/net/forwarding/router_multipath.sh
+++ b/tools/testing/selftests/net/forwarding/router_multipath.sh
@@ -158,6 +158,82 @@ router2_destroy()
 	vrf_destroy "vrf-r2"
 }
 
+multipath_eval()
+{
+       local weight_rp12=$1
+       local weight_rp13=$2
+       local packets_rp12=$3
+       local packets_rp13=$4
+       local weights_ratio packets_ratio diff
+
+       RET=0
+
+       if [[ "$weight_rp12" -gt "$weight_rp13" ]]; then
+               weights_ratio=$(echo "scale=2; $weight_rp12 / $weight_rp13" \
+		       | bc -l)
+               packets_ratio=$(echo "scale=2; $packets_rp12 / $packets_rp13" \
+		       | bc -l)
+       else
+               weights_ratio=$(echo "scale=2; $weight_rp13 / $weight_rp12" | \
+		       bc -l)
+               packets_ratio=$(echo "scale=2; $packets_rp13 / $packets_rp12" | \
+		       bc -l)
+       fi
+
+       diff=$(echo $weights_ratio - $packets_ratio | bc -l)
+       diff=${diff#-}
+
+       test "$(echo "$diff / $weights_ratio > 0.1" | bc -l)" -eq 0
+       check_err $? "Too large discrepancy between expected and measured ratios"
+       log_test "Multipath"
+       log_info "Expected ratio $weights_ratio Measured ratio $packets_ratio"
+}
+
+multipath4_test()
+{
+       local weight_rp12=$1
+       local weight_rp13=$2
+       local t0_rp12 t0_rp13 t1_rp12 t1_rp13
+       local packets_rp12 packets_rp13
+       local hash_policy
+
+       # Transmit multiple flows from h1 to h2 and make sure they are
+       # distributed between both multipath links (rp12 and rp13)
+       # according to the configured weights.
+       hash_policy=$(sysctl -n net.ipv4.fib_multipath_hash_policy)
+       sysctl -q -w net.ipv4.fib_multipath_hash_policy=1
+       ip route replace 198.51.100.0/24 vrf vrf-r1 \
+               nexthop via 169.254.2.22 dev $rp12 weight $weight_rp12 \
+               nexthop via 169.254.3.23 dev $rp13 weight $weight_rp13
+
+       t0_rp12=$(link_stats_tx_packets_get $rp12)
+       t0_rp13=$(link_stats_tx_packets_get $rp13)
+
+       ip vrf exec vrf-h1 $MZ -q -p 64 -A 192.0.2.2 -B 198.51.100.2 \
+	       -d 1msec -t udp "sp=1024,dp=0-32768"
+
+       t1_rp12=$(link_stats_tx_packets_get $rp12)
+       t1_rp13=$(link_stats_tx_packets_get $rp13)
+
+       let "packets_rp12 = $t1_rp12 - $t0_rp12"
+       let "packets_rp13 = $t1_rp13 - $t0_rp13"
+       multipath_eval $weight_rp12 $weight_rp13 $packets_rp12 $packets_rp13
+
+       # Restore settings.
+       ip route replace 198.51.100.0/24 vrf vrf-r1 \
+               nexthop via 169.254.2.22 dev $rp12 \
+               nexthop via 169.254.3.23 dev $rp13
+       sysctl -q -w net.ipv4.fib_multipath_hash_policy=$hash_policy
+}
+
+multipath_test()
+{
+	log_info "Running IPv4 multipath tests"
+	multipath4_test 1 1
+	multipath4_test 2 1
+	multipath4_test 11 45
+}
+
 setup_prepare()
 {
 	h1=${NETIFS[p1]}
@@ -205,5 +281,6 @@ setup_wait
 
 ping_test $h1 198.51.100.2
 ping6_test $h1 2001:db8:2::2
+multipath_test
 
 exit $EXIT_STATUS
-- 
2.14.3

WARNING: multiple messages have this Message-ID (diff)
From: idosch at mellanox.com (Ido Schimmel)
Subject: [PATCH net-next v2 06/14] selftests: forwarding: Test IPv4 weighted nexthops
Date: Wed, 28 Feb 2018 12:25:11 +0200	[thread overview]
Message-ID: <20180228102519.4156-7-idosch@mellanox.com> (raw)
In-Reply-To: <20180228102519.4156-1-idosch@mellanox.com>

Use different weights for the multipath route configured on the first
router and check that the different flows generated by the first host
are distributed according to the provided weights.

Signed-off-by: Ido Schimmel <idosch at mellanox.com>
---
 tools/testing/selftests/net/forwarding/lib.sh      | 14 ++++
 .../selftests/net/forwarding/router_multipath.sh   | 77 ++++++++++++++++++++++
 2 files changed, 91 insertions(+)

diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index 962153b7181b..6866f4a4bc4e 100644
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -113,6 +113,13 @@ log_test()
 	return 0
 }
 
+log_info()
+{
+	local msg=$1
+
+	echo "INFO: $msg"
+}
+
 setup_wait()
 {
 	for i in $(eval echo {1..$NUM_NETIFS}); do
@@ -256,6 +263,13 @@ master_name_get()
 	ip -j link show dev $if_name | jq -r '.[]["master"]'
 }
 
+link_stats_tx_packets_get()
+{
+       local if_name=$1
+
+       ip -j -s link show dev $if_name | jq '.[]["stats64"]["tx"]["packets"]'
+}
+
 bridge_ageing_time_get()
 {
 	local bridge=$1
diff --git a/tools/testing/selftests/net/forwarding/router_multipath.sh b/tools/testing/selftests/net/forwarding/router_multipath.sh
index 86d189b42e9b..5b425dffb5d0 100755
--- a/tools/testing/selftests/net/forwarding/router_multipath.sh
+++ b/tools/testing/selftests/net/forwarding/router_multipath.sh
@@ -158,6 +158,82 @@ router2_destroy()
 	vrf_destroy "vrf-r2"
 }
 
+multipath_eval()
+{
+       local weight_rp12=$1
+       local weight_rp13=$2
+       local packets_rp12=$3
+       local packets_rp13=$4
+       local weights_ratio packets_ratio diff
+
+       RET=0
+
+       if [[ "$weight_rp12" -gt "$weight_rp13" ]]; then
+               weights_ratio=$(echo "scale=2; $weight_rp12 / $weight_rp13" \
+		       | bc -l)
+               packets_ratio=$(echo "scale=2; $packets_rp12 / $packets_rp13" \
+		       | bc -l)
+       else
+               weights_ratio=$(echo "scale=2; $weight_rp13 / $weight_rp12" | \
+		       bc -l)
+               packets_ratio=$(echo "scale=2; $packets_rp13 / $packets_rp12" | \
+		       bc -l)
+       fi
+
+       diff=$(echo $weights_ratio - $packets_ratio | bc -l)
+       diff=${diff#-}
+
+       test "$(echo "$diff / $weights_ratio > 0.1" | bc -l)" -eq 0
+       check_err $? "Too large discrepancy between expected and measured ratios"
+       log_test "Multipath"
+       log_info "Expected ratio $weights_ratio Measured ratio $packets_ratio"
+}
+
+multipath4_test()
+{
+       local weight_rp12=$1
+       local weight_rp13=$2
+       local t0_rp12 t0_rp13 t1_rp12 t1_rp13
+       local packets_rp12 packets_rp13
+       local hash_policy
+
+       # Transmit multiple flows from h1 to h2 and make sure they are
+       # distributed between both multipath links (rp12 and rp13)
+       # according to the configured weights.
+       hash_policy=$(sysctl -n net.ipv4.fib_multipath_hash_policy)
+       sysctl -q -w net.ipv4.fib_multipath_hash_policy=1
+       ip route replace 198.51.100.0/24 vrf vrf-r1 \
+               nexthop via 169.254.2.22 dev $rp12 weight $weight_rp12 \
+               nexthop via 169.254.3.23 dev $rp13 weight $weight_rp13
+
+       t0_rp12=$(link_stats_tx_packets_get $rp12)
+       t0_rp13=$(link_stats_tx_packets_get $rp13)
+
+       ip vrf exec vrf-h1 $MZ -q -p 64 -A 192.0.2.2 -B 198.51.100.2 \
+	       -d 1msec -t udp "sp=1024,dp=0-32768"
+
+       t1_rp12=$(link_stats_tx_packets_get $rp12)
+       t1_rp13=$(link_stats_tx_packets_get $rp13)
+
+       let "packets_rp12 = $t1_rp12 - $t0_rp12"
+       let "packets_rp13 = $t1_rp13 - $t0_rp13"
+       multipath_eval $weight_rp12 $weight_rp13 $packets_rp12 $packets_rp13
+
+       # Restore settings.
+       ip route replace 198.51.100.0/24 vrf vrf-r1 \
+               nexthop via 169.254.2.22 dev $rp12 \
+               nexthop via 169.254.3.23 dev $rp13
+       sysctl -q -w net.ipv4.fib_multipath_hash_policy=$hash_policy
+}
+
+multipath_test()
+{
+	log_info "Running IPv4 multipath tests"
+	multipath4_test 1 1
+	multipath4_test 2 1
+	multipath4_test 11 45
+}
+
 setup_prepare()
 {
 	h1=${NETIFS[p1]}
@@ -205,5 +281,6 @@ setup_wait
 
 ping_test $h1 198.51.100.2
 ping6_test $h1 2001:db8:2::2
+multipath_test
 
 exit $EXIT_STATUS
-- 
2.14.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: idosch@mellanox.com (Ido Schimmel)
Subject: [PATCH net-next v2 06/14] selftests: forwarding: Test IPv4 weighted nexthops
Date: Wed, 28 Feb 2018 12:25:11 +0200	[thread overview]
Message-ID: <20180228102519.4156-7-idosch@mellanox.com> (raw)
Message-ID: <20180228102511.fJlFqVdz2IXfHYIY9qqtVxrXoUwsVQMNqja5PDDgom0@z> (raw)
In-Reply-To: <20180228102519.4156-1-idosch@mellanox.com>

Use different weights for the multipath route configured on the first
router and check that the different flows generated by the first host
are distributed according to the provided weights.

Signed-off-by: Ido Schimmel <idosch at mellanox.com>
---
 tools/testing/selftests/net/forwarding/lib.sh      | 14 ++++
 .../selftests/net/forwarding/router_multipath.sh   | 77 ++++++++++++++++++++++
 2 files changed, 91 insertions(+)

diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index 962153b7181b..6866f4a4bc4e 100644
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -113,6 +113,13 @@ log_test()
 	return 0
 }
 
+log_info()
+{
+	local msg=$1
+
+	echo "INFO: $msg"
+}
+
 setup_wait()
 {
 	for i in $(eval echo {1..$NUM_NETIFS}); do
@@ -256,6 +263,13 @@ master_name_get()
 	ip -j link show dev $if_name | jq -r '.[]["master"]'
 }
 
+link_stats_tx_packets_get()
+{
+       local if_name=$1
+
+       ip -j -s link show dev $if_name | jq '.[]["stats64"]["tx"]["packets"]'
+}
+
 bridge_ageing_time_get()
 {
 	local bridge=$1
diff --git a/tools/testing/selftests/net/forwarding/router_multipath.sh b/tools/testing/selftests/net/forwarding/router_multipath.sh
index 86d189b42e9b..5b425dffb5d0 100755
--- a/tools/testing/selftests/net/forwarding/router_multipath.sh
+++ b/tools/testing/selftests/net/forwarding/router_multipath.sh
@@ -158,6 +158,82 @@ router2_destroy()
 	vrf_destroy "vrf-r2"
 }
 
+multipath_eval()
+{
+       local weight_rp12=$1
+       local weight_rp13=$2
+       local packets_rp12=$3
+       local packets_rp13=$4
+       local weights_ratio packets_ratio diff
+
+       RET=0
+
+       if [[ "$weight_rp12" -gt "$weight_rp13" ]]; then
+               weights_ratio=$(echo "scale=2; $weight_rp12 / $weight_rp13" \
+		       | bc -l)
+               packets_ratio=$(echo "scale=2; $packets_rp12 / $packets_rp13" \
+		       | bc -l)
+       else
+               weights_ratio=$(echo "scale=2; $weight_rp13 / $weight_rp12" | \
+		       bc -l)
+               packets_ratio=$(echo "scale=2; $packets_rp13 / $packets_rp12" | \
+		       bc -l)
+       fi
+
+       diff=$(echo $weights_ratio - $packets_ratio | bc -l)
+       diff=${diff#-}
+
+       test "$(echo "$diff / $weights_ratio > 0.1" | bc -l)" -eq 0
+       check_err $? "Too large discrepancy between expected and measured ratios"
+       log_test "Multipath"
+       log_info "Expected ratio $weights_ratio Measured ratio $packets_ratio"
+}
+
+multipath4_test()
+{
+       local weight_rp12=$1
+       local weight_rp13=$2
+       local t0_rp12 t0_rp13 t1_rp12 t1_rp13
+       local packets_rp12 packets_rp13
+       local hash_policy
+
+       # Transmit multiple flows from h1 to h2 and make sure they are
+       # distributed between both multipath links (rp12 and rp13)
+       # according to the configured weights.
+       hash_policy=$(sysctl -n net.ipv4.fib_multipath_hash_policy)
+       sysctl -q -w net.ipv4.fib_multipath_hash_policy=1
+       ip route replace 198.51.100.0/24 vrf vrf-r1 \
+               nexthop via 169.254.2.22 dev $rp12 weight $weight_rp12 \
+               nexthop via 169.254.3.23 dev $rp13 weight $weight_rp13
+
+       t0_rp12=$(link_stats_tx_packets_get $rp12)
+       t0_rp13=$(link_stats_tx_packets_get $rp13)
+
+       ip vrf exec vrf-h1 $MZ -q -p 64 -A 192.0.2.2 -B 198.51.100.2 \
+	       -d 1msec -t udp "sp=1024,dp=0-32768"
+
+       t1_rp12=$(link_stats_tx_packets_get $rp12)
+       t1_rp13=$(link_stats_tx_packets_get $rp13)
+
+       let "packets_rp12 = $t1_rp12 - $t0_rp12"
+       let "packets_rp13 = $t1_rp13 - $t0_rp13"
+       multipath_eval $weight_rp12 $weight_rp13 $packets_rp12 $packets_rp13
+
+       # Restore settings.
+       ip route replace 198.51.100.0/24 vrf vrf-r1 \
+               nexthop via 169.254.2.22 dev $rp12 \
+               nexthop via 169.254.3.23 dev $rp13
+       sysctl -q -w net.ipv4.fib_multipath_hash_policy=$hash_policy
+}
+
+multipath_test()
+{
+	log_info "Running IPv4 multipath tests"
+	multipath4_test 1 1
+	multipath4_test 2 1
+	multipath4_test 11 45
+}
+
 setup_prepare()
 {
 	h1=${NETIFS[p1]}
@@ -205,5 +281,6 @@ setup_wait
 
 ping_test $h1 198.51.100.2
 ping6_test $h1 2001:db8:2::2
+multipath_test
 
 exit $EXIT_STATUS
-- 
2.14.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2018-02-28 10:42 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-28 10:25 [PATCH net-next v2 00/14] selftests: forwarding: Add VRF-based tests Ido Schimmel
2018-02-28 10:25 ` Ido Schimmel
2018-02-28 10:25 ` idosch
2018-02-28 10:25 ` [PATCH net-next v2 01/14] selftests: forwarding: Add initial testing framework Ido Schimmel
2018-02-28 10:25   ` Ido Schimmel
2018-02-28 10:25   ` idosch
2018-02-28 10:25 ` [PATCH net-next v2 02/14] selftests: forwarding: Add a test for FDB learning Ido Schimmel
2018-02-28 10:25   ` Ido Schimmel
2018-02-28 10:25   ` idosch
2018-02-28 10:25 ` [PATCH net-next v2 03/14] selftests: forwarding: Add a test for flooded traffic Ido Schimmel
2018-02-28 10:25   ` Ido Schimmel
2018-02-28 10:25   ` idosch
2018-02-28 10:25 ` [PATCH net-next v2 04/14] selftests: forwarding: Add a test for basic IPv4 and IPv6 routing Ido Schimmel
2018-02-28 10:25   ` Ido Schimmel
2018-02-28 10:25   ` idosch
2018-02-28 10:25 ` [PATCH net-next v2 05/14] selftests: forwarding: Create test topology for multipath routing Ido Schimmel
2018-02-28 10:25   ` Ido Schimmel
2018-02-28 10:25   ` idosch
2018-02-28 10:25 ` Ido Schimmel [this message]
2018-02-28 10:25   ` [PATCH net-next v2 06/14] selftests: forwarding: Test IPv4 weighted nexthops Ido Schimmel
2018-02-28 10:25   ` idosch
2018-02-28 10:25 ` [PATCH net-next v2 07/14] selftests: forwarding: Test IPv6 " Ido Schimmel
2018-02-28 10:25   ` Ido Schimmel
2018-02-28 10:25   ` idosch
2018-02-28 10:25 ` [PATCH net-next v2 08/14] selftests: forwarding: Add tc offload check helper Ido Schimmel
2018-02-28 10:25   ` Ido Schimmel
2018-02-28 10:25   ` idosch
2018-02-28 10:25 ` [PATCH net-next v2 09/14] selftests: forwarding: Add MAC get helper Ido Schimmel
2018-02-28 10:25   ` Ido Schimmel
2018-02-28 10:25   ` idosch
2018-02-28 10:25 ` [PATCH net-next v2 10/14] selftests: forwarding: Allow to get netdev interfaces names from commandline Ido Schimmel
2018-02-28 10:25   ` Ido Schimmel
2018-02-28 10:25   ` idosch
2018-02-28 10:25 ` [PATCH net-next v2 11/14] selftests: forwarding: Introduce tc flower matching tests Ido Schimmel
2018-02-28 10:25   ` Ido Schimmel
2018-02-28 10:25   ` idosch
2018-02-28 10:25 ` [PATCH net-next v2 12/14] selftests: forwarding: Introduce tc actions tests Ido Schimmel
2018-02-28 10:25   ` Ido Schimmel
2018-02-28 10:25   ` idosch
2018-02-28 10:25 ` [PATCH net-next v2 13/14] selftests: forwarding: Introduce basic tc chains tests Ido Schimmel
2018-02-28 10:25   ` Ido Schimmel
2018-02-28 10:25   ` idosch
2018-02-28 10:25 ` [PATCH net-next v2 14/14] selftests: forwarding: Introduce basic shared blocks tests Ido Schimmel
2018-02-28 10:25   ` Ido Schimmel
2018-02-28 10:25   ` idosch
2018-02-28 17:27 ` [PATCH net-next v2 00/14] selftests: forwarding: Add VRF-based tests David Miller
2018-02-28 17:27   ` David Miller
2018-02-28 17:27   ` davem

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180228102519.4156-7-idosch@mellanox.com \
    --to=idosch@mellanox.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=dsahern@gmail.com \
    --cc=f.fainelli@gmail.com \
    --cc=jiri@mellanox.com \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mlxsw@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=nikolay@cumulusnetworks.com \
    --cc=roopa@cumulusnetworks.com \
    --cc=shuah@kernel.org \
    --cc=vivien.didelot@savoirfairelinux.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.