vxlan: move vxlan-gpe to a plugin 98/40898/19
authorlajoskatona <[email protected]>
Wed, 8 May 2024 15:02:54 +0000 (17:02 +0200)
committerBenoit Ganne <[email protected]>
Tue, 25 Feb 2025 08:23:39 +0000 (08:23 +0000)
Move vxlan-gpe folder under vnet to the plugin folder,
update cmake configuration and header paths,
and add plugin.c to register plugin.

JIRA: VPP-2059

Type: improvement
Change-Id: I31b6d326276c4aa684fcdcf8443ef349f7816a6d
Signed-off-by: lajoskatona <[email protected]>
Signed-off-by: Nicolas PLANEL <[email protected]>
29 files changed:
src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.c
src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_node.c
src/plugins/ioam/lib-vxlan-gpe/ioam_decap.c
src/plugins/ioam/lib-vxlan-gpe/ioam_encap.c
src/plugins/ioam/lib-vxlan-gpe/ioam_pop.c
src/plugins/ioam/lib-vxlan-gpe/ioam_transit.c
src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c
src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_ioam.c
src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_ioam.h
src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_ioam_packet.h
src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_ioam_trace.c
src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_ioam_util.h
src/plugins/nsh/nsh.c
src/plugins/nsh/nsh.h
src/plugins/nsh/nsh_pop.c
src/plugins/vxlan-gpe/CMakeLists.txt [new file with mode: 0644]
src/plugins/vxlan-gpe/FEATURE.yaml [moved from src/vnet/vxlan-gpe/FEATURE.yaml with 100% similarity]
src/plugins/vxlan-gpe/decap.c [moved from src/vnet/vxlan-gpe/decap.c with 99% similarity]
src/plugins/vxlan-gpe/dir.dox [moved from src/vnet/vxlan-gpe/dir.dox with 100% similarity]
src/plugins/vxlan-gpe/encap.c [moved from src/vnet/vxlan-gpe/encap.c with 99% similarity]
src/plugins/vxlan-gpe/plugin.c [new file with mode: 0644]
src/plugins/vxlan-gpe/vxlan-gpe-rfc.txt [moved from src/vnet/vxlan-gpe/vxlan-gpe-rfc.txt with 100% similarity]
src/plugins/vxlan-gpe/vxlan_gpe.api [moved from src/vnet/vxlan-gpe/vxlan_gpe.api with 100% similarity]
src/plugins/vxlan-gpe/vxlan_gpe.c [moved from src/vnet/vxlan-gpe/vxlan_gpe.c with 99% similarity]
src/plugins/vxlan-gpe/vxlan_gpe.h [moved from src/vnet/vxlan-gpe/vxlan_gpe.h with 92% similarity]
src/plugins/vxlan-gpe/vxlan_gpe_api.c [moved from src/vnet/vxlan-gpe/vxlan_gpe_api.c with 98% similarity]
src/plugins/vxlan-gpe/vxlan_gpe_error.def [moved from src/vnet/vxlan-gpe/vxlan_gpe_error.def with 100% similarity]
src/plugins/vxlan-gpe/vxlan_gpe_packet.h [moved from src/vnet/vxlan-gpe/vxlan_gpe_packet.h with 100% similarity]
src/vnet/CMakeLists.txt

index 1606f72..ca6483b 100644 (file)
@@ -21,7 +21,7 @@
 #include <vnet/vnet.h>
 #include <vnet/plugin/plugin.h>
 #include <ioam/export-common/ioam_export.h>
-#include <vnet/vxlan-gpe/vxlan_gpe.h>
+#include <plugins/vxlan-gpe/vxlan_gpe.h>
 
 #include <vlibapi/api.h>
 #include <vlibmemory/api.h>
index 839fd80..1708476 100644 (file)
@@ -16,8 +16,8 @@
 #include <vnet/vnet.h>
 #include <vppinfra/error.h>
 #include <vnet/ip/ip.h>
-#include <vnet/vxlan-gpe/vxlan_gpe.h>
-#include <vnet/vxlan-gpe/vxlan_gpe_packet.h>
+#include <plugins/vxlan-gpe/vxlan_gpe.h>
+#include <plugins/vxlan-gpe/vxlan_gpe_packet.h>
 #include <ioam/export-common/ioam_export.h>
 
 typedef struct
