Skip to contentSkip to conversation

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

PATCH In review Wenyu Zhang 3 participants 3 messages Aug 5, 2015 – Aug 7, 2015 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 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.

---
 net/openvswitch/actions.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
net/openvswitch/actions.c +4 -1
index cf04c2f..a0ac410 100644
@@ -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;
 
Signature · 6 lines
1.7.9.5

_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

A message that is not in the archive (sent off-list or not yet received): 1438759847-27666-1-git-send-email-wenyuz-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org

#3 lore raw

From: Wenyu Zhang <[email protected]>
Date: Wed, 5 Aug 2015 00:30:47 -0700

Quoted 5 lines

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.

Applied.
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev