2 # SPDX-License-Identifier: GPL-2.0
4 ALL_TESTS
="match_cfm_opcode match_cfm_level match_cfm_level_and_opcode"
22 tc qdisc add dev
$h2 clsact
27 tc qdisc del dev
$h2 clsact
43 local tlv_offset
=$1; shift
46 )"$(u8_to_hex $((mdl << 5))):"$
( : MD level and Version
47 )"$(u8_to_hex $op):"$
( : OpCode
48 )"$(u8_to_hex $flags):"$
( : Flags
49 )"$(u8_to_hex $tlv_offset)"$
( : TLV offset
57 local ethtype
="89 02"; readonly ethtype
60 tc filter add dev
$h2 ingress protocol cfm pref
1 handle
101 \
61 flower cfm op
47 action drop
62 tc filter add dev
$h2 ingress protocol cfm pref
1 handle
102 \
63 flower cfm op
43 action drop
65 pkt
="$ethtype $(generate_cfm_hdr 7 47 0 32)"
66 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
67 pkt
="$ethtype $(generate_cfm_hdr 6 5 0 4)"
68 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
70 tc_check_packets
"dev $h2 ingress" 101 1
71 check_err $?
"Did not match on correct opcode"
73 tc_check_packets
"dev $h2 ingress" 102 0
74 check_err $?
"Matched on the wrong opcode"
76 pkt
="$ethtype $(generate_cfm_hdr 0 43 0 12)"
77 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
79 tc_check_packets
"dev $h2 ingress" 101 1
80 check_err $?
"Matched on the wrong opcode"
82 tc_check_packets
"dev $h2 ingress" 102 1
83 check_err $?
"Did not match on correct opcode"
85 tc filter del dev
$h2 ingress protocol cfm pref
1 handle
101 flower
86 tc filter del dev
$h2 ingress protocol cfm pref
1 handle
102 flower
88 log_test
"CFM opcode match test"
93 local ethtype
="89 02"; readonly ethtype
96 tc filter add dev
$h2 ingress protocol cfm pref
1 handle
101 \
97 flower cfm mdl
5 action drop
98 tc filter add dev
$h2 ingress protocol cfm pref
1 handle
102 \
99 flower cfm mdl
3 action drop
100 tc filter add dev
$h2 ingress protocol cfm pref
1 handle
103 \
101 flower cfm mdl
0 action drop
103 pkt
="$ethtype $(generate_cfm_hdr 5 42 0 12)"
104 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
105 pkt
="$ethtype $(generate_cfm_hdr 6 1 0 70)"
106 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
107 pkt
="$ethtype $(generate_cfm_hdr 0 1 0 70)"
108 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
110 tc_check_packets
"dev $h2 ingress" 101 1
111 check_err $?
"Did not match on correct level"
113 tc_check_packets
"dev $h2 ingress" 102 0
114 check_err $?
"Matched on the wrong level"
116 tc_check_packets
"dev $h2 ingress" 103 1
117 check_err $?
"Did not match on correct level"
119 pkt
="$ethtype $(generate_cfm_hdr 3 0 0 4)"
120 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
122 tc_check_packets
"dev $h2 ingress" 101 1
123 check_err $?
"Matched on the wrong level"
125 tc_check_packets
"dev $h2 ingress" 102 1
126 check_err $?
"Did not match on correct level"
128 tc_check_packets
"dev $h2 ingress" 103 1
129 check_err $?
"Matched on the wrong level"
131 tc filter del dev
$h2 ingress protocol cfm pref
1 handle
101 flower
132 tc filter del dev
$h2 ingress protocol cfm pref
1 handle
102 flower
133 tc filter del dev
$h2 ingress protocol cfm pref
1 handle
103 flower
135 log_test
"CFM level match test"
138 match_cfm_level_and_opcode
()
140 local ethtype
="89 02"; readonly ethtype
143 tc filter add dev
$h2 ingress protocol cfm pref
1 handle
101 \
144 flower cfm mdl
5 op
41 action drop
145 tc filter add dev
$h2 ingress protocol cfm pref
1 handle
102 \
146 flower cfm mdl
7 op
42 action drop
148 pkt
="$ethtype $(generate_cfm_hdr 5 41 0 4)"
149 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
150 pkt
="$ethtype $(generate_cfm_hdr 7 3 0 4)"
151 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
152 pkt
="$ethtype $(generate_cfm_hdr 3 42 0 12)"
153 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
155 tc_check_packets
"dev $h2 ingress" 101 1
156 check_err $?
"Did not match on correct level and opcode"
158 tc_check_packets
"dev $h2 ingress" 102 0
159 check_err $?
"Matched on the wrong level and opcode"
161 pkt
="$ethtype $(generate_cfm_hdr 7 42 0 12)"
162 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
164 tc_check_packets
"dev $h2 ingress" 101 1
165 check_err $?
"Matched on the wrong level and opcode"
167 tc_check_packets
"dev $h2 ingress" 102 1
168 check_err $?
"Did not match on correct level and opcode"
170 tc filter del dev
$h2 ingress protocol cfm pref
1 handle
101 flower
171 tc filter del dev
$h2 ingress protocol cfm pref
1 handle
102 flower
173 log_test
"CFM opcode and level match test"