misc: Move l2tp to plugin

Type: refactor

Change-Id: Ifb36eeb146b87e9e305881429d32d6879e955e1e
Signed-off-by: Neale Ranns <nranns@cisco.com>
This commit is contained in:
Neale Ranns
2020-09-18 14:05:45 +00:00
committed by Ole Tr�an
parent 3f9fdd9846
commit 6810a77da3
16 changed files with 385 additions and 502 deletions

View File

@ -0,0 +1,38 @@
# Copyright (c) 2018 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.
##############################################################################
# Tunnel protocol: l2tpv3
##############################################################################
add_vpp_plugin(l2tp
SOURCES
l2tp.c
encap.c
decap.c
pg.c
l2tp_api.c
MULTIARCH_SOURCES
encap.c
decap.c
INSTALL_HEADERS
l2tp.h
packet.h
API_FILES
l2tp.api
API_TEST_SOURCES
l2tp_test.c
)

View File

@ -20,7 +20,7 @@
#include <vnet/vnet.h>
#include <vnet/ip/ip.h>
#include <vnet/ethernet/ethernet.h>
#include <vnet/l2tp/l2tp.h>
#include <l2tp/l2tp.h>
#include <vnet/l2/l2_input.h>
/* Statistics (not really errors) */

View File

@ -20,7 +20,7 @@
#include <vnet/vnet.h>
#include <vnet/ip/ip.h>
#include <vnet/ethernet/ethernet.h>
#include <vnet/l2tp/l2tp.h>
#include <l2tp/l2tp.h>
/* Statistics (not really errors) */
#define foreach_l2t_encap_error \

View File

@ -21,7 +21,7 @@
#include <vnet/ip/ip.h>
#include <vnet/l2/l2_input.h>
#include <vnet/ethernet/ethernet.h>
#include <vnet/l2tp/l2tp.h>
#include <l2tp/l2tp.h>
l2t_main_t l2t_main;

View File

