Commit 59b3a4f3 authored by Amit Cohen's avatar Amit Cohen Committed by David S. Miller

selftests: forwarding: router: Add test case for multicast destination MAC mismatch

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: default avatarAmit Cohen <amitc@mellanox.com>
Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 359ec566
......@@ -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
......
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