OpenvSwitch Configure from Packages and Attaching to a Floodlight OpenFlow Controller
OpenvSwitch Configure from Packages and Attaching to a Floodlight OpenFlow Controller:ย Couple folks have asked about installing OpenvSwitch from packages on Ubuntu 12.04 as opposed to from source. The default repos have v1.4 up so almost at the latest v1.4.1. OVS will be the de facto vSwitch in the hyper-scale providers in the future in my opinion. As Vmware’s Nicira acquisition merges it will percolate into the enterprise. So its a good time to learn software switching and OVS is the best platform to start with.
OpenvSwitch Configure from Packages
This is currently not building on Ubuntu 13.04 w/ 3.8.0-29-generic. Give installing from the tarball a run. Detailed instructions are located in the INSTALL file in the root of the release. A post covering the build and overlay tunnels can be found at the following link:
Configuring VXLAN and GRE Tunnels on OpenvSwitch
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
apt-get update apt-get install -y git automake autoconf gcc uml-utilities libtool build-essential git pkg-config linux-headers-`uname -r` wget http://openvswitch.org/releases/openvswitch-1.10.0.tar.gz tar zxvf openvswitch-1.10.0.tar.gz cd openvswitch-1.10.0 ./boot.sh ./configure --with-linux=/lib/modules/`uname -r`/build make && make install make modules_install insmod datapath/linux/openvswitch.ko mkdir -p /usr/local/etc/openvswitch ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema ovsdb-server -v --remote=punix:/usr/local/var/run/openvswitch/db.sock \ --remote=db:Open_vSwitch,manager_options \ --private-key=db:SSL,private_key \ --certificate=db:SSL,certificate \ --pidfile --detach --log-file ovs-vsctl --no-wait init ovs-vswitchd --pidfile --detach ovs-vsctl show |
If running an Ubuntu 12.x distribution the following may still work.
1 2 3 4 5 |
$apt-get install openvswitch-datapath-source bridge-utils $module-assistant auto-install openvswitch-datapathย $apt-get install openvswitch-switch openvswitch-common openvswitch-controller |
Verify install
1 2 3 4 |
$ ovs-vsctl show ovs_version: "1.4.0+build0" |
Processes should look something like this
1 2 3 4 5 6 7 8 |
$ ps -ea | grep ov 26464 ? 00:00:00 ovsdb-server 26465 ? 00:00:00 ovsdb-server 26473 ? 00:00:00 ovs-vswitchd 26474 ? 00:00:00 ovs-vswitchd 26637 ? 00:00:00 ovs-controller |
Restart OVS (probably not necessary)
1 2 3 |
$ /etc/init.d/openvswitch-switch restart |
You can see the version of OVS and the configuration using the following.
1 2 3 |
$ ovs-vsctl show |
Add your bridge, think of this as a subnet or container for VLAN IDs if you aren’t familiar with the term. Each DPID is a separate data plane that appears as a separate switch to something like an OpenFlow controller.
1 2 3 |
$ovs-vsctl add-br br0 |
Add a physical interface to your virtual bridge for connectivity off box. If you don’t script this part you will probably clip your connection as you zero out eth0 and apply it to br0. You can pop the commands into a text file and make it executable with chmod +x.
You can edit the /etc/network/interfaces file for it to be persistent through reboots or use ifconfig from the CLI but it will be temporary. If learning, just use ifconfig, it is good to know Linux networking for the future.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
auto br0 iface br0 inet static address 192.168.1.208 network 192.168.1.0 netmask 255.255.255.0 broadcast 192.168.1.255 gateway 192.168.1.1 #Add your physical interface to the bridge. bridge_ports eth0 bridge_fd 9 bridge_hello 2 bridge_maxage 12 bridge_stp off dns-nameservers 8.8.8.8 |
This will add the physical port (eth0) to the logical bridge (br0).
1 2 3 |
ovs-vsctl add-port br0 eth0 |
Once you edit the file restart networking. *This will cut you off but you should be able to attach to the br0 (bridge) address you added on the same subnet.
1 2 3 |
$/etc/init.d/networking restart |
After you restart networking your ifconfig and route -n should look something like this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
ย ifconfig br0 Link encap:Ethernet HWaddr 0e:85:8b:d1:4b:44 inet addr:192.168.1.208 Bcast:172.31.247.255 Mask:255.255.254.0 inet6 addr: fe80::c85:8bff:fed1:4b44/64 Scope:Link UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1 RX packets:156 errors:0 dropped:0 overruns:0 frame:0 TX packets:103 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:14218 (14.2 KB) TX bytes:15524 (15.5 KB) eth0 Link encap:Ethernet HWaddr 52:54:00:11:11:11 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:27460 errors:0 dropped:0 overruns:0 frame:0 TX packets:19673 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:64786777 (64.7 MB) TX bytes:1518312 (1.5 MB) |
1 2 3 4 5 6 7 8 |
route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 172.31.246.1 0.0.0.0 UG 100 0 0 br0 169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 br0 172.31.246.0 0.0.0.0 255.255.254.0 U 0 0 0 br0 |
Manually using ifconfig if you didn’t edit /etc/network/interfaces
Zero out your eth0 interface and slap it on the bridge interface
(warning will clip you unless you script it)
1 2 3 4 5 6 7 8 |
$brctl add-br br0 if you do not have a br0 interface from ovs. $ifconfig eth0 0 $ifconfig br0 192.168.1.208 netmask 255.255.255.0 #Change your df route $route add default gw 192.168.1.1 br0 andย $route del default gw 192.168.1.1 eth0 |
Show the bridging tables
1 2 3 4 5 6 7 8 9 10 |
# ovs-appctl fdb/show br0 port VLAN MAC Age 1 0 00:1d:09:aa:71:16 47 1 0 00:9c:02:b2:76:c0 18 1 0 68:a8:6d:11:9b:8e 13 0 0 00:50:56:25:21:68 9 1 0 10:40:f3:94:e0:82 5 1 0 00:23:69:62:26:09 0 |
Connect OpenvSwitch to the the OpenFlow Controller
1 2 3 |
ovs-vsctl set-controller br-int tcp:192.168.1.208:6633 |
Attaching to a Floodlight OpenFlow Controller
http://networkstatic.net/floodlight-openflow-controller-screencast-with-hp-switches/
Output from the Floodlight controller:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<strong>00:38:05.808</strong> [New I/O server worker #1-1] INFO n.f.core.internal.Controller - New switch connection from /192.168.1.155:43966 <strong>00:38:05.825</strong> [New I/O server worker #1-1] DEBUG n.f.core.internal.Controller - HELLO from OFSwitchImpl [/192.168.1.155:43966 DPID[?]] <strong>00:38:05.828</strong> [New I/O server worker #1-1] DEBUG n.f.core.internal.Controller - Features Reply from OFSwitchImpl [/192.168.1.155:43966 DPID[?]] <strong>00:38:05.839</strong> [New I/O server worker #1-1] INFO n.f.core.internal.Controller - This controllers role is null - not sending role-request-msg <strong>00:38:05.839</strong> [New I/O server worker #1-1] DEBUG n.f.core.internal.Controller - Config Reply from OFSwitchImpl [/192.168.1.155:43966 DPID[00:00:00:50:56:25:21:68]] confirms miss length set to 0xffff <strong>00:38:05.846</strong> [New I/O server worker #1-1] INFO n.f.core.internal.Controller - Switch handshake successful: OFSwitchImpl [/192.168.1.155:43966 DPID[00:00:00:50:56:25:21:68]] <strong>00:38:05.848</strong> [main] DEBUG n.f.core.internal.Controller - Dispatching switch update OFSwitchImpl [/192.168.1.155:43966 DPID[00:00:00:50:56:25:21:68]] true <strong>00:38:05.848</strong> [main] DEBUG n.f.s.StaticFlowEntryPusher - addedSwitch OFSwitchImpl [/192.168.1.155:43966 DPID[00:00:00:50:56:25:21:68]]; processing its static entries |
Any who, plug away with a hypervisor and build the next-gen of computing! No need to wait on someone to hand it to us. Get rich while you are at it :0 Make it rain and stuff.
Add KVM and build instances using taps from OVS:
http://networkstatic.net/installing-openvswitch-on-ubuntu-11-10-with-kvm/
Or Quantum and OpenStack for the more adventurous:
http://networkstatic.net/openstack-essex-and-quantum-installation-using-openvswitch-from-scratch/
Brent,
Thanks for the nice step by step instruction.
I did this:
Edit /etc/default/openvswitch-switch and change brcompat from no to yes
Change from:
#BRCOMPAT=no
TO and uncomment by removing the #:
BRCOMPAT=yes and try to restart the OVS, I got this:
stack@openstack1:~$ sudo /etc/init.d/openvswitch-switch restart
* ovs-brcompatd is not running
* Killing ovs-vswitchd (5998)
* Killing ovsdb-server (5989)
FATAL: Error inserting brcompat_mod (/lib/modules/3.2.0-23-generic/kernel/brcompat_mod.ko): Invalid module format
* Inserting brcompat module
Module has probably not been built for this kernel.
For instructions, read
/usr/share/doc/openvswitch-datapath-source/README.Debian
FATAL: Error inserting brcompat_mod (/lib/modules/3.2.0-23-generic/kernel/brcompat_mod.ko): Invalid module format
* Inserting brcompat module
Do you know why? I tried to read the README suggested in the message and can not make sense out of it. Thanks.
Robert
Hi Robert. Add the bridge-utils package e.g. “apt-get install bridge-utils”. Let me know if that works for you.
It is in the tutorial with “apt-get install openvswitch-datapath-source bridge-utils”. I just verified the install last night so I want to make sure that is the problem so let me know. Thanks for the comment and let’s see if that fixes you up!
Thanks,
-Brent
Hy Brent,
your site is very good ๐
I have the same problem as Robert, but the bridge-utils are installed.
Have you any idea?
Thanks
Marcel
Okay,
a restart of the pc was helpful.
thanks
I happened to run into the same problem. The brcompat module failed to load.
Luckily the syslog messages informed me with the message:
brcompat_mod: exports duplicate symbol br_should_route_hook (owned by bridge)
So the bridge module was already loaded and prevented the brcompat module from loading.
The solution is obvious … rmmod bridge and loading brcompat from there on is flawless.
Hey Brent, the article was very informative and I was able to connect to my floodlight controller with ease. However, when I restart my computer and try to connect to the controller again I get this error:
jereme@jereme-OptiPlex-755:~$ sudo ovs-vsctl set-controller br11 tcp:192.17.237.12:6633
Sep 30 11:29:38|00002|stream_unix|ERR|/tmp/stream-unix.5820.0: connection to /var/run/openvswitch/db.sock failed: No such file or directory
Sep 30 11:29:38|00003|reconnect|WARN|unix:/var/run/openvswitch/db.sock: connection attempt failed (No such file or directory)
and now when I grep for ov it only results it:
jereme@jereme-OptiPlex-755:~$ ps -ea | grep ov
5390 ? 00:00:00 ovs-controller
How would I get the services to be running again?
Thanks for any help you may have,
Jereme
Hi jereme, riding in a car offline other than my phone but it sounds like we need to get OVS started. Give “sudo /etc/unit.d/openvswitch-switch start” a go. That should start ovsdb and vswitchd started. Get that in your startup rc scripts. Let me know if you have any problems and I will take a look tonight. Thanks for the feedback and stopping by!
Thanks for the quick response!
However, when running the command you suggested, (sudo /etc/init.d/openvswitch-switch start) results in the same error as above –
FATAL: Error inserting brcompat_mod (/lib/modules/3.2.0-29-generic/kernel/brcompat_mod.ko): Invalid module format
* Inserting brcompat module
Module has probably not been built for this kernel.
For instructions, read
/usr/share/doc/openvswitch-datapath-source/README.Debian
FATAL: Error inserting brcompat_mod (/lib/modules/3.2.0-29-generic/kernel/brcompat_mod.ko): Invalid module format
* Inserting brcompat module
Please note I did not have trouble with this when I initially went through your tutorial, this is now occurring after I reboot the machine.
I get the same error :FATAL: Error inserting brcompat_mod (/lib/modules/3.2.0-29-generic/kernel/brcompat_mod.ko): Invalid module format
* Inserting brcompat module
Module has probably not been built for this kernel.
Did anybody get this resolved? Thanks.
I had this issue as well. Siebe Ytsma’s solutions seems to be correct. Check to make sure the bridge module is not loaded and remove it if it is.
lsmod | grep bridge
rmmod bridge
Then restart OVS. Thanks for the great post!
Jroberts, Thank you It’s work!!
Thanks Jroberts, will update the post w/ that reminder.
Hey Brent, I am at the stop where you change BRCOMPAT from no to yes, and when I do the command:
$ sudo /etc/init.d/openvswitch-switch restart
I get the error:
Could not open brcompat socket. Check “brcompat” kernel module.
Any ideas would be amazing!!
Hey Jerry, I totally managed to miss this comment. Sincerely apologize. In case anyone else had the question I wanted to go ahead and put out there that brcompat is being depreciated and not needed now that the OVS kernel module is upstreamed as of ~3.2 kernel .
I guess there could be an application for a userspace use but not really sure. It should be irrelevant as long as you are using the KO module.
Cheers,
-Brent
Hi Brent,
Many thanks for this page it was really useful, well it too me almost two days to configure and make it work anyway i’m happy that it is working. I have one question though, how come the port where floodlight is hooked up is being shown also as a host. Basically my eth2 ( uplink to floodlight) , my pc port and my vm port are being shown as hosts aswell. Is this normal ? i can’t ping them as it supposed to be because as i read the controller port doesnt allow that :/ Any ideas please ?
Cheers
Etienne!
๐ managed to post in this page now phewww ๐
I blog quite often and I genuinely appreciate your content.
Your article has really peaked my interest. I will bookmark your blog and
keep checking for new information about once a week. I opted
in for your RSS feed too.
Hi thank you for your good step by step instructions.
I follow the steps but when I use ovs-vsctl show command it shows the following text :
54789b58-f44f-475d-8e72-521e4afe124f
why is it like this? what should I do?
Take a look at the Bridge Table in the output of ovsdb-client dump. It is the _UUID of the Open_vSwitch table in OVSDB.
Cheers,
-Brent
hi can OVS work on a ubuntu Virtual Machine that is installed on vmware?
How to configure Openflow protocol on openvswitch?
There is one for that on the front page:
http://networkstatic.net/setting-overlays-open-vswitch/
Thanks,
-brent