Commit e05176a3 authored by Wenyu Zhang's avatar Wenyu Zhang Committed by David S. Miller

openvswitch: Make 100 percents packets sampled when sampling rate is 1.

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: default avatarWenyu Zhang <wenyuz@vmware.com>
Acked-by: default avatarPravin B Shelar <pshelar@nicira.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent da8b43c0
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment