Calling dpif_probe_feature() should return if supported or not
without relation to the dpif name.

Signed-off-by: Roi Dayan <r...@nvidia.com>
Reviewed-by: Eli Britstein <el...@nvidia.com>
---
 lib/dpif.c             |  6 ------
 lib/dpif.h             |  1 -
 ofproto/ofproto-dpif.c | 37 ++++++++++++++++++++++++++++++++++++-
 3 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/lib/dpif.c b/lib/dpif.c
index f7b8ffe0fcaa..c539d4a0ac83 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1930,12 +1930,6 @@ log_flow_get_message(const struct dpif *dpif,
     }
 }
 
-bool
-dpif_supports_tnl_push_pop(const struct dpif *dpif)
-{
-    return dpif_is_netdev(dpif);
-}
-
 bool
 dpif_is_recheck_support_needed(const struct dpif *dpif)
 {
diff --git a/lib/dpif.h b/lib/dpif.h
index d40342914f5b..56bd174a9de9 100644
--- a/lib/dpif.h
+++ b/lib/dpif.h
@@ -939,7 +939,6 @@ int dpif_get_pmds_for_port(const struct dpif * dpif, 
odp_port_t port_no,
                            unsigned int **pmds, size_t *n);
 
 char *dpif_get_dp_version(const struct dpif *);
-bool dpif_supports_tnl_push_pop(const struct dpif *);
 bool dpif_is_recheck_support_needed(const struct dpif *);
 bool dpif_synced_dp_layers(struct dpif *);
 
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 15cb53c115da..5664ab2c9238 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -1397,6 +1397,41 @@ check_ct_timeout_policy(struct dpif_backer *backer)
     return !error;
 }
 
+/* Tests whether backer's datapath supports the
+ * OVS_ACTION_ATTR_TUNNEL_POP action. */
+static bool
+check_tnl_pop_action(struct dpif_backer *backer)
+{
+    uint8_t actbuf[NL_A_U32_SIZE];
+    struct odputil_keybuf keybuf;
+    struct ofpbuf actions;
+    struct ofpbuf key;
+    bool supported;
+
+    struct flow flow = {
+        .dl_type = CONSTANT_HTONS(0x1234), /* bogus */
+    };
+    struct odp_flow_key_parms odp_parms = {
+        .flow = &flow,
+        .probe = true,
+    };
+
+    ofpbuf_use_stack(&key, &keybuf, sizeof keybuf);
+    odp_flow_key_from_flow(&odp_parms, &key);
+
+    ofpbuf_use_stack(&actions, &actbuf, sizeof actbuf);
+    nl_msg_put_u32(&actions, OVS_ACTION_ATTR_TUNNEL_POP, 0x1234);
+
+    supported = dpif_probe_feature(backer->dpif, "tunnel_pop", &key, &actions,
+                                   NULL);
+
+    VLOG_INFO("%s: Datapath %s tunnel_pop action",
+              dpif_name(backer->dpif),
+              (supported) ? "supports" : "does not support");
+
+    return supported;
+}
+
 /* Tests whether backer's datapath supports the OVS_ACTION_ATTR_DROP action. */
 static bool
 check_drop_action(struct dpif_backer *backer)
@@ -1731,7 +1766,7 @@ check_support(struct dpif_backer *backer)
     backer->rt_support.masked_set_action = check_masked_set_action(backer);
     backer->rt_support.trunc = check_trunc_action(backer);
     backer->rt_support.ufid = check_ufid(backer);
-    backer->rt_support.tnl_push_pop = dpif_supports_tnl_push_pop(backer->dpif);
+    backer->rt_support.tnl_push_pop = check_tnl_pop_action(backer);
     backer->rt_support.clone = check_clone(backer);
     backer->rt_support.sample_nesting = check_max_sample_nesting(backer);
     backer->rt_support.ct_eventmask = check_ct_eventmask(backer);
-- 
2.21.0

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to