WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / bpf / test_skb_cgroup_id.sh
bloba9bc6f82abc163d47876d4af1f2dcbe540a6c814
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Facebook
5 set -eu
7 wait_for_ip()
9 local _i
10 echo -n "Wait for testing link-local IP to become available "
11 for _i in $(seq ${MAX_PING_TRIES}); do
12 echo -n "."
13 if $PING6 -c 1 -W 1 ff02::1%${TEST_IF} >/dev/null 2>&1; then
14 echo " OK"
15 return
17 sleep 1
18 done
19 echo 1>&2 "ERROR: Timeout waiting for test IP to become available."
20 exit 1
23 setup()
25 # Create testing interfaces not to interfere with current environment.
26 ip link add dev ${TEST_IF} type veth peer name ${TEST_IF_PEER}
27 ip link set ${TEST_IF} up
28 ip link set ${TEST_IF_PEER} up
30 wait_for_ip
32 tc qdisc add dev ${TEST_IF} clsact
33 tc filter add dev ${TEST_IF} egress bpf obj ${BPF_PROG_OBJ} \
34 sec ${BPF_PROG_SECTION} da
36 BPF_PROG_ID=$(tc filter show dev ${TEST_IF} egress | \
37 awk '/ id / {sub(/.* id /, "", $0); print($1)}')
40 cleanup()
42 ip link del ${TEST_IF} 2>/dev/null || :
43 ip link del ${TEST_IF_PEER} 2>/dev/null || :
46 main()
48 trap cleanup EXIT 2 3 6 15
49 setup
50 ${PROG} ${TEST_IF} ${BPF_PROG_ID}
53 DIR=$(dirname $0)
54 TEST_IF="test_cgid_1"
55 TEST_IF_PEER="test_cgid_2"
56 MAX_PING_TRIES=5
57 BPF_PROG_OBJ="${DIR}/test_skb_cgroup_id_kern.o"
58 BPF_PROG_SECTION="cgroup_id_logger"
59 BPF_PROG_ID=0
60 PROG="${DIR}/test_skb_cgroup_id_user"
61 type ping6 >/dev/null 2>&1 && PING6="ping6" || PING6="ping -6"
63 main