vxlan: convert vxlan to a plugin 11/37511/8
authorSteven Luong <sluong@cisco.com>
Mon, 24 Oct 2022 16:10:59 +0000 (09:10 -0700)
committerDave Wallace <dwallacelf@gmail.com>
Thu, 19 Jan 2023 21:37:25 +0000 (21:37 +0000)
per https://jira.fd.io/browse/VPP-2058

Type: improvement

Signed-off-by: Steven Luong <sluong@cisco.com>
Change-Id: Ica0828de218d25ada2d0d1491e373c3b78179ac1

18 files changed:
MAINTAINERS
src/plugins/dpdk/device/flow.c
src/plugins/nsh/FEATURE.yaml
src/plugins/nsh/nsh.c
src/plugins/nsh/nsh_pop.c
src/plugins/vxlan/CMakeLists.txt [new file with mode: 0644]
src/plugins/vxlan/FEATURE.yaml [moved from src/vnet/vxlan/FEATURE.yaml with 100% similarity]
src/plugins/vxlan/decap.c [moved from src/vnet/vxlan/decap.c with 99% similarity]
src/plugins/vxlan/dir.dox [moved from src/vnet/vxlan/dir.dox with 100% similarity]
src/plugins/vxlan/encap.c [moved from src/vnet/vxlan/encap.c with 99% similarity]
src/plugins/vxlan/plugin.c [new file with mode: 0644]
src/plugins/vxlan/vxlan.api [moved from src/vnet/vxlan/vxlan.api with 100% similarity]
src/plugins/vxlan/vxlan.c [moved from src/vnet/vxlan/vxlan.c with 99% similarity]
src/plugins/vxlan/vxlan.h [moved from src/vnet/vxlan/vxlan.h with 98% similarity]
src/plugins/vxlan/vxlan_api.c [moved from src/vnet/vxlan/vxlan_api.c with 99% similarity]
src/plugins/vxlan/vxlan_error.def [moved from src/vnet/vxlan/vxlan_error.def with 100% similarity]
src/plugins/vxlan/vxlan_packet.h [moved from src/vnet/vxlan/vxlan_packet.h with 100% similarity]
src/vnet/CMakeLists.txt

index 5701ebd..d65be38 100644 (file)
@@ -288,9 +288,10 @@ F: src/vnet/udp
 
 VNET VXLAN
 I:     vxlan
+Y:     src/plugins/vxlan/FEATURE.yaml
 M:     John Lo <lojultra2020@outlook.com>
 M:     Steven Luong <sluong@cisco.com>
-F:     src/vnet/vxlan/
+F:     src/plugins/vxlan/
 
 VNET VXLAN-GPE
 I:     vxlan-gpe
index 9f765a6..ae76b3d 100644 (file)
@@ -21,7 +21,7 @@
 #include <vnet/ip/ip.h>
 #include <vnet/ethernet/ethernet.h>
 #include <vnet/ethernet/arp_packet.h>
-#include <vnet/vxlan/vxlan.h>
+#include <vxlan/vxlan.h>
 #include <dpdk/device/dpdk.h>
 #include <dpdk/device/dpdk_priv.h>
 #include <vppinfra/error.h>
index a6ef374..986008e 100644 (file)
@@ -8,6 +8,7 @@ features:
   - NSH Proxy
   - NSH OAM
   - NSH Metadata
+  - Requires vxlan_plugin.so to run
 
 description: "NSH for SFC"
 state: production
index ea084e4..391fa8d 100644 (file)
@@ -19,7 +19,7 @@
 #include <vnet/plugin/plugin.h>
 #include <nsh/nsh.h>
 #include <vnet/gre/gre.h>
-#include <vnet/vxlan/vxlan.h>
+#include <vxlan/vxlan.h>
 #include <vnet/vxlan-gpe/vxlan_gpe.h>
 #include <vnet/l2/l2_classify.h>
 #include <vnet/adj/adj.h>
@@ -188,6 +188,7 @@ nsh_init (vlib_main_t * vm)
   nsh_main_t *nm = &nsh_main;
   clib_error_t *error = 0;
   uword next_node;
