brintos

brintos / linux-shallow public Read only

0
0
Text · 2.4 KiB · b32ba5f Raw
152 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.03#4# Test devlink-trap ACL drops functionality over mlxsw.5 6lib_dir=$(dirname $0)/../../../net/forwarding7 8ALL_TESTS="9	ingress_flow_action_drop_test10	egress_flow_action_drop_test11"12NUM_NETIFS=413source $lib_dir/tc_common.sh14source $lib_dir/lib.sh15source $lib_dir/devlink_lib.sh16 17h1_create()18{19	simple_if_init $h120}21 22h1_destroy()23{24	simple_if_fini $h125}26 27h2_create()28{29	simple_if_init $h230}31 32h2_destroy()33{34	simple_if_fini $h235}36 37switch_create()38{39	ip link add dev br0 type bridge vlan_filtering 1 mcast_snooping 040 41	ip link set dev $swp1 master br042	ip link set dev $swp2 master br043 44	ip link set dev br0 up45	ip link set dev $swp1 up46	ip link set dev $swp2 up47 48	tc qdisc add dev $swp1 clsact49	tc qdisc add dev $swp2 clsact50}51 52switch_destroy()53{54	tc qdisc del dev $swp2 clsact55	tc qdisc del dev $swp1 clsact56 57	ip link set dev $swp2 down58	ip link set dev $swp1 down59 60	ip link del dev br061}62 63setup_prepare()64{65	h1=${NETIFS[p1]}66	swp1=${NETIFS[p2]}67 68	swp2=${NETIFS[p3]}69	h2=${NETIFS[p4]}70 71	h1mac=$(mac_get $h1)72	h2mac=$(mac_get $h2)73 74	vrf_prepare75 76	h1_create77	h2_create78 79	switch_create80}81 82cleanup()83{84	pre_cleanup85 86	switch_destroy87 88	h2_destroy89	h1_destroy90 91	vrf_cleanup92}93 94ingress_flow_action_drop_test()95{96	local mz_pid97 98	tc filter add dev $swp2 egress protocol ip pref 1 handle 101 \99		flower src_mac $h1mac action pass100 101	tc filter add dev $swp1 ingress protocol ip pref 1 handle 101 \102		flower dst_ip 192.0.2.2 action drop103 104	$MZ $h1 -c 0 -p 100 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \105		-t ip -d 1msec -q &106	mz_pid=$!107 108	RET=0109 110	devlink_trap_drop_test ingress_flow_action_drop $swp2 101111 112	log_test "ingress_flow_action_drop"113 114	tc filter del dev $swp1 ingress protocol ip pref 1 handle 101 flower115 116	devlink_trap_drop_cleanup $mz_pid $swp2 ip 1 101117}118 119egress_flow_action_drop_test()120{121	local mz_pid122 123	tc filter add dev $swp2 egress protocol ip pref 2 handle 102 \124		flower src_mac $h1mac action pass125 126	tc filter add dev $swp2 egress protocol ip pref 1 handle 101 \127		flower dst_ip 192.0.2.2 action drop128 129	$MZ $h1 -c 0 -p 100 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \130		-t ip -d 1msec -q &131	mz_pid=$!132 133	RET=0134 135	devlink_trap_drop_test egress_flow_action_drop $swp2 102136 137	log_test "egress_flow_action_drop"138 139	tc filter del dev $swp2 egress protocol ip pref 1 handle 101 flower140 141	devlink_trap_drop_cleanup $mz_pid $swp2 ip 2 102142}143 144trap cleanup EXIT145 146setup_prepare147setup_wait148 149tests_run150 151exit $EXIT_STATUS152