All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/8] mlxsw: Disable checks in hardware pipeline
@ 2020-01-05 16:20 Ido Schimmel
  2020-01-05 16:20 ` [PATCH net-next 1/8] mlxsw: spectrum: Disable SIP_CLASS_E check " Ido Schimmel
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Ido Schimmel @ 2020-01-05 16:20 UTC (permalink / raw)
  To: netdev; +Cc: davem, jiri, amitc, mlxsw, Ido Schimmel

From: Ido Schimmel <idosch@mellanox.com>

Amit says:

The hardware pipeline contains some checks that, by default, are
configured to drop packets. Since the software data path does not drop
packets due to these reasons and since we are interested in offloading
the software data path to hardware, then these checks should be disabled
in the hardware pipeline as well.

This patch set changes mlxsw to disable four of these checks and adds
corresponding selftests. The tests pass both when the software data path
is exercised (using veth pair) and when the hardware data path is
exercised (using mlxsw ports in loopback).

Amit Cohen (8):
  mlxsw: spectrum: Disable SIP_CLASS_E check in hardware pipeline
  selftests: forwarding: router: Add test case for source IP in class E
  mlxsw: spectrum: Disable MC_DMAC check in hardware pipeline
  selftests: forwarding: router: Add test case for multicast destination
    MAC mismatch
  mlxsw: spectrum: Disable SIP_DIP check in hardware pipeline
  selftests: forwarding: router: Add test case for source IP equals
    destination IP
  mlxsw: spectrum: Disable DIP_LINK_LOCAL check in hardware pipeline
  selftests: forwarding: router: Add test case for destination IP
    link-local

 .../net/ethernet/mellanox/mlxsw/spectrum.c    |   8 +
 drivers/net/ethernet/mellanox/mlxsw/trap.h    |   4 +
 .../selftests/net/forwarding/router.sh        | 189 +++++++++++++++++-
 3 files changed, 200 insertions(+), 1 deletion(-)

-- 
2.24.1


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

* [PATCH net-next 1/8] mlxsw: spectrum: Disable SIP_CLASS_E check in hardware pipeline
  2020-01-05 16:20 [PATCH net-next 0/8] mlxsw: Disable checks in hardware pipeline Ido Schimmel
@ 2020-01-05 16:20 ` Ido Schimmel
  2020-01-05 16:20 ` [PATCH net-next 2/8] selftests: forwarding: router: Add test case for source IP in class E Ido Schimmel
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Ido Schimmel @ 2020-01-05 16:20 UTC (permalink / raw)
  To: netdev; +Cc: davem, jiri, amitc, mlxsw, Ido Schimmel

From: Amit Cohen <amitc@mellanox.com>

The check drops packets if they need to be routed and their source IP is
from class E, i.e., belongs to 240.0.0.0/4 address range, but different
from 255.255.255.255.

Disable the check since the kernel forwards such packets and does not
drop them.

Signed-off-by: Amit Cohen <amitc@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 2 ++
 drivers/net/ethernet/mellanox/mlxsw/trap.h     | 1 +
 2 files changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 1a509bb8d269..78162dcf2337 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -4545,6 +4545,8 @@ static const struct mlxsw_listener mlxsw_sp_listener[] = {
 	MLXSW_SP_RXL_MARK(DECAP_ECN0, TRAP_TO_CPU, ROUTER_EXP, false),
 	MLXSW_SP_RXL_MARK(IPV4_VRRP, TRAP_TO_CPU, VRRP, false),
 	MLXSW_SP_RXL_MARK(IPV6_VRRP, TRAP_TO_CPU, VRRP, false),
+	MLXSW_SP_RXL_NO_MARK(DISCARD_ING_ROUTER_SIP_CLASS_E, FORWARD,
+			     ROUTER_EXP, false),
 	/* PKT Sample trap */
 	MLXSW_RXL(mlxsw_sp_rx_listener_sample_func, PKT_SAMPLE, MIRROR_TO_CPU,
 		  false, SP_IP2ME, DISCARD),
diff --git a/drivers/net/ethernet/mellanox/mlxsw/trap.h b/drivers/net/ethernet/mellanox/mlxsw/trap.h
index 0c1c142bb6b0..e63cb82050c6 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/trap.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/trap.h
@@ -80,6 +80,7 @@ enum {
 	MLXSW_TRAP_ID_DISCARD_ING_ROUTER_UC_DIP_MC_DMAC = 0x161,
 	MLXSW_TRAP_ID_DISCARD_ING_ROUTER_DIP_LB = 0x162,
 	MLXSW_TRAP_ID_DISCARD_ING_ROUTER_SIP_MC = 0x163,
+	MLXSW_TRAP_ID_DISCARD_ING_ROUTER_SIP_CLASS_E = 0x164,
 	MLXSW_TRAP_ID_DISCARD_ING_ROUTER_SIP_LB = 0x165,
 	MLXSW_TRAP_ID_DISCARD_ING_ROUTER_CORRUPTED_IP_HDR = 0x167,
 	MLXSW_TRAP_ID_DISCARD_ING_ROUTER_IPV4_SIP_BC = 0x16A,
-- 
2.24.1


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

* [PATCH net-next 2/8] selftests: forwarding: router: Add test case for source IP in class E
  2020-01-05 16:20 [PATCH net-next 0/8] mlxsw: Disable checks in hardware pipeline Ido Schimmel
  2020-01-05 16:20 ` [PATCH net-next 1/8] mlxsw: spectrum: Disable SIP_CLASS_E check " Ido Schimmel
