]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - samples/bpf/test_cgrp2_sock.sh
netfilter: nft_ct: prepare for key-dependent error unwind
[mirror_ubuntu-artful-kernel.git] / samples / bpf / test_cgrp2_sock.sh
1 #!/bin/bash
2
3 function config_device {
4 ip netns add at_ns0
5 ip link add veth0 type veth peer name veth0b
6 ip link set veth0b up
7 ip link set veth0 netns at_ns0
8 ip netns exec at_ns0 ip addr add 172.16.1.100/24 dev veth0
9 ip netns exec at_ns0 ip addr add 2401:db00::1/64 dev veth0 nodad
10 ip netns exec at_ns0 ip link set dev veth0 up
11 ip link add foo type vrf table 1234
12 ip link set foo up
13 ip addr add 172.16.1.101/24 dev veth0b
14 ip addr add 2401:db00::2/64 dev veth0b nodad
15 ip link set veth0b master foo
16 }
17
18 function attach_bpf {
19 rm -rf /tmp/cgroupv2
20 mkdir -p /tmp/cgroupv2
21 mount -t cgroup2 none /tmp/cgroupv2
22 mkdir -p /tmp/cgroupv2/foo
23 test_cgrp2_sock /tmp/cgroupv2/foo foo
24 echo $$ >> /tmp/cgroupv2/foo/cgroup.procs
25 }
26
27 function cleanup {
28 set +ex
29 ip netns delete at_ns0
30 ip link del veth0
31 ip link del foo
32 umount /tmp/cgroupv2
33 rm -rf /tmp/cgroupv2
34 set -ex
35 }
36
37 function do_test {
38 ping -c1 -w1 172.16.1.100
39 ping6 -c1 -w1 2401:db00::1
40 }
41
42 cleanup 2>/dev/null
43 config_device
44 attach_bpf
45 do_test
46 cleanup
47 echo "*** PASS ***"