-
Notifications
You must be signed in to change notification settings - Fork 0
/
pndp_test.sh
executable file
·65 lines (53 loc) · 2.07 KB
/
pndp_test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env sh
set -euxo
make
ip netns add pndpd-p # Provider
ip netns exec pndpd-p sysctl -w net.ipv6.conf.all.forwarding=1
ip netns add pndpd-c # Client
ip netns exec pndpd-c sysctl -w net.ipv6.conf.all.forwarding=1
ip netns add pndpd-i # Inner client
ip netns exec pndpd-i sysctl -w net.ipv6.conf.all.forwarding=1
# Provider bridge
ip -netns pndpd-p link add br0 type bridge
ip -netns pndpd-p addr add fd00::/62 dev br0
ip -netns pndpd-p addr add 2001:db8::/62 dev br0
ip -netns pndpd-p link set dev br0 address 00:00:00:00:00:01 # Predictable link-local
ip -netns pndpd-p link set up dev br0
# Client 0 link to provider bridge
ip -netns pndpd-p link add veth-c0 type veth peer name veth-p
ip -netns pndpd-p link set up veth-c0
ip -netns pndpd-p link set veth-c0 master br0
ip -netns pndpd-p link set veth-p netns pndpd-c
ip -netns pndpd-c addr add fd00:0:0:1::/128 dev veth-p
ip -netns pndpd-c addr add 2001:db8:0:1::/128 dev veth-p
ip -netns pndpd-c link set up dev veth-p
ip -netns pndpd-c route add default via fe80::200:ff:fe00:1 dev veth-p
# Bridge on client 0
ip -netns pndpd-c link add br0 type bridge
ip -netns pndpd-c addr add fd00:0:0:1::/64 dev br0
ip -netns pndpd-c addr add 2001:db8:0:1::/64 dev br0
ip -netns pndpd-c link set dev br0 address 00:00:00:00:00:02
ip -netns pndpd-c link set up dev br0
# Inner client link to client 0 bridge
ip -netns pndpd-c link add veth-i0 type veth peer name veth-c
ip -netns pndpd-c link set up veth-i0
ip -netns pndpd-c link set veth-i0 master br0
ip -netns pndpd-c link set veth-c netns pndpd-i
ip -netns pndpd-i addr add fd00:0:0:1::100/64 dev veth-c
ip -netns pndpd-i addr add 2001:db8:0:1::100/64 dev veth-c
ip -netns pndpd-i link set up dev veth-c
ip -netns pndpd-i route add default via fd00:0:0:1:: dev veth-c
sleep 2
ip netns exec pndpd-c bin/pndpd proxy veth-p br0 auto &
PID=$!
sleep 2
# Perform tests
ip netns exec pndpd-p ping -c 5 -w 10 fd00:0:0:1::100
ip netns exec pndpd-p ping -c 5 -w 10 2001:db8:0:1::100
kill -n 2 "$PID"
wait
echo "Tests successful"
# Teardown
ip netns delete pndpd-p
ip netns delete pndpd-c
ip netns delete pndpd-i