Project

General

Profile

Bug #418 » test-mcast-bla.sh

Linus Lüssing, 09/14/2020 10:40 AM

 
1
#!/bin/sh
2

    
3
PATH=/mnt/batctl:$PATH
4
NUM_NODES=8
5

    
6
setup() {
7
	modprobe crc16 > /dev/null
8
	modprobe libcrc32c > /dev/null
9
	modprobe bridge > /dev/null
10
	modprobe cfg80211 > /dev/null
11

    
12
	insmod /mnt/batman-adv/net/batman-adv/batman-adv.ko
13

    
14
	for i in `seq 1 $NUM_NODES`; do
15
		batctl meshif bat$i interface create
16
		ip link add dummy$i type dummy
17
		batctl meshif bat$i interface add dummy$i
18

    
19
		brctl addbr br$i
20
		brctl addif br$i bat$i
21

    
22
		ip link set up dev bat$i
23
		ip link set up dev dummy$i
24
		ip link set up dev br$i
25
	done
26

    
27
	# cabeling
28
	for i in `seq 1 $NUM_NODES`; do
29
		for j in `seq 1 $NUM_NODES`; do
30
			[ $i -ge $j ] && continue
31

    
32
			ip link add mesh-bat$i-bat$j type veth peer name mesh-bat$j-bat$i
33
			batctl meshif bat$i interface add mesh-bat$i-bat$j
34
			batctl meshif bat$j interface add mesh-bat$j-bat$i
35

    
36
			ip link set up dev mesh-bat$i-bat$j
37
			ip link set up dev mesh-bat$j-bat$i
38
		done
39
	done
40

    
41
	ip link add lan-br1-br0 type veth peer name lan-br0-br1
42
	ip link add lan-br2-br0 type veth peer name lan-br0-br2
43

    
44
	brctl addbr br0
45
	brctl addif br0 lan-br0-br1
46
	brctl addif br0 lan-br0-br2
47
	brctl addif br1 lan-br1-br0
48
	brctl addif br2 lan-br2-br0
49

    
50
	ip link set up dev lan-br0-br1
51
	ip link set up dev lan-br1-br0
52
	ip link set up dev lan-br0-br2
53
	ip link set up dev lan-br2-br0
54
	ip link set up dev br0
55
}
56

    
57
teardown() {
58
	brctl delif br0 lan-br0-br1
59
	brctl delif br0 lan-br0-br2
60
	brctl delif br1 lan-br1-br0
61
	brctl delif br2 lan-br2-br0
62
	ip link delete lan-br0-br1
63
	ip link delete lan-br0-br2
64
	ip link delete br0
65

    
66
	for i in `seq 1 $NUM_NODES`; do
67
		for j in `seq 1 $NUM_NODES`; do
68
			[ $i -ge $j ] && continue
69

    
70
			ip link delete mesh-bat$i-bat$j
71
		done
72

    
73
		ip link delete bat$i
74
		ip link delete br$i
75
		ip link delete dummy$i
76
	done
77

    
78
	rmmod batman-adv
79
}
80

    
81
if [ $# -ne 1 ]; then
82
	echo ups
83
	exit 1
84
fi
85

    
86
if [ "$1" = "setup" ]; then
87
	setup
88
elif [ "$1" = "teardown" ]; then
89
	teardown
90
elif [ "$1" = "reload" ]; then
91
	teardown
92
	setup
93
fi
    (1-1/1)