Hi Tommy,

Here’s how I do it.  It’s essentially the same as what the ‘ovs-ofctl add-flow’ 
command does under the hood.

1. Build a string formatted as the “ovs-ofctl” command would do, for example 
“table=1,cookie=0xdeadbeef,in_port=1,actions=resubmit(,2)”
2. Pass this to parser_ofp_flow_mod_str().  The parser will magically parse the 
string in to a rich struct.
3. Pass the struct to ofputil_encode_flow_mod().  This returns a struct with a 
serialized OpenFlow message buffer.
4. Send this buffer on the wire either via a socket you manage yourself or let 
OpenVswitch do it for you.

—Ben

> On Oct 16, 2017, at 2:05 PM, Tommy Romano <[email protected]> wrote:
> 
> My project was previously calling system commands like ‘ovs-ofctl add-flow’ 
> directly from C, but we would like to do this programmatically now, by 
> calling into the openvswitch library. After looking at this for a bit and 
> what methods I would have to call, I’ve realized this is non trivial, and I 
> can’t find any easily exposed methods to add and delete flows. Does anyone 
> have an example anywhere of calling into openvswitch methods directly to 
> add/remove flows? So far the best way I can find is calling into 
> ovn/controller/ofctrl.h:ofctrl_add_flow(…), but this will require quite a bit 
> of legwork.
> Best,
> Tommy Romano
> _______________________________________________
> discuss mailing list
> [email protected] <mailto:[email protected]>
> https://mail.openvswitch.org/mailman/listinfo/ovs-discuss 
> <https://mail.openvswitch.org/mailman/listinfo/ovs-discuss>

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
discuss mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-discuss

Reply via email to