ip: Use .api declared error counters
[vpp.git] / src / vnet / ip / ip6_input.c
index 6a7669d..8d89890 100644 (file)
@@ -41,6 +41,7 @@
 #include <vnet/ethernet/ethernet.h>
 #include <vnet/ppp/ppp.h>
 #include <vnet/hdlc/hdlc.h>
+#include <vnet/pg/pg.h>
 
 typedef struct
 {
@@ -62,8 +63,8 @@ format_ip6_input_trace (u8 * s, va_list * va)
 
 /* Validate IP v6 packets and pass them either to forwarding code
    or drop exception packets. */
-static uword
-ip6_input (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (ip6_input_node) (vlib_main_t * vm, vlib_node_runtime_t * node,
+                              vlib_frame_t * frame)
 {
   vnet_main_t *vnm = vnet_get_main ();
   ip6_main_t *im = &ip6_main;
@@ -218,20 +219,13 @@ ip6_input (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
   return frame->n_vectors;
 }
 
-char *ip6_error_strings[] = {
-#define _(sym,string) string,
-  foreach_ip6_error
-#undef _
-};
-
 /* *INDENT-OFF* */
 VLIB_REGISTER_NODE (ip6_input_node) = {
-  .function = ip6_input,
   .name = "ip6-input",
   .vector_size = sizeof (u32),
 
   .n_errors = IP6_N_ERROR,
-  .error_strings = ip6_error_strings,
+  .error_counters = ip6_error_counters,
 
   .n_next_nodes = IP6_INPUT_N_NEXT,
   .next_nodes = {
@@ -246,8 +240,8 @@ VLIB_REGISTER_NODE (ip6_input_node) = {
 };
 /* *INDENT-ON* */
 
-VLIB_NODE_FUNCTION_MULTIARCH (ip6_input_node, ip6_input)
-     static clib_error_t *ip6_init (vlib_main_t * vm)
+static clib_error_t *
+ip6_init (vlib_main_t * vm)
 {
   ethernet_register_input_type (vm, ETHERNET_TYPE_IP6, ip6_input_node.index);
   ppp_register_input_protocol (vm, PPP_PROTOCOL_ip6, ip6_input_node.index);
@@ -265,6 +259,15 @@ VLIB_NODE_FUNCTION_MULTIARCH (ip6_input_node, ip6_input)
   /* Default hop limit for packets we generate. */
   ip6_main.host_config.ttl = 64;
 
+
+  uword *u = hash_get (ip_main.protocol_info_by_name, "IPV6_FRAGMENTATION");
+  if (u)
+    {
+      ip_protocol_info_t *info =
+       vec_elt_at_index (ip_main.protocol_infos, *u);
+      ASSERT (NULL == info->format_header);
+      info->format_header = format_ip6_frag_hdr;
+    }
   return /* no error */ 0;
 }