[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CALnjE+pA3ctWthHuMqOwrtcHsFAAM=s5Ptpo01h55sQO8yqTCg@mail.gmail.com>
Date: Tue, 4 Aug 2015 15:00:28 -0700
From: Pravin Shelar <pshelar@...ira.com>
To: Wenyu Zhang <wenyuz@...are.com>
Cc: Jesse Gross <jgross@...are.com>,
"dev@...nvswitch.org" <dev@...nvswitch.org>,
netdev <netdev@...r.kernel.org>
Subject: Re: [ovs-dev] [PATCH net-next v2] openvswitch: Make 100 percents
packets sampled when sampling rate is 1.
On Mon, Aug 3, 2015 at 9:07 PM, Wenyu Zhang <wenyuz@...are.com> wrote:
> When sampling rate is 1, the sampling probability is UINT32_MAX. The packet
> should be sampled even the prandom_u32() generate the number of UINT32_MAX.
> And none packet need be sampled when the probability is 0.
>
> Signed-off-by: Wenyu Zhang <wenyuz@...are.com>
Patch looks good, I have following minor comments.
> ---
> net/openvswitch/actions.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
> index cf04c2f..c81bcf5 100644
> --- a/net/openvswitch/actions.c
> +++ b/net/openvswitch/actions.c
> @@ -669,9 +669,11 @@ static int sample(struct datapath *dp, struct sk_buff *skb,
>
> for (a = nla_data(attr), rem = nla_len(attr); rem > 0;
> a = nla_next(a, &rem)) {
> + uint32_t probability;
> switch (nla_type(a)) {
There should be blank line after variable definitions.
> case OVS_SAMPLE_ATTR_PROBABILITY:
> - if (prandom_u32() >= nla_get_u32(a))
> + probability = nla_get_u32(a);
> + if (!probability || prandom_u32() > probability)
> return 0;
> break;
>
I got following warning on checkpatch.pl
./scripts/checkpatch.pl
0001-openvswitch-Make-100-percents-packets-sampled-when-s.patch
CHECK: Prefer kernel type 'u32' over 'uint32_t'
#24: FILE: net/openvswitch/actions.c:672:
+ uint32_t probability;
total: 0 errors, 0 warnings, 1 checks, 12 lines checked
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists