Hi,

After some work I might be on the right track but I’m having trouble debugging 
my action.
I implemented the code below in the ofproto-dpix-xlate.c file and in order to 
debug (since I couldn’t figure out a better way) I create a new file once a 
packet arrives to the switch(with action:”buffr”) and append strings to it 
based on the conditions satisfied, this is the code:

compose_buffr_action(struct xlate_ctx *ctx)
{
    FILE *fp;
    fp = fopen("/root/openvswitch-2.12.0/LogBuffrDebug.txt", "a+");
    fprintf(fp, "I’m in buffr function...\n");

    if(index1 == 0)
    {
        clear_packetBuff(dp_packet_buff1); //sets buffer to all 0s
    }
    if(&dp_packet_buff1[9] == NULL || &dp_packet_buff1[9] == 0 || index1 < 10)
    {
        fputs("go through this 10 times...\n", fp);
        dp_packet_buff1[index1] = *(ctx->xin->packet);
    }
    else if(index1 == 10)
    {
        fputs("go through the 1/10 times...\n", fp);

        uint16_t size_packet = get_packet_buffer_size(dp_packet_buff1);
        char str2[100];
        sprintf(str2, "%d", size_packet);
        strcat(str2, "\n");
        fputs(str2, fp);
    }
    fclose(fp);

from mininet, I have a simple topology  h1 –s1---h2,  I then add the flow with 
command:
                sh ovs-ofctl add-flow s1 in_port=1,action:buffer
and the flow installs correctly.

I ping from h1 to h2, the log file is created, and it only contains the string: 
"go through this 10 times...” twice.
I don’t understand where the other packets go, are they sent to kernel space? 
I’m trying to only work on userspace as I was suggested to do but I can’t seem 
to get around this issue.





From: Luca Mancini<mailto:[email protected]>
Sent: Wednesday, April 29, 2020 17:27
To: Ben Pfaff<mailto:[email protected]>
Cc: [email protected]<mailto:[email protected]>
Subject: Re: [ovs-discuss] OVS custom action

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:[email protected]>
Sent: Tuesday, April 28, 2020 20:59
To: Luca Mancini<mailto:[email protected]>
Cc: [email protected]<mailto:[email protected]>
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.


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

Reply via email to