2 # SPDX-License-Identifier: GPL-2.0
6 TEST=$MY_DIR/test_cgrp2_sock2
7 LINK_PIN=$BPFFS/test_cgrp2_sock2
8 BPF_PROG=$MY_DIR/sock_flags.bpf.o
10 function config_device {
12 ip link add veth0 type veth peer name veth0b
13 ip link set veth0 netns at_ns0
14 ip netns exec at_ns0 sysctl -q net.ipv6.conf.veth0.disable_ipv6=0
15 ip netns exec at_ns0 ip addr add 172.16.1.100/24 dev veth0
16 ip netns exec at_ns0 ip addr add 2401:db00::1/64 dev veth0 nodad
17 ip netns exec at_ns0 ip link set dev veth0 up
18 sysctl -q net.ipv6.conf.veth0b.disable_ipv6=0
19 ip addr add 172.16.1.101/24 dev veth0b
20 ip addr add 2401:db00::2/64 dev veth0b nodad
24 function config_cgroup {
26 mkdir -p /tmp/cgroupv2
27 mount -t cgroup2 none /tmp/cgroupv2
28 mkdir -p /tmp/cgroupv2/foo
29 echo $$ >> /tmp/cgroupv2/foo/cgroup.procs
32 function config_bpffs {
33 if mount | grep $BPFFS > /dev/null; then
34 echo "bpffs already mounted"
36 echo "bpffs not mounted. Mounting..."
37 mount -t bpf none $BPFFS
42 $TEST /tmp/cgroupv2/foo $BPF_PROG $1
43 [ $? -ne 0 ] && exit 1
49 ip netns delete at_ns0
66 ping -c1 -w1 172.16.1.100
68 echo "ping failed when it should succeed"
73 ping6 -c1 -w1 2401:db00::1
75 echo "ping6 succeeded when it should not"
81 sleep 1 # Wait for link detach
87 ping6 -c1 -w1 2401:db00::1
89 echo "ping6 failed when it should succeed"
94 ping -c1 -w1 172.16.1.100
96 echo "ping succeeded when it should not"