On Tue, Jan 03, 2017 at 05:27:50PM -0800, Jarno Rajahalme wrote:
> 
> > On Dec 22, 2016, at 9:58 PM, Benli Ye <dani...@vmware.com> wrote:
> > 
> > For 100% sampling, no need to use sample action. Just use
> > userspace action for optimizing.
> > 
> > Signed-off-by: Benli Ye <dani...@vmware.com>
> > ---
> > ofproto/ofproto-dpif-xlate.c | 26 +++++++++++++++++---------
> > tests/ofproto-dpif.at        | 10 +++++-----
> > 2 files changed, 22 insertions(+), 14 deletions(-)
> > 
> > diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
> > index 3eb94ac..a133e16 100644
> > --- a/ofproto/ofproto-dpif-xlate.c
> > +++ b/ofproto/ofproto-dpif-xlate.c
> > @@ -2506,18 +2506,24 @@ compose_sample_action(struct xlate_ctx *ctx,
> >                       const odp_port_t tunnel_out_port,
> >                       bool include_actions)
> > {
> > +    bool isSample = false;
> 
> OVS CodingStyle recommends underscores to separate words in identifier names:
> 
> "Naming
> ------
> 
> - Use names that explain the purpose of a function or object.
> 
> - Use underscores to separate words in an identifier: ``multi_word_name``."
> 
> 
> > +    size_t sample_offset, actions_offset;
> > +
> >     if (probability == 0) {
> >         /* No need to generate sampling or the inner action. */
> >         return 0;
> >     }
> > 
> > -    size_t sample_offset = nl_msg_start_nested(ctx->odp_actions,
> > -                                               OVS_ACTION_ATTR_SAMPLE);
> > -
> > -    nl_msg_put_u32(ctx->odp_actions, OVS_SAMPLE_ATTR_PROBABILITY, 
> > probability);
> > -
> > -    size_t actions_offset = nl_msg_start_nested(ctx->odp_actions,
> > -                                                OVS_SAMPLE_ATTR_ACTIONS);
> > +    /* No need to generate sample action for 100% sampling rate. */
> > +    if (probability < UINT32_MAX) {
> 
> 
> Maybe like this:
> 
>   bool using_sample = probability < UINT32_MAX;
> 
>   if (using_sample) {

I applied this a few weeks back.  My change to it was remarkably similar
to your suggestion.
_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to