blob: 925fd467c7cc92043eae39ba9ea76f94401f969a [file] [log] [blame]
David Ahernad2805d2016-12-01 08:48:05 -08001#!/bin/bash
2
3function 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
18function 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
27function 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
37function do_test {
38 ping -c1 -w1 172.16.1.100
39 ping6 -c1 -w1 2401:db00::1
40}
41
42cleanup 2>/dev/null
43config_device
44attach_bpf
45do_test
46cleanup
47echo "*** PASS ***"