2 # SPDX-License-Identifier: GPL-2.0
5 LINK_PIN
=$BPFFS/test_cgrp2_sock2
7 function config_device
{
9 ip link add veth0
type veth peer name veth0b
11 ip link
set veth0 netns at_ns0
12 ip netns
exec at_ns0 ip addr add
172.16.1.100/24 dev veth0
13 ip netns
exec at_ns0 ip addr add
2401:db00
::1/64 dev veth0 nodad
14 ip netns
exec at_ns0 ip link
set dev veth0 up
15 ip addr add
172.16.1.101/24 dev veth0b
16 ip addr add
2401:db00
::2/64 dev veth0b nodad
19 function config_cgroup
{
21 mkdir
-p /tmp
/cgroupv2
22 mount
-t cgroup2 none
/tmp
/cgroupv2
23 mkdir
-p /tmp
/cgroupv
2/foo
24 echo $$
>> /tmp
/cgroupv
2/foo
/cgroup.procs
27 function config_bpffs
{
28 if mount |
grep $BPFFS > /dev
/null
; then
29 echo "bpffs already mounted"
31 echo "bpffs not mounted. Mounting..."
32 mount
-t bpf none
$BPFFS
37 .
/test_cgrp2_sock2
/tmp
/cgroupv
2/foo sock_flags_kern.o
$1
38 [ $?
-ne 0 ] && exit 1
44 ip netns delete at_ns0
61 ping -c1 -w1 172.16.1.100
63 echo "ping failed when it should succeed"
68 ping6
-c1 -w1 2401:db00
::1
70 echo "ping6 succeeded when it should not"
76 sleep 1 # Wait for link detach
82 ping6
-c1 -w1 2401:db00
::1
84 echo "ping6 failed when it should succeed"
89 ping -c1 -w1 172.16.1.100
91 echo "ping succeeded when it should not"