Add rte_flow_validate to verify the flow before calling rte_flow_create. 58/18558/3
authorSimon Zhang <[email protected]>
Thu, 28 Mar 2019 08:38:49 +0000 (16:38 +0800)
committerDave Wallace <[email protected]>
Fri, 17 May 2019 12:57:27 +0000 (12:57 +0000)
Change-Id: I817580963e38bafcc53cc6502b9c58f567070244
Signed-off-by: Simon Zhang <[email protected]>
src/plugins/dpdk/device/flow.c

index 63f04b8..fe52bcb 100644 (file)
@@ -209,12 +209,23 @@ dpdk_flow_add (dpdk_device_t * xd, vnet_flow_t * f, dpdk_flow_entry_t * fe)
   vec_add2 (actions, action, 1);
   action->type = RTE_FLOW_ACTION_TYPE_END;
 
+  rv = rte_flow_validate (xd->device_index, &ingress, items, actions,
+                         &xd->last_flow_error);
+  if (rv != 0)
+    {
+      if (rv == -EINVAL)
+       rv = VNET_FLOW_ERROR_NOT_SUPPORTED;
+      else if (rv == -EEXIST)
+       rv = VNET_FLOW_ERROR_ALREADY_EXISTS;
+      else
+       rv = VNET_FLOW_ERROR_INTERNAL;
+
+      goto done;
+    }
+
   fe->handle = rte_flow_create (xd->device_index, &ingress, items, actions,
                                &xd->last_flow_error);
 
-  if (!fe->handle)
-    rv = VNET_FLOW_ERROR_NOT_SUPPORTED;
-
 done:
   vec_free (items);
   vec_free (actions);