index 801faa9..d8d52e9 100644 (file)
@@ -17,8 +17,7 @@
 #include <vnet/vnet.h>
 #include <vnet/ip/ip.h>
 #include <vnet/ethernet/ethernet.h>
-#include <vnet/vxlan-gpe/vxlan_gpe.h>
-#include <vnet/vxlan-gpe/vxlan_gpe.h>
+#include <plugins/vxlan-gpe/vxlan_gpe.h>
 #include <ioam/lib-vxlan-gpe/vxlan_gpe_ioam_packet.h>
 #include <ioam/lib-vxlan-gpe/vxlan_gpe_ioam.h>
 #include <ioam/lib-vxlan-gpe/vxlan_gpe_ioam_util.h>
@@ -68,8 +67,8 @@ vxlan_gpe_decap_ioam (vlib_main_t * vm,
                      vlib_frame_t * from_frame, u8 is_ipv6)
 {
   u32 n_left_from, next_index, *from, *to_next;
-  vxlan_gpe_main_t *ngm = &vxlan_gpe_main;
   vxlan_gpe_ioam_main_t *hm = &vxlan_gpe_ioam_main;
+  vxlan_gpe_main_t *ngm = hm->gpe_main;
 
   from = vlib_frame_vector_args (from_frame);
   n_left_from = from_frame->n_vectors;
index de375df..9c742d8 100644 (file)
@@ -17,7 +17,7 @@
 #include <vnet/vnet.h>
 #include <vnet/ip/ip.h>
 #include <vnet/ethernet/ethernet.h>
-#include <vnet/vxlan-gpe/vxlan_gpe.h>
+#include <plugins/vxlan-gpe/vxlan_gpe.h>
 #include <ioam/lib-vxlan-gpe/vxlan_gpe_ioam_packet.h>
 #include <ioam/lib-vxlan-gpe/vxlan_gpe_ioam.h>
 #include <ioam/lib-vxlan-gpe/vxlan_gpe_ioam_util.h>
@@ -71,7 +71,8 @@ vxlan_gpe_encap_ioam_v4 (vlib_main_t * vm,
                         vlib_frame_t * from_frame)
 {
   u32 n_left_from, next_index, *from, *to_next;
-  vxlan_gpe_main_t *ngm = &vxlan_gpe_main;
+  vxlan_gpe_ioam_main_t *sm = &vxlan_gpe_ioam_main;
+  vxlan_gpe_main_t *ngm = sm->gpe_main;
 
   from = vlib_frame_vector_args (from_frame);
   n_left_from = from_frame->n_vectors;
index 2fa0aa2..a80662b 100644 (file)
@@ -17,7 +17,7 @@
 #include <vnet/vnet.h>
 #include <vnet/ip/ip.h>
 #include <vnet/ethernet/ethernet.h>
-#include <vnet/vxlan-gpe/vxlan_gpe.h>
+#include <plugins/vxlan-gpe/vxlan_gpe.h>
 #include <ioam/lib-vxlan-gpe/vxlan_gpe_ioam.h>
 
 /* Statistics (not really errors) */
@@ -231,7 +231,8 @@ vxlan_gpe_pop_ioam (vlib_main_t * vm,
                    vlib_frame_t * from_frame, u8 is_ipv6)
 {
   u32 n_left_from, next_index, *from, *to_next;
-  vxlan_gpe_main_t *ngm = &vxlan_gpe_main;
+  vxlan_gpe_ioam_main_t *sm = &vxlan_gpe_ioam_main;
+  vxlan_gpe_main_t *ngm = sm->gpe_main;
 
   from = vlib_frame_vector_args (from_frame);
   n_left_from = from_frame->n_vectors;
index e3c8272..02233cf 100644 (file)
@@ -18,7 +18,7 @@
 #include <vnet/ip/ip.h>
 #include <vnet/udp/udp_local.h>
 #include <vnet/ethernet/ethernet.h>
-#include <vnet/vxlan-gpe/vxlan_gpe.h>
+#include <plugins/vxlan-gpe/vxlan_gpe.h>
 #include <ioam/lib-vxlan-gpe/vxlan_gpe_ioam_packet.h>
 #include <ioam/lib-vxlan-gpe/vxlan_gpe_ioam.h>
 #include <ioam/lib-vxlan-gpe/vxlan_gpe_ioam_util.h>
index d61832d..6de1760 100644 (file)
@@ -80,9 +80,9 @@ static void vl_api_vxlan_gpe_ioam_vni_enable_t_handler
   clib_error_t *error;
   vxlan4_gpe_tunnel_key_t key4;
   uword *p = NULL;
-  vxlan_gpe_main_t *gm = &vxlan_gpe_main;
   vxlan_gpe_tunnel_t *t = 0;
   vxlan_gpe_ioam_main_t *hm = &vxlan_gpe_ioam_main;
+  vxlan_gpe_main_t *gm = hm->gpe_main;
   u32 vni;
 
 
@@ -130,7 +130,8 @@ static void vl_api_vxlan_gpe_ioam_vni_disable_t_handler
   clib_error_t *error;
   vxlan4_gpe_tunnel_key_t key4;
   uword *p = NULL;
-  vxlan_gpe_main_t *gm = &vxlan_gpe_main;
+  vxlan_gpe_ioam_main_t *hm = &vxlan_gpe_ioam_main;
+  vxlan_gpe_main_t *gm = hm->gpe_main;
   vxlan_gpe_tunnel_t *t = 0;
   u32 vni;
 
@@ -214,6 +215,13 @@ ioam_vxlan_gpe_init (vlib_main_t * vm)
   vlib_node_t *vxlan_gpe_decap_node = NULL;
   uword next_node = 0;
 
+  sm->gpe_main =
+    vlib_get_plugin_symbol ("vxlan-gpe_plugin.so", "vxlan_gpe_main");
+  if (sm->gpe_main == 0)
+    {
+      return clib_error_return (0, "vxlan-gpe_plugin.so is not loaded");
+    }
+
   sm->vlib_main = vm;
   sm->vnet_main = vnet_get_main ();
   sm->unix_time_0 = (u32) time (0);    /* Store starting time */
@@ -231,7 +239,7 @@ ioam_vxlan_gpe_init (vlib_main_t * vm)
     vlib_get_node_by_name (vm, (u8 *) "vxlan4-gpe-input");
   next_node =
     vlib_node_add_next (vm, vxlan_gpe_decap_node->index, decap_node_index);
-  vxlan_gpe_register_decap_protocol (VXLAN_GPE_PROTOCOL_IOAM, next_node);
+  sm->gpe_main->register_decap_protocol (VXLAN_GPE_PROTOCOL_IOAM, next_node);
 
   vec_new (vxlan_gpe_ioam_sw_interface_t, pool_elts (sm->sw_interfaces));
   sm->dst_by_ip4 = hash_create_mem (0, sizeof (fib_prefix_t), sizeof (uword));
@@ -243,7 +251,9 @@ ioam_vxlan_gpe_init (vlib_main_t * vm)
   return 0;
 }
 
-VLIB_INIT_FUNCTION (ioam_vxlan_gpe_init);
+VLIB_INIT_FUNCTION (ioam_vxlan_gpe_init) = {
+  .runs_after = VLIB_INITS ("vxlan_gpe_init"),
+};
 
 /*
  * fd.io coding-style-patch-verification: ON
index 327afc3..f83c6e1 100644 (file)
@@ -12,8 +12,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#include <vnet/vxlan-gpe/vxlan_gpe.h>
-#include <vnet/vxlan-gpe/vxlan_gpe_packet.h>
+#include <plugins/vxlan-gpe/vxlan_gpe.h>
+#include <plugins/vxlan-gpe/vxlan_gpe_packet.h>
 #include <vnet/ip/format.h>
 #include <ioam/lib-vxlan-gpe/vxlan_gpe_ioam.h>
 #include <vnet/dpo/load_balance.h>
@@ -423,7 +423,7 @@ vxlan_gpe_set_ioam_rewrite_command_fn (vlib_main_t *
   vxlan4_gpe_tunnel_key_t key4;
   vxlan6_gpe_tunnel_key_t key6;
   uword *p;
-  vxlan_gpe_main_t *gm = &vxlan_gpe_main;
+  vxlan_gpe_main_t *gm = hm->gpe_main;
   vxlan_gpe_tunnel_t *t = 0;
   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
     {
index 0711b87..f9374c9 100644 (file)
 #ifndef __included_vxlan_gpe_ioam_h__
 #define __included_vxlan_gpe_ioam_h__
 
-#include <vnet/vxlan-gpe/vxlan_gpe.h>
-#include <vnet/vxlan-gpe/vxlan_gpe_packet.h>
+#include <plugins/vxlan-gpe/vxlan_gpe.h>
+#include <plugins/vxlan-gpe/vxlan_gpe_packet.h>
 #include <ioam/lib-vxlan-gpe/vxlan_gpe_ioam_packet.h>
 #include <vnet/ip/ip.h>
 
-
 typedef struct vxlan_gpe_sw_interface_
 {
   u32 sw_if_index;
@@ -100,7 +99,8 @@ typedef struct vxlan_gpe_ioam_main_
   vlib_main_t *vlib_main;
   /** State convenience vnet_main_t */
   vnet_main_t *vnet_main;
-
+  /** State convenience vxlan_gpe_main_t */
+  vxlan_gpe_main_t *gpe_main;
 
 } vxlan_gpe_ioam_main_t;
 extern vxlan_gpe_ioam_main_t vxlan_gpe_ioam_main;
index a7ef859..515529c 100644 (file)
@@ -15,8 +15,8 @@
 #ifndef __included_vxlan_gpe_ioam_packet_h__
 #define __included_vxlan_gpe_ioam_packet_h__
 
-#include <vnet/vxlan-gpe/vxlan_gpe.h>
-#include <vnet/vxlan-gpe/vxlan_gpe_packet.h>
+#include <plugins/vxlan-gpe/vxlan_gpe.h>
+#include <plugins/vxlan-gpe/vxlan_gpe_packet.h>
 #include <vnet/ip/ip.h>
 
 
index 9c783c7..9b1b8b8 100644 (file)
@@ -16,8 +16,8 @@
 #include <vnet/vnet.h>
 #include <vppinfra/error.h>
 
-#include <vnet/vxlan-gpe/vxlan_gpe.h>
-#include <vnet/vxlan-gpe/vxlan_gpe_packet.h>
+#include <plugins/vxlan-gpe/vxlan_gpe.h>
+#include <plugins/vxlan-gpe/vxlan_gpe_packet.h>
 
 #include <vppinfra/hash.h>
 #include <vppinfra/error.h>
index c0ad8d9..db7fd56 100644 (file)
@@ -15,8 +15,8 @@
 #ifndef __included_vxlan_gpe_ioam_util_h__
 #define __included_vxlan_gpe_ioam_util_h__
 
-#include <vnet/vxlan-gpe/vxlan_gpe.h>
-#include <vnet/vxlan-gpe/vxlan_gpe_packet.h>
+#include <plugins/vxlan-gpe/vxlan_gpe.h>
+#include <plugins/vxlan-gpe/vxlan_gpe_packet.h>
 #include <vnet/ip/ip.h>
 
 
index a2c24e2..06dd45b 100644 (file)
@@ -20,7 +20,7 @@
 #include <nsh/nsh.h>
 #include <gre/gre.h>
 #include <vxlan/vxlan.h>
-#include <vnet/vxlan-gpe/vxlan_gpe.h>
+#include <plugins/vxlan-gpe/vxlan_gpe.h>
 #include <vnet/l2/l2_classify.h>
 #include <vnet/adj/adj.h>
 #include <vpp/app/version.h>
@@ -182,7 +182,8 @@ nsh_md2_set_next_ioam_export_override (uword next)
 clib_error_t *
 nsh_init (vlib_main_t * vm)
 {
-  vlib_node_t *node, *gre4_input, *gre6_input;
+  vlib_node_t *node, *gre4_input, *gre6_input, *vxlan4_gpe_input,
+    *vxlan6_gpe_input;
   nsh_main_t *nm = &nsh_main;
   clib_error_t *error = 0;
   uword next_node;
@@ -222,20 +223,24 @@ nsh_init (vlib_main_t * vm)
 
   /* Add dispositions to nodes that feed nsh-input */
   //alagalah - validate we don't really need to use the node value
+  vxlan4_gpe_input = vlib_get_node_by_name (vm, (u8 *) "vxlan4-gpe-input");
+  vxlan6_gpe_input = vlib_get_node_by_name (vm, (u8 *) "vxlan6-gpe-input");
+  nm->vgm = vlib_get_plugin_symbol ("vxlan-gpe_plugin.so", "vxlan_gpe_main");
+  if (vxlan4_gpe_input == 0 || vxlan6_gpe_input == 0 || nm->vgm == 0)
+    {
+      error = clib_error_return (0, "vxlan_gpe_plugin.so is not loaded");
+      return error;
+    }
   next_node =
-    vlib_node_add_next (vm, vxlan4_gpe_input_node.index,
-                       nm->nsh_input_node_index);
-  vlib_node_add_next (vm, vxlan4_gpe_input_node.index,
-                     nm->nsh_proxy_node_index);
-  vlib_node_add_next (vm, vxlan4_gpe_input_node.index,
+    vlib_node_add_next (vm, vxlan4_gpe_input->index, nm->nsh_input_node_index);
+  vlib_node_add_next (vm, vxlan4_gpe_input->index, nm->nsh_proxy_node_index);
+  vlib_node_add_next (vm, vxlan4_gpe_input->index,
                      nsh_aware_vnf_proxy_node.index);
-  vxlan_gpe_register_decap_protocol (VXLAN_GPE_PROTOCOL_NSH, next_node);
+  nm->vgm->register_decap_protocol (VXLAN_GPE_PROTOCOL_NSH, next_node);
 
-  vlib_node_add_next (vm, vxlan6_gpe_input_node.index,
-                     nm->nsh_input_node_index);
-  vlib_node_add_next (vm, vxlan6_gpe_input_node.index,
-                     nm->nsh_proxy_node_index);
-  vlib_node_add_next (vm, vxlan6_gpe_input_node.index,
+  vlib_node_add_next (vm, vxlan6_gpe_input->index, nm->nsh_input_node_index);
+  vlib_node_add_next (vm, vxlan6_gpe_input->index, nm->nsh_proxy_node_index);
+  vlib_node_add_next (vm, vxlan6_gpe_input->index,
                      nsh_aware_vnf_proxy_node.index);
 
   gre4_input = vlib_get_node_by_name (vm, (u8 *) "gre4-input");
@@ -280,7 +285,9 @@ nsh_init (vlib_main_t * vm)
   return error;
 }
 
-VLIB_INIT_FUNCTION (nsh_init);
+VLIB_INIT_FUNCTION (nsh_init) = {
+  .runs_after = VLIB_INITS ("vxlan_gpe_init"),
+};
 
 VLIB_PLUGIN_REGISTER () = {
     .version = VPP_BUILD_VER,
index 86a9a7e..c408ddb 100644 (file)
@@ -18,6 +18,7 @@
 #include <vnet/vnet.h>
 #include <nsh/nsh_packet.h>
 #include <vnet/ip/ip4_packet.h>
+#include <plugins/vxlan-gpe/vxlan_gpe.h>
 
 typedef struct {
   u16 class;
@@ -166,6 +167,10 @@ typedef struct {
   /* convenience */
   vlib_main_t * vlib_main;
   vnet_main_t * vnet_main;
+
+  /* vxlan gpe plugin */
+  vxlan_gpe_main_t *vgm;
+
 } nsh_main_t;
 
 extern nsh_main_t nsh_main;
index 8de319e..d66cfc9 100644 (file)
@@ -19,7 +19,7 @@
 #include <vnet/plugin/plugin.h>
 #include <nsh/nsh.h>
 #include <vnet/gre/packet.h>
-#include <vnet/vxlan-gpe/vxlan_gpe.h>
+#include <plugins/vxlan-gpe/vxlan_gpe.h>
 #include <vnet/l2/l2_classify.h>
 
 #include <vlibapi/api.h>
diff --git a/src/plugins/vxlan-gpe/CMakeLists.txt b/src/plugins/vxlan-gpe/CMakeLists.txt
new file mode 100644 (file)
index 0000000..987ebcc
--- /dev/null
@@ -0,0 +1,32 @@
+# Copyright (c) 2024 OpenInfra Foundation Europe
+# Copyright (c) 2025 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+add_vpp_plugin(vxlan-gpe
+  SOURCES
+  encap.c
+  decap.c
+  vxlan_gpe.c
+  vxlan_gpe_api.c
+  vxlan_gpe_packet.h
+  plugin.c
+
+  INSTALL_HEADERS
+  vxlan_gpe.h
+
+  MULTIARCH_SOURCES
+  decap.c
+
+  API_FILES
+  vxlan_gpe.api
+)
similarity index 99%
rename from src/vnet/vxlan-gpe/decap.c
rename to src/plugins/vxlan-gpe/decap.c
index d4c7424..29f03e3 100644 (file)
@@ -22,7 +22,7 @@
 
 #include <vlib/vlib.h>
 #include <vnet/udp/udp_local.h>
-#include <vnet/vxlan-gpe/vxlan_gpe.h>
+#include <vxlan-gpe/vxlan_gpe.h>
 
 /**
  * @brief Struct for VXLAN GPE decap packet tracing
@@ -617,7 +617,7 @@ VLIB_NODE_FN (vxlan6_gpe_input_node) (vlib_main_t * vm,
  */
 static char *vxlan_gpe_error_strings[] = {
 #define vxlan_gpe_error(n,s) s,
-#include <vnet/vxlan-gpe/vxlan_gpe_error.def>
+#include <vxlan-gpe/vxlan_gpe_error.def>
 #undef vxlan_gpe_error
 #undef _
 };
similarity index 99%
rename from src/vnet/vxlan-gpe/encap.c
rename to src/plugins/vxlan-gpe/encap.c
index a769861..d8bab92 100644 (file)
@@ -23,7 +23,7 @@
 #include <vnet/ip/ip.h>
 #include <vnet/ethernet/ethernet.h>
 #include <vnet/udp/udp_inlines.h>
-#include <vnet/vxlan-gpe/vxlan_gpe.h>
+#include <vxlan-gpe/vxlan_gpe.h>
 
 /** Statistics (not really errors) */
 #define foreach_vxlan_gpe_encap_error    \
diff --git a/src/plugins/vxlan-gpe/plugin.c b/src/plugins/vxlan-gpe/plugin.c
new file mode 100644 (file)
index 0000000..5a711a3
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * plugin.c: vxlan-gpe
+ *
+ * Copyright (c) OpenInfra Foundation Europe.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <vlib/vlib.h>
+#include <vnet/plugin/plugin.h>
+#include <vpp/app/version.h>
+// register a plugin
+
+VLIB_PLUGIN_REGISTER () = {
+  .version = VPP_BUILD_VER,
+  .description = "VxLan GPE Tunnels",
+};
similarity index 99%
rename from src/vnet/vxlan-gpe/vxlan_gpe.c
rename to src/plugins/vxlan-gpe/vxlan_gpe.c
index 5a5262e..abb2049 100644 (file)
@@ -17,7 +17,7 @@
  *  @brief Common utility functions for IPv4 and IPv6 VXLAN GPE tunnels
  *
 */
-#include <vnet/vxlan-gpe/vxlan_gpe.h>
+#include <vxlan-gpe/vxlan_gpe.h>
 #include <vnet/fib/fib.h>
 #include <vnet/ip/format.h>
 #include <vnet/fib/fib_entry.h>
@@ -44,7 +44,7 @@
  * You can refer to this kind of L2 overlay bridge domain as a VXLAN-GPE segment.
  */
 
-vxlan_gpe_main_t vxlan_gpe_main;
+vxlan_gpe_main_t vxlan_gpe_main __clib_export;
 
 static u8 *
 format_decap_next (u8 * s, va_list * args)
@@ -1212,11 +1212,13 @@ VNET_FEATURE_INIT (ip6_vxlan_gpe_bypass, static) =
  * @return error
  *
  */
-clib_error_t *
-vxlan_gpe_init (vlib_main_t * vm)
+__clib_export clib_error_t *
+vxlan_gpe_init (vlib_main_t *vm)
 {
   vxlan_gpe_main_t *ngm = &vxlan_gpe_main;
 
+  ngm->register_decap_protocol = vxlan_gpe_register_decap_protocol;
+  ngm->unregister_decap_protocol = vxlan_gpe_unregister_decap_protocol;
   ngm->vnet_main = vnet_get_main ();
   ngm->vlib_main = vm;
 
similarity index 92%
rename from src/vnet/vxlan-gpe/vxlan_gpe.h
rename to src/plugins/vxlan-gpe/vxlan_gpe.h
index aabaafe..138ae84 100644 (file)
@@ -29,7 +29,7 @@
 #include <vnet/l2/l2_output.h>
 #include <vnet/l2/l2_bd.h>
 #include <vnet/ethernet/ethernet.h>
-#include <vnet/vxlan-gpe/vxlan_gpe_packet.h>
+#include <vxlan-gpe/vxlan_gpe_packet.h>
 #include <vnet/ip/ip4_packet.h>
 #include <vnet/ip/ip6_packet.h>
 #include <vnet/udp/udp_packet.h>
@@ -196,11 +196,16 @@ typedef enum
 typedef enum
 {
 #define vxlan_gpe_error(n,s) VXLAN_GPE_ERROR_##n,
-#include <vnet/vxlan-gpe/vxlan_gpe_error.def>
+#include <plugins/vxlan-gpe/vxlan_gpe_error.def>
 #undef vxlan_gpe_error
   VXLAN_GPE_N_ERROR,
 } vxlan_gpe_input_error_t;
 
+typedef void (*vxlan_gpe_register_decap_protocol_callback_t) (
+  u8 protocol_id, uword next_node_index);
+typedef void (*vxlan_gpe_unregister_decap_protocol_callback_t) (
+  u8 protocol_id, uword next_node_index);
+
 /** Struct for VXLAN GPE node state */
 typedef struct
 {
@@ -233,6 +238,10 @@ typedef struct
 
   /** List of next nodes for the decap indexed on protocol */
   uword decap_next_node_list[VXLAN_GPE_PROTOCOL_MAX];
+
+  /* export callbacks to register/unregister decapsulation protocol */
+  vxlan_gpe_register_decap_protocol_callback_t register_decap_protocol;
+  vxlan_gpe_unregister_decap_protocol_callback_t unregister_decap_protocol;
 } vxlan_gpe_main_t;
 
 extern vxlan_gpe_main_t vxlan_gpe_main;
@@ -279,13 +288,10 @@ typedef enum
   VXLAN_GPE_ENCAP_N_NEXT
 } vxlan_gpe_encap_next_t;
 
-
+void vxlan_gpe_register_decap_protocol (u8 protocol_id, uword next_node_index);
 void vxlan_gpe_unregister_decap_protocol (u8 protocol_id,
                                          uword next_node_index);
 
-void vxlan_gpe_register_decap_protocol (u8 protocol_id,
-                                       uword next_node_index);
-
 void vnet_int_vxlan_gpe_bypass_mode (u32 sw_if_index, u8 is_ip6,
                                     u8 is_enable);
 
similarity index 98%
rename from src/vnet/vxlan-gpe/vxlan_gpe_api.c
rename to src/plugins/vxlan-gpe/vxlan_gpe_api.c
index cc74e1f..e824454 100644 (file)
 #include <vnet/interface.h>
 #include <vnet/api_errno.h>
 #include <vnet/feature/feature.h>
-#include <vnet/vxlan-gpe/vxlan_gpe.h>
+#include <vxlan-gpe/vxlan_gpe.h>
 #include <vnet/fib/fib_table.h>
 #include <vnet/format_fns.h>
 
 #include <vnet/ip/ip_types_api.h>
-#include <vnet/vxlan-gpe/vxlan_gpe.api_enum.h>
-#include <vnet/vxlan-gpe/vxlan_gpe.api_types.h>
+#include <vxlan-gpe/vxlan_gpe.api_enum.h>
+#include <vxlan-gpe/vxlan_gpe.api_types.h>
 
 #define REPLY_MSG_ID_BASE msg_id_base
 #include <vlibapi/api_helper_macros.h>
index a071709..9e7734e 100644 (file)
@@ -749,29 +749,6 @@ list(APPEND VNET_HEADERS
 
 list(APPEND VNET_API_FILES mpls/mpls.api)
 
-##############################################################################
-# Tunnel protocol: vxlan-gpe
-##############################################################################
-
-list(APPEND VNET_SOURCES
-  vxlan-gpe/vxlan_gpe.c
-  vxlan-gpe/encap.c
-  vxlan-gpe/decap.c
-  vxlan-gpe/vxlan_gpe_api.c
-)
-
-list (APPEND VNET_MULTIARCH_SOURCES
-  vxlan-gpe/decap.c
-)
-
-list(APPEND VNET_HEADERS
-  vxlan-gpe/vxlan_gpe.h
-  vxlan-gpe/vxlan_gpe_packet.h
-  vxlan-gpe/vxlan_gpe_error.def
-)
-
-list(APPEND VNET_API_FILES vxlan-gpe/vxlan_gpe.api)
-
 ##############################################################################
 # ipv6 segment routing
 ##############################################################################