Skip to content

Commit d159b38

Browse files
jpirkodavem330
authored andcommitted
selftests: forwarding: add tests for TC chain templates
Add basic sanity tests for TC chain templates. Signed-off-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2d73c88 commit d159b38

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

tools/testing/selftests/net/forwarding/tc_chains.sh

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/bin/bash
22
# SPDX-License-Identifier: GPL-2.0
33

4-
ALL_TESTS="unreachable_chain_test gact_goto_chain_test create_destroy_chain"
4+
ALL_TESTS="unreachable_chain_test gact_goto_chain_test create_destroy_chain \
5+
template_filter_fits"
56
NUM_NETIFS=2
67
source tc_common.sh
78
source lib.sh
@@ -99,6 +100,47 @@ create_destroy_chain()
99100
log_test "create destroy chain"
100101
}
101102

103+
template_filter_fits()
104+
{
105+
RET=0
106+
107+
tc chain add dev $h2 ingress protocol ip \
108+
flower dst_mac 00:00:00:00:00:00/FF:FF:FF:FF:FF:FF &> /dev/null
109+
tc chain add dev $h2 ingress chain 1 protocol ip \
110+
flower src_mac 00:00:00:00:00:00/FF:FF:FF:FF:FF:FF &> /dev/null
111+
112+
tc filter add dev $h2 ingress protocol ip pref 1 handle 1101 \
113+
flower dst_mac $h2mac action drop
114+
check_err $? "Failed to insert filter which fits template"
115+
116+
tc filter add dev $h2 ingress protocol ip pref 1 handle 1102 \
117+
flower src_mac $h2mac action drop &> /dev/null
118+
check_fail $? "Incorrectly succeded to insert filter which does not template"
119+
120+
tc filter add dev $h2 ingress chain 1 protocol ip pref 1 handle 1101 \
121+
flower src_mac $h2mac action drop
122+
check_err $? "Failed to insert filter which fits template"
123+
124+
tc filter add dev $h2 ingress chain 1 protocol ip pref 1 handle 1102 \
125+
flower dst_mac $h2mac action drop &> /dev/null
126+
check_fail $? "Incorrectly succeded to insert filter which does not template"
127+
128+
tc filter del dev $h2 ingress chain 1 protocol ip pref 1 handle 1102 \
129+
flower &> /dev/null
130+
tc filter del dev $h2 ingress chain 1 protocol ip pref 1 handle 1101 \
131+
flower &> /dev/null
132+
133+
tc filter del dev $h2 ingress protocol ip pref 1 handle 1102 \
134+
flower &> /dev/null
135+
tc filter del dev $h2 ingress protocol ip pref 1 handle 1101 \
136+
flower &> /dev/null
137+
138+
tc chain del dev $h2 ingress chain 1
139+
tc chain del dev $h2 ingress
140+
141+
log_test "template filter fits"
142+
}
143+
102144
setup_prepare()
103145
{
104146
h1=${NETIFS[p1]}

0 commit comments

Comments
 (0)