summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAmit Cohen <amitc@mellanox.com>2020-01-05 18:20:53 +0200
committerDavid S. Miller <davem@davemloft.net>2020-01-06 13:38:36 -0800
commit59b3a4f3481e89c4936b4baffea9a26a6846b70c (patch)
tree22e46cd78c2a2542dc529556a3435f553d2ab447 /tools
parent359ec56679efde731c09b2f1f9c93f65dd8e29df (diff)
downloadlinux-59b3a4f3481e89c4936b4baffea9a26a6846b70c.tar.bz2
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: Amit Cohen <amitc@mellanox.com> Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/testing/selftests/net/forwarding/router.sh82
1 files changed, 82 insertions, 0 deletions
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