WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / drivers / net / mlxsw / devlink_trap_acl_drops.sh
blobb32ba5fec59d4a2657e9080641bd0ee5ac53c152
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 # Test devlink-trap ACL drops functionality over mlxsw.
6 lib_dir=$(dirname $0)/../../../net/forwarding
8 ALL_TESTS="
9 ingress_flow_action_drop_test
10 egress_flow_action_drop_test
12 NUM_NETIFS=4
13 source $lib_dir/tc_common.sh
14 source $lib_dir/lib.sh
15 source $lib_dir/devlink_lib.sh
17 h1_create()
19 simple_if_init $h1
22 h1_destroy()
24 simple_if_fini $h1
27 h2_create()
29 simple_if_init $h2
32 h2_destroy()
34 simple_if_fini $h2
37 switch_create()
39 ip link add dev br0 type bridge vlan_filtering 1 mcast_snooping 0
41 ip link set dev $swp1 master br0
42 ip link set dev $swp2 master br0
44 ip link set dev br0 up
45 ip link set dev $swp1 up
46 ip link set dev $swp2 up
48 tc qdisc add dev $swp1 clsact
49 tc qdisc add dev $swp2 clsact
52 switch_destroy()
54 tc qdisc del dev $swp2 clsact
55 tc qdisc del dev $swp1 clsact
57 ip link set dev $swp2 down
58 ip link set dev $swp1 down
60 ip link del dev br0
63 setup_prepare()
65 h1=${NETIFS[p1]}
66 swp1=${NETIFS[p2]}
68 swp2=${NETIFS[p3]}
69 h2=${NETIFS[p4]}
71 h1mac=$(mac_get $h1)
72 h2mac=$(mac_get $h2)
74 vrf_prepare
76 h1_create
77 h2_create
79 switch_create
82 cleanup()
84 pre_cleanup
86 switch_destroy
88 h2_destroy
89 h1_destroy
91 vrf_cleanup
94 ingress_flow_action_drop_test()
96 local mz_pid
98 tc filter add dev $swp2 egress protocol ip pref 1 handle 101 \
99 flower src_mac $h1mac action pass
101 tc filter add dev $swp1 ingress protocol ip pref 1 handle 101 \
102 flower dst_ip 192.0.2.2 action drop
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=$!
108 RET=0
110 devlink_trap_drop_test ingress_flow_action_drop $swp2 101
112 log_test "ingress_flow_action_drop"
114 tc filter del dev $swp1 ingress protocol ip pref 1 handle 101 flower
116 devlink_trap_drop_cleanup $mz_pid $swp2 ip 1 101
119 egress_flow_action_drop_test()
121 local mz_pid
123 tc filter add dev $swp2 egress protocol ip pref 2 handle 102 \
124 flower src_mac $h1mac action pass
126 tc filter add dev $swp2 egress protocol ip pref 1 handle 101 \
127 flower dst_ip 192.0.2.2 action drop
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=$!
133 RET=0
135 devlink_trap_drop_test egress_flow_action_drop $swp2 102
137 log_test "egress_flow_action_drop"
139 tc filter del dev $swp2 egress protocol ip pref 1 handle 101 flower
141 devlink_trap_drop_cleanup $mz_pid $swp2 ip 2 102
144 trap cleanup EXIT
146 setup_prepare
147 setup_wait
149 tests_run
151 exit $EXIT_STATUS