From c1c970f1b180bc17422e61fc0d1b02addc3167fd Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 5 Sep 2019 14:54:22 +0200 Subject: libnm: export reload flags Flags to the manager Reload() method are stable API but not exposed in a public header. Export them. --- libnm-core/nm-dbus-interface.h | 28 ++++++++++++++++++++++++++++ libnm/libnm.ver | 1 + src/main.c | 2 +- src/nm-config-data.h | 19 ------------------- src/nm-manager.c | 8 ++++---- 5 files changed, 34 insertions(+), 24 deletions(-) diff --git a/libnm-core/nm-dbus-interface.h b/libnm-core/nm-dbus-interface.h index f00506e2d7..1e7f377d12 100644 --- a/libnm-core/nm-dbus-interface.h +++ b/libnm-core/nm-dbus-interface.h @@ -1122,4 +1122,32 @@ typedef enum { NM_TERNARY_TRUE = 1, } NMTernary; +/** + * NMManagerReloadFlags: + * @NM_MANAGER_RELOAD_FLAG_NONE: an alias for numeric zero, no flags set. This + * reloads everything that is supported and is identical to a SIGHUP. + * @NM_MANAGER_RELOAD_FLAG_CONF: reload the NetworkManager.conf configuration + * from disk. Note that this does not include connections, which can be + * reloaded via Setting's ReloadConnections(). + * @NM_MANAGER_RELOAD_FLAG_DNS_RC: update DNS configuration, which usually + * involves writing /etc/resolv.conf anew. + * @NM_MANAGER_RELOAD_FLAG_DNS_FULL: means to restart the DNS plugin. This + * is for example useful when using dnsmasq plugin, which uses additional + * configuration in /etc/NetworkManager/dnsmasq.d. If you edit those files, + * you can restart the DNS plugin. This action shortly interrupts name + * resolution. + * @NM_MANAGER_RELOAD_FLAG_ALL: all flags. + * + * Flags for the manager Reload() call. + * + * Since: 1.22 + */ +typedef enum { /*< flags >*/ + NM_MANAGER_RELOAD_FLAG_NONE = 0, /*< skip >*/ + NM_MANAGER_RELOAD_FLAG_CONF = 0x1, + NM_MANAGER_RELOAD_FLAG_DNS_RC = 0x2, + NM_MANAGER_RELOAD_FLAG_DNS_FULL = 0x4, + NM_MANAGER_RELOAD_FLAG_ALL = 0x7, /*< skip >*/ +} NMManagerReloadFlags; + #endif /* __NM_DBUS_INTERFACE_H__ */ diff --git a/libnm/libnm.ver b/libnm/libnm.ver index 68eaf745e9..4f2fce6d8c 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -1631,5 +1631,6 @@ global: libnm_1_22_0 { global: + nm_manager_reload_flags_get_type; nm_setting_gsm_get_auto_config; } libnm_1_20_0; diff --git a/src/main.c b/src/main.c index 8267a16670..86b87dc971 100644 --- a/src/main.c +++ b/src/main.c @@ -89,7 +89,7 @@ _init_nm_debug (NMConfig *config) debug = nm_config_data_get_value (nm_config_get_data_orig (config), NM_CONFIG_KEYFILE_GROUP_MAIN, NM_CONFIG_KEYFILE_KEY_MAIN_DEBUG, - NM_MANAGER_RELOAD_FLAGS_NONE); + NM_CONFIG_GET_VALUE_NONE); flags = nm_utils_parse_debug_string (env, keys, G_N_ELEMENTS (keys)); flags |= nm_utils_parse_debug_string (debug, keys, G_N_ELEMENTS (keys)); diff --git a/src/nm-config-data.h b/src/nm-config-data.h index 57f97020d0..76d4432ce9 100644 --- a/src/nm-config-data.h +++ b/src/nm-config-data.h @@ -25,25 +25,6 @@ #define NM_CONFIG_DATA_NO_AUTO_DEFAULT "no-auto-default" #define NM_CONFIG_DATA_DNS_MODE "dns" -/* The flags for Reload. Currently these are internal defines, - * only their numeric value matters and must be stable as - * they are public API! Also, the enum must fit in uint32. */ -enum { /*< skip >*/ - NM_MANAGER_RELOAD_FLAGS_NONE = 0, - - /* reload the configuration from disk */ - NM_MANAGER_RELOAD_FLAGS_CONF = (1LL << 0), - - /* write DNS configuration to resolv.conf */ - NM_MANAGER_RELOAD_FLAGS_DNS_RC = (1LL << 1), - - /* restart the DNS plugin (includes DNS_RC) */ - NM_MANAGER_RELOAD_FLAGS_DNS_FULL = (1LL << 2), - - _NM_MANAGER_RELOAD_FLAGS_ALL, - NM_MANAGER_RELOAD_FLAGS_ALL = ((_NM_MANAGER_RELOAD_FLAGS_ALL - 1) << 1) - 1, -}; - typedef enum { /*< flags >*/ NM_CONFIG_GET_VALUE_NONE = 0, diff --git a/src/nm-manager.c b/src/nm-manager.c index 6d4fb0f55d..6a01426753 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -1155,16 +1155,16 @@ _reload_auth_cb (NMAuthChain *chain, NM_MANAGER_ERROR_PERMISSION_DENIED, "Not authorized to reload configuration"); } else { - if (NM_FLAGS_ANY (flags, ~NM_MANAGER_RELOAD_FLAGS_ALL)) { + if (NM_FLAGS_ANY (flags, ~NM_MANAGER_RELOAD_FLAG_ALL)) { /* invalid flags */ } else if (flags == 0) reload_type = NM_CONFIG_CHANGE_CAUSE_SIGHUP; else { - if (NM_FLAGS_HAS (flags, NM_MANAGER_RELOAD_FLAGS_CONF)) + if (NM_FLAGS_HAS (flags, NM_MANAGER_RELOAD_FLAG_CONF)) reload_type |= NM_CONFIG_CHANGE_CAUSE_CONF; - if (NM_FLAGS_HAS (flags, NM_MANAGER_RELOAD_FLAGS_DNS_RC)) + if (NM_FLAGS_HAS (flags, NM_MANAGER_RELOAD_FLAG_DNS_RC)) reload_type |= NM_CONFIG_CHANGE_CAUSE_DNS_RC; - if (NM_FLAGS_HAS (flags, NM_MANAGER_RELOAD_FLAGS_DNS_FULL)) + if (NM_FLAGS_HAS (flags, NM_MANAGER_RELOAD_FLAG_DNS_FULL)) reload_type |= NM_CONFIG_CHANGE_CAUSE_DNS_FULL; } -- cgit v1.2.1