[ovs-dev] [PATCH v1 1/2] sflow: restrict sampling from 1 to UINT32_MAX

Benli Ye daniely at vmware.com
Fri Dec 16 04:41:29 UTC 2016


When sampling field is 0, no need to generate sample or
the inner action.
---
 ofproto/ofproto-dpif-xlate.c | 5 +++++
 vswitchd/vswitch.ovsschema   | 7 +++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index d0f9a33..840062b 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -2479,6 +2479,11 @@ compose_sample_action(struct xlate_ctx *ctx,
                       const odp_port_t tunnel_out_port,
                       bool include_actions)
 {
+    if (probability == 0) {
+        /* No need to generate sampling or the inner action. */
+        return 0;
+    }
+
     size_t sample_offset = nl_msg_start_nested(ctx->odp_actions,
                                                OVS_ACTION_ATTR_SAMPLE);
 
diff --git a/vswitchd/vswitch.ovsschema b/vswitchd/vswitch.ovsschema
index b04d360..87e00fc 100644
--- a/vswitchd/vswitch.ovsschema
+++ b/vswitchd/vswitch.ovsschema
@@ -1,6 +1,6 @@
 {"name": "Open_vSwitch",
  "version": "7.14.0",
- "cksum": "3374030633 22987",
+ "cksum": "4010240282 23110",
  "tables": {
    "Open_vSwitch": {
      "columns": {
@@ -453,7 +453,10 @@
        "targets": {
          "type": {"key": "string", "min": 1, "max": "unlimited"}},
        "sampling": {
-         "type": {"key": "integer", "min": 0, "max": 1}},
+         "type": {"key": {"type": "integer",
+                          "minInteger": 1,
+                          "maxInteger": 4294967295},
+                  "min": 0, "max": 1}},
        "polling": {
          "type": {"key": "integer", "min": 0, "max": 1}},
        "header": {
-- 
1.9.1



More information about the dev mailing list