From 2dabc509d8e37144d6a1f148b8fc1fd629d79902 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Meira?= Date: Mon, 24 Jan 2022 14:47:09 +0000 Subject: [PATCH 01/13] added plugins configuration directory option --- include/mptcpd/private/configuration.h | 3 ++ src/configuration.c | 69 ++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/include/mptcpd/private/configuration.h b/include/mptcpd/private/configuration.h index 0625cd20..f6f70c43 100644 --- a/include/mptcpd/private/configuration.h +++ b/include/mptcpd/private/configuration.h @@ -66,6 +66,9 @@ struct mptcpd_config /// A list of plugins to load. struct l_queue *plugins_to_load; + + /// Location of mptcpd plugins configuration files + char *plugins_conf_dir; }; /** diff --git a/src/configuration.c b/src/configuration.c index 9edd5448..7e63fbc1 100644 --- a/src/configuration.c +++ b/src/configuration.c @@ -334,6 +334,23 @@ static void set_plugins_to_load(struct mptcpd_config *config, l_free((char *) plugins); } +/** + * @brief Set mptcpd plugins configuration directory. + * + * Set mptcpd plugins configuration directory in the mptcpd configuration, + * @a config, being careful to deallocate a previously set plugins + * configuration directory. + * + * @param[in,out] config Mptcpd configuration. + * @param[in] dir Mptcpd plugins configuration directory. Ownership + * of memory is transferred to @a config. + */ +static void set_plugins_conf_dir(struct mptcpd_config *config, + char *dir) +{ + reset_string(&config->plugins_conf_dir, dir); +} + // --------------------------------------------------------------- // Command line options // --------------------------------------------------------------- @@ -359,6 +376,9 @@ static char const doc[] = "Start the Multipath TCP daemon."; /// Command line option key for "--load-plugins" #define MPTCPD_LOAD_PLUGINS_KEY 0x104 + +/// Command line option key for "--plugins-conf-dir" +#define MPTCPD_PLUGINS_CONF_DIR_KEY 0x105 ///@} static struct argp_option const options[] = { @@ -402,6 +422,12 @@ static struct argp_option const options[] = { "Specify which plugins to load, e.g. --load-plugins=addr_adv," "sspi", 0 }, + { "plugins-conf-dir", + MPTCPD_PLUGINS_CONF_DIR_KEY, + "DIR", + 0, + "Set plugins configuration directory to DIR", + 0 }, { 0 } }; @@ -452,6 +478,14 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) set_plugins_to_load(config, l_strdup(arg)); break; + case MPTCPD_PLUGINS_CONF_DIR_KEY: + if (strlen(arg) == 0) + argp_error(state, + "Empty plugins configuration directory" + " command line option."); + + set_plugins_conf_dir(config, l_strdup(arg)); + break; default: return ARGP_ERR_UNKNOWN; }; @@ -625,6 +659,23 @@ static void parse_config_plugins_to_load( set_plugins_to_load(config, plugins_to_load); } +static void parse_config_plugins_conf_dir( + struct mptcpd_config *config, + struct l_settings const *settings, + char const *group) +{ + if (config->plugins_conf_dir != NULL) + return; // Previously set, e.g. via command line. + + char *const plugins_conf_dir = + l_settings_get_string(settings, + group, + "plugins-conf-dir"); + + if (plugins_conf_dir != NULL) + set_plugins_conf_dir(config, plugins_conf_dir); +} + /** * @brief Parse configuration file. * @@ -669,6 +720,9 @@ static bool parse_config_file(struct mptcpd_config *config, // Plugins to load. parse_config_plugins_to_load(config, settings, group); + + // Plugins configuration directory. + parse_config_plugins_conf_dir(config, settings, group); } else { l_debug("Unable to load mptcpd settings from file '%s'", filename); @@ -761,6 +815,9 @@ static bool merge_config(struct mptcpd_config *dst, } } + if (dst->plugins_conf_dir == NULL) + dst->plugins_conf_dir = l_strdup(src->plugins_conf_dir); + return true; } @@ -780,6 +837,13 @@ static bool check_config(struct mptcpd_config const *config) return false; } + if (config->plugins_conf_dir == NULL) { + l_error("mptcpd plugins configuration directory was not " + "configured."); + + return false; + } + return true; } @@ -815,6 +879,7 @@ struct mptcpd_config *mptcpd_config_create(int argc, char *argv[]) && merge_config(config, &def_config) && check_config(config); + l_free(sys_config.plugins_conf_dir); l_queue_destroy(sys_config.plugins_to_load, l_free); l_free(sys_config.default_plugin); l_free(sys_config.plugin_dir); @@ -853,6 +918,9 @@ struct mptcpd_config *mptcpd_config_create(int argc, char *argv[]) l_free(str); } + l_debug("plugins configuration directory: %s", + config->plugins_conf_dir); + return config; } @@ -861,6 +929,7 @@ void mptcpd_config_destroy(struct mptcpd_config *config) if (config == NULL) return; + l_free(config->plugins_conf_dir); l_queue_destroy(config->plugins_to_load, l_free); l_free(config->default_plugin); l_free(config->plugin_dir); From d73de8128f22d27c2fcddd5fdd6e07eb9e239dcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Meira?= Date: Mon, 24 Jan 2022 15:05:46 +0000 Subject: [PATCH 02/13] added default plugins_conf_dir --- src/Makefile.am | 8 +++++--- src/configuration.c | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 93212cff..8598a94d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -32,10 +32,12 @@ libpath_manager_la_LIBADD = \ $(top_builddir)/lib/libmptcpd.la \ $(ELL_LIBS) $(CODE_COVERAGE_LIBS) -libpath_manager_la_CPPFLAGS = \ - $(AM_CPPFLAGS) \ +libpath_manager_la_CPPFLAGS = \ + $(AM_CPPFLAGS) \ -DMPTCPD_CONFIG_FILE='"$(sysconfdir)/@PACKAGE@/@PACKAGE@.conf"' \ - -DMPTCPD_DEFAULT_PLUGINDIR='"$(libdir)/@PACKAGE@"' + -DMPTCPD_DEFAULT_PLUGINDIR='"$(libdir)/@PACKAGE@"' \ + -DMPTCPD_DEFAULT_PLUGINSCONFDIR='"$(sysconfdir)/@PACKAGE@/$\ + plugins.conf.d/"' EXTRA_DIST = mptcp.service.in diff --git a/src/configuration.c b/src/configuration.c index 7e63fbc1..589326d5 100644 --- a/src/configuration.c +++ b/src/configuration.c @@ -863,7 +863,8 @@ struct mptcpd_config *mptcpd_config_create(int argc, char *argv[]) // System configuration, e.g. /etc/mptcpd/mptcpd.conf. struct mptcpd_config sys_config = { .log_set = NULL }; static struct mptcpd_config const def_config = { - .plugin_dir = MPTCPD_DEFAULT_PLUGINDIR }; + .plugin_dir = MPTCPD_DEFAULT_PLUGINDIR, + .plugins_conf_dir = MPTCPD_DEFAULT_PLUGINSCONFDIR }; char flags[128]; /* From 54086ff398fc309eb34938247e4dc8a77c970fee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Meira?= Date: Mon, 24 Jan 2022 16:29:20 +0000 Subject: [PATCH 03/13] create default dir at install --- etc/Makefile.am | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/etc/Makefile.am b/etc/Makefile.am index a5c9b880..17ad9bb5 100644 --- a/etc/Makefile.am +++ b/etc/Makefile.am @@ -6,6 +6,7 @@ EXTRA_DIST = mptcpd.conf.in pkgsysconf_DATA = mptcpd.conf pkgsysconfdir = $(sysconfdir)/@PACKAGE@ +pluginsconfdir = $(pkgsysconfdir)/plugins.conf.d ## The configure script won't fully expand $pkglibdir so leverage ## `make' based variable expansion instead. @@ -27,8 +28,11 @@ CLEANFILES = mptcpd.conf # writable. install-data-hook: installcheck-local chmod o-w $(DESTDIR)$(pkgsysconfdir) + mkdir -p $(DESTDIR)$(pluginsconfdir) + chmod o-w $(DESTDIR)$(pluginsconfdir) installcheck-local: - $(top_srcdir)/scripts/check-permissions \ - $(DESTDIR)$(pkgsysconfdir) \ - $(DESTDIR)$(pkgsysconfdir)/mptcpd.conf + $(top_srcdir)/scripts/check-permissions \ + $(DESTDIR)$(pkgsysconfdir) \ + $(DESTDIR)$(pkgsysconfdir)/mptcpd.conf \ + $(DESTDIR)$(pluginsconfdir) From d2907b1f8cb8b34892d5ca2ff0d1e26ec72010d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Meira?= Date: Tue, 1 Feb 2022 15:44:30 +0000 Subject: [PATCH 04/13] added internal read config function --- include/mptcpd/private/configuration.h | 6 ++ include/mptcpd/types.h | 5 ++ lib/Makefile.am | 1 + lib/configuration.c | 84 ++++++++++++++++++++++ src/configuration.c | 99 ++++++-------------------- 5 files changed, 117 insertions(+), 78 deletions(-) create mode 100644 lib/configuration.c diff --git a/include/mptcpd/private/configuration.h b/include/mptcpd/private/configuration.h index f6f70c43..b6d1e0e9 100644 --- a/include/mptcpd/private/configuration.h +++ b/include/mptcpd/private/configuration.h @@ -10,6 +10,8 @@ #ifndef MPTCPD_CONFIGURATION_H #define MPTCPD_CONFIGURATION_H +#include +#include /** * Function pointer corresponding to the ELL functions that set the @@ -90,6 +92,10 @@ struct mptcpd_config *mptcpd_config_create(int argc, char *argv[]); */ void mptcpd_config_destroy(struct mptcpd_config *config); +MPTCPD_API bool mptcpd_config_read(char const *filename, + mptcpd_parse_func_t fun, + void *user_data); + #endif // MPTCPD_CONFIGURATION_H /* diff --git a/include/mptcpd/types.h b/include/mptcpd/types.h index 059ff1e0..2b1f24c7 100644 --- a/include/mptcpd/types.h +++ b/include/mptcpd/types.h @@ -12,6 +12,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { @@ -162,6 +163,10 @@ typedef void (*mptcpd_pm_get_limits_cb)( size_t len, void *callback_data); +typedef void (*mptcpd_parse_func_t) ( + struct l_settings *const settings, + void *user_data); + #ifdef __cplusplus } #endif diff --git a/lib/Makefile.am b/lib/Makefile.am index a8a871bf..bc3d8662 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -20,6 +20,7 @@ libmptcpd_la_LDFLAGS = \ libmptcpd_la_SOURCES = \ addr_info.c \ + configuration.c \ id_manager.c \ network_monitor.c \ path_manager.c \ diff --git a/lib/configuration.c b/lib/configuration.c new file mode 100644 index 00000000..44810098 --- /dev/null +++ b/lib/configuration.c @@ -0,0 +1,84 @@ +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include + +/** + * @brief Verify file permissions are secure. + * + * Mptcpd requires that its files are only writable by the owner and + * group. Verify that the "other" write mode, @c S_IWOTH, isn't set. + * + * @param[in] f Name of file to check for expected permissions. + * + * @note There is a TOCTOU race condition between this file + * permissions check and subsequent calls to functions that + * access the given file @a f, such as the call to + * @c l_settings_load_from_file(). There is currently no way + * to avoid that with the existing ELL API. + */ +static bool check_file_perms(char const *f) +{ + struct stat sb; + bool perms_ok = false; + + if (stat(f, &sb) == 0) { + perms_ok = S_ISREG(sb.st_mode) + && (sb.st_mode & S_IWOTH) == 0; + + if (!perms_ok) + l_error("\"%s\" should be a file that is not " + "world writable.", + f); + } else if (errno == ENOENT) { + perms_ok = true; + + l_debug("File \"%s\" does not exist.", f); + } else { + l_debug("Unexpected error during file " + "permissions check."); + } + + return perms_ok; +} + +bool mptcpd_config_read(char const *filename, + mptcpd_parse_func_t fun, + void *user_data) +{ + assert(filename != NULL); + assert(fun != NULL); + + if (!check_file_perms(filename)) + return false; + + struct l_settings *const settings = l_settings_new(); + if (settings == NULL) { + l_error("Unable to create mptcpd settings."); + + return false; + } + + bool success = l_settings_load_from_file(settings, filename); + + if (success) + fun(settings, user_data); + else + l_debug("Unable to load mptcpd settings from file '%s'", + filename); + + l_settings_free(settings); + + return success; +} + diff --git a/src/configuration.c b/src/configuration.c index 589326d5..0c730f84 100644 --- a/src/configuration.c +++ b/src/configuration.c @@ -521,45 +521,6 @@ parse_options(struct mptcpd_config *config, int argc, char *argv[]) // Configuration files // --------------------------------------------------------------- -/** - * @brief Verify file permissions are secure. - * - * Mptcpd requires that its files are only writable by the owner and - * group. Verify that the "other" write mode, @c S_IWOTH, isn't set. - * - * @param[in] f Name of file to check for expected permissions. - * - * @note There is a TOCTOU race condition between this file - * permissions check and subsequent calls to functions that - * access the given file @a f, such as the call to - * @c l_settings_load_from_file(). There is currently no way - * to avoid that with the existing ELL API. - */ -static bool check_file_perms(char const *f) -{ - struct stat sb; - bool perms_ok = false; - - if (stat(f, &sb) == 0) { - perms_ok = S_ISREG(sb.st_mode) - && (sb.st_mode & S_IWOTH) == 0; - - if (!perms_ok) - l_error("\"%s\" should be a file that is not " - "world writable.", - f); - } else if (errno == ENOENT) { - perms_ok = true; - - l_debug("File \"%s\" does not exist.", f); - } else { - l_debug("Unexpected error during file " - "permissions check."); - } - - return perms_ok; -} - static void parse_config_log(struct mptcpd_config *config, struct l_settings const *settings, char const *group) @@ -685,52 +646,33 @@ static void parse_config_plugins_conf_dir( * @return @c true on successful configuration file parse, and * @c false otherwise. */ -static bool parse_config_file(struct mptcpd_config *config, - char const *filename) +static void parse_config_file(struct l_settings *const settings, + void *user_data) { - assert(filename != NULL); + struct mptcpd_config *config = user_data; - if (!check_file_perms(filename)) - return false; + static char const group[] = "core"; - struct l_settings *const settings = l_settings_new(); - if (settings == NULL) { - l_error("Unable to create mptcpd settings."); + // Logging mechanism. + parse_config_log(config, settings, group); - return false; - } - - if (l_settings_load_from_file(settings, filename)) { - static char const group[] = "core"; - - // Logging mechanism. - parse_config_log(config, settings, group); - - // Plugin directory. - parse_config_plugin_dir(config, settings, group); + // Plugin directory. + parse_config_plugin_dir(config, settings, group); - // Notification for existing addresses. - parse_config_notify_flags(config, settings, group); + // Notification for existing addresses. + parse_config_notify_flags(config, settings, group); - // Address flags. - parse_config_addr_flags(config, settings, group); + // Address flags. + parse_config_addr_flags(config, settings, group); - // Default plugin. - parse_config_default_plugin(config, settings, group); + // Default plugin. + parse_config_default_plugin(config, settings, group); - // Plugins to load. - parse_config_plugins_to_load(config, settings, group); + // Plugins to load. + parse_config_plugins_to_load(config, settings, group); - // Plugins configuration directory. - parse_config_plugins_conf_dir(config, settings, group); - } else { - l_debug("Unable to load mptcpd settings from file '%s'", - filename); - } - - l_settings_free(settings); - - return true; + // Plugins configuration directory. + parse_config_plugins_conf_dir(config, settings, group); } /** @@ -764,7 +706,9 @@ static bool parse_config_files(struct mptcpd_config *config) for (char const *const *file = files; file != end && parsed; ++file) { - parsed = parse_config_file(config, *file); + parsed = mptcpd_config_read(*file, + parse_config_file, + config); } return parsed; @@ -937,7 +881,6 @@ void mptcpd_config_destroy(struct mptcpd_config *config) l_free(config); } - /* Local Variables: c-file-style: "linux" From 78b72c5446cf187b308c7508f483d186e11b2c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Meira?= Date: Tue, 1 Feb 2022 15:47:57 +0000 Subject: [PATCH 05/13] added plugin read config op --- include/mptcpd/plugin.h | 4 ++++ include/mptcpd/private/plugin.h | 1 + lib/plugin.c | 31 +++++++++++++++++++++++++++++++ src/path_manager.c | 1 + 4 files changed, 37 insertions(+) diff --git a/include/mptcpd/plugin.h b/include/mptcpd/plugin.h index 25ff5308..69aeb1b5 100644 --- a/include/mptcpd/plugin.h +++ b/include/mptcpd/plugin.h @@ -345,6 +345,10 @@ MPTCPD_API bool mptcpd_plugin_register_ops( char const *name, struct mptcpd_plugin_ops const *ops); +MPTCPD_API bool mptcpd_plugin_read_config(char const *filename, + mptcpd_parse_func_t fun, + void *user_data); + #ifdef __cplusplus } #endif diff --git a/include/mptcpd/private/plugin.h b/include/mptcpd/private/plugin.h index b8e00ba9..a5ea38c6 100644 --- a/include/mptcpd/private/plugin.h +++ b/include/mptcpd/private/plugin.h @@ -42,6 +42,7 @@ struct mptcpd_interface; */ MPTCPD_API bool mptcpd_plugin_load(char const *dir, char const *default_name, + char const *plugins_conf_dir, struct l_queue const *plugins_to_load, struct mptcpd_pm *pm); diff --git a/lib/plugin.c b/lib/plugin.c index 3d322b42..06df5648 100644 --- a/lib/plugin.c +++ b/lib/plugin.c @@ -39,6 +39,7 @@ # define MPTCP_PM_NAME_LEN GENL_NAMSIZ #endif +#include #include #include @@ -86,6 +87,8 @@ static char _default_name[MPTCP_PM_NAME_LEN + 1]; */ static struct mptcpd_plugin_ops const *_default_ops; +static char *_conf_dir; + // ---------------------------------------------------------------- // Implementation Details // ---------------------------------------------------------------- @@ -432,6 +435,7 @@ static void unload_plugins(struct mptcpd_pm *pm) bool mptcpd_plugin_load(char const *dir, char const *default_name, + char const *plugins_conf_dir, struct l_queue const *plugins_to_load, struct mptcpd_pm *pm) { @@ -440,6 +444,14 @@ bool mptcpd_plugin_load(char const *dir, return false; } + if (plugins_conf_dir == NULL) { + l_error("No plugins configuration directory specified."); + return false; + } + + if (_conf_dir == NULL) + _conf_dir = l_strdup(plugins_conf_dir); + if (_plugin_infos == NULL) _plugin_infos = l_queue_new(); @@ -569,6 +581,25 @@ bool mptcpd_plugin_register_ops(char const *name, return registered; } +bool mptcpd_plugin_read_config(char const *filename, + mptcpd_parse_func_t fun, + void *user_data) +{ + assert(filename != NULL); + assert(fun != NULL); + + char *const path = l_strdup_printf("%s/%s.conf", + _conf_dir, + filename); + + bool success = mptcpd_config_read(path, fun, user_data); + + l_free(path); + + return success; +} + + // ---------------------------------------------------------------- // Plugin Operation Callback Invocation // ---------------------------------------------------------------- diff --git a/src/path_manager.c b/src/path_manager.c index 5ccd849d..4e4234d2 100644 --- a/src/path_manager.c +++ b/src/path_manager.c @@ -826,6 +826,7 @@ static void complete_pm_init(void *data) */ if (!mptcpd_plugin_load(pm->config->plugin_dir, pm->config->default_plugin, + pm->config->plugins_conf_dir, pm->config->plugins_to_load, pm)) { l_error("Unable to load path manager plugins."); From 0a609a93727e13b97b459aa0cb1369b4fe6a94aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Meira?= Date: Tue, 1 Feb 2022 15:48:17 +0000 Subject: [PATCH 06/13] updated tests --- tests/test-cxx-build.cpp | 6 +++++- tests/test-plugin.c | 12 ++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/test-cxx-build.cpp b/tests/test-cxx-build.cpp index 729c11f2..cad90510 100644 --- a/tests/test-cxx-build.cpp +++ b/tests/test-cxx-build.cpp @@ -71,7 +71,11 @@ class test_plugin struct mptcpd_pm *const pm = NULL; bool const loaded = - mptcpd_plugin_load(dir, default_plugin, NULL, this->pm); + mptcpd_plugin_load(dir, + default_plugin, + dir, + NULL, + this->pm); assert(loaded); call_plugin_ops(&test_count_4, diff --git a/tests/test-plugin.c b/tests/test-plugin.c index 120da24a..eb14268c 100644 --- a/tests/test-plugin.c +++ b/tests/test-plugin.c @@ -43,7 +43,7 @@ static bool run_plugin_load(mode_t mode, struct l_queue const *queue) assert(mode_ok == 0); bool const loaded = - mptcpd_plugin_load(dir, default_plugin, queue, pm); + mptcpd_plugin_load(dir, default_plugin, dir, queue, pm); if (loaded) { call_plugin_ops(&test_count_4, @@ -118,7 +118,7 @@ static void test_no_plugins(void const *test_data) assert(dir != NULL); struct mptcpd_pm *const pm = NULL; - bool const loaded = mptcpd_plugin_load(dir, NULL, NULL, pm); + bool const loaded = mptcpd_plugin_load(dir, NULL, dir, NULL, pm); (void) rmdir(dir); @@ -187,7 +187,7 @@ static void test_plugin_dispatch(void const *test_data) struct mptcpd_pm *const pm = NULL; bool const loaded = - mptcpd_plugin_load(dir, default_plugin, NULL, pm); + mptcpd_plugin_load(dir, default_plugin, dir, NULL, pm); assert(loaded); // Notice that we call plugin 1 twice. @@ -257,7 +257,11 @@ static void test_null_plugin_ops(void const *test_data) static char const *const default_plugin = NULL; struct mptcpd_pm *const pm = NULL; - bool const loaded = mptcpd_plugin_load(dir, default_plugin, NULL, pm); + bool const loaded = mptcpd_plugin_load(dir, + default_plugin, + dir, + NULL, + pm); assert(loaded); char const name[] = "null ops"; From e42841cf9de17264cd8a701d9e2f58e7d0e69132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Meira?= Date: Mon, 7 Feb 2022 22:03:38 +0000 Subject: [PATCH 07/13] fixed mkdir --- etc/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/Makefile.am b/etc/Makefile.am index 17ad9bb5..64dba474 100644 --- a/etc/Makefile.am +++ b/etc/Makefile.am @@ -28,7 +28,7 @@ CLEANFILES = mptcpd.conf # writable. install-data-hook: installcheck-local chmod o-w $(DESTDIR)$(pkgsysconfdir) - mkdir -p $(DESTDIR)$(pluginsconfdir) + $(MKDIR_P) $(DESTDIR)$(pluginsconfdir) chmod o-w $(DESTDIR)$(pluginsconfdir) installcheck-local: From 8169b07b071ed0c0a3aa69a4b753db6a93836de5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Meira?= Date: Mon, 7 Feb 2022 22:04:21 +0000 Subject: [PATCH 08/13] fixed mptcpd_parse_func_t const --- include/mptcpd/types.h | 2 +- src/configuration.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/mptcpd/types.h b/include/mptcpd/types.h index 2b1f24c7..b5c7abc9 100644 --- a/include/mptcpd/types.h +++ b/include/mptcpd/types.h @@ -164,7 +164,7 @@ typedef void (*mptcpd_pm_get_limits_cb)( void *callback_data); typedef void (*mptcpd_parse_func_t) ( - struct l_settings *const settings, + struct l_settings const* settings, void *user_data); #ifdef __cplusplus diff --git a/src/configuration.c b/src/configuration.c index 0c730f84..c9fbd0bd 100644 --- a/src/configuration.c +++ b/src/configuration.c @@ -646,7 +646,7 @@ static void parse_config_plugins_conf_dir( * @return @c true on successful configuration file parse, and * @c false otherwise. */ -static void parse_config_file(struct l_settings *const settings, +static void parse_config_file(struct l_settings const* settings, void *user_data) { struct mptcpd_config *config = user_data; From 95c6c765de7a1d02bcd0f40373c325265dac4e63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Meira?= Date: Thu, 24 Feb 2022 20:26:45 +0000 Subject: [PATCH 09/13] reverted return l_settings_load_from_file success --- lib/configuration.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/configuration.c b/lib/configuration.c index 44810098..70dc4be8 100644 --- a/lib/configuration.c +++ b/lib/configuration.c @@ -69,9 +69,7 @@ bool mptcpd_config_read(char const *filename, return false; } - bool success = l_settings_load_from_file(settings, filename); - - if (success) + if (l_settings_load_from_file(settings, filename)) fun(settings, user_data); else l_debug("Unable to load mptcpd settings from file '%s'", @@ -79,6 +77,6 @@ bool mptcpd_config_read(char const *filename, l_settings_free(settings); - return success; + return true; } From 47dc8ed117c822118aa8e4ccb7452f82f2b349e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Meira?= Date: Wed, 2 Mar 2022 09:34:41 +0000 Subject: [PATCH 10/13] workaround ell/cleanup.h c++ error --- configure.ac | 1 + include/Makefile.am | 2 +- include/ell/Makefile.am | 1 + include/ell/cleanup.h | 5 +++++ include/mptcpd/types.h | 1 + 5 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 include/ell/Makefile.am create mode 100644 include/ell/cleanup.h diff --git a/configure.ac b/configure.ac index 8dcd67ba..2911c2e1 100644 --- a/configure.ac +++ b/configure.ac @@ -360,6 +360,7 @@ AC_CONFIG_FILES([Makefile etc/Makefile man/Makefile include/Makefile + include/ell/Makefile include/linux/Makefile include/mptcpd/Makefile lib/Makefile diff --git a/include/Makefile.am b/include/Makefile.am index 2b598730..f8ab9cc0 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -2,4 +2,4 @@ ## ## Copyright (c) 2017-2019, Intel Corporation -SUBDIRS = mptcpd linux +SUBDIRS = mptcpd linux ell diff --git a/include/ell/Makefile.am b/include/ell/Makefile.am new file mode 100644 index 00000000..1d684b04 --- /dev/null +++ b/include/ell/Makefile.am @@ -0,0 +1 @@ +noinst_HEADERS = cleanup.h diff --git a/include/ell/cleanup.h b/include/ell/cleanup.h new file mode 100644 index 00000000..9f47830b --- /dev/null +++ b/include/ell/cleanup.h @@ -0,0 +1,5 @@ +#pragma once + +#define DEFINE_CLEANUP_FUNC(func) \ + inline __attribute__((always_inline)) \ + void func ## _cleanup(struct l_settings *p) { func(*(struct l_settings **) p); } diff --git a/include/mptcpd/types.h b/include/mptcpd/types.h index b5c7abc9..2d636270 100644 --- a/include/mptcpd/types.h +++ b/include/mptcpd/types.h @@ -12,6 +12,7 @@ #include #include +#include #include #ifdef __cplusplus From ae30db3a421f87c665c62c373803176f919e5263 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Meira?= Date: Wed, 9 Mar 2022 08:45:27 +0000 Subject: [PATCH 11/13] Revert "workaround ell/cleanup.h c++ error" This reverts commit 47dc8ed117c822118aa8e4ccb7452f82f2b349e2. --- configure.ac | 1 - include/Makefile.am | 2 +- include/ell/Makefile.am | 1 - include/ell/cleanup.h | 5 ----- include/mptcpd/types.h | 1 - 5 files changed, 1 insertion(+), 9 deletions(-) delete mode 100644 include/ell/Makefile.am delete mode 100644 include/ell/cleanup.h diff --git a/configure.ac b/configure.ac index 2911c2e1..8dcd67ba 100644 --- a/configure.ac +++ b/configure.ac @@ -360,7 +360,6 @@ AC_CONFIG_FILES([Makefile etc/Makefile man/Makefile include/Makefile - include/ell/Makefile include/linux/Makefile include/mptcpd/Makefile lib/Makefile diff --git a/include/Makefile.am b/include/Makefile.am index f8ab9cc0..2b598730 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -2,4 +2,4 @@ ## ## Copyright (c) 2017-2019, Intel Corporation -SUBDIRS = mptcpd linux ell +SUBDIRS = mptcpd linux diff --git a/include/ell/Makefile.am b/include/ell/Makefile.am deleted file mode 100644 index 1d684b04..00000000 --- a/include/ell/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -noinst_HEADERS = cleanup.h diff --git a/include/ell/cleanup.h b/include/ell/cleanup.h deleted file mode 100644 index 9f47830b..00000000 --- a/include/ell/cleanup.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#define DEFINE_CLEANUP_FUNC(func) \ - inline __attribute__((always_inline)) \ - void func ## _cleanup(struct l_settings *p) { func(*(struct l_settings **) p); } diff --git a/include/mptcpd/types.h b/include/mptcpd/types.h index 2d636270..b5c7abc9 100644 --- a/include/mptcpd/types.h +++ b/include/mptcpd/types.h @@ -12,7 +12,6 @@ #include #include -#include #include #ifdef __cplusplus From 000354496b6ab0749e3133dd49de1066c3e5df24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Meira?= Date: Wed, 9 Mar 2022 08:48:57 +0000 Subject: [PATCH 12/13] declared struct l_settings in types.h --- include/mptcpd/types.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/mptcpd/types.h b/include/mptcpd/types.h index b5c7abc9..3014b51a 100644 --- a/include/mptcpd/types.h +++ b/include/mptcpd/types.h @@ -12,12 +12,13 @@ #include #include -#include #ifdef __cplusplus extern "C" { #endif +struct l_settings; + /** * @todo These rely on MPTCP genl related implementation details in * the kernel. Should we move these typedefs to From c99c691b799ff5f5f39db07a18d025c8c833af5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Meira?= Date: Thu, 29 Sep 2022 15:13:39 +0100 Subject: [PATCH 13/13] fixed test plugins --- tests/test-plugin.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test-plugin.c b/tests/test-plugin.c index 7b8a0c83..0546ae3e 100644 --- a/tests/test-plugin.c +++ b/tests/test-plugin.c @@ -339,6 +339,7 @@ static void test_null_plugin_dir(void const *test_data) bool const loaded = mptcpd_plugin_load(dir, default_plugin, + dir, plugins_to_load, pm); assert(!loaded); @@ -359,6 +360,7 @@ static void test_bad_plugins(void const *test_data) bool const loaded = mptcpd_plugin_load(dir, default_plugin, + dir, plugins_to_load, pm); assert(!loaded);