Open vSwitch Red Hat Installation
This is an updated tutorial for an Open vSwitch Red Hat Installation. It is a little tricky at the moment from a kernel-devel bug that has a broken symbolic link. I did a screencast also in case anyone gets stuck. Just let me know if I mistyped anything and I will update it.
Install Open vSwitch Pre-Reqs for Red Hat
The OS details are here.
[root@localhost]# uname -a Linux localhost.localdomain 2.6.32-279.el6.x86_64 #1 SMP Fri Jun 22 12:19:21 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux [root@localhost]# cat /etc/redhat-release CentOS release 6.3 (Final)
Next using Yum, install some dependencies.
yum install gcc make python-devel openssl-devel kernel-devel kernel-debug-devel wget http://openvswitch.org/releases/openvswitch-1.7.1.tar.gz tar xvfz openvswitch-1.7.1.tar.gz cd openvswitch-1.7.1
Open vSwitch Red Hat Installation
No need to run -> ./boot.sh from the tarball.
Next fix a bug from kernel-devel before you run ./configure.
cd /lib/modules/2.6.32-279.el6.x86_64/
rm build Add the new symlink based on the output of:
ls /usr/src/kernels/ rm build ln -s /usr/src/kernels/2.6.32-279.14.1.el6.x86_64/ build

Figure 1. It will look something like this. Notice the symbolic link is linked to a bad target. you will simply re-link that.
Once you fix the symlink your configure will run clean so cd back into the openvswitch dir.
cd ~/openvswitch-1.7.1
Now ./configure will go clean.
./configure --with-linux=/lib/modules/uname -r/build
If you leave the bad symlink you will get this error:
configure: error: source dir /lib/modules/2.6.32-279.el6.x86_64/build doesn't exist
Next we need to edit a kernel file and comment something out.
vi openvswitch-1.7.1/datapath/linux/compat/include/linux/skbuff.h
Open skbuff.h and head to line 242 or there about. Find the following code and comment it out.

Figure 2. Edit skbuff.h around line 242.
Change it to reflect the next screenshot by commenting out the following method and next three lines after it.
static inline struct page *skb_frag_page(const skb_frag_t *frag)

Figure 3. Here is what it should look like after the edit.
Now finish the build.
make && make install
If you do not comment out the file properly you will get and error like the following:
make -C /lib/modules/2.6.32-279.el6.x86_64/build M=/home/brent/openvswitch-1.7.1/datapath/linux modules make[4]: Entering directory/usr/src/kernels/2.6.32-279.14.1.el6.x86_64' CC [M] /home/brent/openvswitch-1.7.1/datapath/linux/genetlink-brcompat.o In file included from /home/brent/openvswitch-1.7.1/datapath/linux/compat/include/linux/netlink.h:4, from /home/brent/openvswitch-1.7.1/datapath/linux/compat/include/net/genetlink.h:5, from /home/brent/openvswitch-1.7.1/datapath/linux/compat/genetlink.inc:3, from /home/brent/openvswitch-1.7.1/datapath/linux/genetlink-brcompat.c:10: /home/brent/openvswitch-1.7.1/datapath/linux/compat/include/linux/skbuff.h:242: error: redefinition of ‘skb_frag_page’ include/linux/skbuff.h:1612: note: previous definition of ‘skb_frag_page’ was here make[5]: *** [/home/brent/openvswitch-1.7.1/datapath/linux/genetlink-brcompat.o] Error 1 make[4]: *** [_module_/home/brent/openvswitch-1.7.1/datapath/linux] Error 2 make[4]: Leaving directory/usr/src/kernels/2.6.32-279.14.1.el6.x86_64' make[3]: *** [default] Error 2 make[3]: Leaving directory/home/brent/openvswitch-1.7.1/datapath/linux' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory/home/brent/openvswitch-1.7.1/datapath' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/brent/openvswitch-1.7.1' make: *** [all] Error 2
Now that you got it to build cleanly you need to make sure the linux bridge kernel module is not loaded.
lsmod | grep bridge bridge 79950 0 /sbin/rmmod bridge
Then insert the openvswitch.ko kernel module. Fastpath good, slow path bad. This is executed from within the untarred Open vSwitch directory where you compiled the code so the full path would be /home//openvswitch/datapath/linux/openvswitch.ko.
insmod datapath/linux/openvswitch.ko
If you do not remove the Linux bridge module you will get ths follwoing error.
$ insmod datapath/linux/openvswitch.ko insmod: error inserting 'datapath/linux/openvswitch.ko': -1 Invalid module format $ dmesg | tail openvswitch: exports duplicate symbol br_should_route_hook (owned by bridge)
The rest is just copy and paste.
insmod datapath/linux/openvswitch.ko touch /usr/local/etc/ovs-vswitchd.conf mkdir -p /usr/local/etc/openvswitch ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema ovsdb-server /usr/local/etc/openvswitch/conf.db \ --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 \ --bootstrap-ca-cert=db:SSL,ca_cert --pidfile --detach --log-file ovs-vsctl --no-wait init ovs-vswitchd --pidfile --detach ovs-vsctl show
Configure the Open vSwitch Bridge and Network
ovs-vsctl add-br br0 sudo ifconfig eth0 0 sudo ovs-vsctl add-port br0 eth0 sudo ifconfig br0 192.168.1.20 netmask 255.255.255.0 route add default gw 192.168.1.1 br0
Open vSwitch Red Hat Installation Screencast
Thanks for stopping by, feel free to post any issues, apologies for any delays in response.














I exactly followed the instruction to compile openvswitch-1.4.5 on CentOS 6.3. Compilation was a success. However, when I did ‘insmod openvswitch_mod’, the following error message was found in dmesg:
openvswitch_mod: Undefined symbol ‘kmem_cache_alloc_trace’
Laster I found out that it was caused by a mismatch between the running kernel, which was installed from original ISO, and the kernel headers, which was installed by yum install kernel-devel.
I did a yum distribution-synchronization. Then reboot the system with the up-to-date kernel and redo the compilation. Finally, the kernel module can be insmod without any error.
Great Blog. I’ve found lots of useful information. I really appreciate it.
I just ran these instructions on a CentOS 6.4 system and the kernel-devel bug is not there (I dod not have to fix the symlink).
Thanks again!
CentOS 6.4 kernel already includes the openvswitch kernel module. So just compile the userspace program without –with-linux option.
Thanks Jian!