OVS:
Adding a new action to OVS is a long story that you can follow. here is a list of most important code files that you should change:
- lib/ofp-actions.c: Defining new action, encoding, decoding and formating
- include/openvswitch/ofp-actions.h: propagating action
- datapath/linux/compat/include/linux/openvswitch.h: defining in kernel level
- lib/odp-util.c: defining action's bytes length
- ofproto/ofproto-dpif-xlate.c: this file handles comunication between kernel and userspace. specifically when there is no match for a new flow
- datapath/flow_netlink.c: define action's bytes in kernel
- datapath/actions.c: execution action
For complete steps, I highly recommend following Custom Open vSwitch Actions
After changing in source files use these commands in the root directory of OVS to stop, make and run it. be careful that your gcc version should be the same as the version that your Linux header files have been compiled.
ovs-ctl stop
ovs-dpctl del-dp ovs-system
rmmod openvswitch
make clean
make modules_install clean
./boot.sh
./configure --with-linux=/lib/modules/`uname -r`/build --enable-Werror
make
make install
make modules_install
config_file="/etc/depmod.d/openvswitch.conf"
for module in datapath/linux/*.ko; do
modname="$(basename ${module})"
echo "override ${modname%.ko} * extra" >> "$config_file"
echo "override ${modname%.ko} * weak-updates" >> "$config_file"
done
depmod -a
modprobe openvswitch
lsmod | grep openvswitch
mkdir -p /usr/local/etc/openvswitch
ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema
mkdir -p /usr/local/var/run/openvswitch
ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock --remote=db:Open_vSwitch,Open_vSwitch,manager_options --pidfile --detach --log-file
ovs-vsctl --no-wait init
ovs-vswitchd --pidfile --detach --log-file
export PATH=$PATH:/usr/local/share/openvswitch/scripts
ovs-ctl start
Controller:
In the controller, you should be able to create and push Action to switch. I have no information about the way of defining new Action in OpenDayLight but, I know that in Floodlight it is achieved by using Loxigen.
If you had any problem, feel free to contact me.