* [PATCH net-next v3] openvswitch: Make 100 percents packets sampled when sampling rate is 1.
@ 2015-08-05 7:30 Wenyu Zhang
2015-08-05 18:06 ` [ovs-dev] " Pravin Shelar
[not found] ` <1438759847-27666-1-git-send-email-wenyuz-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
0 siblings, 2 replies; 3+ messages in thread
From: Wenyu Zhang @ 2015-08-05 7:30 UTC (permalink / raw)
To: wenyuz-pghWNbHTmq7QT0dZR+AlfA, jgross-pghWNbHTmq7QT0dZR+AlfA,
netdev-u79uwXL29TY76Z2rM5mHXA, dev-yBygre7rU0TnMu66kgdUjQ
When sampling rate is 1, the sampling probability is UINT32_MAX. The packet
should be sampled even the prandom32() generate the number of UINT32_MAX.
And none packet need be sampled when the probability is 0.
Signed-off-by: Wenyu Zhang <wenyuz@vmware.com>
---
net/openvswitch/actions.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index cf04c2f..a0ac410 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -669,9 +669,12 @@ 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)) {
+ u32 probability;
+
switch (nla_type(a)) {
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;
--
1.7.9.5
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [ovs-dev] [PATCH net-next v3] openvswitch: Make 100 percents packets sampled when sampling rate is 1.
2015-08-05 7:30 [PATCH net-next v3] openvswitch: Make 100 percents packets sampled when sampling rate is 1 Wenyu Zhang
@ 2015-08-05 18:06 ` Pravin Shelar
[not found] ` <1438759847-27666-1-git-send-email-wenyuz-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
1 sibling, 0 replies; 3+ messages in thread
From: Pravin Shelar @ 2015-08-05 18:06 UTC (permalink / raw)
To: Wenyu Zhang; +Cc: Jesse Gross, netdev, dev
On Wed, Aug 5, 2015 at 12:30 AM, Wenyu Zhang <wenyuz@vmware.com> wrote:
> When sampling rate is 1, the sampling probability is UINT32_MAX. The packet
> should be sampled even the prandom32() generate the number of UINT32_MAX.
> And none packet need be sampled when the probability is 0.
>
> Signed-off-by: Wenyu Zhang <wenyuz@vmware.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
Thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next v3] openvswitch: Make 100 percents packets sampled when sampling rate is 1.
[not found] ` <1438759847-27666-1-git-send-email-wenyuz-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
@ 2015-08-07 19:01 ` David Miller
0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2015-08-07 19:01 UTC (permalink / raw)
To: wenyuz-pghWNbHTmq7QT0dZR+AlfA
Cc: dev-yBygre7rU0TnMu66kgdUjQ, netdev-u79uwXL29TY76Z2rM5mHXA,
jgross-pghWNbHTmq7QT0dZR+AlfA
From: Wenyu Zhang <wenyuz@vmware.com>
Date: Wed, 5 Aug 2015 00:30:47 -0700
> When sampling rate is 1, the sampling probability is UINT32_MAX. The packet
> should be sampled even the prandom32() generate the number of UINT32_MAX.
> And none packet need be sampled when the probability is 0.
>
> Signed-off-by: Wenyu Zhang <wenyuz@vmware.com>
Applied.
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-08-07 19:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-05 7:30 [PATCH net-next v3] openvswitch: Make 100 percents packets sampled when sampling rate is 1 Wenyu Zhang
2015-08-05 18:06 ` [ovs-dev] " Pravin Shelar
[not found] ` <1438759847-27666-1-git-send-email-wenyuz-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2015-08-07 19:01 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.