ixgbe: fix MAC anti-spoofing filter after VFLR
[muen/linux.git] / tools / testing / selftests / bpf / test_sock_addr.sh
1 #!/bin/sh
2
3 set -eu
4
5 ping_once()
6 {
7         ping -${1} -q -c 1 -W 1 ${2%%/*} >/dev/null 2>&1
8 }
9
10 wait_for_ip()
11 {
12         local _i
13         echo -n "Wait for testing IPv4/IPv6 to become available "
14         for _i in $(seq ${MAX_PING_TRIES}); do
15                 echo -n "."
16                 if ping_once 4 ${TEST_IPv4} && ping_once 6 ${TEST_IPv6}; then
17                         echo " OK"
18                         return
19                 fi
20         done
21         echo 1>&2 "ERROR: Timeout waiting for test IP to become available."
22         exit 1
23 }
24
25 setup()
26 {
27         # Create testing interfaces not to interfere with current environment.
28         ip link add dev ${TEST_IF} type veth peer name ${TEST_IF_PEER}
29         ip link set ${TEST_IF} up
30         ip link set ${TEST_IF_PEER} up
31
32         ip -4 addr add ${TEST_IPv4} dev ${TEST_IF}
33         ip -6 addr add ${TEST_IPv6} dev ${TEST_IF}
34         wait_for_ip
35 }
36
37 cleanup()
38 {
39         ip link del ${TEST_IF} 2>/dev/null || :
40         ip link del ${TEST_IF_PEER} 2>/dev/null || :
41 }
42
43 main()
44 {
45         trap cleanup EXIT 2 3 6 15
46         setup
47         ./test_sock_addr setup_done
48 }
49
50 BASENAME=$(basename $0 .sh)
51 TEST_IF="${BASENAME}1"
52 TEST_IF_PEER="${BASENAME}2"
53 TEST_IPv4="127.0.0.4/8"
54 TEST_IPv6="::6/128"
55 MAX_PING_TRIES=5
56
57 main