diff options
author | Gabriel Oginski <gabrielx.oginski@intel.com> | 2022-06-29 12:54:30 +0000 |
---|---|---|
committer | Gabriel Oginski <gabrielx.oginski@intel.com> | 2022-10-18 06:26:30 +0000 |
commit | 225d15cae9680b505c0cf73018177d0e8bb88668 (patch) | |
tree | 264f9f048fda1b826faaccb30e179bc49373f4ca /extras/strongswan/vpp_sswan/kernel_vpp_plugin.c | |
parent | 994d86f70e1957b30d18eebdd6a06634153b2308 (diff) |
vpp-swan: Add plugin for vpp-swan
Added plugin vpp-swan is a plugin that helps offloading
Strongswan IPsec ESP process from Linux Kernel to VPP.
Type: feature
Signed-off-by: Gabriel Oginski <gabrielx.oginski@intel.com>
Change-Id: Iec77945892453fac1890d3c49d7d86fc6b09c893
(cherry picked from commit 4e88e041ad47bf422bbb2a0940f77aba11ea2178)
Diffstat (limited to 'extras/strongswan/vpp_sswan/kernel_vpp_plugin.c')
-rw-r--r-- | extras/strongswan/vpp_sswan/kernel_vpp_plugin.c | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/extras/strongswan/vpp_sswan/kernel_vpp_plugin.c b/extras/strongswan/vpp_sswan/kernel_vpp_plugin.c new file mode 100644 index 00000000000..9791987f5ae --- /dev/null +++ b/extras/strongswan/vpp_sswan/kernel_vpp_plugin.c @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2022 Intel 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. + */ + +#include <utils/debug.h> +#include <vlibapi/api.h> +#include <vlibmemory/api.h> + +#define vl_typedefs +#define vl_endianfun +/* Include the (first) vlib-api API definition layer */ +#include <vlibmemory/vl_memory_api_h.h> +/* Include the current layer (third) vpp API definition layer */ +#include <vpp/api/vpe_types.api.h> +#include <vpp/api/vpe.api.h> +#undef vl_typedefs +#undef vl_endianfun + +#include "kernel_vpp_plugin.h" +#include "kernel_vpp_shared.h" +#include "kernel_vpp_ipsec.h" +#include "kernel_vpp_net.h" + +typedef struct private_kernel_vpp_plugin_t private_kernel_vpp_plugin_t; + +/** + * private data of kernel vpp plugin + */ +struct private_kernel_vpp_plugin_t +{ + /** + * implements plugin interface + */ + kernel_vpp_plugin_t public; + + vac_t *vac; +}; + +METHOD (plugin_t, get_name, char *, private_kernel_vpp_plugin_t *this) +{ + return "kernel-vpp"; +} + +METHOD (plugin_t, get_features, int, private_kernel_vpp_plugin_t *this, + plugin_feature_t *features[]) +{ + static plugin_feature_t f[] = { + PLUGIN_CALLBACK (kernel_ipsec_register, kernel_vpp_ipsec_create), + PLUGIN_PROVIDE (CUSTOM, "kernel-ipsec"), + PLUGIN_CALLBACK (kernel_net_register, kernel_vpp_net_create), + PLUGIN_PROVIDE (CUSTOM, "kernel-net"), + }; + *features = f; + return countof (f); +} + +METHOD (plugin_t, destroy, void, private_kernel_vpp_plugin_t *this) +{ + if (this->vac) + { + lib->set (lib, "kernel-vpp-vac", NULL); + this->vac->destroy (this->vac); + } + free (this); +} + +plugin_t * +kernel_vpp_plugin_create () +{ + private_kernel_vpp_plugin_t *this; + + INIT(this, + .public = { + .plugin = { + .get_name = _get_name, + .get_features = _get_features, + .destroy = _destroy, + }, + }, + ); + + this->vac = vac_create ("strongswan"); + if (!this->vac) + { + DBG1 (DBG_KNL, "vac_create failed"); + destroy (this); + return NULL; + } + lib->set (lib, "kernel-vpp-vac", this->vac); + + return &this->public.plugin; +} |