All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@idosch.org>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, jiri@nvidia.com,
	dsahern@gmail.com, mlxsw@nvidia.com,
	Ido Schimmel <idosch@nvidia.com>
Subject: [PATCH net-next 10/10] selftests: mlxsw: Add blackhole_nexthop trap test
Date: Mon, 23 Nov 2020 09:12:30 +0200	[thread overview]
Message-ID: <20201123071230.676469-11-idosch@idosch.org> (raw)
In-Reply-To: <20201123071230.676469-1-idosch@idosch.org>

From: Ido Schimmel <idosch@nvidia.com>

Test that packets hitting a blackhole nexthop are trapped to the CPU
when the trap is enabled. Test that packets are not reported when the
trap is disabled.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
 .../net/mlxsw/devlink_trap_l3_drops.sh        | 36 +++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_l3_drops.sh b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_l3_drops.sh
index f5abb1ebd392..4029833f7e27 100755
--- a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_l3_drops.sh
+++ b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_l3_drops.sh
@@ -52,6 +52,7 @@ ALL_TESTS="
 	blackhole_route_test
 	irif_disabled_test
 	erif_disabled_test
+	blackhole_nexthop_test
 "
 
 NUM_NETIFS=4
@@ -647,6 +648,41 @@ erif_disabled_test()
 	devlink_trap_action_set $trap_name "drop"
 }
 
+__blackhole_nexthop_test()
+{
+	local flags=$1; shift
+	local subnet=$1; shift
+	local proto=$1; shift
+	local dip=$1; shift
+	local trap_name="blackhole_nexthop"
+	local mz_pid
+
+	RET=0
+
+	ip -$flags nexthop add id 1 blackhole
+	ip -$flags route add $subnet nhid 1
+	tc filter add dev $rp2 egress protocol $proto pref 1 handle 101 \
+		flower skip_hw dst_ip $dip ip_proto udp action drop
+
+	# Generate packets to the blackhole nexthop
+	$MZ $h1 -$flags -t udp "sp=54321,dp=12345" -c 0 -p 100 -b $rp1mac \
+		-B $dip -d 1msec -q &
+	mz_pid=$!
+
+	devlink_trap_drop_test $trap_name $rp2 101
+	log_test "Blackhole nexthop: IPv$flags"
+
+	devlink_trap_drop_cleanup $mz_pid $rp2 $proto 1 101
+	ip -$flags route del $subnet
+	ip -$flags nexthop del id 1
+}
+
+blackhole_nexthop_test()
+{
+	__blackhole_nexthop_test "4" "198.51.100.0/30" "ip" $h2_ipv4
+	__blackhole_nexthop_test "6" "2001:db8:2::/120" "ipv6" $h2_ipv6
+}
+
 trap cleanup EXIT
 
 setup_prepare
-- 
2.28.0


  parent reply	other threads:[~2020-11-23  7:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-23  7:12 [PATCH net-next 00/10] mlxsw: Add support for blackhole nexthops Ido Schimmel
2020-11-23  7:12 ` [PATCH net-next 01/10] mlxsw: spectrum_router: Create loopback RIF during initialization Ido Schimmel
2020-11-23  7:12 ` [PATCH net-next 02/10] mlxsw: spectrum_router: Use different trap identifier for unresolved nexthops Ido Schimmel
2020-11-23  7:12 ` [PATCH net-next 03/10] mlxsw: spectrum_router: Use loopback RIF " Ido Schimmel
2020-11-23  7:12 ` [PATCH net-next 04/10] mlxsw: spectrum_router: Resolve RIF from nexthop struct instead of neighbour Ido Schimmel
2020-11-23  7:12 ` [PATCH net-next 05/10] mlxsw: spectrum_router: Add support for blackhole nexthops Ido Schimmel
2020-11-23  7:12 ` [PATCH net-next 06/10] selftests: mlxsw: Add blackhole nexthop configuration tests Ido Schimmel
2020-11-23  7:12 ` [PATCH net-next 07/10] selftests: forwarding: Add blackhole nexthops tests Ido Schimmel
2020-11-23  7:12 ` [PATCH net-next 08/10] devlink: Add blackhole_nexthop trap Ido Schimmel
2020-11-23  7:12 ` [PATCH net-next 09/10] mlxsw: spectrum_trap: " Ido Schimmel
2020-11-23  7:12 ` Ido Schimmel [this message]
2020-11-24 20:19 ` [PATCH net-next 00/10] mlxsw: Add support for blackhole nexthops Jakub Kicinski

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=20201123071230.676469-11-idosch@idosch.org \
    --to=idosch@idosch.org \
    --cc=davem@davemloft.net \
    --cc=dsahern@gmail.com \
    --cc=idosch@nvidia.com \
    --cc=jiri@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=mlxsw@nvidia.com \
    --cc=netdev@vger.kernel.org \
    /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.