@ -20,7 +20,7 @@
#include <vlib/vlib.h>
#include <vnet/ip/ip.h>
#include <vnet/l2tp/packet.h>
#include <l2tp/packet.h>
typedef struct
{

View File

@ -22,34 +22,22 @@
#include <vnet/interface.h>
#include <vnet/api_errno.h>
#include <vnet/l2tp/l2tp.h>
#include <l2tp/l2tp.h>
#include <vnet/ip/ip_types_api.h>
#include <vnet/vnet_msg_enum.h>
/* define message IDs */
#include <vnet/format_fns.h>
#include <l2tp/l2tp.api_enum.h>
#include <l2tp/l2tp.api_types.h>
#define vl_typedefs /* define message structures */
#include <vnet/vnet_all_api_h.h>
#undef vl_typedefs
#define vl_endianfun /* define message structures */
#include <vnet/vnet_all_api_h.h>
#undef vl_endianfun
/* instantiate all the print functions we know about */
#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
#define vl_printfun
#include <vnet/vnet_all_api_h.h>
#undef vl_printfun
/**
* Base message ID fot the plugin
*/
static u32 l2tp_base_msg_id;
#define REPLY_MSG_ID_BASE l2tp_base_msg_id
#include <vlibapi/api_helper_macros.h>
#define foreach_vpe_api_msg \
_(L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel) \
_(L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies) \
_(L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable) \
_(L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key) \
_(SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump)
static void
send_sw_if_l2tpv3_tunnel_details (vpe_api_main_t * am,
vl_api_registration_t * reg,
@ -67,9 +55,10 @@ send_sw_if_l2tpv3_tunnel_details (vpe_api_main_t * am,
mp = vl_msg_api_alloc (sizeof (*mp));
clib_memset (mp, 0, sizeof (*mp));
mp->_vl_msg_id = ntohs (VL_API_SW_IF_L2TPV3_TUNNEL_DETAILS);
strncpy ((char *) mp->interface_name,
(char *) if_name, ARRAY_LEN (mp->interface_name) - 1);
mp->_vl_msg_id =
ntohs (VL_API_SW_IF_L2TPV3_TUNNEL_DETAILS + REPLY_MSG_ID_BASE);
strncpy ((char *) mp->interface_name, (char *) if_name,
ARRAY_LEN (mp->interface_name) - 1);
mp->sw_if_index = ntohl (si->sw_if_index);
mp->local_session_id = s->local_session_id;
mp->remote_session_id = s->remote_session_id;
@ -227,43 +216,32 @@ out:
* added the client registration handlers.
* See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
*/
#define vl_msg_name_crc_list
#include <vnet/vnet_all_api_h.h>
#undef vl_msg_name_crc_list
static void
setup_message_id_table (api_main_t * am)
{
#define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
foreach_vl_msg_name_crc_l2tp;
#undef _
}
#include <l2tp/l2tp.api.c>
static clib_error_t *
l2tp_api_hookup (vlib_main_t * vm)
{
api_main_t *am = vlibapi_get_main ();
#define _(N,n) \
vl_msg_api_set_handlers(VL_API_##N, #n, \
vl_api_##n##_t_handler, \
vl_noop_handler, \
vl_api_##n##_t_endian, \
vl_api_##n##_t_print, \
sizeof(vl_api_##n##_t), 1);
foreach_vpe_api_msg;
#undef _
/*
* Set up the (msg_name, crc, message-id) table
*/
setup_message_id_table (am);
l2tp_base_msg_id = setup_message_id_table ();
return 0;
}
VLIB_API_INIT_FUNCTION (l2tp_api_hookup);
#include <vlib/unix/plugin.h>
#include <vpp/app/version.h>
/* *INDENT-OFF* */
VLIB_PLUGIN_REGISTER () = {
.version = VPP_BUILD_VER,
.description = "Layer 2 Tunneling Protocol v3 (L2TP)",
};
/* *INDENT-ON* */
/*
* fd.io coding-style-patch-verification: ON
*

File diff suppressed because it is too large Load Diff

View File

@ -17,7 +17,7 @@
#include <vlib/vlib.h>
#include <vnet/pg/pg.h>
#include <vnet/l2tp/l2tp.h>
#include <l2tp/l2tp.h>
typedef struct
{

File diff suppressed because it is too large Load Diff

View File

@ -761,29 +761,6 @@ list(APPEND VNET_HEADERS
tunnel/tunnel_dp.h
)
##############################################################################
# Tunnel protocol: l2tpv3
##############################################################################
list(APPEND VNET_SOURCES
l2tp/l2tp.c
l2tp/encap.c
l2tp/decap.c
l2tp/pg.c
l2tp/l2tp_api.c
)
list(APPEND VNET_MULTIARCH_SOURCES
l2tp/encap.c
l2tp/decap.c
)
list(APPEND VNET_HEADERS
l2tp/l2tp.h
l2tp/packet.h
)
list(APPEND VNET_API_FILES l2tp/l2tp.api)
##############################################################################
# Tunnel protocol: gre+mpls
##############################################################################

View File

@ -40,7 +40,6 @@
#include <vnet/gre/gre.api.h>
#include <vnet/interface.api.h>
#include <vnet/l2/l2.api.h>
#include <vnet/l2tp/l2tp.api.h>
#include <vnet/span/span.api.h>
#include <vnet/ip/ip.api.h>
#include <vnet/vxlan/vxlan.api.h>

View File

@ -24,7 +24,6 @@
#include <vnet/fib/fib_api.h>
#include <vnet/unix/tuntap.h>
#include <vnet/mpls/mpls.h>
#include <vnet/l2tp/l2tp.h>
#include <vnet/l2/l2_input.h>
#include <vnet/srv6/sr.h>
#include <vnet/srmpls/sr_mpls.h>
@ -1429,100 +1428,6 @@ static void *vl_api_add_node_next_t_print
FINISH;
}
static void *vl_api_l2tpv3_create_tunnel_t_print
(vl_api_l2tpv3_create_tunnel_t * mp, void *handle)
{
u8 *s;
s = format (0, "SCRIPT: l2tpv3_create_tunnel ");
s = format (s, "client_address %U our_address %U ",
format_ip6_address,
(ip6_address_t *) (mp->client_address.un.ip6),
format_ip6_address, (ip6_address_t *) (mp->our_address.un.ip6));
s = format (s, "local_session_id %d ", (mp->local_session_id));
s = format (s, "remote_session_id %d ", (mp->remote_session_id));
s = format (s, "local_cookie %lld ",
clib_net_to_host_u64 (mp->local_cookie));
s = format (s, "remote_cookie %lld ",
clib_net_to_host_u64 (mp->remote_cookie));
if (mp->l2_sublayer_present)
s = format (s, "l2-sublayer-present ");
FINISH;
}
static void *vl_api_l2tpv3_set_tunnel_cookies_t_print
(vl_api_l2tpv3_set_tunnel_cookies_t * mp, void *handle)
{
u8 *s;
s = format (0, "SCRIPT: l2tpv3_set_tunnel_cookies ");
s = format (s, "sw_if_index %d ", (mp->sw_if_index));
s = format (s, "new_local_cookie %llu ",
clib_net_to_host_u64 (mp->new_local_cookie));
s = format (s, "new_remote_cookie %llu ",
clib_net_to_host_u64 (mp->new_remote_cookie));
FINISH;
}
static void *vl_api_l2tpv3_interface_enable_disable_t_print
(vl_api_l2tpv3_interface_enable_disable_t * mp, void *handle)
{
u8 *s;
s = format (0, "SCRIPT: l2tpv3_interface_enable_disable ");
s = format (s, "sw_if_index %d ", (mp->sw_if_index));
if (mp->enable_disable == 0)
s = format (s, "del ");
FINISH;
}
static void *vl_api_l2tpv3_set_lookup_key_t_print
(vl_api_l2tpv3_set_lookup_key_t * mp, void *handle)
{
u8 *s;
char *str = "unknown";
s = format (0, "SCRIPT: l2tpv3_set_lookup_key ");
switch (mp->key)
{
case L2T_LOOKUP_SRC_ADDRESS:
str = "lookup_v6_src";
break;
case L2T_LOOKUP_DST_ADDRESS:
str = "lookup_v6_dst";
break;
case L2T_LOOKUP_SESSION_ID:
str = "lookup_session_id";
break;
default:
break;
}
s = format (s, "%s ", str);
FINISH;
}
static void *vl_api_sw_if_l2tpv3_tunnel_dump_t_print
(vl_api_sw_if_l2tpv3_tunnel_dump_t * mp, void *handle)
{
u8 *s;
s = format (0, "SCRIPT: sw_if_l2tpv3_tunnel_dump ");
FINISH;
}
static void *vl_api_vxlan_add_del_tunnel_t_print
(vl_api_vxlan_add_del_tunnel_t * mp, void *handle)
{
@ -3552,11 +3457,6 @@ _(BRIDGE_DOMAIN_SET_MAC_AGE, bridge_domain_set_mac_age) \
_(CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table) \
_(CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables) \
_(ADD_NODE_NEXT, add_node_next) \
_(L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel) \
_(L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies) \
_(L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable) \
_(L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key) \
_(SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump) \
_(VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel) \
_(VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump) \
_(VXLAN_OFFLOAD_RX, vxlan_offload_rx) \