]> 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 8a8c0b8b4f63a4bd8e5ff776250189558e6fcb1e..a0ac410e9570abf493370f04990aef55695de750 100644 (file)
@@ -611,7 +611,7 @@ static int output_userspace(struct datapath *dp, struct sk_buff *skb,
                            struct sw_flow_key *key, const struct nlattr *attr,
                            const struct nlattr *actions, int actions_len)
 {
-       struct ovs_tunnel_info info;
+       struct ip_tunnel_info info;
        struct dp_upcall_info upcall;
        const struct nlattr *a;
        int rem;
@@ -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;
 
@@ -733,7 +736,15 @@ static int execute_set_action(struct sk_buff *skb,
 {
        /* Only tunnel set execution is supported without a mask. */
        if (nla_type(a) == OVS_KEY_ATTR_TUNNEL_INFO) {
-               OVS_CB(skb)->egress_tun_info = nla_data(a);
+               struct ovs_tunnel_info *tun = nla_data(a);
+
+               skb_dst_drop(skb);
+               dst_hold((struct dst_entry *)tun->tun_dst);
+               skb_dst_set(skb, (struct dst_entry *)tun->tun_dst);
+
+               /* FIXME: Remove when all vports have been converted */
+               OVS_CB(skb)->egress_tun_info = &tun->tun_dst->u.tun_info;
+
                return 0;
        }