diff options
-rw-r--r-- | docs/spelling_wordlist.txt | 1 | ||||
-rw-r--r-- | src/plugins/cdp/cdp_periodic.c | 2 | ||||
-rw-r--r-- | src/plugins/osi/node.c | 19 | ||||
-rw-r--r-- | src/plugins/ppp/CMakeLists.txt | 25 | ||||
-rw-r--r-- | src/plugins/ppp/error.def (renamed from src/vnet/ppp/error.def) | 0 | ||||
-rw-r--r-- | src/plugins/ppp/node.c (renamed from src/vnet/ppp/node.c) | 9 | ||||
-rw-r--r-- | src/plugins/ppp/packet.h (renamed from src/vnet/ppp/packet.h) | 0 | ||||
-rw-r--r-- | src/plugins/ppp/pg.c (renamed from src/vnet/ppp/pg.c) | 2 | ||||
-rw-r--r-- | src/plugins/ppp/plugin.c | 26 | ||||
-rw-r--r-- | src/plugins/ppp/ppp.c (renamed from src/vnet/ppp/ppp.c) | 23 | ||||
-rw-r--r-- | src/plugins/ppp/ppp.h (renamed from src/vnet/ppp/ppp.h) | 12 | ||||
-rw-r--r-- | src/plugins/pppoe/pppoe.c | 2 | ||||
-rw-r--r-- | src/plugins/pppoe/pppoe_cp_node.c | 2 | ||||
-rw-r--r-- | src/plugins/pppoe/pppoe_decap.c | 2 | ||||
-rw-r--r-- | src/vnet/CMakeLists.txt | 15 | ||||
-rw-r--r-- | src/vnet/ip/ip4_forward.c | 1 | ||||
-rw-r--r-- | src/vnet/ip/ip4_input.c | 2 | ||||
-rw-r--r-- | src/vnet/ip/ip6_input.c | 2 |
18 files changed, 105 insertions, 40 deletions
diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt index d6c5b97793e..7f62393716e 100644 --- a/docs/spelling_wordlist.txt +++ b/docs/spelling_wordlist.txt @@ -868,6 +868,7 @@ Pollable portranges poweroff ppc +ppp pppoe pps pre diff --git a/src/plugins/cdp/cdp_periodic.c b/src/plugins/cdp/cdp_periodic.c index 03a2de0d9ab..3e700ae46f8 100644 --- a/src/plugins/cdp/cdp_periodic.c +++ b/src/plugins/cdp/cdp_periodic.c @@ -16,7 +16,7 @@ #include <vppinfra/hash.h> #include <vppinfra/pcap.h> #include <vnet/srp/srp.h> -#include <vnet/ppp/ppp.h> +#include <plugins/ppp/ppp.h> #include <vnet/hdlc/hdlc.h> #include <vnet/srp/packet.h> diff --git a/src/plugins/osi/node.c b/src/plugins/osi/node.c index a36b1525e0e..51a3dc6424d 100644 --- a/src/plugins/osi/node.c +++ b/src/plugins/osi/node.c @@ -40,9 +40,10 @@ #include <vlib/vlib.h> #include <vnet/pg/pg.h> #include <osi/osi.h> -#include <vnet/ppp/ppp.h> +#include <plugins/ppp/ppp.h> #include <vnet/hdlc/hdlc.h> #include <vnet/llc/llc.h> +#include <vnet/plugin/plugin.h> #define foreach_osi_input_next \ _ (PUNT, "error-punt") \ @@ -271,11 +272,24 @@ osi_setup_node (vlib_main_t *vm, u32 node_index) pn->unformat_edit = unformat_pg_osi_header; } +typedef void (*ppp_register_input_protocol_fn) (vlib_main_t *vm, + ppp_protocol_t protocol, + u32 node_index); + static clib_error_t * osi_input_init (vlib_main_t * vm) { clib_error_t *error = 0; osi_main_t *lm = &osi_main; + ppp_register_input_protocol_fn ppp_register_input_protocol_fn_ptr; + + ppp_register_input_protocol_fn_ptr = + vlib_get_plugin_symbol ("ppp_plugin.so", "ppp_register_input_protocol"); + if (ppp_register_input_protocol_fn_ptr == 0) + { + error = clib_error_return (0, "ppp_plugin.so is not loaded"); + return error; + } if ((error = vlib_call_init_function (vm, osi_init))) return error; @@ -288,7 +302,8 @@ osi_input_init (vlib_main_t * vm) lm->input_next_by_protocol[i] = OSI_INPUT_NEXT_DROP; } - ppp_register_input_protocol (vm, PPP_PROTOCOL_osi, osi_input_node.index); + ppp_register_input_protocol_fn_ptr (vm, PPP_PROTOCOL_osi, + osi_input_node.index); hdlc_register_input_protocol (vm, HDLC_PROTOCOL_osi, osi_input_node.index); llc_register_input_protocol (vm, LLC_PROTOCOL_osi_layer1, osi_input_node.index); diff --git a/src/plugins/ppp/CMakeLists.txt b/src/plugins/ppp/CMakeLists.txt new file mode 100644 index 00000000000..771d4dcd732 --- /dev/null +++ b/src/plugins/ppp/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (c) 2024 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(ppp + SOURCES + node.c + pg.c + ppp.c + plugin.c + + INSTALL_HEADERS + ppp.h + error.def + packet.h +)
\ No newline at end of file diff --git a/src/vnet/ppp/error.def b/src/plugins/ppp/error.def index ba645408582..ba645408582 100644 --- a/src/vnet/ppp/error.def +++ b/src/plugins/ppp/error.def diff --git a/src/vnet/ppp/node.c b/src/plugins/ppp/node.c index fa056bfb99f..4c252e444c7 100644 --- a/src/vnet/ppp/node.c +++ b/src/plugins/ppp/node.c @@ -39,7 +39,7 @@ #include <vlib/vlib.h> #include <vnet/pg/pg.h> -#include <vnet/ppp/ppp.h> +#include <plugins/ppp/ppp.h> #include <vppinfra/sparse_vec.h> #define foreach_ppp_input_next \ @@ -323,7 +323,6 @@ ppp_setup_node (vlib_main_t *vm, u32 node_index) static clib_error_t * ppp_input_init (vlib_main_t * vm) { - { clib_error_t *error = vlib_call_init_function (vm, ppp_init); if (error) @@ -339,9 +338,9 @@ ppp_input_init (vlib_main_t * vm) VLIB_INIT_FUNCTION (ppp_input_init); VLIB_WORKER_INIT_FUNCTION (ppp_input_runtime_init); -void -ppp_register_input_protocol (vlib_main_t * vm, - ppp_protocol_t protocol, u32 node_index) +__clib_export void +ppp_register_input_protocol (vlib_main_t *vm, ppp_protocol_t protocol, + u32 node_index) { ppp_main_t *em = &ppp_main; ppp_protocol_info_t *pi; diff --git a/src/vnet/ppp/packet.h b/src/plugins/ppp/packet.h index cab9743de92..cab9743de92 100644 --- a/src/vnet/ppp/packet.h +++ b/src/plugins/ppp/packet.h diff --git a/src/vnet/ppp/pg.c b/src/plugins/ppp/pg.c index 0b46ccb9052..39f6c25badc 100644 --- a/src/vnet/ppp/pg.c +++ b/src/plugins/ppp/pg.c @@ -39,7 +39,7 @@ #include <vlib/vlib.h> #include <vnet/pg/pg.h> -#include <vnet/ppp/ppp.h> +#include <plugins/ppp/ppp.h> typedef struct { diff --git a/src/plugins/ppp/plugin.c b/src/plugins/ppp/plugin.c new file mode 100644 index 00000000000..fac25b3e5c7 --- /dev/null +++ b/src/plugins/ppp/plugin.c @@ -0,0 +1,26 @@ +/* + * plugin.c: ppp + * + * Copyright (c) 2024 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. + */ + +#include <vlib/vlib.h> +#include <vnet/plugin/plugin.h> +#include <vpp/app/version.h> + +// register a plugin +VLIB_PLUGIN_REGISTER () = { + .version = VPP_BUILD_VER, + .description = "Point-to-Point Protocol (PPP) plugin", +}; diff --git a/src/vnet/ppp/ppp.c b/src/plugins/ppp/ppp.c index 8aa8504fcdd..8b394dc4b72 100644 --- a/src/vnet/ppp/ppp.c +++ b/src/plugins/ppp/ppp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Cisco and/or its affiliates. + * Copyright (c) 2024 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: @@ -38,7 +38,7 @@ */ #include <vnet/vnet.h> -#include <vnet/ppp/ppp.h> +#include <plugins/ppp/ppp.h> /* Global main structure. */ ppp_main_t ppp_main; @@ -226,10 +226,21 @@ static clib_error_t * ppp_init (vlib_main_t * vm) { ppp_main_t *pm = &ppp_main; + clib_error_t *error; + vlib_node_t *ip4_input_node, *ip6_input_node; clib_memset (pm, 0, sizeof (pm[0])); pm->vlib_main = vm; + if ((error = vlib_call_init_function (vm, ip_main_init))) + return error; + + if ((error = vlib_call_init_function (vm, ip4_init))) + return error; + + if ((error = vlib_call_init_function (vm, ip6_init))) + return error; + pm->protocol_info_by_name = hash_create_string (0, sizeof (uword)); pm->protocol_info_by_protocol = hash_create (0, sizeof (uword)); @@ -237,6 +248,14 @@ ppp_init (vlib_main_t * vm) foreach_ppp_protocol; #undef _ + ip4_input_node = vlib_get_node_by_name (vm, (u8 *) "ip4-input"); + ASSERT (ip4_input_node); + ip6_input_node = vlib_get_node_by_name (vm, (u8 *) "ip6-input"); + ASSERT (ip6_input_node); + + ppp_register_input_protocol (vm, PPP_PROTOCOL_ip4, ip4_input_node->index); + ppp_register_input_protocol (vm, PPP_PROTOCOL_ip6, ip6_input_node->index); + return vlib_call_init_function (vm, ppp_input_init); } diff --git a/src/vnet/ppp/ppp.h b/src/plugins/ppp/ppp.h index 77da8c19bba..b94f096476a 100644 --- a/src/vnet/ppp/ppp.h +++ b/src/plugins/ppp/ppp.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Cisco and/or its affiliates. + * Copyright (c) 2024 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: @@ -41,14 +41,14 @@ #define included_ppp_h #include <vnet/vnet.h> -#include <vnet/ppp/packet.h> +#include <ppp/packet.h> extern vnet_hw_interface_class_t ppp_hw_interface_class; typedef enum { #define ppp_error(n,s) PPP_ERROR_##n, -#include <vnet/ppp/error.def> +#include <ppp/error.def> #undef ppp_error PPP_N_ERROR, } ppp_error_t; @@ -105,9 +105,9 @@ unformat_function_t unformat_ppp_protocol_net_byte_order; unformat_function_t unformat_ppp_header; unformat_function_t unformat_pg_ppp_header; -void -ppp_register_input_protocol (vlib_main_t * vm, - ppp_protocol_t protocol, u32 node_index); +__clib_export void ppp_register_input_protocol (vlib_main_t *vm, + ppp_protocol_t protocol, + u32 node_index); #endif /* included_ppp_h */ diff --git a/src/plugins/pppoe/pppoe.c b/src/plugins/pppoe/pppoe.c index 0d5f9c1aeac..497fbc09ae0 100644 --- a/src/plugins/pppoe/pppoe.c +++ b/src/plugins/pppoe/pppoe.c @@ -27,7 +27,7 @@ #include <vnet/dpo/interface_tx_dpo.h> #include <vnet/plugin/plugin.h> #include <vpp/app/version.h> -#include <vnet/ppp/packet.h> +#include <ppp/packet.h> #include <pppoe/pppoe.h> #include <vnet/adj/adj_midchain.h> #include <vnet/adj/adj_mcast.h> diff --git a/src/plugins/pppoe/pppoe_cp_node.c b/src/plugins/pppoe/pppoe_cp_node.c index 1a44b5d3853..c96559679f0 100644 --- a/src/plugins/pppoe/pppoe_cp_node.c +++ b/src/plugins/pppoe/pppoe_cp_node.c @@ -16,7 +16,7 @@ */ #include <vlib/vlib.h> -#include <vnet/ppp/packet.h> +#include <ppp/packet.h> #include <pppoe/pppoe.h> #define foreach_pppoe_cp_next \ diff --git a/src/plugins/pppoe/pppoe_decap.c b/src/plugins/pppoe/pppoe_decap.c index 7c456a7a9cc..854364b1aca 100644 --- a/src/plugins/pppoe/pppoe_decap.c +++ b/src/plugins/pppoe/pppoe_decap.c @@ -16,7 +16,7 @@ */ #include <vlib/vlib.h> -#include <vnet/ppp/packet.h> +#include <ppp/packet.h> #include <pppoe/pppoe.h> typedef struct { diff --git a/src/vnet/CMakeLists.txt b/src/vnet/CMakeLists.txt index 254849cbc1b..46b1a870e9e 100644 --- a/src/vnet/CMakeLists.txt +++ b/src/vnet/CMakeLists.txt @@ -269,21 +269,6 @@ list(APPEND VNET_HEADERS ) ############################################################################## -# Layer 2 protocol: PPP -############################################################################## -list(APPEND VNET_SOURCES - ppp/node.c - ppp/pg.c - ppp/ppp.c -) - -list(APPEND VNET_HEADERS - ppp/error.def - ppp/ppp.h - ppp/packet.h -) - -############################################################################## # Layer 2 protocol: HDLC ############################################################################## list(APPEND VNET_SOURCES diff --git a/src/vnet/ip/ip4_forward.c b/src/vnet/ip/ip4_forward.c index ff74b52eb18..a378dc5268a 100644 --- a/src/vnet/ip/ip4_forward.c +++ b/src/vnet/ip/ip4_forward.c @@ -42,7 +42,6 @@ #include <vnet/ip/ip_frag.h> #include <vnet/ethernet/ethernet.h> /* for ethernet_header_t */ #include <vnet/ethernet/arp_packet.h> /* for ethernet_arp_header_t */ -#include <vnet/ppp/ppp.h> #include <vnet/srp/srp.h> /* for srp_hw_interface_class */ #include <vnet/api_errno.h> /* for API error numbers */ #include <vnet/fib/fib_table.h> /* for FIB table and entry creation */ diff --git a/src/vnet/ip/ip4_input.c b/src/vnet/ip/ip4_input.c index 106d17da3cb..af2b89ab2ec 100644 --- a/src/vnet/ip/ip4_input.c +++ b/src/vnet/ip/ip4_input.c @@ -40,7 +40,6 @@ #include <vnet/ip/ip4_input.h> #include <vnet/ethernet/ethernet.h> #include <vnet/pg/pg.h> -#include <vnet/ppp/ppp.h> #include <vnet/hdlc/hdlc.h> #include <vnet/util/throttle.h> @@ -411,7 +410,6 @@ ip4_init (vlib_main_t * vm) clib_error_t *error; ethernet_register_input_type (vm, ETHERNET_TYPE_IP4, ip4_input_node.index); - ppp_register_input_protocol (vm, PPP_PROTOCOL_ip4, ip4_input_node.index); hdlc_register_input_protocol (vm, HDLC_PROTOCOL_ip4, ip4_input_node.index); { diff --git a/src/vnet/ip/ip6_input.c b/src/vnet/ip/ip6_input.c index 64c9d76ebaa..ae59b765d2e 100644 --- a/src/vnet/ip/ip6_input.c +++ b/src/vnet/ip/ip6_input.c @@ -39,7 +39,6 @@ #include <vnet/ip/ip6_input.h> #include <vnet/ethernet/ethernet.h> -#include <vnet/ppp/ppp.h> #include <vnet/hdlc/hdlc.h> #include <vnet/pg/pg.h> @@ -242,7 +241,6 @@ static clib_error_t * ip6_init (vlib_main_t * vm) { ethernet_register_input_type (vm, ETHERNET_TYPE_IP6, ip6_input_node.index); - ppp_register_input_protocol (vm, PPP_PROTOCOL_ip6, ip6_input_node.index); hdlc_register_input_protocol (vm, HDLC_PROTOCOL_ip6, ip6_input_node.index); { |