@ 2020-01-05 16:20 ` Ido Schimmel
  2020-01-05 16:20 ` [PATCH net-next 3/8] mlxsw: spectrum: Disable MC_DMAC check in hardware pipeline Ido Schimmel
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Ido Schimmel @ 2020-01-05 16:20 UTC (permalink / raw)
  To: netdev; +Cc: davem, jiri, amitc, mlxsw, Ido Schimmel

From: Amit Cohen <amitc@mellanox.com>

Add test case to check that packets are not dropped when they need to be
routed and their source IP in class E, (i.e., 240.0.0.0 –
255.255.255.254).

Signed-off-by: Amit Cohen <amitc@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 .../selftests/net/forwarding/router.sh        | 38 ++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/forwarding/router.sh b/tools/testing/selftests/net/forwarding/router.sh
index a75cb51cc5bd..6ad652ad7e73 100755
--- a/tools/testing/selftests/net/forwarding/router.sh
+++ b/tools/testing/selftests/net/forwarding/router.sh
@@ -1,9 +1,15 @@
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
 
-ALL_TESTS="ping_ipv4 ping_ipv6"
+ALL_TESTS="
+	ping_ipv4
+	ping_ipv6
+	sip_in_class_e
+"
+
 NUM_NETIFS=4
 source lib.sh
+source tc_common.sh
 
 h1_create()
 {
@@ -64,6 +70,8 @@ router_create()
 	ip link set dev $rp1 up
 	ip link set dev $rp2 up
 
+	tc qdisc add dev $rp2 clsact
+
 	ip address add 192.0.2.1/24 dev $rp1
 	ip address add 2001:db8:1::1/64 dev $rp1
 
@@ -79,6 +87,8 @@ router_destroy()
 	ip address del 2001:db8:1::1/64 dev $rp1
 	ip address del 192.0.2.1/24 dev $rp1
 
+	tc qdisc del dev $rp2 clsact
+
 	ip link set dev $rp2 down
 	ip link set dev $rp1 down
 }
@@ -91,6 +101,8 @@ setup_prepare()
 	rp2=${NETIFS[p3]}
 	h2=${NETIFS[p4]}
 
+	rp1mac=$(mac_get $rp1)
+
 	vrf_prepare
 
 	h1_create
@@ -125,6 +137,30 @@ ping_ipv6()
 	ping6_test $h1 2001:db8:2::2
 }
 
+sip_in_class_e()
+{
+	RET=0
+
+	# Disable rpfilter to prevent packets to be dropped because of it.
+	sysctl_set net.ipv4.conf.all.rp_filter 0
+	sysctl_set net.ipv4.conf.$rp1.rp_filter 0
+
+	tc filter add dev $rp2 egress protocol ip pref 1 handle 101 \
+		flower src_ip 240.0.0.1 ip_proto udp action pass
+
+	$MZ $h1 -t udp "sp=54321,dp=12345" -c 5 -d 1msec \
+		-A 240.0.0.1 -b $rp1mac -B 198.51.100.2 -q
+
+	tc_check_packets "dev $rp2 egress" 101 5
+	check_err $? "Packets were dropped"
+
+	log_test "Source IP in class E"
+
+	tc filter del dev $rp2 egress protocol ip pref 1 handle 101 flower
+	sysctl_restore net.ipv4.conf.$rp1.rp_filter
+	sysctl_restore net.ipv4.conf.all.rp_filter
+}
+
 trap cleanup EXIT
 
 setup_prepare
