diff options
-rw-r--r-- | MAINTAINERS | 5 | ||||
-rw-r--r-- | src/plugins/geneve/CMakeLists.txt | 35 | ||||
-rw-r--r-- | src/plugins/geneve/decap.c (renamed from src/vnet/geneve/decap.c) | 6 | ||||
-rw-r--r-- | src/plugins/geneve/encap.c (renamed from src/vnet/geneve/encap.c) | 2 | ||||
-rw-r--r-- | src/plugins/geneve/geneve.api (renamed from src/vnet/geneve/geneve.api) | 0 | ||||
-rw-r--r-- | src/plugins/geneve/geneve.c (renamed from src/vnet/geneve/geneve.c) | 2 | ||||
-rw-r--r-- | src/plugins/geneve/geneve.h (renamed from src/vnet/geneve/geneve.h) | 6 | ||||
-rw-r--r-- | src/plugins/geneve/geneve_api.c (renamed from src/vnet/geneve/geneve_api.c) | 41 | ||||
-rw-r--r-- | src/plugins/geneve/geneve_error.def (renamed from src/vnet/geneve/geneve_error.def) | 0 | ||||
-rw-r--r-- | src/plugins/geneve/geneve_packet.h (renamed from src/vnet/geneve/geneve_packet.h) | 0 | ||||
-rw-r--r-- | src/plugins/geneve/geneve_test.c (renamed from src/vnet/geneve/geneve_test.c) | 98 | ||||
-rw-r--r-- | src/plugins/geneve/test/test_geneve.py (renamed from test/test_geneve.py) | 0 | ||||
-rw-r--r-- | src/vat/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/vnet/CMakeLists.txt | 23 | ||||
-rw-r--r-- | src/vpp/CMakeLists.txt | 1 |
15 files changed, 146 insertions, 74 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index c7d3c5bb49e..ddde0d1e34a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -715,6 +715,11 @@ M: BenoƮt Ganne <bganne@cisco.com> M: Damjan Marion <damarion@cisco.com> F: src/plugins/af_xdp/ +Plugin - geneve +I: geneve +M: community vpp-dev@lists.fd.io +F: src/plugins/geneve/ + THE REST I: misc C: Contact vpp-dev Mailing List <vpp-dev@fd.io> diff --git a/src/plugins/geneve/CMakeLists.txt b/src/plugins/geneve/CMakeLists.txt new file mode 100644 index 00000000000..43eb0172097 --- /dev/null +++ b/src/plugins/geneve/CMakeLists.txt @@ -0,0 +1,35 @@ +# Copyright (c) 2020 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(geneve + SOURCES + geneve.c + encap.c + decap.c + geneve_api.c + + MULTIARCH_SOURCES + encap.c + decap.c + + API_FILES + geneve.api + + INSTALL_HEADERS + geneve.h + geneve_packet.h + geneve_error.def + + API_TEST_SOURCES + geneve_test.c +) diff --git a/src/vnet/geneve/decap.c b/src/plugins/geneve/decap.c index b570e3512c4..f42c0a88a5a 100644 --- a/src/vnet/geneve/decap.c +++ b/src/plugins/geneve/decap.c @@ -14,8 +14,8 @@ */ #include <vlib/vlib.h> -#include <vnet/pg/pg.h> -#include <vnet/geneve/geneve.h> + +#include <geneve/geneve.h> typedef struct { @@ -807,7 +807,7 @@ VLIB_NODE_FN (geneve6_input_node) (vlib_main_t * vm, static char *geneve_error_strings[] = { #define geneve_error(n,s) s, -#include <vnet/geneve/geneve_error.def> +#include <geneve/geneve_error.def> #undef geneve_error #undef _ }; diff --git a/src/vnet/geneve/encap.c b/src/plugins/geneve/encap.c index 2859a9ae652..6a84d0c5490 100644 --- a/src/vnet/geneve/encap.c +++ b/src/plugins/geneve/encap.c @@ -17,7 +17,7 @@ #include <vnet/vnet.h> #include <vnet/ip/ip.h> #include <vnet/ethernet/ethernet.h> -#include <vnet/geneve/geneve.h> +#include <geneve/geneve.h> /* Statistics (not all errors) */ #define foreach_geneve_encap_error \ diff --git a/src/vnet/geneve/geneve.api b/src/plugins/geneve/geneve.api index fd871733fb9..fd871733fb9 100644 --- a/src/vnet/geneve/geneve.api +++ b/src/plugins/geneve/geneve.api diff --git a/src/vnet/geneve/geneve.c b/src/plugins/geneve/geneve.c index e16616b69ea..f991af97571 100644 --- a/src/vnet/geneve/geneve.c +++ b/src/plugins/geneve/geneve.c @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include <vnet/geneve/geneve.h> +#include <geneve/geneve.h> #include <vnet/ip/format.h> #include <vnet/fib/fib_entry.h> #include <vnet/fib/fib_table.h> diff --git a/src/vnet/geneve/geneve.h b/src/plugins/geneve/geneve.h index 46b048ada3f..029f7534497 100644 --- a/src/vnet/geneve/geneve.h +++ b/src/plugins/geneve/geneve.h @@ -18,13 +18,15 @@ #include <vppinfra/error.h> #include <vppinfra/hash.h> #include <vnet/vnet.h> + +#include <geneve/geneve_packet.h> + #include <vnet/ip/ip.h> #include <vnet/ip/vtep.h> #include <vnet/l2/l2_input.h> #include <vnet/l2/l2_output.h> #include <vnet/l2/l2_bd.h> #include <vnet/ethernet/ethernet.h> -#include <vnet/geneve/geneve_packet.h> #include <vnet/ip/ip4_packet.h> #include <vnet/ip/ip6_packet.h> #include <vnet/udp/udp.h> @@ -154,7 +156,7 @@ typedef enum typedef enum { #define geneve_error(n,s) GENEVE_ERROR_##n, -#include <vnet/geneve/geneve_error.def> +#include <geneve/geneve_error.def> #undef geneve_error GENEVE_N_ERROR, } geneve_input_error_t; diff --git a/src/vnet/geneve/geneve_api.c b/src/plugins/geneve/geneve_api.c index 8c4a4cadc28..f6b9afda7d5 100644 --- a/src/vnet/geneve/geneve_api.c +++ b/src/plugins/geneve/geneve_api.c @@ -20,21 +20,28 @@ #include <vnet/interface.h> #include <vnet/api_errno.h> #include <vnet/feature/feature.h> -#include <vnet/geneve/geneve.h> #include <vnet/fib/fib_table.h> #include <vnet/ip/ip_types_api.h> -#include <vnet/geneve/geneve.api_enum.h> -#include <vnet/geneve/geneve.api_types.h> +#include <geneve/geneve.h> + +/* define message IDs */ +#include <vnet/format_fns.h> +#include <geneve/geneve.api_enum.h> +#include <geneve/geneve.api_types.h> + +/** + * Base message ID fot the plugin + */ +static u32 geneve_base_msg_id; +#define REPLY_MSG_ID_BASE geneve_base_msg_id -#define REPLY_MSG_ID_BASE gm->msg_id_base #include <vlibapi/api_helper_macros.h> static void vl_api_sw_interface_set_geneve_bypass_t_handler (vl_api_sw_interface_set_geneve_bypass_t * mp) { - geneve_main_t *gm = &geneve_main; vl_api_sw_interface_set_geneve_bypass_reply_t *rmp; int rv = 0; u32 sw_if_index = ntohl (mp->sw_if_index); @@ -50,7 +57,6 @@ static void static void vl_api_geneve_add_del_tunnel_t_handler (vl_api_geneve_add_del_tunnel_t * mp) { - geneve_main_t *gm = &geneve_main; vl_api_geneve_add_del_tunnel_reply_t *rmp; int rv = 0; ip4_main_t *im = &ip4_main; @@ -102,7 +108,6 @@ out: static void vl_api_geneve_add_del_tunnel2_t_handler (vl_api_geneve_add_del_tunnel2_t * mp) { - geneve_main_t *gm = &geneve_main; vl_api_geneve_add_del_tunnel2_reply_t *rmp; int rv = 0; ip4_main_t *im = &ip4_main; @@ -155,7 +160,6 @@ out: static void send_geneve_tunnel_details (geneve_tunnel_t * t, vl_api_registration_t * reg, u32 context) { - geneve_main_t *gm = &geneve_main; vl_api_geneve_tunnel_details_t *rmp; ip4_main_t *im4 = &ip4_main; ip6_main_t *im6 = &ip6_main; @@ -163,7 +167,7 @@ static void send_geneve_tunnel_details rmp = vl_msg_api_alloc (sizeof (*rmp)); clib_memset (rmp, 0, sizeof (*rmp)); - rmp->_vl_msg_id = ntohs (VL_API_GENEVE_TUNNEL_DETAILS + gm->msg_id_base); + rmp->_vl_msg_id = ntohs (VL_API_GENEVE_TUNNEL_DETAILS + REPLY_MSG_ID_BASE); ip_address_encode (&t->local, is_ipv6 ? IP46_TYPE_IP6 : IP46_TYPE_IP4, &rmp->src_address); ip_address_encode (&t->remote, is_ipv6 ? IP46_TYPE_IP6 : IP46_TYPE_IP4, @@ -222,23 +226,36 @@ static void vl_api_geneve_tunnel_dump_t_handler */ /* API definitions */ #include <vnet/format_fns.h> -#include <vnet/geneve/geneve.api.c> +#include <geneve/geneve.api.c> static clib_error_t * geneve_api_hookup (vlib_main_t * vm) { - geneve_main_t *gm = &geneve_main; + api_main_t *am = vlibapi_get_main (); /* * Set up the (msg_name, crc, message-id) table */ - gm->msg_id_base = setup_message_id_table (); + geneve_base_msg_id = setup_message_id_table (); + + am->api_trace_cfg[VL_API_GENEVE_ADD_DEL_TUNNEL + REPLY_MSG_ID_BASE].size += + 16 * sizeof (u32); return 0; } VLIB_API_INIT_FUNCTION (geneve_api_hookup); +#include <vlib/unix/plugin.h> +#include <vpp/app/version.h> + +/* *INDENT-OFF* */ +VLIB_PLUGIN_REGISTER () = { + .version = VPP_BUILD_VER, + .description = "GENEVE Tunnels", +}; +/* *INDENT-ON* */ + /* * fd.io coding-style-patch-verification: ON * diff --git a/src/vnet/geneve/geneve_error.def b/src/plugins/geneve/geneve_error.def index 73abc8ddbf1..73abc8ddbf1 100644 --- a/src/vnet/geneve/geneve_error.def +++ b/src/plugins/geneve/geneve_error.def diff --git a/src/vnet/geneve/geneve_packet.h b/src/plugins/geneve/geneve_packet.h index a0d0687434c..a0d0687434c 100644 --- a/src/vnet/geneve/geneve_packet.h +++ b/src/plugins/geneve/geneve_packet.h diff --git a/src/vnet/geneve/geneve_test.c b/src/plugins/geneve/geneve_test.c index 183ce5311de..ad6d3296ef6 100644 --- a/src/vnet/geneve/geneve_test.c +++ b/src/plugins/geneve/geneve_test.c @@ -1,7 +1,4 @@ /* - *------------------------------------------------------------------ - * geneve_test.c - * * Copyright (c) 2020 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. @@ -14,16 +11,22 @@ * 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 <vat/vat.h> #include <vlibapi/api.h> #include <vlibmemory/api.h> -#include <vnet/format_fns.h> +#include <vppinfra/error.h> + #include <vnet/ip/ip.h> -#include <vpp/api/types.h> -#include <vnet/geneve/geneve.h> +#include <vnet/ip/ip_types_api.h> +#include <geneve/geneve.h> + +/* define message IDs */ +#include <vnet/format_fns.h> +#include <geneve/geneve.api_enum.h> +#include <geneve/geneve.api_types.h> +#include <vpp/api/vpe.api_types.h> typedef struct { @@ -35,19 +38,17 @@ typedef struct geneve_test_main_t geneve_test_main; -/* Declare message IDs */ -#include <vnet/geneve/geneve.api_enum.h> -#include <vnet/geneve/geneve.api_types.h> -#include <vpp/api/vpe.api_types.h> - #define __plugin_msg_base geneve_test_main.msg_id_base #include <vlibapi/vat_helper_macros.h> -uword unformat_sw_if_index (unformat_input_t * input, va_list * args); -static void vl_api_geneve_add_del_tunnel2_reply_t_handler - (vl_api_geneve_add_del_tunnel2_reply_t * mp) -{ -} +/* Macro to finish up custom dump fns */ +#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) +#define FINISH \ + vec_add1 (s, 0); \ + vl_print (handle, (char *)s); \ + vec_free (s); \ + return handle; + static void vl_api_geneve_add_del_tunnel_reply_t_handler (vl_api_geneve_add_del_tunnel_reply_t * mp) { @@ -65,6 +66,23 @@ static void vl_api_geneve_add_del_tunnel_reply_t_handler } } +static void vl_api_geneve_add_del_tunnel2_reply_t_handler + (vl_api_geneve_add_del_tunnel2_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + if (vam->async_mode) + { + vam->async_errors += (retval < 0); + } + else + { + vam->retval = retval; + vam->sw_if_index = ntohl (mp->sw_if_index); + vam->result_ready = 1; + } +} + static int api_sw_interface_set_geneve_bypass (vat_main_t * vam) { @@ -115,6 +133,7 @@ api_sw_interface_set_geneve_bypass (vat_main_t * vam) W (ret); return ret; } + static uword unformat_geneve_decap_next (unformat_input_t * input, va_list * args) { @@ -131,12 +150,6 @@ static uword unformat_geneve_decap_next } static int -api_geneve_add_del_tunnel2 (vat_main_t * vam) -{ - return 0; // NOT YET IMPLEMENTED -} - -static int api_geneve_add_del_tunnel (vat_main_t * vam) { unformat_input_t *line_input = vam->input; @@ -291,6 +304,12 @@ api_geneve_add_del_tunnel (vat_main_t * vam) return ret; } +static int +api_geneve_add_del_tunnel2 (vat_main_t * vam) +{ + return api_geneve_add_del_tunnel (vam); +} + static void vl_api_geneve_tunnel_details_t_handler (vl_api_geneve_tunnel_details_t * mp) { @@ -327,7 +346,6 @@ api_geneve_tunnel_dump (vat_main_t * vam) u32 sw_if_index; u8 sw_if_index_set = 0; int ret; - geneve_test_main_t *gm = &geneve_test_main; /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -358,17 +376,37 @@ api_geneve_tunnel_dump (vat_main_t * vam) S (mp); /* Use a control ping for synchronization */ - if (!gm->ping_id) - gm->ping_id = vl_msg_api_get_msg_index ((u8 *) (VL_API_CONTROL_PING_CRC)); + if (!geneve_test_main.ping_id) + geneve_test_main.ping_id = + vl_msg_api_get_msg_index ((u8 *) (VL_API_CONTROL_PING_CRC)); mp_ping = vl_msg_api_alloc_as_if_client (sizeof (*mp_ping)); - mp_ping->_vl_msg_id = htons (gm->ping_id); + mp_ping->_vl_msg_id = htons (geneve_test_main.ping_id); mp_ping->client_index = vam->my_client_index; + + fformat (vam->ofp, "Sending ping id=%d\n", geneve_test_main.ping_id); + + vam->result_ready = 0; S (mp_ping); W (ret); return ret; } -#include <vnet/geneve/geneve.api_test.c> -VAT_REGISTER_FEATURE_FUNCTION(vat_geneve_plugin_register); +/* _(sw_interface_set_geneve_bypass, */ +/* "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") */ +/* _(geneve_add_del_tunnel, */ +/* "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" */ +/* "{ <intfc> | mcast_sw_if_index <nn> } }\n" */ +/* "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") */ +/* _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") */ + + +#include <geneve/geneve.api_test.c> +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/test/test_geneve.py b/src/plugins/geneve/test/test_geneve.py index 9ce1f8ff643..9ce1f8ff643 100644 --- a/test/test_geneve.py +++ b/src/plugins/geneve/test/test_geneve.py diff --git a/src/vat/CMakeLists.txt b/src/vat/CMakeLists.txt index ed14e846625..ee53386f114 100644 --- a/src/vat/CMakeLists.txt +++ b/src/vat/CMakeLists.txt @@ -33,7 +33,6 @@ add_vpp_executable(vpp_api_test ENABLE_EXPORTS ip_types.c protocols.def ../vnet/arp/arp_test.c - ../vnet/geneve/geneve_test.c DEPENDS api_headers diff --git a/src/vnet/CMakeLists.txt b/src/vnet/CMakeLists.txt index 579302c4687..124af13f202 100644 --- a/src/vnet/CMakeLists.txt +++ b/src/vnet/CMakeLists.txt @@ -322,29 +322,6 @@ list(APPEND VNET_MULTIARCH_SOURCES vxlan/decap.c) list(APPEND VNET_API_FILES vxlan/vxlan.api) ############################################################################## -# Layer 2 / Geneve -############################################################################## -list(APPEND VNET_SOURCES - geneve/geneve.c - geneve/encap.c - geneve/decap.c - geneve/geneve_api.c -) - -list(APPEND VNET_MULTIARCH_SOURCES - geneve/encap.c - geneve/decap.c -) - -list(APPEND VNET_HEADERS - geneve/geneve.h - geneve/geneve_packet.h - geneve/geneve_error.def -) - -list(APPEND VNET_API_FILES geneve/geneve.api) - -############################################################################## # Layer 2 / Bonding ############################################################################## list(APPEND VNET_SOURCES diff --git a/src/vpp/CMakeLists.txt b/src/vpp/CMakeLists.txt index 64a8eb86bc6..ae1e4d76c02 100644 --- a/src/vpp/CMakeLists.txt +++ b/src/vpp/CMakeLists.txt @@ -74,7 +74,6 @@ if(VPP_API_TEST_BUILTIN) api/plugin.c api/types.c ../vnet/arp/arp_test.c - ../vnet/geneve/geneve_test.c ) add_definitions(-DVPP_API_TEST_BUILTIN=1) endif() |