[ovs-dev] [PATCHv2] ofproto-dpif-sflow: Add snaplen for sample action and sFlow.

Ben Pfaff blp at ovn.org
Sat Jul 2 04:28:20 UTC 2016


On Fri, Jul 01, 2016 at 12:43:02PM -0700, William Tu wrote:
> This patch adds a 'snaplen' field in sample action (nx_action_sample2).
> Currently, sample action is used by sFlow and IPFIX. For IPFIX, nothing
> is changed.  For sFlow configuration, the patch translates header=N to
> a sample action with snaplen=N, then the snaplen=N translates to trunc(N)
> in kernel datapath.  Thus, only N bytes instead of full-packet size will
> be copied from kernel to userspace, saving the copying overhead.
> 
> Also, the patch parses OVS_PACKET_ATTR_LEN from nlattr to upcall related
> structures so the sFlow receiver knows the original packet size before it
> is truncated.
> 
> Tested-at: https://travis-ci.org/williamtu/ovs-travis/builds/141704344
> Signed-off-by: William Tu <u9012063 at gmail.com>
> ---
> v1->v2
> http://openvswitch.org/pipermail/dev/2016-June/072404.html
> - Add snaplen to nx_action_sample2
> - Since truncate then userspace action is supported in userspace datapath,
>   ,commit aaca4fe0ce9e (ofp-actions: Add truncate action.), remove
>   datapath-specific implementation and testcase.

This changes the OpenFlow sample action but it doesn't document the new
feature in ovs-ofctl(8).

The new features should be mentioned in NEWS.

In encode_SAMPLE(), NXAST_RAW_SAMPLE2 should also be selected if
nas->snaplen != 0.

In format_SAMPLE(), I would only output snaplen if it is nonzero (and
not UINT16_MAX?).

The datapath will reject a snaplen less than 14, but I don't see
anything here that prevents userspace from trying such a snaplen.

Thanks,

Ben.



More information about the dev mailing list