-- 
2.24.1


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

* [PATCH net-next 3/8] mlxsw: spectrum: Disable MC_DMAC check in hardware pipeline
  2020-01-05 16:20 [PATCH net-next 0/8] mlxsw: Disable checks in hardware pipeline Ido Schimmel
  2020-01-05 16:20 ` [PATCH net-next 1/8] mlxsw: spectrum: Disable SIP_CLASS_E check " Ido Schimmel
  2020-01-05 16:20 ` [PATCH net-next 2/8] selftests: forwarding: router: Add test case for source IP in class E Ido Schimmel
@ 2020-01-05 16:20 ` Ido Schimmel
  2020-01-05 16:20 ` [PATCH net-next 4/8] selftests: forwarding: router: Add test case for multicast destination MAC mismatch Ido Schimmel
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Ido Schimmel @ 2020-01-05 16:20 UTC (permalink / raw)
  To: netdev; +Cc: davem, jiri, amitc, mlxsw, Ido Schimmel

From: Amit Cohen <amitc@mellanox.com>

The check drops packets if they need to be routed and their multicast
MAC mismatched to their multicast destination IP.

For IPV4:
DMAC is mismatched if it is different from {01-00-5E-0 (25 bits),
DIP[22:0]}

For IPV6:
DMAC is mismatched if it is different from {33-33-0 (16 bits),
DIP[31:0]}

Disable the check since the kernel forwards such packets and does not
drop them.