+  vlib_node_registration_t *vxlan4_input, *vxlan6_input;
 
   /* Init the main structures from VPP */
   nm->vlib_main = vm;
@@ -250,8 +251,17 @@ nsh_init (vlib_main_t * vm)
                      nsh_aware_vnf_proxy_node.index);
 
   /* Add NSH-Proxy support */
-  vlib_node_add_next (vm, vxlan4_input_node.index, nm->nsh_proxy_node_index);
-  vlib_node_add_next (vm, vxlan6_input_node.index, nm->nsh_proxy_node_index);
+  vxlan4_input =
+    vlib_get_plugin_symbol ("vxlan_plugin.so", "vxlan4_input_node");
+  vxlan6_input =
+    vlib_get_plugin_symbol ("vxlan_plugin.so", "vxlan6_input_node");
+  if (vxlan4_input == 0 || vxlan6_input == 0)
+    {
+      error = clib_error_return (0, "vxlan_plugin.so is not loaded");
+      return error;
+    }
+  vlib_node_add_next (vm, vxlan4_input->index, nm->nsh_proxy_node_index);
+  vlib_node_add_next (vm, vxlan6_input->index, nm->nsh_proxy_node_index);
 
   /* Add NSH-Classifier support */
   vlib_node_add_next (vm, ip4_classify_node.index,
index 90b8a73..8de319e 100644 (file)
@@ -19,7 +19,6 @@
 #include <vnet/plugin/plugin.h>
 #include <nsh/nsh.h>
 #include <vnet/gre/packet.h>
-#include <vnet/vxlan/vxlan.h>
 #include <vnet/vxlan-gpe/vxlan_gpe.h>
 #include <vnet/l2/l2_classify.h>
 
diff --git a/src/plugins/vxlan/CMakeLists.txt b/src/plugins/vxlan/CMakeLists.txt
new file mode 100644 (file)
index 0000000..bd0272a
--- /dev/null
@@ -0,0 +1,29 @@
+# Copyright (c) 2022 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
+  SOURCES
+  vxlan.c
+  encap.c
+  decap.c
+  vxlan_api.c
+  plugin.c
+  vxlan.h
+  vxlan_packet.h
+
+  MULTIARCH_SOURCES
+  encap.c
+
+  API_FILES
+  vxlan.api
+)
similarity index 99%
rename from src/vnet/vxlan/decap.c
rename to src/plugins/vxlan/decap.c
index 729293f..f5d1efa 100644 (file)
  */
 
 #include <vlib/vlib.h>
-#include <vnet/vxlan/vxlan.h>
+#include <vxlan/vxlan.h>
 #include <vnet/udp/udp_local.h>
 
 #ifndef CLIB_MARCH_VARIANT
-vlib_node_registration_t vxlan4_input_node;
-vlib_node_registration_t vxlan6_input_node;
+__clib_export vlib_node_registration_t vxlan4_input_node;
+__clib_export vlib_node_registration_t vxlan6_input_node;
 #endif
 
 typedef struct
