[ovs-dev] Cloning packets for "action: set field"

Saurabh Shah ssaurabh at vmware.com
Mon Aug 4 19:25:21 UTC 2014


Hi Samuel,

This is a bug. As you rightfully pointed, we shouldn't modify the original packet but instead copy out the relevant bits before modifying them. Copying the entire data buffer is simpler, but sub-optimal. We should only copy out the headers that are being modified. We already have the infrastructure to do this.  I will create an issue to track it.

Thanks!
Saurabh

> -----Original Message-----
> From: dev [mailto:dev-bounces at openvswitch.org] On Behalf Of Samuel
> Ghinet
> Sent: Saturday, August 02, 2014 5:03 AM
> To: dev at openvswitch.org
> Subject: [ovs-dev] Cloning packets for "action: set field"
> 
> Hello guys,
> 
> I wanted to ask you: do you have buffer management functionality to
> duplicate a packet?
> 
> I have seen that the function OvsOutputBeforeSetAction CLONES instead of
> duplicating the packet.
> 
> Did you know that, when cloning a packet, both the old and the cloned
> packet reference the same data (buffer)?
> So that setting bytes, say, in the ipv4 header of the cloned NET_BUFFER
> actually modifies the original NET_BUFFER as well?
> 
> Also, we are not allowed to set data in the original packet. We must create a
> clone / duplicate for this.
> For tunneling (i.e. adding headroom) cloning is ok, because the clone writes
> bytes to the "unused" area of the buffer, or allocates a new MDL for the
> headroom (which is removed at Complete).
> 
> The procedure for setting data within the buffer using cloning is a bit more
> complicated:
> You must allocate a new MDL, copy the 'modified' data into its buffer, and
> chain it to the cloned NET_BUFFER (replacing the old MDL). And at Complete,
> you must free your MDL and put the old MDL back.
> A simpler method would be to duplicate the buffer, instead of cloning it.
> 
> Here the architecture of a cloned NET_BUFFER_LIST is presented:
> https://urldefense.proofpoint.com/v1/url?u=http://msdn.microsoft.com/en
> -
> us/library/windows/hardware/ff544929%28v%3Dvs.85%29.aspx&k=oIvRg1%
> 2BdGAgOoM1BIlLLqw%3D%3D%0A&r=pEkjsHfytvHEWufeZPpgqSOJMdMjuZ
> PbesVsNhCUc0E%3D%0A&m=jhsFuJNgUaiglvJZi08Spr39W%2F4PBNhLh4%2B
> MJdlvCis%3D%0A&s=c65b8be59f4145534cbfafbc06598cd82b85bd4b2f95caee
> d5edd4f657fabed3
> 
> Samuel Ghinet
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> https://urldefense.proofpoint.com/v1/url?u=http://openvswitch.org/mailm
> an/listinfo/dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=pEkjsHfytv
> HEWufeZPpgqSOJMdMjuZPbesVsNhCUc0E%3D%0A&m=jhsFuJNgUaiglvJZi08
> Spr39W%2F4PBNhLh4%2BMJdlvCis%3D%0A&s=a2e562875bfab9326b93c55ff0
> 3bc9dd974c081a4449c5a7a8977b175de72691



More information about the dev mailing list