/
usr
/
src
/
linux-headers-5.15.0-181
/
tools
/
testing
/
selftests
/
net
/
/usr/src/linux-headers-5.15.0-181/tools/testing/selftests/net
mkdir
upload
Name
Size
Mode
Actions
af_unix/
-
0755
rm
forwarding/
-
0755
rm
mptcp/
-
0755
rm
altnames.sh
1817
0755
edit
dl
rm
bareudp.sh
21290
0755
edit
dl
rm
drop_monitor_tests.sh
4439
0755
edit
dl
rm
fcnal-test.sh
103221
0755
edit
dl
rm
fib-onlink-tests.sh
12409
0755
edit
dl
rm
fib_nexthops.sh
68003
0755
edit
dl
rm
fib_nexthop_multiprefix.sh
5870
0755
edit
dl
rm
fib_nexthop_nongw.sh
2327
0755
edit
dl
rm
fib_rule_tests.sh
5981
0755
edit
dl
rm
fib_tests.sh
57224
0755
edit
dl
rm
fin_ack_lat.sh
507
0755
edit
dl
rm
gre_gso.sh
4237
0755
edit
dl
rm
gro.sh
2132
0755
edit
dl
rm
icmp.sh
2618
0755
edit
dl
rm
icmp_redirect.sh
12820
0755
edit
dl
rm
in_netns.sh
323
0755
edit
dl
rm
ioam6.sh
25962
0755
edit
dl
rm
ip6_gre_headroom.sh
1400
0755
edit
dl
rm
ipv6_flowlabel.sh
502
0755
edit
dl
rm
ip_defrag.sh
2087
0755
edit
dl
rm
l2tp.sh
9909
0755
edit
dl
rm
lib.sh
597
0644
edit
dl
rm
Makefile
2499
0644
edit
dl
rm
msg_zerocopy.sh
3012
0755
edit
dl
rm
netdevice.sh
4521
0755
edit
dl
rm
net_helper.sh
514
0644
edit
dl
rm
pmtu.sh
74711
0755
edit
dl
rm
psock_snd.sh
2252
0755
edit
dl
rm
reuseaddr_ports_exhausted.sh
635
0755
edit
dl
rm
reuseport_addr_any.sh
81
0755
edit
dl
rm
route_localnet.sh
1871
0755
edit
dl
rm
rtnetlink.sh
29476
0755
edit
dl
rm
rxtimestamp.sh
79
0755
edit
dl
rm
setup_loopback.sh
2654
0644
edit
dl
rm
setup_veth.sh
929
0644
edit
dl
rm
so_txtime.sh
2434
0755
edit
dl
rm
srv6_end_dt4_l3vpn_test.sh
17454
0755
edit
dl
rm
srv6_end_dt6_l3vpn_test.sh
17615
0755
edit
dl
rm
srv6_end_dt46_l3vpn_test.sh
21121
0755
edit
dl
rm
tcp_fastopen_backup_key.sh
1086
0755
edit
dl
rm
test_blackhole_dev.sh
280
0755
edit
dl
rm
test_bpf.sh
225
0755
edit
dl
rm
test_vxlan_fdb_changelink.sh
678
0755
edit
dl
rm
test_vxlan_under_vrf.sh
5607
0755
edit
dl
rm
toeplitz.sh
4983
0755
edit
dl
rm
toeplitz_client.sh
667
0755
edit
dl
rm
traceroute.sh
7131
0755
edit
dl
rm
txtimestamp.sh
1702
0755
edit
dl
rm
udpgro.sh
5988
0755
edit
dl
rm
udpgro_bench.sh
2126
0755
edit
dl
rm
udpgro_fwd.sh
7145
0755
edit
dl
rm
udpgso.sh
545
0755
edit
dl
rm
udpgso_bench.sh
2852
0755
edit
dl
rm
unicast_extensions.sh
8263
0755
edit
dl
rm
veth.sh
10441
0755
edit
dl
rm
vrf-xfrm-tests.sh
10970
0755
edit
dl
rm
vrf_route_leaking.sh
14946
0755
edit
dl
rm
vrf_strict_mode_test.sh
7688
0755
edit
dl
rm
xfrm_policy.sh
14759
0755
edit
dl
rm
Edit:
/usr/src/linux-headers-5.15.0-181/tools/testing/selftests/net/fib_rule_tests.sh
(5981B)
#!/bin/bash # SPDX-License-Identifier: GPL-2.0 # This test is for checking IPv4 and IPv6 FIB rules API # Kselftest framework requirement - SKIP code is 4. ksft_skip=4 ret=0 PAUSE_ON_FAIL=${PAUSE_ON_FAIL:=no} IP="ip -netns testns" RTABLE=100 GW_IP4=192.51.100.2 SRC_IP=192.51.100.3 GW_IP6=2001:db8:1::2 SRC_IP6=2001:db8:1::3 DEV_ADDR=192.51.100.1 DEV_ADDR6=2001:db8:1::1 DEV=dummy0 log_test() { local rc=$1 local expected=$2 local msg="$3" if [ ${rc} -eq ${expected} ]; then nsuccess=$((nsuccess+1)) printf "\n TEST: %-50s [ OK ]\n" "${msg}" else ret=1 nfail=$((nfail+1)) printf "\n TEST: %-50s [FAIL]\n" "${msg}" if [ "${PAUSE_ON_FAIL}" = "yes" ]; then echo echo "hit enter to continue, 'q' to quit" read a [ "$a" = "q" ] && exit 1 fi fi } log_section() { echo echo "######################################################################" echo "TEST SECTION: $*" echo "######################################################################" } setup() { set -e ip netns add testns $IP link set dev lo up $IP link add dummy0 type dummy $IP link set dev dummy0 up $IP address add $DEV_ADDR/24 dev dummy0 $IP -6 address add $DEV_ADDR6/64 dev dummy0 ip netns exec testns sysctl -w net.ipv4.ip_forward=1 set +e } cleanup() { $IP link del dev dummy0 &> /dev/null ip netns del testns } fib_check_iproute_support() { ip rule help 2>&1 | grep -q $1 if [ $? -ne 0 ]; then echo "SKIP: iproute2 iprule too old, missing $1 match" return 1 fi ip route get help 2>&1 | grep -q $2 if [ $? -ne 0 ]; then echo "SKIP: iproute2 get route too old, missing $2 match" return 1 fi return 0 } fib_rule6_del() { $IP -6 rule del $1 log_test $? 0 "rule6 del $1" } fib_rule6_del_by_pref() { pref=$($IP -6 rule show | grep "$1 lookup $TABLE" | cut -d ":" -f 1) $IP -6 rule del pref $pref } fib_rule6_test_match_n_redirect() { local match="$1" local getmatch="$2" $IP -6 rule add $match table $RTABLE $IP -6 route get $GW_IP6 $getmatch | grep -q "table $RTABLE" log_test $? 0 "rule6 check: $1" fib_rule6_del_by_pref "$match" log_test $? 0 "rule6 del by pref: $match" } fib_rule6_test() { # setup the fib rule redirect route $IP -6 route add table $RTABLE default via $GW_IP6 dev $DEV onlink match="oif $DEV" fib_rule6_test_match_n_redirect "$match" "$match" "oif redirect to table" match="from $SRC_IP6 iif $DEV" fib_rule6_test_match_n_redirect "$match" "$match" "iif redirect to table" match="tos 0x10" fib_rule6_test_match_n_redirect "$match" "$match" "tos redirect to table" match="fwmark 0x64" getmatch="mark 0x64" fib_rule6_test_match_n_redirect "$match" "$getmatch" "fwmark redirect to table" fib_check_iproute_support "uidrange" "uid" if [ $? -eq 0 ]; then match="uidrange 100-100" getmatch="uid 100" fib_rule6_test_match_n_redirect "$match" "$getmatch" "uid redirect to table" fi fib_check_iproute_support "sport" "sport" if [ $? -eq 0 ]; then match="sport 666 dport 777" fib_rule6_test_match_n_redirect "$match" "$match" "sport and dport redirect to table" fi fib_check_iproute_support "ipproto" "ipproto" if [ $? -eq 0 ]; then match="ipproto tcp" fib_rule6_test_match_n_redirect "$match" "$match" "ipproto match" fi fib_check_iproute_support "ipproto" "ipproto" if [ $? -eq 0 ]; then match="ipproto ipv6-icmp" fib_rule6_test_match_n_redirect "$match" "$match" "ipproto ipv6-icmp match" fi } fib_rule4_del() { $IP rule del $1 log_test $? 0 "del $1" } fib_rule4_del_by_pref() { pref=$($IP rule show | grep "$1 lookup $TABLE" | cut -d ":" -f 1) $IP rule del pref $pref } fib_rule4_test_match_n_redirect() { local match="$1" local getmatch="$2" $IP rule add $match table $RTABLE $IP route get $GW_IP4 $getmatch | grep -q "table $RTABLE" log_test $? 0 "rule4 check: $1" fib_rule4_del_by_pref "$match" log_test $? 0 "rule4 del by pref: $match" } fib_rule4_test() { # setup the fib rule redirect route $IP route add table $RTABLE default via $GW_IP4 dev $DEV onlink match="oif $DEV" fib_rule4_test_match_n_redirect "$match" "$match" "oif redirect to table" # need enable forwarding and disable rp_filter temporarily as all the # addresses are in the same subnet and egress device == ingress device. ip netns exec testns sysctl -w net.ipv4.ip_forward=1 ip netns exec testns sysctl -w net.ipv4.conf.$DEV.rp_filter=0 match="from $SRC_IP iif $DEV" fib_rule4_test_match_n_redirect "$match" "$match" "iif redirect to table" ip netns exec testns sysctl -w net.ipv4.ip_forward=0 match="tos 0x10" fib_rule4_test_match_n_redirect "$match" "$match" "tos redirect to table" match="fwmark 0x64" getmatch="mark 0x64" fib_rule4_test_match_n_redirect "$match" "$getmatch" "fwmark redirect to table" fib_check_iproute_support "uidrange" "uid" if [ $? -eq 0 ]; then match="uidrange 100-100" getmatch="uid 100" fib_rule4_test_match_n_redirect "$match" "$getmatch" "uid redirect to table" fi fib_check_iproute_support "sport" "sport" if [ $? -eq 0 ]; then match="sport 666 dport 777" fib_rule4_test_match_n_redirect "$match" "$match" "sport and dport redirect to table" fi fib_check_iproute_support "ipproto" "ipproto" if [ $? -eq 0 ]; then match="ipproto tcp" fib_rule4_test_match_n_redirect "$match" "$match" "ipproto tcp match" fi fib_check_iproute_support "ipproto" "ipproto" if [ $? -eq 0 ]; then match="ipproto icmp" fib_rule4_test_match_n_redirect "$match" "$match" "ipproto icmp match" fi } run_fibrule_tests() { log_section "IPv4 fib rule" fib_rule4_test log_section "IPv6 fib rule" fib_rule6_test } if [ "$(id -u)" -ne 0 ];then echo "SKIP: Need root privileges" exit $ksft_skip fi if [ ! -x "$(command -v ip)" ]; then echo "SKIP: Could not run test without ip tool" exit $ksft_skip fi # start clean cleanup &> /dev/null setup run_fibrule_tests cleanup if [ "$TESTS" != "none" ]; then printf "\nTests passed: %3d\n" ${nsuccess} printf "Tests failed: %3d\n" ${nfail} fi exit $ret
Save
cmd:
run