Introduction

In this lab we will connect to our datapath element and perform the necessary steps to ensure that it is running Open vSwitch and can connect to our controller.

Goals

Notes

Installation

Installing telnet

To connect to the datapath element from your controller you will need to install telnet on your VM. Alternatively you can telnet directly from your laptop

$ sudo apt-get install telnet

Telnet to your datapath element

$ telnet 10.10.0.1XX
Trying 10.10.0.1XX...
Connected to 10.10.0.1XX.
Escape character is '^]'.
 === IMPORTANT ============================
  Use 'passwd' to set your login password
  this will disable telnet and enable SSH
 ------------------------------------------


BusyBox v1.15.3 (2013-12-28 17:47:54 NZDT) built-in shell (ash)
Enter 'help' for a list of built-in commands.

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 ---------------------------------------------------
 Backfire (10.03.x Snapshot, r33081)
 ---------------------------------------------------
  * 1/3 shot Kahlua    In a shot glass, layer Kahlua 
  * 1/3 shot Bailey's  on the bottom, then Bailey's, 
  * 1/3 shot Vodka     then Vodka.
 ---------------------------------------------------
root@SDNX:/# 

Creating a boot script

Change to the root users home directory

# cd

Start editing the following file

# vi bootovs-rb532.sh

Enter in the following information being careful to change the top three variables to suit your number in class

#Setup variables
#My IP address is required for the ovsdb server.
MYIP=10.10.0.1XX  

# This is the OpenFlow controller ID which we're going to load into the OVS
CTLIP=10.10.0.X

# This is our DataPath ID
DPID=00000000000000XX

# This is the name of the bridge that we're going to be creating
SW=br0

#What ports are we going to put in the OVS?
DPPORTS="eth0 eth1"

#Alias some variables
VSCTL="ovs-vsctl --db=tcp:$MYIP:9999"
OVSDB=/tmp/ovs-vswitchd.conf.db

# Subroutine to wait until a port is ready
wait_port_listen() {
    port=$1
    while ! `netstat -na | grep $port` ; do
        echo -n .
        sleep 1
    done
}

# Kill off the servers and remove any stale lockfiles
/usr/bin/killall ovsdb-server
/usr/bin/killall ovs-vswitchd
rm /tmp/.ovs-vswitchd.conf.db.~lock~

# Remove the OVS Database and then recreate.
rm -f $OVSDB
ovsdb-tool create $OVSDB /usr/share/openvswitch/vswitch.ovsschema

# Start the OVSDB server and wait until it starts
ovsdb-server $OVSDB --remote=ptcp:9999:$MYIP &
#wait_port_listen 9999
sleep 5

# Start vSwitchd
ovs-vswitchd tcp:$MYIP:9999 --pidfile=ovs-vswitchd.pid --overwrite-pidfile -- &

# Create the bridge and pass in some configuration options
$VSCTL add-br $SW -- set bridge $SW datapath_type=netdev
$VSCTL set bridge $SW datapath_type=netdev
$VSCTL set bridge $SW protocols=OpenFlow13

#Cycle through the DataPath ports adding them to the switch
for i in $DPPORTS ; do
    PORT=$i
        ifconfig $PORT up
    $VSCTL add-port $SW $PORT 
done

#Ensure that the switch has the correct DataPath ID
$VSCTL set bridge $SW other-config:datapath-id=$DPID

#Configure the switch to have an OpenFlow Controller.  This will contact the controller.
$VSCTL set-controller $SW tcp:$CTLIP:6633

Make the file executable

# chmod 755 /root/bootovs-rb532.sh

Edit the startup script to start this by default

# vi /etc/rc.local

Change the file to look like this.

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.
/root/bootovs-rb532.sh
exit 0

Creating a flow monitor script

Start editing the following file

# cd
# vi monitor_flows.sh

Put the following information into that file

#!/bin/ash

clear
while true
do
        date
        ovs-ofctl -O OpenFlow13 dump-flows br0
        sleep 5
        clear
done

Make the file executable

    # chmod 755 /root/monitor_flows.sh

Running the bootscript

Even if the script has been started at boot time it's ok to start it from the command line. The script will kill any existing instances of the daemons.

Here is an example below

