Commit f233789d authored by David S. Miller's avatar David S. Miller

Merge branch 'mlxsw-Disable-checks-in-hardware-pipeline'

Ido Schimmel says:

====================
mlxsw: Disable checks in hardware pipeline

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).
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 02b0442c ef11ffa2
......@@ -4545,6 +4545,14 @@ 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),
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),
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),
......
......@@ -80,10 +80,14 @@ 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_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_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,
......
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
ALL_TESTS="ping_ipv4 ping_ipv6"
ALL_TESTS="
ping_ipv4
ping_ipv6
sip_in_class_e
mc_mac_mismatch
ipv4_sip_equal_dip
ipv6_sip_equal_dip
ipv4_dip_link_local
"
NUM_NETIFS=4
source lib.sh
source tc_common.sh
require_command $MCD
require_command $MC_CLI
table_name=selftests
h1_create()
{
......@@ -64,6 +78,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,10 +95,31 @@ 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
}
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]}
......@@ -91,6 +128,10 @@ setup_prepare()
rp2=${NETIFS[p3]}
h2=${NETIFS[p4]}
rp1mac=$(mac_get $rp1)
start_mcd
vrf_prepare
h1_create
......@@ -113,6 +154,8 @@ cleanup()
h1_destroy
vrf_cleanup
kill_mcd
}
ping_ipv4()
......@@ -125,6 +168,150 @@ 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
}
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"
}
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
}
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment