[ovs-dev] [PATCH v2 1/3] odp-util: Add utility function, odp_flow_key_to_flow_verbose.

Saurabh Shah ssaurabh at vmware.com
Thu Jul 24 17:24:51 UTC 2014


Signed-off-by: Saurabh Shah <ssaurabh at vmware.com>
---
 lib/dpif-netdev.c |   17 +----------------
 lib/odp-util.c    |   24 ++++++++++++++++++++++++
 lib/odp-util.h    |    2 ++
 3 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index fce2650..01ebcec 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -1185,22 +1185,7 @@ dpif_netdev_flow_from_nlattrs(const struct nlattr *key, uint32_t key_len,
 {
     odp_port_t in_port;
 
-    if (odp_flow_key_to_flow(key, key_len, flow)) {
-        /* This should not happen: it indicates that odp_flow_key_from_flow()
-         * and odp_flow_key_to_flow() disagree on the acceptable form of a
-         * flow.  Log the problem as an error, with enough details to enable
-         * debugging. */
-        static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
-
-        if (!VLOG_DROP_ERR(&rl)) {
-            struct ds s;
-
-            ds_init(&s);
-            odp_flow_format(key, key_len, NULL, 0, NULL, &s, true);
-            VLOG_ERR("internal error parsing flow key %s", ds_cstr(&s));
-            ds_destroy(&s);
-        }
-
+    if (odp_flow_key_to_flow_verbose(key, key_len, flow)) {
         return EINVAL;
     }
 
diff --git a/lib/odp-util.c b/lib/odp-util.c
index 162d85a..1e288ec 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -3466,6 +3466,30 @@ odp_flow_key_to_flow(const struct nlattr *key, size_t key_len,
    return odp_flow_key_to_flow__(key, key_len, flow, flow);
 }
 
+enum odp_key_fitness
+odp_flow_key_to_flow_verbose(const struct nlattr *key, size_t key_len,
+                             struct flow *flow)
+{
+    enum odp_key_fitness error = odp_flow_key_to_flow(key, key_len, flow);
+    if (error) {
+        /* This should not happen: it indicates that odp_flow_key_from_flow()
+         * and odp_flow_key_to_flow() disagree on the acceptable form of a
+         * flow.  Log the problem as an error, with enough details to enable
+         * debugging. */
+        static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
+
+        if (!VLOG_DROP_ERR(&rl)) {
+            struct ds s;
+
+            ds_init(&s);
+            odp_flow_format(key, key_len, NULL, 0, NULL, &s, true);
+            VLOG_ERR("internal error parsing flow key %s", ds_cstr(&s));
+            ds_destroy(&s);
+        }
+    }
+    return error;
+}
+
 /* Converts the 'key_len' bytes of OVS_KEY_ATTR_* attributes in 'key' to a mask
  * structure in 'mask'.  'flow' must be a previously translated flow
  * corresponding to 'mask'.  Returns an ODP_FIT_* value that indicates how well
diff --git a/lib/odp-util.h b/lib/odp-util.h
index 4ce693c..a90a5f4 100644
--- a/lib/odp-util.h
+++ b/lib/odp-util.h
@@ -176,6 +176,8 @@ enum odp_key_fitness {
 };
 enum odp_key_fitness odp_flow_key_to_flow(const struct nlattr *, size_t,
                                           struct flow *);
+enum odp_key_fitness odp_flow_key_to_flow_verbose(const struct nlattr *,
+                                                  size_t, struct flow *);
 enum odp_key_fitness odp_flow_key_to_mask(const struct nlattr *key, size_t len,
                                           struct flow *mask,
                                           const struct flow *flow);
-- 
1.7.9.5




More information about the dev mailing list