brintos

brintos / linux-shallow public Read only

0
0
Text · 1.6 KiB · 5acc3ff Raw
104 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.03 4# Kselftest framework requirement - SKIP code is 4.5ksft_skip=46 7ALL_TESTS="loopback_test"8NUM_NETIFS=29lib_dir=$(dirname "$0")10source "$lib_dir"/../../../net/forwarding/tc_common.sh11source "$lib_dir"/../../../net/forwarding/lib.sh12 13h1_create()14{15	simple_if_init $h1 192.0.2.1/2416	tc qdisc add dev $h1 clsact17}18 19h1_destroy()20{21	tc qdisc del dev $h1 clsact22	simple_if_fini $h1 192.0.2.1/2423}24 25h2_create()26{27	simple_if_init $h228}29 30h2_destroy()31{32	simple_if_fini $h233}34 35loopback_test()36{37	RET=038 39	tc filter add dev $h1 ingress protocol arp pref 1 handle 101 flower \40		skip_hw arp_op reply arp_tip 192.0.2.1 action drop41 42	$MZ $h1 -c 1 -t arp -q43 44	tc_check_packets "dev $h1 ingress" 101 145	check_fail $? "Matched on a filter without loopback setup"46 47	ethtool -K $h1 loopback on48	check_err $? "Failed to enable loopback"49 50	setup_wait_dev $h151 52	$MZ $h1 -c 1 -t arp -q53 54	tc_check_packets "dev $h1 ingress" 101 155	check_err $? "Did not match on filter with loopback"56 57	ethtool -K $h1 loopback off58	check_err $? "Failed to disable loopback"59 60	$MZ $h1 -c 1 -t arp -q61 62	tc_check_packets "dev $h1 ingress" 101 263	check_fail $? "Matched on a filter after loopback was removed"64 65	tc filter del dev $h1 ingress protocol arp pref 1 handle 101 flower66 67	log_test "loopback"68}69 70setup_prepare()71{72	h1=${NETIFS[p1]}73	h2=${NETIFS[p2]}74 75	vrf_prepare76 77	h1_create78	h2_create79 80	if ethtool -k $h1 | grep loopback | grep -q fixed; then81		log_test "SKIP: dev $h1 does not support loopback feature"82		exit $ksft_skip83	fi84}85 86cleanup()87{88	pre_cleanup89 90	h2_destroy91	h1_destroy92 93	vrf_cleanup94}95 96trap cleanup EXIT97 98setup_prepare99setup_wait100 101tests_run102 103exit $EXIT_STATUS104