[ovs-dev] [PATCH 1/3] dpif: Refactor dpif_probe_feature()

Andy Zhou azhou at ovn.org
Thu Mar 9 22:50:08 UTC 2017


Allow actions to be part of the probe. No functional changes.
Future patch will make use this new API.

Signed-off-by: Andy Zhou <azhou at ovn.org>
---
 lib/dpif.c             | 8 ++++++--
 lib/dpif.h             | 3 ++-
 ofproto/ofproto-dpif.c | 8 ++++----
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/lib/dpif.c b/lib/dpif.c
index 5c17f18..dad0fcd 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -897,19 +897,23 @@ dpif_flow_flush(struct dpif *dpif)
  */
 bool
 dpif_probe_feature(struct dpif *dpif, const char *name,
-                   const struct ofpbuf *key, const ovs_u128 *ufid)
+                   const struct ofpbuf *key, const struct ofpbuf *actions,
+                   const ovs_u128 *ufid)
 {
     struct dpif_flow flow;
     struct ofpbuf reply;
     uint64_t stub[DPIF_FLOW_BUFSIZE / 8];
     bool enable_feature = false;
     int error;
+    const struct nlattr *nl_actions = actions ? actions->data : NULL;
+    const size_t nl_actions_size = actions ? actions->size : 0;
 
     /* Use DPIF_FP_MODIFY to cover the case where ovs-vswitchd is killed (and
      * restarted) at just the right time such that feature probes from the
      * previous run are still present in the datapath. */
     error = dpif_flow_put(dpif, DPIF_FP_CREATE | DPIF_FP_MODIFY | DPIF_FP_PROBE,
-                          key->data, key->size, NULL, 0, NULL, 0,
+                          key->data, key->size, NULL, 0,
+                          nl_actions, nl_actions_size,
                           ufid, NON_PMD_CORE_ID, NULL);
     if (error) {
         if (error != EINVAL) {
diff --git a/lib/dpif.h b/lib/dpif.h
index f81d9fe..5d49b11 100644
--- a/lib/dpif.h
+++ b/lib/dpif.h
@@ -519,7 +519,8 @@ enum dpif_flow_put_flags {
 };
 
 bool dpif_probe_feature(struct dpif *, const char *name,
-                        const struct ofpbuf *key, const ovs_u128 *ufid);
+                        const struct ofpbuf *key, const struct ofpbuf *actions,
+                        const ovs_u128 *ufid);
 void dpif_flow_hash(const struct dpif *, const void *key, size_t key_len,
                     ovs_u128 *hash);
 int dpif_flow_flush(struct dpif *);
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 4ef7166..5289693 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -822,7 +822,7 @@ check_recirc(struct dpif_backer *backer)
     ofpbuf_use_stack(&key, &keybuf, sizeof keybuf);
     odp_flow_key_from_flow(&odp_parms, &key);
     enable_recirc = dpif_probe_feature(backer->dpif, "recirculation", &key,
-                                       NULL);
+                                       NULL, NULL);
 
     if (enable_recirc) {
         VLOG_INFO("%s: Datapath supports recirculation",
@@ -859,7 +859,7 @@ check_ufid(struct dpif_backer *backer)
     odp_flow_key_from_flow(&odp_parms, &key);
     dpif_flow_hash(backer->dpif, key.data, key.size, &ufid);
 
-    enable_ufid = dpif_probe_feature(backer->dpif, "UFID", &key, &ufid);
+    enable_ufid = dpif_probe_feature(backer->dpif, "UFID", &key, NULL, &ufid);
 
     if (enable_ufid) {
         VLOG_INFO("%s: Datapath supports unique flow ids",
@@ -973,7 +973,7 @@ check_max_mpls_depth(struct dpif_backer *backer)
 
         ofpbuf_use_stack(&key, &keybuf, sizeof keybuf);
         odp_flow_key_from_flow(&odp_parms, &key);
-        if (!dpif_probe_feature(backer->dpif, "MPLS", &key, NULL)) {
+        if (!dpif_probe_feature(backer->dpif, "MPLS", &key, NULL, NULL)) {
             break;
         }
     }
@@ -1166,7 +1166,7 @@ check_##NAME(struct dpif_backer *backer)                                    \
                                                                             \
     ofpbuf_use_stack(&key, &keybuf, sizeof keybuf);                         \
     odp_flow_key_from_flow(&odp_parms, &key);                               \
-    enable = dpif_probe_feature(backer->dpif, #NAME, &key, NULL);           \
+    enable = dpif_probe_feature(backer->dpif, #NAME, &key, NULL, NULL);     \
                                                                             \
     if (enable) {                                                           \
         VLOG_INFO("%s: Datapath supports "#NAME, dpif_name(backer->dpif));  \
-- 
1.8.3.1



More information about the dev mailing list