gso: fix the error handling 75/32475/2
authorMohsin Kazmi <sykazmi@cisco.com>
Thu, 27 May 2021 19:05:41 +0000 (21:05 +0200)
committerBeno�t Ganne <bganne@cisco.com>
Fri, 28 May 2021 07:24:10 +0000 (07:24 +0000)
Type: fix

Change-Id: I7ada1b780b5c40261f6b14cfadc3f382e4e39086
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
src/vnet/gso/node.c
src/vnet/interface.c
src/vnet/interface_funcs.h

index 5814aad..5e793a5 100644 (file)
 #include <vnet/ip/ip6.h>
 #include <vnet/udp/udp_packet.h>
 
+#define foreach_gso_error                                                     \
+  _ (NO_BUFFERS, "no buffers to segment GSO")                                 \
+  _ (UNHANDLED_TYPE, "unhandled gso type")
+
+static char *gso_error_strings[] = {
+#define _(sym, string) string,
+  foreach_gso_error
+#undef _
+};
+
+typedef enum
+{
+#define _(sym, str) GSO_ERROR_##sym,
+  foreach_gso_error
+#undef _
+    GSO_N_ERROR,
+} gso_error_t;
+
+typedef enum
+{
+  GSO_NEXT_DROP,
+  GSO_N_NEXT,
+} gso_next_t;
+
 typedef struct
 {
   u32 flags;
@@ -459,9 +483,8 @@ drop_one_buffer_and_count (vlib_main_t * vm, vnet_main_t * vnm,
 
   vlib_error_drop_buffers (vm, node, pbi0,
                           /* buffer stride */ 1,
-                          /* n_buffers */ 1,
-                          VNET_INTERFACE_OUTPUT_NEXT_DROP,
-                          node->node_index, drop_error_code);
+                          /* n_buffers */ 1, GSO_NEXT_DROP, node->node_index,
+                          drop_error_code);
 }
 
 static_always_inline uword
@@ -670,7 +693,7 @@ vnet_gso_node_inline (vlib_main_t * vm,
                          /* not supported yet */
                          drop_one_buffer_and_count (vm, vnm, node, from - 1,
                                                     hi->sw_if_index,
-                                                    VNET_INTERFACE_OUTPUT_ERROR_UNHANDLED_GSO_TYPE);
+                                                    GSO_ERROR_UNHANDLED_TYPE);
                          b += 1;
                          continue;
                        }
@@ -689,7 +712,7 @@ vnet_gso_node_inline (vlib_main_t * vm,
                    {
                      drop_one_buffer_and_count (vm, vnm, node, from - 1,
                                                 hi->sw_if_index,
-                                                VNET_INTERFACE_OUTPUT_ERROR_NO_BUFFERS_FOR_GSO);
+                                                GSO_ERROR_NO_BUFFERS);
                      b += 1;
                      continue;
                    }
@@ -822,8 +845,12 @@ VLIB_REGISTER_NODE (gso_l2_ip4_node) = {
   .vector_size = sizeof (u32),
   .format_trace = format_gso_trace,
   .type = VLIB_NODE_TYPE_INTERNAL,
-  .n_errors = 0,
-  .n_next_nodes = 0,
+  .n_errors = ARRAY_LEN(gso_error_strings),
+  .error_strings = gso_error_strings,
+  .n_next_nodes = GSO_N_NEXT,
+  .next_nodes = {
+        [GSO_NEXT_DROP] = "error-drop",
+  },
   .name = "gso-l2-ip4",
 };
 
@@ -831,8 +858,12 @@ VLIB_REGISTER_NODE (gso_l2_ip6_node) = {
   .vector_size = sizeof (u32),
   .format_trace = format_gso_trace,
   .type = VLIB_NODE_TYPE_INTERNAL,
-  .n_errors = 0,
-  .n_next_nodes = 0,
+  .n_errors = ARRAY_LEN(gso_error_strings),
+  .error_strings = gso_error_strings,
+  .n_next_nodes = GSO_N_NEXT,
+  .next_nodes = {
+        [GSO_NEXT_DROP] = "error-drop",
+  },
   .name = "gso-l2-ip6",
 };
 
@@ -840,8 +871,12 @@ VLIB_REGISTER_NODE (gso_ip4_node) = {
   .vector_size = sizeof (u32),
   .format_trace = format_gso_trace,
   .type = VLIB_NODE_TYPE_INTERNAL,
-  .n_errors = 0,
-  .n_next_nodes = 0,
+  .n_errors = ARRAY_LEN(gso_error_strings),
+  .error_strings = gso_error_strings,
+  .n_next_nodes = GSO_N_NEXT,
+  .next_nodes = {
+        [GSO_NEXT_DROP] = "error-drop",
+  },
   .name = "gso-ip4",
 };
 
@@ -849,8 +884,12 @@ VLIB_REGISTER_NODE (gso_ip6_node) = {
   .vector_size = sizeof (u32),
   .format_trace = format_gso_trace,
   .type = VLIB_NODE_TYPE_INTERNAL,
-  .n_errors = 0,
-  .n_next_nodes = 0,
+  .n_errors = ARRAY_LEN(gso_error_strings),
+  .error_strings = gso_error_strings,
+  .n_next_nodes = GSO_N_NEXT,
+  .next_nodes = {
+        [GSO_NEXT_DROP] = "error-drop",
+  },
   .name = "gso-ip6",
 };
 
index 5c0ccaa..278cd6e 100644 (file)
@@ -993,7 +993,6 @@ vnet_register_interface (vnet_main_t * vnm,
        static char *e[] = {
          "interface is down",
          "interface is deleted",
-         "no buffers to segment GSO",
        };
 
        r.n_errors = ARRAY_LEN (e);
index 9bcce3d..1416840 100644 (file)
@@ -502,8 +502,6 @@ typedef enum
 {
   VNET_INTERFACE_OUTPUT_ERROR_INTERFACE_DOWN,
   VNET_INTERFACE_OUTPUT_ERROR_INTERFACE_DELETED,
-  VNET_INTERFACE_OUTPUT_ERROR_NO_BUFFERS_FOR_GSO,
-  VNET_INTERFACE_OUTPUT_ERROR_UNHANDLED_GSO_TYPE,
 } vnet_interface_output_error_t;
 
 /* Format for interface output traces. */