Punt Infra
[vpp.git] / src / plugins / gbp / gbp_vxlan.c
index 286345e..49dae7e 100644 (file)
@@ -22,6 +22,7 @@
 #include <vnet/vxlan-gbp/vxlan_gbp.h>
 #include <vlibmemory/api.h>
 #include <vnet/fib/fib_table.h>
+#include <vlib/punt.h>
 
 /**
  * A reference to a VXLAN-GBP tunnel created as a child/dependent tunnel
@@ -66,6 +67,10 @@ index_t *gbp_vxlan_tunnel_db;
  */
 index_t *vxlan_tunnel_ref_db;
 
+/**
+ * handle registered with the ;unt infra
+ */
+static vlib_punt_hdl_t punt_hdl;
 
 static char *gbp_vxlan_tunnel_layer_strings[] = {
 #define _(n,s) [GBP_VXLAN_TUN_##n] = s,
@@ -672,28 +677,23 @@ VLIB_CLI_COMMAND (gbp_vxlan_show_node, static) = {
 static clib_error_t *
 gbp_vxlan_init (vlib_main_t * vm)
 {
-  u32 slot4;
-  vlib_node_t *node = vlib_get_node_by_name (vm, (u8 *) "gbp-vxlan4");
-
-  /*
-   * insert ourselves into the VXLAN-GBP arc to collect the no-tunnel
-   * packets.
-   */
-  slot4 = vlib_node_add_next_with_slot (vm,
-                                       vxlan4_gbp_input_node.index,
-                                       node->index,
-                                       VXLAN_GBP_INPUT_NEXT_NO_TUNNEL);
-  ASSERT (slot4 == VXLAN_GBP_INPUT_NEXT_NO_TUNNEL);
-
-  /* slot6 = vlib_node_add_next_with_slot (vm, */
-  /*                                    vxlan6_gbp_input_node.index, */
-  /*                                    gbp_vxlan6_input_node.index, */
-  /*                                    VXLAN_GBP_INPUT_NEXT_NO_TUNNEL); */
-  /* ASSERT (slot6 == VXLAN_GBP_INPUT_NEXT_NO_TUNNEL); */
+  vxlan_gbp_main_t *vxm = &vxlan_gbp_main;
+  clib_error_t *error;
 
   gt_logger = vlib_log_register_class ("gbp", "tun");
 
-  return (NULL);
+  if ((error = vlib_call_init_function (vm, punt_init)))
+    return error;
+  if ((error = vlib_call_init_function (vm, vxlan_gbp_init)))
+    return error;
+
+  punt_hdl = vlib_punt_client_register ("gbp-vxlan");
+
+  vlib_punt_register (punt_hdl,
+                     vxm->punt_no_such_tunnel[FIB_PROTOCOL_IP4],
+                     "gbp-vxlan4");
+
+  return (error);
 }
 
 VLIB_INIT_FUNCTION (gbp_vxlan_init);