Type: refactor
This patch moves osi into a plugin, and also modifies
the init functions of llc and snap to preserve init
order dependency (llc_init --> osi_init --> snap_init).
While the initial intent was to move osi/llc/snap together
into a single plugin, there exists a dependency on llc
in vnet/ethernet, which would require further refactoring
and testing work.
Change-Id: Ic0eff030ee29c8d316c0e0fe13931451aa193527
Signed-off-by: Hadi Rayan Al-Sandid <[email protected]>
Optimisations
optimised
os
+osi
outacl
packagecloud
papi
--- /dev/null
+# Copyright (c) 2023 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(osi
+
+ SOURCES
+ osi.c
+ node.c
+ pg.c
+ plugin.c
+
+ INSTALL_HEADERS
+ osi.h
+)
--- /dev/null
+---
+name: OSI plugin
+maintainer:
+features:
+ - Adds support for OSI protocols (SAP types)
+ - Registered as input protocol for PPP, HDLC, and LLC
+missing:
+ - No tests for this feature currently exist
+description: ""
+state: experimental
#include <vlib/vlib.h>
#include <vnet/pg/pg.h>
-#include <vnet/osi/osi.h>
+#include <osi/osi.h>
#include <vnet/ppp/ppp.h>
#include <vnet/hdlc/hdlc.h>
#include <vnet/llc/llc.h>
*/
#include <vnet/vnet.h>
-#include <vnet/osi/osi.h>
+#include <osi/osi.h>
/* Global main structure. */
osi_main_t osi_main;
static clib_error_t *
osi_init (vlib_main_t * vm)
{
- clib_error_t *error = 0;
osi_main_t *pm = &osi_main;
- /* init order dependency: llc_init -> osi_init */
- if ((error = vlib_call_init_function (vm, llc_init)))
- return error;
-
clib_memset (pm, 0, sizeof (pm[0]));
pm->vlib_main = vm;
return vlib_call_init_function (vm, osi_input_init);
}
-VLIB_INIT_FUNCTION (osi_init);
-
+/* init order dependency: llc_init -> osi_init -> snap_init*/
+/* Otherwise, osi_input_init will wipe out e.g. the snap init */
+VLIB_INIT_FUNCTION (osi_init) = {
+ .init_order = VLIB_INITS ("llc_init", "osi_init", "snap_init"),
+};
/*
* fd.io coding-style-patch-verification: ON
#include <vlib/vlib.h>
#include <vnet/pg/pg.h>
-#include <vnet/osi/osi.h>
+#include <osi/osi.h>
typedef struct
{
--- /dev/null
+/*
+ * plugin.c: osi
+ *
+ * Copyright (c) 2023 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>
+VLIB_PLUGIN_REGISTER () = {
+ .version = VPP_BUILD_VER,
+ .description = "OSI plugin",
+};
\ No newline at end of file
ipsec/ah.h
)
-##############################################################################
-# Layer 3 protocol: osi
-##############################################################################
-list(APPEND VNET_SOURCES
- osi/node.c
- osi/osi.c
- osi/pg.c
-)
-
-list(APPEND VNET_HEADERS
- osi/osi.h
-)
-
##############################################################################
# Layer 4 protocol: tcp
##############################################################################
static clib_error_t *
llc_init (vlib_main_t * vm)
{
- clib_error_t *error;
llc_main_t *pm = &llc_main;
clib_memset (pm, 0, sizeof (pm[0]));
foreach_llc_protocol;
#undef _
- if ((error = vlib_call_init_function (vm, snap_init)))
- return error;
-
return vlib_call_init_function (vm, llc_input_init);
}
clib_error_t *error = vlib_call_init_function (vm, llc_input_init);
if (error)
clib_error_report (error);
- /* Otherwise, osi_input_init will wipe out e.g. the snap init */
- error = vlib_call_init_function (vm, osi_input_init);
- if (error)
- clib_error_report (error);
}
pi = llc_get_protocol_info (lm, protocol);
return vlib_call_init_function (vm, snap_input_init);
}
-VLIB_INIT_FUNCTION (snap_init);
-
+VLIB_INIT_FUNCTION (snap_init) = {
+ .runs_after = VLIB_INITS ("llc_init"),
+};
/*
* fd.io coding-style-patch-verification: ON