From 8bd4db5996ba1144f659ea5341f1c2727c650bcd Mon Sep 17 00:00:00 2001 From: Steven Luong Date: Mon, 24 Oct 2022 09:10:59 -0700 Subject: [PATCH] vxlan: convert vxlan to a plugin per https://jira.fd.io/browse/VPP-2058 Type: improvement Signed-off-by: Steven Luong Change-Id: Ica0828de218d25ada2d0d1491e373c3b78179ac1 --- MAINTAINERS | 3 ++- src/plugins/dpdk/device/flow.c | 2 +- src/plugins/nsh/FEATURE.yaml | 1 + src/plugins/nsh/nsh.c | 16 +++++++++++++--- src/plugins/nsh/nsh_pop.c | 1 - src/plugins/vxlan/CMakeLists.txt | 29 +++++++++++++++++++++++++++++ src/{vnet => plugins}/vxlan/FEATURE.yaml | 0 src/{vnet => plugins}/vxlan/decap.c | 8 ++++---- src/{vnet => plugins}/vxlan/dir.dox | 0 src/{vnet => plugins}/vxlan/encap.c | 2 +- src/plugins/vxlan/plugin.c | 22 ++++++++++++++++++++++ src/{vnet => plugins}/vxlan/vxlan.api | 0 src/{vnet => plugins}/vxlan/vxlan.c | 2 +- src/{vnet => plugins}/vxlan/vxlan.h | 4 ++-- src/{vnet => plugins}/vxlan/vxlan_api.c | 2 +- src/{vnet => plugins}/vxlan/vxlan_error.def | 0 src/{vnet => plugins}/vxlan/vxlan_packet.h | 0 src/vnet/CMakeLists.txt | 24 ------------------------ 18 files changed, 77 insertions(+), 39 deletions(-) create mode 100644 src/plugins/vxlan/CMakeLists.txt rename src/{vnet => plugins}/vxlan/FEATURE.yaml (100%) rename src/{vnet => plugins}/vxlan/decap.c (99%) rename src/{vnet => plugins}/vxlan/dir.dox (100%) rename src/{vnet => plugins}/vxlan/encap.c (99%) create mode 100644 src/plugins/vxlan/plugin.c rename src/{vnet => plugins}/vxlan/vxlan.api (100%) rename src/{vnet => plugins}/vxlan/vxlan.c (99%) rename src/{vnet => plugins}/vxlan/vxlan.h (98%) rename src/{vnet => plugins}/vxlan/vxlan_api.c (99%) rename src/{vnet => plugins}/vxlan/vxlan_error.def (100%) rename src/{vnet => plugins}/vxlan/vxlan_packet.h (100%) diff --git a/MAINTAINERS b/MAINTAINERS index 5701ebdd9ff..d65be3844c1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -288,9 +288,10 @@ F: src/vnet/udp VNET VXLAN I: vxlan +Y: src/plugins/vxlan/FEATURE.yaml M: John Lo M: Steven Luong -F: src/vnet/vxlan/ +F: src/plugins/vxlan/ VNET VXLAN-GPE I: vxlan-gpe diff --git a/src/plugins/dpdk/device/flow.c b/src/plugins/dpdk/device/flow.c index 9f765a6f845..ae76b3df169 100644 --- a/src/plugins/dpdk/device/flow.c +++ b/src/plugins/dpdk/device/flow.c @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/plugins/nsh/FEATURE.yaml b/src/plugins/nsh/FEATURE.yaml index a6ef3749952..986008e41a5 100644 --- a/src/plugins/nsh/FEATURE.yaml +++ b/src/plugins/nsh/FEATURE.yaml @@ -8,6 +8,7 @@ features: - NSH Proxy - NSH OAM - NSH Metadata + - Requires vxlan_plugin.so to run description: "NSH for SFC" state: production diff --git a/src/plugins/nsh/nsh.c b/src/plugins/nsh/nsh.c index ea084e4a553..391fa8dbac5 100644 --- a/src/plugins/nsh/nsh.c +++ b/src/plugins/nsh/nsh.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include @@ -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, diff --git a/src/plugins/nsh/nsh_pop.c b/src/plugins/nsh/nsh_pop.c index 90b8a73b5fb..8de319e158b 100644 --- a/src/plugins/nsh/nsh_pop.c +++ b/src/plugins/nsh/nsh_pop.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include diff --git a/src/plugins/vxlan/CMakeLists.txt b/src/plugins/vxlan/CMakeLists.txt new file mode 100644 index 00000000000..bd0272a868e --- /dev/null +++ b/src/plugins/vxlan/CMakeLists.txt @@ -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 +) diff --git a/src/vnet/vxlan/FEATURE.yaml b/src/plugins/vxlan/FEATURE.yaml similarity index 100% rename from src/vnet/vxlan/FEATURE.yaml rename to src/plugins/vxlan/FEATURE.yaml diff --git a/src/vnet/vxlan/decap.c b/src/plugins/vxlan/decap.c similarity index 99% rename from src/vnet/vxlan/decap.c rename to src/plugins/vxlan/decap.c index 729293fb3e5..f5d1efa2b86 100644 --- a/src/vnet/vxlan/decap.c +++ b/src/plugins/vxlan/decap.c @@ -16,12 +16,12 @@ */ #include -#include +#include #include #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 +#include #undef vxlan_error }; diff --git a/src/vnet/vxlan/dir.dox b/src/plugins/vxlan/dir.dox similarity index 100% rename from src/vnet/vxlan/dir.dox rename to src/plugins/vxlan/dir.dox diff --git a/src/vnet/vxlan/encap.c b/src/plugins/vxlan/encap.c similarity index 99% rename from src/vnet/vxlan/encap.c rename to src/plugins/vxlan/encap.c index 0961a27942d..e4103ec0083 100644 --- a/src/vnet/vxlan/encap.c +++ b/src/plugins/vxlan/encap.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/plugins/vxlan/plugin.c b/src/plugins/vxlan/plugin.c new file mode 100644 index 00000000000..aaeafb03a3b --- /dev/null +++ b/src/plugins/vxlan/plugin.c @@ -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 +#include +#include + +VLIB_PLUGIN_REGISTER () = { + .version = VPP_BUILD_VER, + .description = "VxLan Tunnels", +}; diff --git a/src/vnet/vxlan/vxlan.api b/src/plugins/vxlan/vxlan.api similarity index 100% rename from src/vnet/vxlan/vxlan.api rename to src/plugins/vxlan/vxlan.api diff --git a/src/vnet/vxlan/vxlan.c b/src/plugins/vxlan/vxlan.c similarity index 99% rename from src/vnet/vxlan/vxlan.c rename to src/plugins/vxlan/vxlan.c index 1871e5d71d2..f1ab7a7cb8b 100644 --- a/src/vnet/vxlan/vxlan.c +++ b/src/plugins/vxlan/vxlan.c @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include +#include #include #include #include diff --git a/src/vnet/vxlan/vxlan.h b/src/plugins/vxlan/vxlan.h similarity index 98% rename from src/vnet/vxlan/vxlan.h rename to src/plugins/vxlan/vxlan.h index fa47605e42d..72d82e79cf5 100644 --- a/src/vnet/vxlan/vxlan.h +++ b/src/plugins/vxlan/vxlan.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include @@ -152,7 +152,7 @@ typedef enum typedef enum { #define vxlan_error(n,s) VXLAN_ERROR_##n, -#include +#include #undef vxlan_error VXLAN_N_ERROR, } vxlan_input_error_t; diff --git a/src/vnet/vxlan/vxlan_api.c b/src/plugins/vxlan/vxlan_api.c similarity index 99% rename from src/vnet/vxlan/vxlan_api.c rename to src/plugins/vxlan/vxlan_api.c index 56fd654951f..8fd0928cc63 100644 --- a/src/vnet/vxlan/vxlan_api.c +++ b/src/plugins/vxlan/vxlan_api.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/vnet/vxlan/vxlan_error.def b/src/plugins/vxlan/vxlan_error.def similarity index 100% rename from src/vnet/vxlan/vxlan_error.def rename to src/plugins/vxlan/vxlan_error.def diff --git a/src/vnet/vxlan/vxlan_packet.h b/src/plugins/vxlan/vxlan_packet.h similarity index 100% rename from src/vnet/vxlan/vxlan_packet.h rename to src/plugins/vxlan/vxlan_packet.h diff --git a/src/vnet/CMakeLists.txt b/src/vnet/CMakeLists.txt index 963e000807c..c1c9acc41a0 100644 --- a/src/vnet/CMakeLists.txt +++ b/src/vnet/CMakeLists.txt @@ -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 ############################################################################## -- 2.16.6