[ovs-discuss] OVS custom action

Luca Mancini luca.mancini at outlook.com
Wed Apr 29 15:26:54 UTC 2020


Hi Ben,
Thanks again for helping me out.
I wanted to clarify a bit better how I envisioned my action.
Once the packets are buffered, I’d like to create a new packet who’s payload will contain this buffer, and send this new packet  out the correct port. The packets to be buffered by this action will be chosen by the controller based on the dst-ip, so that the route they will need to take  along the network will be the same.
Eventually, I’ll need to implement another action that performs the opposite of this, that is, extract the packet buffer and output the packets one by one as they were meant to be.

So if this is feasible, correct me if I’m wrong, basically I need to:

  1.  initialize the action in file:ofp-actions.c
  2.  implement my action in file: packet.c,
  3.  call the function created in step 2 from the odp_execute_actions function found in file: odp-execute.c.

Also, in the function I implement in packet.c, once my packet buffer will be full,  I need to find a way to create a new dp_packet with the payload containing the buffer of packets stored previously, and send this new packet with the existing output action.
Thank you very much for your time,

L

From: Ben Pfaff<mailto:blp at ovn.org>
Sent: Tuesday, April 28, 2020 20:59
To: Luca Mancini<mailto:luca.mancini at outlook.com>
Cc: ovs-discuss at openvswitch.org<mailto:ovs-discuss at openvswitch.org>
Subject: Re: [ovs-discuss] OVS custom action

On Sat, Apr 25, 2020 at 08:29:24AM +0000, Luca Mancini wrote:
> Hi Ben,
> Firstly thank you for the swift response,
> In order to get a better understanding of what I was doing (I’ve starting working with openvswitch a week ago) I tried defining an action called OFPAT_RAW_BUFFER (that did absolutely nothing)
> just like the FAQ says and my mininet topology did in fact recognize it as a valid action.
> Now I was starting the actual implementation of the action and that’s where my problems arise, I know how I’m going to program it I just don’t know where I’m meant to implement it and it’s somewhat frustrating.
>
> Based on what you said :
> “You'll need to make the action send packets that need to be buffered to userspace, with a "userspace" kernel action”
> How exactly is this done? I believe the kernel receives the packet, and the datapath folder contains the code where the packet is recvd and processed, how exactly is it then sent to userspace, I’m having a tough time understanding how packets work in ovs.
> Diving in the code I found the ovs_dp_process_packet should be what I’m looking for, but I’m not quite sure.

I don't think you need to modify kernel code at all, or even look at
it.  When userspace sets up the kernel flow, it would add a "userspace"
kernel action to the flow.  Userspace would receive the packet and
buffer it.  When buffering was no longer needed, it would pass it back
to the kernel.

> I guess a more accurate question for my case would be, where does
> someone who is new to ovs start from in order to understand the ovs
> codebase and learn how to implement a new action such as this one?

It might help to look at previous commits that added actions.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openvswitch.org/pipermail/ovs-discuss/attachments/20200429/7ea7a440/attachment.html>


More information about the discuss mailing list