]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - net/openvswitch/actions.c
openvswitch: Make 100 percents packets sampled when sampling rate is 1.
[karo-tx-linux.git] / net / openvswitch / actions.c
index cf04c2f8b32a57bfec8e024d2db95dd8c0468b3f..a0ac410e9570abf493370f04990aef55695de750 100644 (file)
@@ -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;