<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">Hi Greg, <o:p></o:p></p>
<p class="MsoNormal">I realized I didn’t give a lot of context.. <o:p></o:p></p>
<p class="MsoNormal">Basically, I’m implementing a custom action which is meant to buffer an x amount of dp_packets that match a certain flow, and then send a new packet directly from the switch, containing the buffer of packets, as its payload. At some other
 switch this payload is then meant to be extracted so that I can retrieve the buffer of dp_packets and send the single packets contained in the buffer to the correct hosts.
<o:p></o:p></p>
<p class="MsoNormal">My action is implemented in userspace only for now since efficiency isn’t a concern for me atm. I already implemented the buffering mechanism and it works, and now I’m trying to create this custom udp packet so that I can store the buffer
 in it. For now I’m only trying to create a dummy udp packet with a “hello world” string as its payload just to see if I can create this custom packet however I just can’t figure out what I’m missing. My most recent attempt is the following:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">1.Extract flow from one of the previously stored dp_packets<o:p></o:p></p>
<p class="MsoNormal">2.create a new dp_packet with dp_packet_new(65035)<o:p></o:p></p>
<p class="MsoNormal">3.use flow_compose() function on new packet to create a valid packet<o:p></o:p></p>
<p class="MsoNormal">4.add payload with dp_packet_put<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Code:<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">struct flow flow;<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">flow_extract(&dp_packet_buff1[0].packet, &flow);<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">flow_compose(packetAggr, &flow, NULL, 0);<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">char * payload = "hello world";<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">dp_packet_put(packetAggr, payload, sizeof payload);
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">if I print out the payload I get the string “hello w” so maybe I’m forgetting something when I build the new packet.<o:p></o:p></p>
<p class="MsoNormal">Any help is very appreciated! <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Cheers,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:12.0pt">L<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="border:none;padding:0in"><b>From: </b><a href="mailto:gvrose8192@gmail.com">Gregory Rose</a><br>
<b>Sent: </b>Friday, June 5, 2020 18:58<br>
<b>To: </b><a href="mailto:luca.mancini@outlook.com">Luca Mancini</a>; <a href="mailto:ovs-discuss@openvswitch.org">
ovs-discuss@openvswitch.org</a><br>
<b>Subject: </b>Re: [ovs-discuss] DP_Packet Payload Modification</p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><br>
<br>
On 6/4/2020 10:06 AM, Luca Mancini wrote:<br>
> Hello,<br>
> This is sort of a repost from my previous question about creating a custom udp payload.<br>
> I figured I could just clone a received udp payload and modify its payload, do you think this is possible?  I tried creating a packet from 0 but I just couldn’t manage to do it.<br>
> <br>
> I’m guessing I could do something along the lines of dp_packet_clone(), dp_packet_l4() to get the pointer to the UDP header and then overwrite it with memcpy?<br>
> Any help is really appreciated, Thanks!<br>
> <br>
> Luca Mancini<br>
<br>
Luca,<br>
<br>
I'm having a hard time understanding this.  If you want to generate a<br>
UDP packet with custom payload why not just use scapy or some other such<br>
tool?<br>
<br>
- Greg<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>