@@ -408,7 +408,7 @@ VLIB_NODE_FN (vxlan6_input_node) (vlib_main_t * vm,
 
 static char *vxlan_error_strings[] = {
 #define vxlan_error(n,s) s,
-#include <vnet/vxlan/vxlan_error.def>
+#include <vxlan/vxlan_error.def>
 #undef vxlan_error
 };
 
similarity index 99%
rename from src/vnet/vxlan/encap.c
rename to src/plugins/vxlan/encap.c
index 0961a27..e4103ec 100644 (file)
@@ -19,7 +19,7 @@
 #include <vnet/ip/ip.h>
 #include <vnet/ethernet/ethernet.h>
 #include <vnet/interface_output.h>
-#include <vnet/vxlan/vxlan.h>
+#include <vxlan/vxlan.h>
 #include <vnet/qos/qos_types.h>
 #include <vnet/adj/rewrite.h>
 
diff --git a/src/plugins/vxlan/plugin.c b/src/plugins/vxlan/plugin.c
new file mode 100644 (file)
index 0000000..aaeafb0
--- /dev/null
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: Apache-2.0
+ * Copyright (c) 2022 Cisco Systems, Inc.
+ * License: Cisco Proprietary Closed Source License - Cisco Internal.
+ * The software, documentation and any fonts accompanying this License whether
+ * on disk, in read only memory, on any other media or in any other form (col-
+ * lectively the “Software”) are licensed, not sold, to you by Cisco, Inc.
+ * (“Cisco”) for use only under the terms of this License, and Cisco reserves
+ * all rights not expressly granted to you. The rights granted herein are
+ * limited to Cisco’s intel- lectual property rights in the Cisco Software and
+ * do not include any other patents or intellectual property rights. You own
+ * the media on which the Cisco Software is recorded but Cisco and/or Cisco’s
+ * licensor(s) retain ownership of the Software itself.
+ */
+
+#include <vlib/vlib.h>
+#include <vnet/plugin/plugin.h>
+#include <vpp/app/version.h>
+
+VLIB_PLUGIN_REGISTER () = {
+  .version = VPP_BUILD_VER,
+  .description = "VxLan Tunnels",
+};
similarity index 99%
rename from src/vnet/vxlan/vxlan.c
rename to src/plugins/vxlan/vxlan.c
index 1871e5d..f1ab7a7 100644 (file)
@@ -12,7 +12,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#include <vnet/vxlan/vxlan.h>
+#include <vxlan/vxlan.h>
 #include <vnet/ip/format.h>
 #include <vnet/fib/fib_entry.h>
 #include <vnet/fib/fib_table.h>
similarity index 98%
rename from src/vnet/vxlan/vxlan.h
rename to src/plugins/vxlan/vxlan.h
index fa47605..72d82e7 100644 (file)
@@ -26,7 +26,7 @@
 #include <vnet/l2/l2_output.h>
 #include <vnet/l2/l2_bd.h>
 #include <vnet/ethernet/ethernet.h>
-#include <vnet/vxlan/vxlan_packet.h>
+#include <vxlan/vxlan_packet.h>
 #include <vnet/ip/ip4_packet.h>
 #include <vnet/ip/ip6_packet.h>
 #include <vnet/udp/udp_packet.h>
@@ -152,7 +152,7 @@ typedef enum
 typedef enum
 {
 #define vxlan_error(n,s) VXLAN_ERROR_##n,
-#include <vnet/vxlan/vxlan_error.def>
+#include <vxlan/vxlan_error.def>
 #undef vxlan_error
   VXLAN_N_ERROR,
 } vxlan_input_error_t;
similarity index 99%
rename from src/vnet/vxlan/vxlan_api.c
rename to src/plugins/vxlan/vxlan_api.c
index 56fd654..8fd0928 100644 (file)
@@ -23,7 +23,7 @@
 #include <vnet/interface.h>
 #include <vnet/api_errno.h>
 #include <vnet/feature/feature.h>
-#include <vnet/vxlan/vxlan.h>
+#include <vxlan/vxlan.h>
 #include <vnet/fib/fib_table.h>
 #include <vnet/ip/ip_types_api.h>
 #include <vnet/udp/udp_local.h>
index 963e000..c1c9acc 100644 (file)
@@ -296,30 +296,6 @@ list(APPEND VNET_HEADERS
   snap/snap.h
 )
 
-##############################################################################
-# Layer 2 / vxlan
-##############################################################################
-list(APPEND VNET_SOURCES
-  vxlan/vxlan.c
-  vxlan/encap.c
-  vxlan/decap.c
-  vxlan/vxlan_api.c
-)
-
-list(APPEND VNET_MULTIARCH_SOURCES
-  vxlan/encap.c
-)
-
-list(APPEND VNET_HEADERS
-  vxlan/vxlan.h
-  vxlan/vxlan_packet.h
-  vxlan/vxlan_error.def
-)
-
-list(APPEND VNET_MULTIARCH_SOURCES vxlan/decap.c)
-
-list(APPEND VNET_API_FILES vxlan/vxlan.api)
-
 ##############################################################################
 # Layer 2 / Bonding
 ##############################################################################