Commit 91d7694b authored by Kirill Smelkov's avatar Kirill Smelkov

BAC: Add -cycle option so that both linear and triangle topologies could be tested

linear:

	B--A--C

triangle:

	B-----A
	 \   /
	  \ /
	   C
parent 58707f40
...@@ -6,6 +6,7 @@ PID=$$ ...@@ -6,6 +6,7 @@ PID=$$
xunshare() { xunshare() {
ref=$1 ref=$1
shift shift
echo "create $ref"
rm -rf "$ref" rm -rf "$ref"
mkdir "$ref" mkdir "$ref"
touch $ref/mnt $ref/net touch $ref/mnt $ref/net
...@@ -29,6 +30,7 @@ xlink() { ...@@ -29,6 +30,7 @@ xlink() {
B=$2 B=$2
a="${A,,}" # A -> a a="${A,,}" # A -> a
b="${B,,}" # B -> b b="${B,,}" # B -> b
echo "link $A-$B"
xnsenter $A -- ip link add $a-$b type veth peer br$A$B.$a xnsenter $A -- ip link add $a-$b type veth peer br$A$B.$a
xnsenter $A -- ip link set br$A$B.$a netns $PID xnsenter $A -- ip link set br$A$B.$a netns $PID
......
#!/bin/bash -ex #!/bin/bash -e
# topo B-A-C creates the following network topology: # topo B-A-C creates the following network topology:
# #
# #
# ns:B ns:A ns:C # ns:B ns:A ns:C
# #
# B --- br0 --- A --- br1 --- C # B ----- A ----- C
# b-a a-b a-c c-a # b-a a-b a-c c-a
# #
# #
# if run with -cycle, it also creates B-C link:
#
#
# B ............... C
# | |
# '-------------------'
#
# should be run under unshare -mrun . # should be run under unshare -mrun .
# use xnsenter {A,B,C} to enter into namespaces of A/B/C. # use xnsenter {A,B,C} to enter into namespaces of A/B/C.
# #
...@@ -15,6 +22,8 @@ ...@@ -15,6 +22,8 @@
. lib.sh . lib.sh
cycle=n
[ "$1" = "-cycle" ] && cycle=y
# lo on everything # lo on everything
xunshare A -- ip link set lo up xunshare A -- ip link set lo up
...@@ -24,13 +33,19 @@ xunshare C -- ip link set lo up ...@@ -24,13 +33,19 @@ xunshare C -- ip link set lo up
# links # links
xlink B A # B-A xlink B A # B-A
xlink A C # A-C xlink A C # A-C
[ $cycle = y ] && xlink B C
set -x
# addresses # addresses
xnsenter B -- ip addr add 10.0.0.1/24 dev b-a xnsenter B -- ip addr add 10.0.0.1/24 dev b-a
xnsenter A -- ip addr add 10.0.0.2/24 dev a-b xnsenter A -- ip addr add 10.0.0.2/24 dev a-b
xnsenter C -- ip addr add 20.0.0.1/24 dev c-a xnsenter C -- ip addr add 20.0.0.1/24 dev c-a
xnsenter A -- ip addr add 20.0.0.2/24 dev a-c xnsenter A -- ip addr add 20.0.0.2/24 dev a-c
if [ $cycle = y ]; then
xnsenter B -- ip addr add 30.0.0.1/24 dev b-c
xnsenter C -- ip addr add 30.0.0.2/24 dev c-b
fi
# multicast routing # multicast routing
xnsenter B -- ip route add 224.0.0.0/4 dev b-a xnsenter B -- ip route add 224.0.0.0/4 dev b-a
...@@ -39,6 +54,11 @@ xnsenter C -- ip route add 224.0.0.0/4 dev c-a ...@@ -39,6 +54,11 @@ xnsenter C -- ip route add 224.0.0.0/4 dev c-a
xnsenter A -- ip route add 224.0.0.0/4 dev a-b # NOTE on A 224.0.0.0/4 is routed xnsenter A -- ip route add 224.0.0.0/4 dev a-b # NOTE on A 224.0.0.0/4 is routed
xnsenter A -- ip route append 224.0.0.0/4 dev a-c # to _both_ a-b and a-c xnsenter A -- ip route append 224.0.0.0/4 dev a-c # to _both_ a-b and a-c
if [ $cycle = y ]; then
xnsenter B -- ip route append 224.0.0.0/4 dev b-c
xnsenter C -- ip route append 224.0.0.0/4 dev c-b
fi
# mount private /var/run so that smcrouted can be started # mount private /var/run so that smcrouted can be started
xnsenter A -- mount -t tmpfs none /var/run xnsenter A -- mount -t tmpfs none /var/run
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment