diff options
Diffstat (limited to 'tools/route-server')
-rw-r--r-- | tools/route-server/README.md | 109 | ||||
-rw-r--r-- | tools/route-server/quagga-rsconfig.go | 103 | ||||
-rwxr-xr-x | tools/route-server/route-server-docker.sh | 105 |
3 files changed, 0 insertions, 317 deletions
diff --git a/tools/route-server/README.md b/tools/route-server/README.md deleted file mode 100644 index 1940551e..00000000 --- a/tools/route-server/README.md +++ /dev/null @@ -1,109 +0,0 @@ -# Route Server testing env - -## Preparation - -Set up Ubuntu 14.04 Server Edition Virtual Machine environment. We -tested this with Fusion on Mac OS X and VirtualBox on Windows 8. - -## Setup - -Open a terminal and execute the following commands: - -```bash -% sudo apt-get install -y --force-yes wget -% wget https://raw.githubusercontent.com/osrg/gobgp/master/tools/route-server/route-server-docker.sh -% chmod +x route-server-docker.sh -% ./route-server-docker.sh install -``` - -All necessary software will be installed. You can find all configuration files -(for Quagga and gobgp) at /usr/local/gobgp. Let's make sure: - -```bash -fujita@ubuntu:~$ find /usr/local/gobgp|sort -/usr/local/gobgp -/usr/local/gobgp/gobgpd.conf -/usr/local/gobgp/q1 -/usr/local/gobgp/q1/bgpd.conf -/usr/local/gobgp/q2 -/usr/local/gobgp/q2/bgpd.conf -/usr/local/gobgp/q3 -/usr/local/gobgp/q3/bgpd.conf -/usr/local/gobgp/q4 -/usr/local/gobgp/q4/bgpd.conf -/usr/local/gobgp/q5 -/usr/local/gobgp/q5/bgpd.conf -/usr/local/gobgp/q6 -/usr/local/gobgp/q6/bgpd.conf -/usr/local/gobgp/q7 -/usr/local/gobgp/q7/bgpd.conf -/usr/local/gobgp/q8 -/usr/local/gobgp/q8/bgpd.conf -``` - -Before going to playing with this environment, you need to log out and log in -again. - -## Start - -```bash -% ./route-server-docker.sh start -``` - -Eight containers for Quagga and one container for gobgp started. - -Now ready to start gobgp so let's go into the container for gobgp: - -```bash -% docker exec -it gobgp bash -``` - -You are supposed to get a console like the following: - -```bash -root@ec36881de971:~# -``` - -```bash -root@e7cb66415e2f:~# go run gobgp/bgpd.go -f /mnt/gobgpd.conf -INFO[0000] Peer 10.0.0.1 is added -INFO[0000] Peer 10.0.0.2 is added -INFO[0000] Peer 10.0.0.3 is added -INFO[0000] Peer 10.0.0.4 is added -INFO[0000] Peer 10.0.0.5 is added -INFO[0000] Peer 10.0.0.6 is added -INFO[0000] Peer 10.0.0.7 is added -INFO[0000] Peer 10.0.0.8 is added -``` - -After some time, you'll see more messages on the console (it means -Quagga bgpd connected to gobgp). - -On a different console, let's check the status of Quagga. - -```bash -% docker exec -it q1 bash -``` - -You can do something like: - -```bash -root@a40ac8058ca7:/# telnet localhost bgpd -``` - -btw, the password is "zebra". - -The names of Quagga containers are q1, q2, q3, q4, q5, q6, q7, and q8 -respectively. You can execute bash on any container with 'docker exec' -command. - -## Stop - -The following command stops and cleans up everything. - -```bash -% ./route-server-docker.sh stop -``` - -You can safely execute this command whenever something goes wrong and start -again. diff --git a/tools/route-server/quagga-rsconfig.go b/tools/route-server/quagga-rsconfig.go deleted file mode 100644 index 24ff62c3..00000000 --- a/tools/route-server/quagga-rsconfig.go +++ /dev/null @@ -1,103 +0,0 @@ -package main - -import ( - "bytes" - "fmt" - "io/ioutil" - "log" - "net" - "os" - "path/filepath" - - "github.com/BurntSushi/toml" - "github.com/jessevdk/go-flags" - "github.com/osrg/gobgp/internal/pkg/config" -) - -type QuaggaConfig struct { - id int - config *config.Neighbor - gobgpConfig *config.Global - serverIP net.IP -} - -func NewQuaggaConfig(id int, gConfig *config.Global, myConfig *config.Neighbor, server net.IP) *QuaggaConfig { - return &QuaggaConfig{ - id: id, - config: myConfig, - gobgpConfig: gConfig, - serverIP: server, - } -} - -func (qt *QuaggaConfig) Config() *bytes.Buffer { - buf := bytes.NewBuffer(nil) - - buf.WriteString("hostname bgpd\n") - buf.WriteString("password zebra\n") - buf.WriteString(fmt.Sprintf("router bgp %d\n", qt.config.Config.PeerAs)) - buf.WriteString(fmt.Sprintf("bgp router-id 192.168.0.%d\n", qt.id)) - buf.WriteString(fmt.Sprintf("network 192.168.%d.0/24\n", qt.id)) - buf.WriteString(fmt.Sprintf("neighbor %s remote-as %d\n", qt.serverIP, qt.gobgpConfig.Config.As)) - buf.WriteString(fmt.Sprintf("neighbor %s password %s\n", qt.serverIP, qt.config.Config.AuthPassword)) - buf.WriteString("log file /var/log/quagga/bgpd.log") - return buf -} - -func create_config_files(nr int, outputDir string) { - gobgpConf := config.Bgp{} - gobgpConf.Global.Config.As = 65000 - gobgpConf.Global.Config.RouterId = "192.168.255.1" - - for i := 1; i < nr+1; i++ { - - c := config.Neighbor{} - c.Config.PeerAs = 65000 + uint32(i) - c.Config.NeighborAddress = fmt.Sprintf("10.0.0.%d", i) - c.Config.AuthPassword = fmt.Sprintf("password%d", i) - - gobgpConf.Neighbors = append(gobgpConf.Neighbors, c) - q := NewQuaggaConfig(i, &gobgpConf.Global, &c, net.ParseIP("10.0.255.1")) - - if err := os.Mkdir(fmt.Sprintf("%s/q%d", outputDir, i), 0755); err != nil { - log.Fatalf("failed to make directory: %v", err) - } - - if err := ioutil.WriteFile(fmt.Sprintf("%s/q%d/bgpd.conf", outputDir, i), q.Config().Bytes(), 0644); err != nil { - log.Fatal(err) - } - } - - var buffer bytes.Buffer - encoder := toml.NewEncoder(&buffer) - if err := encoder.Encode(gobgpConf); err != nil { - log.Fatalf("failed to encode config: %v", err) - } - - if err := ioutil.WriteFile(fmt.Sprintf("%s/gobgpd.conf", outputDir), buffer.Bytes(), 0644); err != nil { - log.Fatalf("failed to write config file: %v", err) - } -} - -func main() { - var opts struct { - ClientNumber int `short:"n" long:"client-number" description:"specfying the number of clients" default:"8"` - OutputDir string `short:"c" long:"output" description:"specifying the output directory"` - } - parser := flags.NewParser(&opts, flags.Default) - - _, err := parser.Parse() - if err != nil { - os.Exit(1) - } - - if opts.OutputDir == "" { - opts.OutputDir, _ = filepath.Abs(".") - } else { - if _, err := os.Stat(opts.OutputDir); os.IsNotExist(err) { - os.Mkdir(opts.OutputDir, 0755) - } - } - - create_config_files(opts.ClientNumber, opts.OutputDir) -} diff --git a/tools/route-server/route-server-docker.sh b/tools/route-server/route-server-docker.sh deleted file mode 100755 index 144fbade..00000000 --- a/tools/route-server/route-server-docker.sh +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/sh - -NR_PEERS=8 -BRIDGE_NAME=br0 -CONFIG_DIR=/usr/local/gobgp -GOBGP_DOCKER_NAME=gobgp -USE_HOST=0 - -check_user() { - if [ `whoami` = "root" ]; then - echo "Super user cannot execute! Please execute as non super user" - exit 2 - fi -} - -run_quagga() { - local docker_name=q$1 - docker run --privileged=true -v $CONFIG_DIR/$docker_name:/etc/quagga --name $docker_name -id osrg/quagga - sudo pipework $BRIDGE_NAME $docker_name 10.0.0.$1/16 -} - -stop_quagga() { - local docker_name=q$1 - docker rm -f $docker_name -} - -delete_bridge() { - local name=$1 - local sysfs_name=/sys/class/net/$name - if [ -e $sysfs_name ]; then - sudo ifconfig $name down - sudo brctl delbr $name - fi -} - -while getopts c:n:u OPT -do - case $OPT in - c) CONFIG_DIR="$OPTARG" - ;; - n) NR_PEERS="$OPTARG" - ;; - u) USE_HOST=1 - ;; - *) echo "Unknown option" - exit 1 - ;; - esac -done - -shift $((OPTIND - 1)) - -case "$1" in - start) - i=1 - while [ $i -le $NR_PEERS ] - do - run_quagga $i - i=$(( i+1 )) - done - if [ $USE_HOST -eq 1 ]; then - sudo ip addr add 10.0.255.1/16 dev $BRIDGE_NAME - else - docker run --privileged=true -v $CONFIG_DIR:/mnt -d --name $GOBGP_DOCKER_NAME -id osrg/gobgp - sudo pipework $BRIDGE_NAME $GOBGP_DOCKER_NAME 10.0.255.1/16 - fi - ;; - stop) - i=1 - while [ $i -le $NR_PEERS ] - do - stop_quagga $i - i=$(( i+1 )) - done - delete_bridge $BRIDGE_NAME - docker rm -f $GOBGP_DOCKER_NAME - ;; - install) - sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 - sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list" - sudo apt-get update - sudo apt-get install -y --force-yes lxc-docker-1.3.2 - sudo ln -sf /usr/bin/docker.io /usr/local/bin/docker - sudo gpasswd -a `whoami` docker - sudo apt-get install -y --force-yes emacs23-nox - sudo apt-get install -y --force-yes wireshark - sudo apt-get install -y --force-yes iputils-arping - sudo apt-get install -y --force-yes bridge-utils - sudo apt-get install -y --force-yes tcpdump - sudo apt-get install -y --force-yes lv - sudo wget https://raw.github.com/jpetazzo/pipework/master/pipework -O /usr/local/bin/pipework - sudo chmod 755 /usr/local/bin/pipework - sudo docker pull osrg/quagga - sudo docker pull osrg/gobgp - sudo mkdir /usr/local/gobgp - sudo docker run --privileged=true -v /usr/local/gobgp:/mnt --name gobgp --rm osrg/gobgp go run /root/gobgp/tools/route-server/quagga-rsconfig.go -c /mnt - ;; - *) - echo $1 - echo "Usage: root-server-docker {start|stop|install}" - exit 2 - ;; -esac - - |