Signed-off-by: Amit Cohen <amitc@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 2 ++
 drivers/net/ethernet/mellanox/mlxsw/trap.h     | 1 +
 2 files changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 78162dcf2337..2134bc7661c1 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -4547,6 +4547,8 @@ static const struct mlxsw_listener mlxsw_sp_listener[] = {
 	MLXSW_SP_RXL_MARK(IPV6_VRRP, TRAP_TO_CPU, VRRP, false),
 	MLXSW_SP_RXL_NO_MARK(DISCARD_ING_ROUTER_SIP_CLASS_E, FORWARD,
 			     ROUTER_EXP, false),
+	MLXSW_SP_RXL_NO_MARK(DISCARD_ING_ROUTER_MC_DMAC, FORWARD,
+			     ROUTER_EXP, false),
 	/* PKT Sample trap */
 	MLXSW_RXL(mlxsw_sp_rx_listener_sample_func, PKT_SAMPLE, MIRROR_TO_CPU,
 		  false, SP_IP2ME, DISCARD),
diff --git a/drivers/net/ethernet/mellanox/mlxsw/trap.h b/drivers/net/ethernet/mellanox/mlxsw/trap.h
index e63cb82050c6..7ccec9e28cdd 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/trap.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/trap.h
@@ -83,6 +83,7 @@ enum {
 	MLXSW_TRAP_ID_DISCARD_ING_ROUTER_SIP_CLASS_E = 0x164,
 	MLXSW_TRAP_ID_DISCARD_ING_ROUTER_SIP_LB = 0x165,
 	MLXSW_TRAP_ID_DISCARD_ING_ROUTER_CORRUPTED_IP_HDR = 0x167,
+	MLXSW_TRAP_ID_DISCARD_ING_ROUTER_MC_DMAC = 0x168,
 	MLXSW_TRAP_ID_DISCARD_ING_ROUTER_IPV4_SIP_BC = 0x16A,
 	MLXSW_TRAP_ID_DISCARD_ING_ROUTER_IPV4_DIP_LOCAL_NET = 0x16B,
 	MLXSW_TRAP_ID_DISCARD_ROUTER_LPM4 = 0x17B,
-- 
2.24.1


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

* [PATCH net-next 4/8] selftests: forwarding: router: Add test case for multicast destination MAC mismatch
  2020-01-05 16:20 [PATCH net-next 0/8] mlxsw: Disable checks in hardware pipeline Ido Schimmel
                   ` (2 preceding siblings ...)
  2020-01-05 16:20 ` [PATCH net-next 3/8] mlxsw: spectrum: Disable MC_DMAC check in hardware pipeline Ido Schimmel
@ 2020-01-05 16:20 ` Ido Schimmel
  2020-01-05 16:20 ` [PATCH net-next 5/8] mlxsw: spectrum: Disable SIP_DIP check in hardware pipeline Ido Schimmel
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Ido Schimmel @ 2020-01-05 16:20 UTC (permalink / raw)
  To: netdev; +Cc: davem, jiri, amitc, mlxsw, Ido Schimmel

From: Amit Cohen <amitc@mellanox.com>

Add test case to check that packets are not dropped when they need to be
routed and their multicast MAC mismatched to their multicast destination
IP.

i.e., destination IP is multicast and
	* for IPV4: DMAC !=  {01-00-5E-0 (25 bits), DIP[22:0]}
	* for IPV6: DMAC !=  {33-33-0 (16 bits), DIP[31:0]}

Signed-off-by: Amit Cohen <amitc@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 .../selftests/net/forwarding/router.sh        | 82 +++++++++++++++++++
 1 file changed, 82 insertions(+)

diff --git a/tools/testing/selftests/net/forwarding/router.sh b/tools/testing/selftests/net/forwarding/router.sh
index 6ad652ad7e73..e1f4d6145326 100755
--- a/tools/testing/selftests/net/forwarding/router.sh
+++ b/tools/testing/selftests/net/forwarding/router.sh
@@ -5,12 +5,17 @@ ALL_TESTS="
 	ping_ipv4
 	ping_ipv6
 	sip_in_class_e
+	mc_mac_mismatch
 "
 
 NUM_NETIFS=4
 source lib.sh
 source tc_common.sh
 
+require_command $MCD
+require_command $MC_CLI
+table_name=selftests
+
 h1_create()
 {
 	vrf_create "vrf-h1"
@@ -93,6 +98,25 @@ router_destroy()
 	ip link set dev $rp1 down
 }
 
+start_mcd()
+{
+	SMCROUTEDIR="$(mktemp -d)"
+
+	for ((i = 1; i <= $NUM_NETIFS; ++i)); do
+		echo "phyint ${NETIFS[p$i]} enable" >> \
+			$SMCROUTEDIR/$table_name.conf
+	done
+
+	$MCD -N -I $table_name -f $SMCROUTEDIR/$table_name.conf \
+		-P $SMCROUTEDIR/$table_name.pid
+}
+
+kill_mcd()
+{
+	pkill $MCD
+	rm -rf $SMCROUTEDIR
+}
+
 setup_prepare()
 {
 	h1=${NETIFS[p1]}
@@ -103,6 +127,8 @@ setup_prepare()
 
 	rp1mac=$(mac_get $rp1)
 
+	start_mcd
+
 	vrf_prepare
 
 	h1_create
@@ -125,6 +151,8 @@ cleanup()
 	h1_destroy
 
 	vrf_cleanup
+
+	kill_mcd
 }
 
 ping_ipv4()
@@ -161,6 +189,60 @@ sip_in_class_e()
 	sysctl_restore net.ipv4.conf.all.rp_filter
 }
 
+create_mcast_sg()
+{
+	local if_name=$1; shift
+	local s_addr=$1; shift
+	local mcast=$1; shift
+	local dest_ifs=${@}
+
+	$MC_CLI -I $table_name add $if_name $s_addr $mcast $dest_ifs
+}
+
+delete_mcast_sg()
+{
+	local if_name=$1; shift
+	local s_addr=$1; shift
+	local mcast=$1; shift
+	local dest_ifs=${@}
+
+	$MC_CLI -I $table_name remove $if_name $s_addr $mcast $dest_ifs
+}
+
+__mc_mac_mismatch()
+{
+	local desc=$1; shift
+	local proto=$1; shift
+	local sip=$1; shift
+	local dip=$1; shift
+	local flags=${1:-""}; shift
+	local dmac=01:02:03:04:05:06
+
+	RET=0
+
+	tc filter add dev $rp2 egress protocol $proto pref 1 handle 101 \
+		flower dst_ip $dip action pass
+
+	create_mcast_sg $rp1 $sip $dip $rp2
+
+	$MZ $flags $h1 -t udp "sp=54321,dp=12345" -c 5 -d 1msec -b $dmac \
+		-B $dip -q
+
+	tc_check_packets "dev $rp2 egress" 101 5
+	check_err $? "Packets were dropped"
+
+	log_test "Multicast MAC mismatch: $desc"
+
+	delete_mcast_sg $rp1 $sip $dip $rp2
+	tc filter del dev $rp2 egress protocol $proto pref 1 handle 101 flower
+}
+
+mc_mac_mismatch()
+{
+	__mc_mac_mismatch "IPv4" "ip" 192.0.2.2 225.1.2.3
+	__mc_mac_mismatch "IPv6" "ipv6" 2001:db8:1::2 ff0e::3 "-6"
+}
+
 trap cleanup EXIT
 
 setup_prepare
-- 
2.24.1


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

* [PATCH net-next 5/8] mlxsw: spectrum: Disable SIP_DIP check in hardware pipeline
  2020-01-05 16:20 [PATCH net-next 0/8] mlxsw: Disable checks in hardware pipeline Ido Schimmel
                   ` (3 preceding siblings ...)
  2020-01-05 16:20 ` [PATCH net-next 4/8] selftests: forwarding: router: Add test case for multicast destination MAC mismatch Ido Schimmel
@ 2020-01-05 16:20 ` Ido Schimmel
  2020-01-05 16:20 ` [PATCH net-next 6/8] selftests: forwarding: router: Add test case for source IP equals destination IP Ido Schimmel
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Ido Schimmel @ 2020-01-05 16:20 UTC (permalink / raw)
  To: netdev; +Cc: davem, jiri, amitc, mlxsw, Ido Schimmel

From: Amit Cohen <amitc@mellanox.com>

The check drops packets if they need to be routed and their source IP
equals to their destination IP.

Disable the check since the kernel forwards such packets and does not
drop them.

Signed-off-by: Amit Cohen <amitc@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 2 ++
 drivers/net/ethernet/mellanox/mlxsw/trap.h     | 1 +
 2 files changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 2134bc7661c1..74a08eb45ec8 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -4549,6 +4549,8 @@ static const struct mlxsw_listener mlxsw_sp_listener[] = {
 			     ROUTER_EXP, false),
 	MLXSW_SP_RXL_NO_MARK(DISCARD_ING_ROUTER_MC_DMAC, FORWARD,
 			     ROUTER_EXP, false),
+	MLXSW_SP_RXL_NO_MARK(DISCARD_ING_ROUTER_SIP_DIP, FORWARD,
+			     ROUTER_EXP, false),
 	/* PKT Sample trap */
 	MLXSW_RXL(mlxsw_sp_rx_listener_sample_func, PKT_SAMPLE, MIRROR_TO_CPU,
 		  false, SP_IP2ME, DISCARD),
diff --git a/drivers/net/ethernet/mellanox/mlxsw/trap.h b/drivers/net/ethernet/mellanox/mlxsw/trap.h
index 7ccec9e28cdd..02c68820eae5 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/trap.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/trap.h
@@ -84,6 +84,7 @@ enum {
 	MLXSW_TRAP_ID_DISCARD_ING_ROUTER_SIP_LB = 0x165,
 	MLXSW_TRAP_ID_DISCARD_ING_ROUTER_CORRUPTED_IP_HDR = 0x167,
 	MLXSW_TRAP_ID_DISCARD_ING_ROUTER_MC_DMAC = 0x168,
+	MLXSW_TRAP_ID_DISCARD_ING_ROUTER_SIP_DIP = 0x169,
 	MLXSW_TRAP_ID_DISCARD_ING_ROUTER_IPV4_SIP_BC = 0x16A,
 	MLXSW_TRAP_ID_DISCARD_ING_ROUTER_IPV4_DIP_LOCAL_NET = 0x16B,
 	MLXSW_TRAP_ID_DISCARD_ROUTER_LPM4 = 0x17B,
-- 
2.24.1


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

* [PATCH net-next 6/8] selftests: forwarding: router: Add test case for source IP equals destination IP
  2020-01-05 16:20 [PATCH net-next 0/8] mlxsw: Disable checks in hardware pipeline Ido Schimmel
                   ` (4 preceding siblings ...)
  2020-01-05 16:20 ` [PATCH net-next 5/8] mlxsw: spectrum: Disable SIP_DIP check in hardware pipeline Ido Schimmel
@ 2020-01-05 16:20 ` Ido Schimmel
  2020-01-05 16:20 ` [PATCH net-next 7/8] mlxsw: spectrum: Disable DIP_LINK_LOCAL check in hardware pipeline Ido Schimmel
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Ido Schimmel @ 2020-01-05 16:20 UTC (permalink / raw)
  To: netdev; +Cc: davem, jiri, amitc, mlxsw, Ido Schimmel

From: Amit Cohen <amitc@mellanox.com>

Add test case to check that packets are not dropped when they need to be
routed and their source IP equals to their destination IP.

Signed-off-by: Amit Cohen <amitc@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 .../selftests/net/forwarding/router.sh        | 44 +++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/tools/testing/selftests/net/forwarding/router.sh b/tools/testing/selftests/net/forwarding/router.sh
index e1f4d6145326..c894f7240417 100755
--- a/tools/testing/selftests/net/forwarding/router.sh
+++ b/tools/testing/selftests/net/forwarding/router.sh
@@ -6,6 +6,8 @@ ALL_TESTS="
 	ping_ipv6
 	sip_in_class_e
 	mc_mac_mismatch
+	ipv4_sip_equal_dip
+	ipv6_sip_equal_dip
 "
 
 NUM_NETIFS=4
@@ -243,6 +245,48 @@ mc_mac_mismatch()
 	__mc_mac_mismatch "IPv6" "ipv6" 2001:db8:1::2 ff0e::3 "-6"
 }
 
+ipv4_sip_equal_dip()
+{
+	RET=0
+
+	# Disable rpfilter to prevent packets to be dropped because of it.
+	sysctl_set net.ipv4.conf.all.rp_filter 0
+	sysctl_set net.ipv4.conf.$rp1.rp_filter 0
+
+	tc filter add dev $rp2 egress protocol ip pref 1 handle 101 \
+		flower src_ip 198.51.100.2  action pass
+
+	$MZ $h1 -t udp "sp=54321,dp=12345" -c 5 -d 1msec \
+		-A 198.51.100.2 -b $rp1mac -B 198.51.100.2 -q
+
+	tc_check_packets "dev $rp2 egress" 101 5
+	check_err $? "Packets were dropped"
+
+	log_test "Source IP is equal to destination IP: IPv4"
+
+	tc filter del dev $rp2 egress protocol ip pref 1 handle 101 flower
+	sysctl_restore net.ipv4.conf.$rp1.rp_filter
+	sysctl_restore net.ipv4.conf.all.rp_filter
+}
+
+ipv6_sip_equal_dip()
+{
+	RET=0
+
+	tc filter add dev $rp2 egress protocol ipv6 pref 1 handle 101 \
+		flower src_ip 2001:db8:2::2 action pass
+
+	$MZ -6 $h1 -t udp "sp=54321,dp=12345" -c 5 -d 1msec \
+		-A 2001:db8:2::2 -b $rp1mac -B 2001:db8:2::2 -q
+
+	tc_check_packets "dev $rp2 egress" 101 5
+	check_err $? "Packets were dropped"
+
+	log_test "Source IP is equal to destination IP: IPv6"
+
+	tc filter del dev $rp2 egress protocol ipv6 pref 1 handle 101 flower
+}
+
 trap cleanup EXIT
 
 setup_prepare
-- 
2.24.1


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

* [PATCH net-next 7/8] mlxsw: spectrum: Disable DIP_LINK_LOCAL check in hardware pipeline
  2020-01-05 16:20 [PATCH net-next 0/8] mlxsw: Disable checks in hardware pipeline Ido Schimmel
                   ` (5 preceding siblings ...)
  2020-01-05 16:20 ` [PATCH net-next 6/8] selftests: forwarding: router: Add test case for source IP equals destination IP Ido Schimmel
@ 2020-01-05 16:20 ` Ido Schimmel
  2020-01-05 16:20 ` [PATCH net-next 8/8] selftests: forwarding: router: Add test case for destination IP link-local Ido Schimmel
  2020-01-06 21:38 ` [PATCH net-next 0/8] mlxsw: Disable checks in hardware pipeline David Miller
  8 siblings, 0 replies; 10+ messages in thread
From: Ido Schimmel @ 2020-01-05 16:20 UTC (permalink / raw)
  To: netdev; +Cc: davem, jiri, amitc, mlxsw, Ido Schimmel

From: Amit Cohen <amitc@mellanox.com>

The check drops packets if they need to be routed and their destination
IP is link-local, i.e., belongs to 169.254.0.0/16 address range.

Disable the check since the kernel forwards such packets and does not
drop them.

Signed-off-by: Amit Cohen <amitc@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 2 ++
 drivers/net/ethernet/mellanox/mlxsw/trap.h     | 1 +
 2 files changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 74a08eb45ec8..845201c344ed 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -4551,6 +4551,8 @@ static const struct mlxsw_listener mlxsw_sp_listener[] = {
 			     ROUTER_EXP, false),
 	MLXSW_SP_RXL_NO_MARK(DISCARD_ING_ROUTER_SIP_DIP, FORWARD,
 			     ROUTER_EXP, false),
+	MLXSW_SP_RXL_NO_MARK(DISCARD_ING_ROUTER_DIP_LINK_LOCAL, FORWARD,
+			     ROUTER_EXP, false),
 	/* PKT Sample trap */
 	MLXSW_RXL(mlxsw_sp_rx_listener_sample_func, PKT_SAMPLE, MIRROR_TO_CPU,
 		  false, SP_IP2ME, DISCARD),
diff --git a/drivers/net/ethernet/mellanox/mlxsw/trap.h b/drivers/net/ethernet/mellanox/mlxsw/trap.h
index 02c68820eae5..3d2331be05d8 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/trap.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/trap.h
@@ -87,6 +87,7 @@ enum {
 	MLXSW_TRAP_ID_DISCARD_ING_ROUTER_SIP_DIP = 0x169,
 	MLXSW_TRAP_ID_DISCARD_ING_ROUTER_IPV4_SIP_BC = 0x16A,
 	MLXSW_TRAP_ID_DISCARD_ING_ROUTER_IPV4_DIP_LOCAL_NET = 0x16B,
+	MLXSW_TRAP_ID_DISCARD_ING_ROUTER_DIP_LINK_LOCAL = 0x16C,
 	MLXSW_TRAP_ID_DISCARD_ROUTER_LPM4 = 0x17B,
 	MLXSW_TRAP_ID_DISCARD_ROUTER_LPM6 = 0x17C,
 	MLXSW_TRAP_ID_DISCARD_IPV6_MC_DIP_RESERVED_SCOPE = 0x1B0,
-- 
2.24.1


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

* [PATCH net-next 8/8] selftests: forwarding: router: Add test case for destination IP link-local
  2020-01-05 16:20 [PATCH net-next 0/8] mlxsw: Disable checks in hardware pipeline Ido Schimmel
                   ` (6 preceding siblings ...)
  2020-01-05 16:20 ` [PATCH net-next 7/8] mlxsw: spectrum: Disable DIP_LINK_LOCAL check in hardware pipeline Ido Schimmel
@ 2020-01-05 16:20 ` Ido Schimmel
  2020-01-06 21:38 ` [PATCH net-next 0/8] mlxsw: Disable checks in hardware pipeline David Miller
  8 siblings, 0 replies; 10+ messages in thread
From: Ido Schimmel @ 2020-01-05 16:20 UTC (permalink / raw)
  To: netdev; +Cc: davem, jiri, amitc, mlxsw, Ido Schimmel

From: Amit Cohen <amitc@mellanox.com>

Add test case to check that packets are not dropped when they need to be
routed and their destination is link-local, i.e., 169.254.0.0/16.

Signed-off-by: Amit Cohen <amitc@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 .../selftests/net/forwarding/router.sh        | 25 +++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/tools/testing/selftests/net/forwarding/router.sh b/tools/testing/selftests/net/forwarding/router.sh
index c894f7240417..057f91b05098 100755
--- a/tools/testing/selftests/net/forwarding/router.sh
+++ b/tools/testing/selftests/net/forwarding/router.sh
@@ -8,6 +8,7 @@ ALL_TESTS="
 	mc_mac_mismatch
 	ipv4_sip_equal_dip
 	ipv6_sip_equal_dip
+	ipv4_dip_link_local
 "
 
 NUM_NETIFS=4
@@ -287,6 +288,30 @@ ipv6_sip_equal_dip()
 	tc filter del dev $rp2 egress protocol ipv6 pref 1 handle 101 flower
 }
 
+ipv4_dip_link_local()
+{
+	local dip=169.254.1.1
+
+	RET=0
+
+	tc filter add dev $rp2 egress protocol ip pref 1 handle 101 \
+		flower dst_ip $dip action pass
+
+	ip neigh add 169.254.1.1 lladdr 00:11:22:33:44:55 dev $rp2
+	ip route add 169.254.1.0/24 dev $rp2
+
+	$MZ $h1 -t udp "sp=54321,dp=12345" -c 5 -d 1msec -b $rp1mac -B $dip -q
+
+	tc_check_packets "dev $rp2 egress" 101 5
+	check_err $? "Packets were dropped"
+
+	log_test "IPv4 destination IP is link-local"
+
+	ip route del 169.254.1.0/24 dev $rp2
+	ip neigh del 169.254.1.1 lladdr 00:11:22:33:44:55 dev $rp2
+	tc filter del dev $rp2 egress protocol ip pref 1 handle 101 flower
+}
+
 trap cleanup EXIT
 
 setup_prepare
-- 
2.24.1


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

* Re: [PATCH net-next 0/8] mlxsw: Disable checks in hardware pipeline
  2020-01-05 16:20 [PATCH net-next 0/8] mlxsw: Disable checks in hardware pipeline Ido Schimmel
                   ` (7 preceding siblings ...)
  2020-01-05 16:20 ` [PATCH net-next 8/8] selftests: forwarding: router: Add test case for destination IP link-local Ido Schimmel
@ 2020-01-06 21:38 ` David Miller
  8 siblings, 0 replies; 10+ messages in thread
From: David Miller @ 2020-01-06 21:38 UTC (permalink / raw)
  To: idosch; +Cc: netdev, jiri, amitc, mlxsw, idosch

From: Ido Schimmel <idosch@idosch.org>
Date: Sun,  5 Jan 2020 18:20:49 +0200

> From: Ido Schimmel <idosch@mellanox.com>
> 
> Amit says:
> 
> The hardware pipeline contains some checks that, by default, are
> configured to drop packets. Since the software data path does not drop
> packets due to these reasons and since we are interested in offloading
> the software data path to hardware, then these checks should be disabled
> in the hardware pipeline as well.
> 
> This patch set changes mlxsw to disable four of these checks and adds
> corresponding selftests. The tests pass both when the software data path
> is exercised (using veth pair) and when the hardware data path is
> exercised (using mlxsw ports in loopback).

Series applied, thanks.


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

end of thread, other threads:[~2020-01-06 21:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-05 16:20 [PATCH net-next 0/8] mlxsw: Disable checks in hardware pipeline Ido Schimmel
2020-01-05 16:20 ` [PATCH net-next 1/8] mlxsw: spectrum: Disable SIP_CLASS_E check " Ido Schimmel
2020-01-05 16:20 ` [PATCH net-next 2/8] selftests: forwarding: router: Add test case for source IP in class E Ido Schimmel
2020-01-05 16:20 ` [PATCH net-next 3/8] mlxsw: spectrum: Disable MC_DMAC check in hardware pipeline Ido Schimmel
2020-01-05 16:20 ` [PATCH net-next 4/8] selftests: forwarding: router: Add test case for multicast destination MAC mismatch Ido Schimmel
2020-01-05 16:20 ` [PATCH net-next 5/8] mlxsw: spectrum: Disable SIP_DIP check in hardware pipeline Ido Schimmel
2020-01-05 16:20 ` [PATCH net-next 6/8] selftests: forwarding: router: Add test case for source IP equals destination IP Ido Schimmel
2020-01-05 16:20 ` [PATCH net-next 7/8] mlxsw: spectrum: Disable DIP_LINK_LOCAL check in hardware pipeline Ido Schimmel
2020-01-05 16:20 ` [PATCH net-next 8/8] selftests: forwarding: router: Add test case for destination IP link-local Ido Schimmel
2020-01-06 21:38 ` [PATCH net-next 0/8] mlxsw: Disable checks in hardware pipeline David Miller

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.