# /root/bootovs-rb532.sh 
2014-01-28T03:05:18Z|00001|ovsdb_server|INFO|ovsdb-server (Open vSwitch) 2.0.0
2014-01-28T03:05:23Z|00001|reconnect|INFO|tcp:10.10.0.101:9999: connecting...
2014-01-28T03:05:23Z|00002|reconnect|INFO|tcp:10.10.0.101:9999: connected
2014-01-28T03:05:23Z|00003|bridge|INFO|bridge br0: added interface br0 on port 65534
2014-01-28T03:05:23Z|00004|dpif_linux|ERR|Generic Netlink family 'ovs_datapath' does not exist. The Open vSwitch kernel module is probably not loaded.
2014-01-28T03:05:23Z|00005|bridge|INFO|bridge br0: using datapath ID 0000ee25de8f4343
2014-01-28T03:05:23Z|00006|connmgr|INFO|br0: added service controller "punix:/var/run/br0.mgmt"
2014-01-28T03:05:23Z|00007|bridge|INFO|ovs-vswitchd (Open vSwitch) 2.0.0
2014-01-28T03:05:24Z|00008|connmgr|INFO|br0: re-added service controller "punix:/var/run/br0.mgmt"
2014-01-28T03:05:24Z|00009|bridge|INFO|bridge br0: added interface eth0 on port 1
2014-01-28T03:05:24Z|00010|bridge|INFO|bridge br0: using datapath ID 0000000c42065803
2014-01-28T03:05:25Z|00011|bridge|INFO|bridge br0: added interface eth1 on port 2
2014-01-28T03:05:25Z|00012|bridge|INFO|bridge br0: using datapath ID 0000000000000001
2014-01-28T03:05:25Z|00013|connmgr|INFO|br0: added primary controller "tcp:10.10.0.4:6633"
2014-01-28T03:05:25Z|00014|rconn|INFO|br0<->tcp:10.10.0.4:6633: connecting...
2014-01-28T03:05:26Z|00015|rconn|INFO|br0<->tcp:10.10.0.4:6633: connection timed out
2014-01-28T03:05:26Z|00016|rconn|INFO|br0<->tcp:10.10.0.4:6633: waiting 1 seconds before reconnect
2014-01-28T03:05:27Z|00017|rconn|INFO|br0<->tcp:10.10.0.4:6633: connecting...
2014-01-28T03:05:28Z|00018|rconn|INFO|br0<->tcp:10.10.0.4:6633: connection timed out
2014-01-28T03:05:28Z|00019|rconn|INFO|br0<->tcp:10.10.0.4:6633: waiting 2 seconds before reconnect
2014-01-28T03:05:28Z|00002|memory|INFO|1440 kB peak resident set size after 10.2 seconds
2014-01-28T03:05:28Z|00003|memory|INFO|cells:200 monitors:1 sessions:1
2014-01-28T03:05:30Z|00020|rconn|INFO|br0<->tcp:10.10.0.4:6633: connecting...
2014-01-28T03:05:32Z|00021|rconn|INFO|br0<->tcp:10.10.0.4:6633: connection timed out
2014-01-28T03:05:32Z|00022|rconn|INFO|br0<->tcp:10.10.0.4:6633: waiting 4 seconds before reconnect
2014-01-28T03:05:33Z|00023|memory|INFO|1720 kB peak resident set size after 10.2 seconds
2014-01-28T03:05:33Z|00024|memory|INFO|facets:2 ofconns:1 ports:3 rules:10 subfacets:2
2014-01-28T03:05:36Z|00025|rconn|INFO|br0<->tcp:10.10.0.4:6633: connecting...
2014-01-28T03:05:39Z|00026|rconn|INFO|br0<->tcp:10.10.0.4:6633: connection failed (No route to host)
2014-01-28T03:05:39Z|00027|rconn|INFO|br0<->tcp:10.10.0.4:6633: continuing to retry connections in the background but suppressing further logging
2014-01-28T03:05:40Z|00028|fail_open|WARN|Could not connect to controller (or switch failed controller's post-connection admission control policy) for 15 seconds, failing open

You can see that in this case OVS is trying and failing to contact the OpenFlow controller. We will fix this in a later lab.

--End