From 21a438465ca0dee88d13d9dd9621929116c95614 Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Tue, 9 Jul 2019 10:04:18 -0400 Subject: vat: unload unused vat plugins If the corresponding vpp plugin is absent, return a non-zero clib_error_t * from vat_plugin_register ("xxx plugin not loaded"). The vat plugin calls dlclose on the vat plugin, and it disappears. Depending on the plugin configuration, this can reduce the vpp virtual size by several gigabytes. Added a VAT_PLUGIN() macro to vat_helper_macros, clean up boilerplate vat_plugin_register() implementations. Fixed a number of non-standard vat_plugin_register methods. Type: refactor Change-Id: Iac908e5af7d5497c78d6aa9c3c51cdae08374045 Signed-off-by: Dave Barach --- src/vlibapi/vat_helper_macros.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/vlibapi') diff --git a/src/vlibapi/vat_helper_macros.h b/src/vlibapi/vat_helper_macros.h index 5bc67729d4a..0abfa73851f 100644 --- a/src/vlibapi/vat_helper_macros.h +++ b/src/vlibapi/vat_helper_macros.h @@ -109,5 +109,26 @@ do { \ } \ } while(0); +#define VAT_PLUGIN_REGISTER(plug) \ +clib_error_t * vat_plugin_register (vat_main_t *vam) \ +{ \ + plug##_test_main_t * mp = &plug##_test_main; \ + u8 * name; \ + \ + mp->vat_main = vam; \ + \ + /* Ask the vpp engine for the first assigned message-id */ \ + name = format (0, #plug "_%08x%c", api_version, 0); \ + mp->msg_id_base = \ + vl_client_get_first_plugin_msg_id ((char *) name); \ + vec_free(name); \ + \ + if (mp->msg_id_base != (u16) ~0) \ + plug##_api_hookup (vam); \ + else \ + return clib_error_return (0, #plug " plugin not loaded...");\ + return 0; \ +} + #endif /* __vat_helper_macros_h__ */ -- cgit 1.2.3-korg