OvS: ovs-ofctl adding parameters analysis

if using dpdk, then OvS' datapath folder is ignored. Only OvS' userspace code are in use. According to manpages of ovs-vsctl/ovs-dpctl, it says that these commands are not responsible for controlling datapath of switch over userspace, and that ovs-ofctl is in charge.

Time to analyse ovs-ofctl.c file. It has a main function.

this function encapsulates argv/argc into ctx. where we can see:

the parse_option is a ovs global function parses all the ovs-related functions program name and options. We are not caring for this function.

the useful functions are the ovs_cmdl_run_command(_read_only), the two functions are both encapsulation of ovs_cmdl_run_command__ inner function.

 

in this function, we look the important part:

here we iterates all the commands to see if argv is the following of:

if same as the written commands, then call the corresponding function with ctx.

I am going to add a flow rule, so I follow into the function dpctl_add_flow..

I will skip some steps, here we can see the codes that specifies the flow:

and the following is the command parser for flow specifier:

here we see the code that extract all the actions commands do to a specified flow into actions:

 

follow into the function parse_odp_action, we can see it is this function that read command and call the corresponding function with the right ctx.

it consists of blocks of code. We can add names to it and call functions to set label to this flow, for future use to seperate flows and call functions..

once added commands and labels, (lables are in include/odp-netlink.h) we can set functions to call when certain flow matches..

it is in odp-execute.c:

add a case according to our previous work and do the work to the packets as we like.

 

In short, to modify ovs flow control works, 3 files to modify:

include/odp-netlink.h

lib/odp-util.c

lib/odp-execute.c

posted on 2017-01-04 15:45  三叁  阅读(464)  评论(0编辑  收藏  举报

导航