2 # SPDX-License-Identifier: GPL-2.0
3 # Kselftest framework requirement - SKIP code is 4.
6 ALL_TESTS="tunnel_key_nofrag_test"
16 simple_if_init $h1 192.0.2.1/24
19 tunnel_create h1-et vxlan 192.0.2.1 192.0.2.2 dev $h1 dstport 0 external
20 tc qdisc add dev h1-et clsact
28 tc qdisc del dev h1-et clsact
32 simple_if_fini $h1 192.0.2.1/24
37 simple_if_init $h2 192.0.2.2/24
42 simple_if_fini $h2 192.0.2.2/24
47 simple_if_init $swp1 192.0.2.2/24
48 tc qdisc add dev $swp1 clsact
49 simple_if_init $swp2 192.0.2.1/24
54 simple_if_fini $swp2 192.0.2.1/24
55 tc qdisc del dev $swp1 clsact
56 simple_if_fini $swp1 192.0.2.2/24
70 swp1origmac=$(mac_get $swp1)
71 swp2origmac=$(mac_get $swp2)
72 ip link set $swp1 address $h2mac
73 ip link set $swp2 address $h1mac
81 if ! tc action add action tunnel_key help 2>&1 | grep -q nofrag; then
82 log_test "SKIP: iproute doesn't support nofrag"
97 ip link set $swp2 address $swp2origmac
98 ip link set $swp1 address $swp1origmac
101 tunnel_key_nofrag_test()
106 tc filter add dev $swp1 ingress protocol ip pref 100 handle 100 \
107 flower ip_flags nofrag action drop
108 tc filter add dev $swp1 ingress protocol ip pref 101 handle 101 \
109 flower ip_flags firstfrag action drop
110 tc filter add dev $swp1 ingress protocol ip pref 102 handle 102 \
111 flower ip_flags nofirstfrag action drop
114 tc filter add dev h1-et egress protocol all pref 1 handle 1 matchall $tcflags \
115 action tunnel_key set src_ip 192.0.2.1 dst_ip 192.0.2.2 id 42 nofrag index 10
116 $MZ h1-et -c 1 -p 930 -a 00:aa:bb:cc:dd:ee -b 00:ee:dd:cc:bb:aa -t ip -q
117 tc_check_packets "dev $swp1 ingress" 100 1
118 check_err $? "packet smaller than MTU was not tunneled"
120 $MZ h1-et -c 1 -p 931 -a 00:aa:bb:cc:dd:ee -b 00:ee:dd:cc:bb:aa -t ip -q
121 tc_check_packets "dev $swp1 ingress" 100 1
122 check_err $? "packet bigger than MTU matched nofrag (nofrag was set)"
123 tc_check_packets "dev $swp1 ingress" 101 0
124 check_err $? "packet bigger than MTU matched firstfrag (nofrag was set)"
125 tc_check_packets "dev $swp1 ingress" 102 0
126 check_err $? "packet bigger than MTU matched nofirstfrag (nofrag was set)"
128 # test 'nofrag' cleared
129 tc actions change action tunnel_key set src_ip 192.0.2.1 dst_ip 192.0.2.2 id 42 index 10
130 $MZ h1-et -c 1 -p 931 -a 00:aa:bb:cc:dd:ee -b 00:ee:dd:cc:bb:aa -t ip -q
131 tc_check_packets "dev $swp1 ingress" 100 1
132 check_err $? "packet bigger than MTU matched nofrag (nofrag was unset)"
133 tc_check_packets "dev $swp1 ingress" 101 1
134 check_err $? "packet bigger than MTU didn't match firstfrag (nofrag was unset) "
135 tc_check_packets "dev $swp1 ingress" 102 1
136 check_err $? "packet bigger than MTU didn't match nofirstfrag (nofrag was unset) "
138 for i in 100 101 102; do
139 tc filter del dev $swp1 ingress protocol ip pref $i handle $i flower
141 tc filter del dev h1-et egress pref 1 handle 1 matchall
143 log_test "tunnel_key nofrag ($tcflags)"
154 if [[ $? -ne 0 ]]; then
155 log_info "Could not test offloaded functionality"