From cb034b9b374927c7552e36dcbc306d8456b2a0cb Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Wed, 28 Dec 2016 18:38:59 +0100 Subject: Move java,lua api and remaining plugins to src/ Change-Id: I1c3b87e886603678368428ae56a6bd3327cbc90d Signed-off-by: Damjan Marion --- src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c | 378 +++++++++++++++++++++++++ 1 file changed, 378 insertions(+) create mode 100644 src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c (limited to 'src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c') diff --git a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c new file mode 100644 index 00000000..68752365 --- /dev/null +++ b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c @@ -0,0 +1,378 @@ +/* + * Copyright (c) 2016 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. + */ +/* + *------------------------------------------------------------------ + * vxlan_gpe_api.c - iOAM VxLAN-GPE related APIs to create + * and maintain profiles + *------------------------------------------------------------------ + */ + +#include +#include +#include + +#include +#include +#include + +/* define message IDs */ +#include + +/* define message structures */ +#define vl_typedefs +#include +#undef vl_typedefs + +/* define generated endian-swappers */ +#define vl_endianfun +#include +#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 +#undef vl_printfun + +/* Get the API version number */ +#define vl_api_version(n,v) static u32 api_version=(v); +#include +#undef vl_api_version + +/* + * A handy macro to set up a message reply. + * Assumes that the following variables are available: + * mp - pointer to request message + * rmp - pointer to reply message type + * rv - return value + */ + +#define VXLAN_GPE_REPLY_MACRO(t) \ +do { \ + unix_shared_memory_queue_t * q = \ + vl_api_client_index_to_input_queue (mp->client_index); \ + if (!q) \ + return; \ + \ + rmp = vl_msg_api_alloc (sizeof (*rmp)); \ + rmp->_vl_msg_id = ntohs((t)+sm->msg_id_base); \ + rmp->context = mp->context; \ + rmp->retval = ntohl(rv); \ + \ + vl_msg_api_send_shmem (q, (u8 *)&rmp); \ +} while(0); + +/* *INDENT-OFF* */ +#define VXLAN_GPE_REPLY_MACRO2(t, body) \ +do { \ + unix_shared_memory_queue_t * q; \ + rv = vl_msg_api_pd_handler (mp, rv); \ + q = vl_api_client_index_to_input_queue (mp->client_index); \ + if (!q) \ + return; \ + \ + rmp = vl_msg_api_alloc (sizeof (*rmp)); \ + rmp->_vl_msg_id = ntohs((t)); \ + rmp->context = mp->context; \ + rmp->retval = ntohl(rv); \ + do {body;} while (0); \ + vl_msg_api_send_shmem (q, (u8 *)&rmp); \ +} while(0); +/* *INDENT-ON* */ + +/* List of message types that this plugin understands */ + +#define foreach_vxlan_gpe_plugin_api_msg \ +_(VXLAN_GPE_IOAM_ENABLE, vxlan_gpe_ioam_enable) \ +_(VXLAN_GPE_IOAM_DISABLE, vxlan_gpe_ioam_disable) \ +_(VXLAN_GPE_IOAM_VNI_ENABLE, vxlan_gpe_ioam_vni_enable) \ +_(VXLAN_GPE_IOAM_VNI_DISABLE, vxlan_gpe_ioam_vni_disable) \ +_(VXLAN_GPE_IOAM_TRANSIT_ENABLE, vxlan_gpe_ioam_transit_enable) \ +_(VXLAN_GPE_IOAM_TRANSIT_DISABLE, vxlan_gpe_ioam_transit_disable) \ + + +static void vl_api_vxlan_gpe_ioam_enable_t_handler + (vl_api_vxlan_gpe_ioam_enable_t * mp) +{ + int rv = 0; + vl_api_vxlan_gpe_ioam_enable_reply_t *rmp; + clib_error_t *error; + vxlan_gpe_ioam_main_t *sm = &vxlan_gpe_ioam_main; + + /* Ignoring the profile id as currently a single profile + * is supported */ + error = + vxlan_gpe_ioam_enable (mp->trace_enable, mp->pow_enable, mp->trace_ppc); + if (error) + { + clib_error_report (error); + rv = clib_error_get_code (error); + } + + VXLAN_GPE_REPLY_MACRO (VL_API_VXLAN_GPE_IOAM_ENABLE_REPLY); +} + +static void vl_api_vxlan_gpe_ioam_disable_t_handler + (vl_api_vxlan_gpe_ioam_disable_t * mp) +{ + int rv = 0; + vl_api_vxlan_gpe_ioam_disable_reply_t *rmp; + clib_error_t *error; + vxlan_gpe_ioam_main_t *sm = &vxlan_gpe_ioam_main; + + /* Ignoring the profile id as currently a single profile + * is supported */ + error = vxlan_gpe_ioam_disable (0, 0, 0); + if (error) + { + clib_error_report (error); + rv = clib_error_get_code (error); + } + + VXLAN_GPE_REPLY_MACRO (VL_API_VXLAN_GPE_IOAM_DISABLE_REPLY); +} + +static void vl_api_vxlan_gpe_ioam_vni_enable_t_handler + (vl_api_vxlan_gpe_ioam_vni_enable_t * mp) +{ + int rv = 0; + vl_api_vxlan_gpe_ioam_vni_enable_reply_t *rmp; + clib_error_t *error; + vxlan_gpe_ioam_main_t *sm = &vxlan_gpe_ioam_main; + vxlan4_gpe_tunnel_key_t key4; + uword *p = NULL; + vxlan_gpe_main_t *gm = &vxlan_gpe_main; + vxlan_gpe_tunnel_t *t = 0; + vxlan_gpe_ioam_main_t *hm = &vxlan_gpe_ioam_main; + u32 vni; + + + if (!mp->is_ipv6) + { + clib_memcpy (&key4.local, &mp->local, sizeof (key4.local)); + clib_memcpy (&key4.remote, &mp->remote, sizeof (key4.remote)); + vni = clib_net_to_host_u32 (mp->vni); + key4.vni = clib_host_to_net_u32 (vni << 8); + key4.pad = 0; + + p = hash_get_mem (gm->vxlan4_gpe_tunnel_by_key, &key4); + } + else + { + return; + } + + if (!p) + return; + + t = pool_elt_at_index (gm->tunnels, p[0]); + + error = vxlan_gpe_ioam_set (t, hm->has_trace_option, + hm->has_pot_option, + hm->has_ppc_option, mp->is_ipv6); + + + if (error) + { + clib_error_report (error); + rv = clib_error_get_code (error); + } + + VXLAN_GPE_REPLY_MACRO (VL_API_VXLAN_GPE_IOAM_VNI_ENABLE_REPLY); +} + + +static void vl_api_vxlan_gpe_ioam_vni_disable_t_handler + (vl_api_vxlan_gpe_ioam_vni_disable_t * mp) +{ + int rv = 0; + vl_api_vxlan_gpe_ioam_vni_enable_reply_t *rmp; + clib_error_t *error; + vxlan_gpe_ioam_main_t *sm = &vxlan_gpe_ioam_main; + vxlan4_gpe_tunnel_key_t key4; + uword *p = NULL; + vxlan_gpe_main_t *gm = &vxlan_gpe_main; + vxlan_gpe_tunnel_t *t = 0; + u32 vni; + + + if (!mp->is_ipv6) + { + clib_memcpy (&key4.local, &mp->local, sizeof (key4.local)); + clib_memcpy (&key4.remote, &mp->remote, sizeof (key4.remote)); + vni = clib_net_to_host_u32 (mp->vni); + key4.vni = clib_host_to_net_u32 (vni << 8); + key4.pad = 0; + + p = hash_get_mem (gm->vxlan4_gpe_tunnel_by_key, &key4); + } + else + { + return; + } + + if (!p) + return; + + t = pool_elt_at_index (gm->tunnels, p[0]); + + error = vxlan_gpe_ioam_clear (t, 0, 0, 0, 0); + + + if (error) + { + clib_error_report (error); + rv = clib_error_get_code (error); + } + + + VXLAN_GPE_REPLY_MACRO (VL_API_VXLAN_GPE_IOAM_VNI_DISABLE_REPLY); +} + +static void vl_api_vxlan_gpe_ioam_transit_enable_t_handler + (vl_api_vxlan_gpe_ioam_transit_enable_t * mp) +{ + int rv = 0; + vl_api_vxlan_gpe_ioam_transit_enable_reply_t *rmp; + vxlan_gpe_ioam_main_t *sm = &vxlan_gpe_ioam_main; + ip46_address_t dst_addr; + + memset (&dst_addr.ip4, 0, sizeof (dst_addr.ip4)); + if (!mp->is_ipv6) + { + clib_memcpy (&dst_addr.ip4, &mp->dst_addr, sizeof (dst_addr.ip4)); + } + rv = vxlan_gpe_enable_disable_ioam_for_dest (sm->vlib_main, + dst_addr, + ntohl (mp->outer_fib_index), + mp->is_ipv6 ? 0 : 1, + 1 /* is_add */ ); + + VXLAN_GPE_REPLY_MACRO (VL_API_VXLAN_GPE_IOAM_TRANSIT_ENABLE_REPLY); +} + +static void vl_api_vxlan_gpe_ioam_transit_disable_t_handler + (vl_api_vxlan_gpe_ioam_transit_disable_t * mp) +{ + int rv = 0; + vl_api_vxlan_gpe_ioam_transit_disable_reply_t *rmp; + vxlan_gpe_ioam_main_t *sm = &vxlan_gpe_ioam_main; + ip46_address_t dst_addr; + + memset (&dst_addr.ip4, 0, sizeof (dst_addr.ip4)); + if (!mp->is_ipv6) + { + clib_memcpy (&dst_addr.ip4, &mp->dst_addr, sizeof (dst_addr.ip4)); + } + + rv = vxlan_gpe_ioam_disable_for_dest (sm->vlib_main, + dst_addr, + ntohl (mp->outer_fib_index), + mp->is_ipv6 ? 0 : 1); + VXLAN_GPE_REPLY_MACRO (VL_API_VXLAN_GPE_IOAM_TRANSIT_DISABLE_REPLY); +} + + +/* + * This routine exists to convince the vlib plugin framework that + * we haven't accidentally copied a random .dll into the plugin directory. + * + * Also collects global variable pointers passed from the vpp engine + */ + +clib_error_t * +vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h, + int from_early_init) +{ + vxlan_gpe_ioam_main_t *sm = &vxlan_gpe_ioam_main; + clib_error_t *error = 0; + + sm->vlib_main = vm; + sm->vnet_main = h->vnet_main; + sm->unix_time_0 = (u32) time (0); /* Store starting time */ + sm->vlib_time_0 = vlib_time_now (vm); + return error; +} + +/* Set up the API message handling tables */ +static clib_error_t * +vxlan_gpe_plugin_api_hookup (vlib_main_t * vm) +{ + vxlan_gpe_ioam_main_t *sm = &vxlan_gpe_ioam_main; +#define _(N,n) \ + vl_msg_api_set_handlers((VL_API_##N + sm->msg_id_base), \ + #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_vxlan_gpe_plugin_api_msg; +#undef _ + + return 0; +} + +static clib_error_t * +vxlan_gpe_init (vlib_main_t * vm) +{ + vxlan_gpe_ioam_main_t *sm = &vxlan_gpe_ioam_main; + clib_error_t *error = 0; + u8 *name; + u32 encap_node_index = vxlan_gpe_encap_ioam_v4_node.index; + u32 decap_node_index = vxlan_gpe_decap_ioam_v4_node.index; + vlib_node_t *vxlan_gpe_encap_node = NULL; + vlib_node_t *vxlan_gpe_decap_node = NULL; + uword next_node = 0; + + name = format (0, "ioam_vxlan_gpe_%08x%c", api_version, 0); + + /* Ask for a correctly-sized block of API message decode slots */ + sm->msg_id_base = vl_msg_api_get_msg_ids + ((char *) name, VL_MSG_FIRST_AVAILABLE); + + error = vxlan_gpe_plugin_api_hookup (vm); + + /* Hook the ioam-encap node to vxlan-gpe-encap */ + vxlan_gpe_encap_node = vlib_get_node_by_name (vm, (u8 *) "vxlan-gpe-encap"); + sm->encap_v4_next_node = + vlib_node_add_next (vm, vxlan_gpe_encap_node->index, encap_node_index); + + vxlan_gpe_decap_node = + vlib_get_node_by_name (vm, (u8 *) "vxlan4-gpe-input"); + next_node = + vlib_node_add_next (vm, vxlan_gpe_decap_node->index, decap_node_index); + vxlan_gpe_register_decap_protocol (VXLAN_GPE_PROTOCOL_IOAM, next_node); + + vec_new (vxlan_gpe_ioam_sw_interface_t, pool_elts (sm->sw_interfaces)); + sm->dst_by_ip4 = hash_create_mem (0, sizeof (fib_prefix_t), sizeof (uword)); + + sm->dst_by_ip6 = hash_create_mem (0, sizeof (fib_prefix_t), sizeof (uword)); + + vxlan_gpe_ioam_interface_init (); + vec_free (name); + + return error; +} + +VLIB_INIT_FUNCTION (vxlan_gpe_init); + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ -- cgit 1.2.3-korg From a90ba9d3d0daf583f225617e57252f172e99df21 Mon Sep 17 00:00:00 2001 From: AkshayaNadahalli Date: Fri, 23 Dec 2016 17:46:08 +0530 Subject: Merging all ioam plugin libraries to single library Double commit from 1702 branch to master. Change-Id: I33a646ba45848c7400df4271e4933e28e62c9ad7 Signed-off-by: AkshayaNadahalli (cherry picked from commit e4e9fbbb7c8fa4385ae31072d60ad8621fe798a4) Signed-off-by: AkshayaNadahalli --- src/plugins/ioam.am | 64 ++++++++++++++-------- src/plugins/ioam/encap/ip6_ioam_e2e.c | 22 +------- src/plugins/ioam/encap/ip6_ioam_trace.c | 13 +++++ src/plugins/ioam/export-common/ioam_export.h | 1 + .../ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.c | 2 +- src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_node.c | 4 +- src/plugins/ioam/export/ioam_export.c | 23 +------- src/plugins/ioam/lib-pot/pot_api.c | 24 ++------ src/plugins/ioam/lib-trace/trace_api.c | 23 ++------ src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c | 27 ++------- 10 files changed, 78 insertions(+), 125 deletions(-) (limited to 'src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c') diff --git a/src/plugins/ioam.am b/src/plugins/ioam.am index a4984b18..a2b298b1 100644 --- a/src/plugins/ioam.am +++ b/src/plugins/ioam.am @@ -16,82 +16,79 @@ # iOAM Proof of Transit ######################################## -ioam_pot_plugin_la_SOURCES = \ +IOAM_POT_SRC = \ ioam/lib-pot/pot_util.c \ ioam/encap/ip6_ioam_pot.c \ ioam/lib-pot/pot_util.h \ ioam/lib-pot/math64.h \ ioam/lib-pot/pot_api.c -noinst_HEADERS += \ +IOAM_POT_NOINST_HDR = \ ioam/lib-pot/pot_all_api_h.h \ ioam/lib-pot/pot_msg_enum.h \ ioam/lib-pot/pot.api.h \ ioam/lib-pot/pot_util.h \ ioam/lib-pot/math64.h -API_FILES += ioam/lib-pot/pot.api +IOAM_POT_API = ioam/lib-pot/pot.api ioam_pot_test_plugin_la_SOURCES = \ ioam/lib-pot/pot_test.c \ ioam/lib-pot/pot_plugin.api.h vppapitestplugins_LTLIBRARIES += ioam_pot_test_plugin.la -vppplugins_LTLIBRARIES += ioam_pot_plugin.la ######################################## # iOAM trace export for IPv6 ######################################## -ioam_export_plugin_la_SOURCES = \ +IOAM_EXPORT_SRC = \ ioam/export/ioam_export.c \ ioam/export/node.c \ ioam/export/ioam_export.api.h \ ioam/export/ioam_export_thread.c -noinst_HEADERS += \ +IOAM_EXPORT_NOINST_HDR = \ ioam/export/ioam_export_all_api_h.h \ ioam/export/ioam_export_msg_enum.h \ ioam/export/ioam_export.api.h -API_FILES += ioam/export/ioam_export.api +IOAM_EXPORT_API = ioam/export/ioam_export.api ioam_export_test_plugin_la_SOURCES = \ ioam/export/ioam_export_test.c \ ioam/export/ioam_export_plugin.api.h vppapitestplugins_LTLIBRARIES += ioam_export_test_plugin.la -vppplugins_LTLIBRARIES += ioam_export_plugin.la ######################################## # iOAM Trace ######################################## -libioam_trace_plugin_la_SOURCES = \ +IOAM_TRACE_SRC = \ ioam/lib-trace/trace_util.c \ ioam/encap/ip6_ioam_trace.c \ ioam/lib-trace/trace_util.h \ ioam/lib-trace/trace_api.c -noinst_HEADERS += \ +IOAM_TRACE_NOINST_HDR = \ ioam/export/ioam_export_all_api_h.h \ ioam/lib-trace/trace_all_api_h.h \ ioam/lib-trace/trace_msg_enum.h \ ioam/lib-trace/trace.api.h \ ioam/lib-trace/trace_util.h -API_FILES += ioam/lib-trace/trace.api +IOAM_TRACE_API = ioam/lib-trace/trace.api ioam_trace_test_plugin_la_SOURCES = \ ioam/lib-trace/trace_test.c \ ioam/lib-trace/trace_plugin.api.h vppapitestplugins_LTLIBRARIES += ioam_trace_test_plugin.la -vppplugins_LTLIBRARIES += libioam_trace_plugin.la ######################################## # VxLAN-GPE ######################################## -libioam_vxlan_gpe_plugin_la_SOURCES = \ +IOAM_VXLAN_GPE_SRC = \ ioam/lib-vxlan-gpe/ioam_encap.c \ ioam/lib-vxlan-gpe/ioam_decap.c \ ioam/lib-vxlan-gpe/ioam_transit.c \ @@ -104,27 +101,26 @@ libioam_vxlan_gpe_plugin_la_SOURCES = \ ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.api.h\ ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_thread.c -noinst_HEADERS += \ - ioam/export/ioam_export_all_api_h.h \ +IOAM_VXLAN_GPE_NOINST_HDR = \ + ioam/export/ioam_export_all_api_h.h \ ioam/lib-vxlan-gpe/vxlan_gpe_all_api_h.h \ ioam/lib-vxlan-gpe/vxlan_gpe_msg_enum.h \ ioam/lib-vxlan-gpe/ioam_vxlan_gpe.api.h \ ioam/lib-vxlan-gpe/vxlan_gpe_ioam_util.h \ ioam/lib-vxlan-gpe/vxlan_gpe_ioam_packet.h \ - ioam/lib-vxlan-gpe/vxlan_gpe_ioam.h \ + ioam/lib-vxlan-gpe/vxlan_gpe_ioam.h \ ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_all_api_h.h \ ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_msg_enum.h \ ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.api.h -API_FILES += ioam/lib-vxlan-gpe/ioam_vxlan_gpe.api -API_FILES += ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.api +IOAM_VXLAN_GPE_API = ioam/lib-vxlan-gpe/ioam_vxlan_gpe.api +IOAM_VXLAN_GPE_API += ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.api ioam_vxlan_gpe_test_plugin_la_SOURCES = \ ioam/lib-vxlan-gpe/vxlan_gpe_test.c \ ioam/lib-vxlan-gpe/vxlan_gpe_plugin.api.h vppapitestplugins_LTLIBRARIES += ioam_vxlan_gpe_test_plugin.la -vppplugins_LTLIBRARIES += libioam_vxlan_gpe_plugin.la vxlan_gpe_ioam_export_test_plugin_la_SOURCES = \ ioam/export-vxlan-gpe/vxlan_gpe_ioam_export_test.c \ @@ -136,15 +132,39 @@ vppapitestplugins_LTLIBRARIES += vxlan_gpe_ioam_export_test_plugin.la # iOAM E2E plugin ######################################## -ioam_e2e_plugin_la_SOURCES = \ +IOAM_E2E_SRC = \ ioam/encap/ip6_ioam_e2e.c \ ioam/encap/ip6_ioam_seqno.c \ ioam/encap/ip6_ioam_seqno_analyse.c -noinst_HEADERS += \ +IOAM_E2E_NOINST_HDR = \ ioam/encap/ip6_ioam_e2e.h \ ioam/encap/ip6_ioam_seqno.h -vppplugins_LTLIBRARIES += ioam_e2e_plugin.la +######################################## +# iOAM plugins +######################################## + +ioam_plugin_la_SOURCES = \ + $(IOAM_POT_SRC) \ + $(IOAM_EXPORT_SRC) \ + $(IOAM_TRACE_SRC) \ + $(IOAM_VXLAN_GPE_SRC) \ + $(IOAM_E2E_SRC) + +API_FILES += \ + $(IOAM_POT_API) \ + $(IOAM_EXPORT_API) \ + $(IOAM_TRACE_API) \ + $(IOAM_VXLAN_GPE_API) + +noinst_HEADERS += \ + $(IOAM_POT_NOINST_HDR) \ + $(IOAM_EXPORT_NOINST_HDR) \ + $(IOAM_TRACE_NOINST_HDR) \ + $(IOAM_VXLAN_GPE_NOINST_HDR) \ + $(IOAM_E2E_NOINST_HDR) + +vppplugins_LTLIBRARIES += ioam_plugin.la # vi:syntax=automake diff --git a/src/plugins/ioam/encap/ip6_ioam_e2e.c b/src/plugins/ioam/encap/ip6_ioam_e2e.c index 0839cdce..2831a351 100644 --- a/src/plugins/ioam/encap/ip6_ioam_e2e.c +++ b/src/plugins/ioam/encap/ip6_ioam_e2e.c @@ -25,8 +25,6 @@ #include #include -#include - #include "ip6_ioam_e2e.h" ioam_e2e_main_t ioam_e2e_main; @@ -166,23 +164,6 @@ VLIB_CLI_COMMAND (ioam_show_e2e_cmd, static) = { .function = ioam_show_e2e_cmd_fn, }; -/* - * This routine exists to convince the vlib plugin framework that - * we haven't accidentally copied a random .dll into the plugin directory. - * - * Also collects global variable pointers passed from the vpp engine - */ -clib_error_t * -vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h, - int from_early_init) -{ - clib_error_t * error = 0; - - ioam_e2e_main.vlib_main = vm; - ioam_e2e_main.vnet_main = h->vnet_main; - return error; -} - /* * Init handler E2E headet handling. * Init hanlder registers encap, decap, trace and Rewrite handlers. @@ -222,6 +203,9 @@ ioam_e2e_init (vlib_main_t * vm) "HBH_OPTION_TYPE_IOAM_EDGE_TO_EDGE Flow handler failed")); } + ioam_e2e_main.vlib_main = vm; + ioam_e2e_main.vnet_main = vnet_get_main(); + return (0); } diff --git a/src/plugins/ioam/encap/ip6_ioam_trace.c b/src/plugins/ioam/encap/ip6_ioam_trace.c index e63db6e4..3a6758cd 100644 --- a/src/plugins/ioam/encap/ip6_ioam_trace.c +++ b/src/plugins/ioam/encap/ip6_ioam_trace.c @@ -24,6 +24,7 @@ #include #include #include +#include #include @@ -348,6 +349,18 @@ VLIB_CLI_COMMAND (ip6_show_ioam_trace_cmd, static) = { }; /* *INDENT-ON* */ +/* + * This routine exists to convince the vlib plugin framework that + * we haven't accidentally copied a random .dll into the plugin directory. + * + * Also collects global variable pointers passed from the vpp engine + */ +clib_error_t * +vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h, + int from_early_init) +{ + return 0; +} static clib_error_t * ip6_hop_by_hop_ioam_trace_init (vlib_main_t * vm) diff --git a/src/plugins/ioam/export-common/ioam_export.h b/src/plugins/ioam/export-common/ioam_export.h index fbd86180..e6ab0344 100644 --- a/src/plugins/ioam/export-common/ioam_export.h +++ b/src/plugins/ioam/export-common/ioam_export.h @@ -77,6 +77,7 @@ ioam_export_main_t ioam_export_main; ioam_export_main_t vxlan_gpe_ioam_export_main; extern vlib_node_registration_t export_node; +extern vlib_node_registration_t vxlan_export_node; #define DEFAULT_EXPORT_SIZE (3 * CLIB_CACHE_LINE_BYTES) /* diff --git a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.c b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.c index bab8d977..0924d68f 100644 --- a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.c +++ b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.c @@ -92,7 +92,7 @@ vxlan_gpe_ioam_export_enable_disable (ioam_export_main_t * em, ip4_address_t * src_address) { vlib_main_t *vm = em->vlib_main; - u32 node_index = export_node.index; + u32 node_index = vxlan_export_node.index; vlib_node_t *vxlan_gpe_decap_ioam_node = NULL; if (is_disable == 0) diff --git a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_node.c b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_node.c index 722c2b06..f75b7081 100644 --- a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_node.c +++ b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_node.c @@ -40,7 +40,7 @@ format_export_trace (u8 * s, va_list * args) return s; } -vlib_node_registration_t export_node; +vlib_node_registration_t vxlan_export_node; #define foreach_export_error \ _(RECORDED, "Packets recorded for export") @@ -137,7 +137,7 @@ vxlan_gpe_export_node_fn (vlib_main_t * vm, * Node for VXLAN-GPE export */ /* *INDENT-OFF* */ -VLIB_REGISTER_NODE (export_node) = +VLIB_REGISTER_NODE (vxlan_export_node) = { .function = vxlan_gpe_export_node_fn, .name = "vxlan-gpe-ioam-export", diff --git a/src/plugins/ioam/export/ioam_export.c b/src/plugins/ioam/export/ioam_export.c index b122e445..06634baa 100644 --- a/src/plugins/ioam/export/ioam_export.c +++ b/src/plugins/ioam/export/ioam_export.c @@ -81,26 +81,6 @@ do { \ #define foreach_ioam_export_plugin_api_msg \ _(IOAM_EXPORT_IP6_ENABLE_DISABLE, ioam_export_ip6_enable_disable) -/* - * This routine exists to convince the vlib plugin framework that - * we haven't accidentally copied a random .dll into the plugin directory. - * - * Also collects global variable pointers passed from the vpp engine - */ - -clib_error_t * -vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h, - int from_early_init) -{ - ioam_export_main_t *em = &ioam_export_main; - clib_error_t *error = 0; - - em->vlib_main = vm; - em->vnet_main = h->vnet_main; - - return error; -} - /* Action function shared between message handler and debug CLI */ int @@ -250,6 +230,9 @@ ioam_export_init (vlib_main_t * vm) u32 node_index = export_node.index; vlib_node_t *ip6_hbyh_node = NULL; + em->vlib_main = vm; + em->vnet_main = vnet_get_main (); + name = format (0, "ioam_export_%08x%c", api_version, 0); /* Ask for a correctly-sized block of API message decode slots */ diff --git a/src/plugins/ioam/lib-pot/pot_api.c b/src/plugins/ioam/lib-pot/pot_api.c index d3af7b40..04c2aaa5 100644 --- a/src/plugins/ioam/lib-pot/pot_api.c +++ b/src/plugins/ioam/lib-pot/pot_api.c @@ -213,26 +213,6 @@ static void vl_api_pot_profile_del_t_handler REPLY_MACRO(VL_API_POT_PROFILE_DEL_REPLY); } - -/* - * This routine exists to convince the vlib plugin framework that - * we haven't accidentally copied a random .dll into the plugin directory. - * - * Also collects global variable pointers passed from the vpp engine - */ - -clib_error_t * -vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h, - int from_early_init) -{ - pot_main_t * sm = &pot_main; - clib_error_t * error = 0; - - sm->vlib_main = vm; - sm->vnet_main = h->vnet_main; - return error; -} - /* Set up the API message handling tables */ static clib_error_t * pot_plugin_api_hookup (vlib_main_t *vm) @@ -273,6 +253,10 @@ static clib_error_t * pot_init (vlib_main_t * vm) bzero(sm, sizeof(pot_main)); (void)pot_util_init(); + + sm->vlib_main = vm; + sm->vnet_main = vnet_get_main(); + name = format (0, "ioam_pot_%08x%c", api_version, 0); /* Ask for a correctly-sized block of API message decode slots */ diff --git a/src/plugins/ioam/lib-trace/trace_api.c b/src/plugins/ioam/lib-trace/trace_api.c index 7e0d708e..2ada5b7e 100644 --- a/src/plugins/ioam/lib-trace/trace_api.c +++ b/src/plugins/ioam/lib-trace/trace_api.c @@ -165,25 +165,6 @@ static void vl_api_trace_profile_show_config_t_handler } } -/* - * This routine exists to convince the vlib plugin framework that - * we haven't accidentally copied a random .dll into the plugin directory. - * - * Also collects global variable pointers passed from the vpp engine - */ - -clib_error_t * -vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h, - int from_early_init) -{ - trace_main_t *sm = &trace_main; - clib_error_t *error = 0; - - sm->vlib_main = vm; - sm->vnet_main = h->vnet_main; - return error; -} - /* Set up the API message handling tables */ static clib_error_t * trace_plugin_api_hookup (vlib_main_t * vm) @@ -225,6 +206,10 @@ trace_init (vlib_main_t * vm) bzero (sm, sizeof (trace_main)); (void) trace_util_init (); + + sm->vlib_main = vm; + sm->vnet_main = vnet_get_main (); + name = format (0, "ioam_trace_%08x%c", api_version, 0); /* Ask for a correctly-sized block of API message decode slots */ diff --git a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c index 68752365..247bcf59 100644 --- a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c +++ b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c @@ -284,28 +284,6 @@ static void vl_api_vxlan_gpe_ioam_transit_disable_t_handler VXLAN_GPE_REPLY_MACRO (VL_API_VXLAN_GPE_IOAM_TRANSIT_DISABLE_REPLY); } - -/* - * This routine exists to convince the vlib plugin framework that - * we haven't accidentally copied a random .dll into the plugin directory. - * - * Also collects global variable pointers passed from the vpp engine - */ - -clib_error_t * -vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h, - int from_early_init) -{ - vxlan_gpe_ioam_main_t *sm = &vxlan_gpe_ioam_main; - clib_error_t *error = 0; - - sm->vlib_main = vm; - sm->vnet_main = h->vnet_main; - sm->unix_time_0 = (u32) time (0); /* Store starting time */ - sm->vlib_time_0 = vlib_time_now (vm); - return error; -} - /* Set up the API message handling tables */ static clib_error_t * vxlan_gpe_plugin_api_hookup (vlib_main_t * vm) @@ -337,6 +315,11 @@ vxlan_gpe_init (vlib_main_t * vm) vlib_node_t *vxlan_gpe_decap_node = NULL; uword next_node = 0; + sm->vlib_main = vm; + sm->vnet_main = vnet_get_main (); + sm->unix_time_0 = (u32) time (0); /* Store starting time */ + sm->vlib_time_0 = vlib_time_now (vm); + name = format (0, "ioam_vxlan_gpe_%08x%c", api_version, 0); /* Ask for a correctly-sized block of API message decode slots */ -- cgit 1.2.3-korg From 851a37a78f80427a910a9cb571e5a7d70c120e38 Mon Sep 17 00:00:00 2001 From: Shwetha Bhandari Date: Thu, 27 Apr 2017 14:13:10 +0530 Subject: ioam: adding missing setup api msg crc table Change-Id: Ic95fe6179de1151796188813cc595187d4c842a0 Signed-off-by: Shwetha Bhandari --- .../ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.c | 17 +++++++++++++++++ src/plugins/ioam/ip6/ioam_cache.c | 17 +++++++++++++++++ src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c | 16 ++++++++++++++++ src/plugins/ioam/udp-ping/udp_ping_api.c | 16 ++++++++++++++++ 4 files changed, 66 insertions(+) (limited to 'src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c') diff --git a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.c b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.c index cef60903..ec43e484 100644 --- a/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.c +++ b/src/plugins/ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.c @@ -155,6 +155,19 @@ vxlan_gpe_ioam_export_plugin_api_hookup (vlib_main_t * vm) return 0; } +#define vl_msg_name_crc_list +#include +#undef vl_msg_name_crc_list + +static void +setup_message_id_table (ioam_export_main_t * sm, api_main_t * am) +{ +#define _(id,n,crc) \ + vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + sm->msg_id_base); + foreach_vl_msg_name_crc_vxlan_gpe_ioam_export; +#undef _ +} + static clib_error_t * set_vxlan_gpe_ioam_export_ipfix_command_fn (vlib_main_t * vm, @@ -233,6 +246,10 @@ vxlan_gpe_ioam_export_init (vlib_main_t * vm) em->vlib_time_0 = vlib_time_now (vm); error = vxlan_gpe_ioam_export_plugin_api_hookup (vm); + + /* Add our API messages to the global name_crc hash table */ + setup_message_id_table (em, &api_main); + em->my_hbh_slot = ~0; em->vlib_main = vm; em->vnet_main = vnet_get_main (); diff --git a/src/plugins/ioam/ip6/ioam_cache.c b/src/plugins/ioam/ip6/ioam_cache.c index a4079e84..92e7075d 100644 --- a/src/plugins/ioam/ip6/ioam_cache.c +++ b/src/plugins/ioam/ip6/ioam_cache.c @@ -186,6 +186,19 @@ ioam_cache_plugin_api_hookup (vlib_main_t * vm) return 0; } +#define vl_msg_name_crc_list +#include +#undef vl_msg_name_crc_list + +static void +setup_message_id_table (ioam_cache_main_t * sm, api_main_t * am) +{ +#define _(id,n,crc) \ + vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + sm->msg_id_base); + foreach_vl_msg_name_crc_ioam_cache; +#undef _ +} + static clib_error_t * set_ioam_cache_command_fn (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) @@ -334,6 +347,10 @@ ioam_cache_init (vlib_main_t * vm) ((char *) name, VL_MSG_FIRST_AVAILABLE); error = ioam_cache_plugin_api_hookup (vm); + + /* Add our API messages to the global name_crc hash table */ + setup_message_id_table (em, &api_main); + /* Hook this node to ip6-hop-by-hop */ ip6_hbyh_node = vlib_get_node_by_name (vm, (u8 *) "ip6-hop-by-hop"); em->cache_hbh_slot = diff --git a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c index 247bcf59..634133a4 100644 --- a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c +++ b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c @@ -303,6 +303,19 @@ vxlan_gpe_plugin_api_hookup (vlib_main_t * vm) return 0; } +#define vl_msg_name_crc_list +#include +#undef vl_msg_name_crc_list + +static void +setup_message_id_table (vxlan_gpe_ioam_main_t * sm, api_main_t * am) +{ +#define _(id,n,crc) \ + vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + sm->msg_id_base); + foreach_vl_msg_name_crc_ioam_vxlan_gpe; +#undef _ +} + static clib_error_t * vxlan_gpe_init (vlib_main_t * vm) { @@ -328,6 +341,9 @@ vxlan_gpe_init (vlib_main_t * vm) error = vxlan_gpe_plugin_api_hookup (vm); + /* Add our API messages to the global name_crc hash table */ + setup_message_id_table (sm, &api_main); + /* Hook the ioam-encap node to vxlan-gpe-encap */ vxlan_gpe_encap_node = vlib_get_node_by_name (vm, (u8 *) "vxlan-gpe-encap"); sm->encap_v4_next_node = diff --git a/src/plugins/ioam/udp-ping/udp_ping_api.c b/src/plugins/ioam/udp-ping/udp_ping_api.c index 6e5ef61e..75938731 100644 --- a/src/plugins/ioam/udp-ping/udp_ping_api.c +++ b/src/plugins/ioam/udp-ping/udp_ping_api.c @@ -122,6 +122,19 @@ udp_ping_api_hookup (vlib_main_t * vm) return 0; } +#define vl_msg_name_crc_list +#include +#undef vl_msg_name_crc_list + +static void +setup_message_id_table (udp_ping_main_t * sm, api_main_t * am) +{ +#define _(id,n,crc) \ + vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + sm->msg_id_base); + foreach_vl_msg_name_crc_udp_ping; +#undef _ +} + static clib_error_t * udp_ping_api_init (vlib_main_t * vm) { @@ -137,6 +150,9 @@ udp_ping_api_init (vlib_main_t * vm) error = udp_ping_api_hookup (vm); + /* Add our API messages to the global name_crc hash table */ + setup_message_id_table (sm, &api_main); + vec_free (name); return error; -- cgit 1.2.3-korg