diff --git a/Makefile.am b/Makefile.am index 25ea649484..bb59bf8354 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2662,14 +2662,6 @@ $(src_core_libNetworkManagerTest_la_OBJECTS): $(src_libnm_core_public_mkenums_h) ############################################################################### -# NetworkManager binary also must contain symbols that are not used by the binary -# itself, but by the plugins (that are dlopened). We need to explicitly include -# them during linking. -networkmanager_undefined_symbols = \ - nm_sudo_call_get_fd \ - nm_sudo_utils_open_fd \ - $(NULL) - noinst_PROGRAMS += src/core/NetworkManager-all-sym src_core_NetworkManager_all_sym_CPPFLAGS = $(src_core_cppflags) @@ -2684,7 +2676,6 @@ src_core_NetworkManager_all_sym_LDADD = \ src_core_NetworkManager_all_sym_LDFLAGS = \ -rdynamic \ - $(networkmanager_undefined_symbols:%=-u %) \ $(SANITIZER_EXEC_LDFLAGS) \ $(NULL) @@ -2711,7 +2702,6 @@ src_core_NetworkManager_LDADD = \ src_core_NetworkManager_LDFLAGS = \ -rdynamic \ -Wl,--version-script="src/core/NetworkManager.ver" \ - $(networkmanager_undefined_symbols:%=-u %) \ $(SANITIZER_EXEC_LDFLAGS) \ $(NULL) diff --git a/config.h.meson b/config.h.meson index 5979793e5c..901535cf9f 100644 --- a/config.h.meson +++ b/config.h.meson @@ -224,6 +224,9 @@ /* Define if you have oFono support (experimental) */ #mesondefine WITH_OFONO +/* Whether we build with OVS plugin */ +#mesondefine WITH_OPENVSWITCH + /* Define if you have PPP support */ #mesondefine WITH_PPP @@ -261,3 +264,4 @@ /* Define to 1 if you have history support from -lreadline. */ #mesondefine HAVE_READLINE_HISTORY + diff --git a/configure.ac b/configure.ac index 3fc92d0892..a5e59514b0 100644 --- a/configure.ac +++ b/configure.ac @@ -851,6 +851,11 @@ if test "${enable_ovs}" != "no"; then fi fi AM_CONDITIONAL(WITH_OPENVSWITCH, test "${enable_ovs}" = "yes") +if test "${enable_ovs}" = "yes" ; then + AC_DEFINE(WITH_OPENVSWITCH, 1, [Whether we build with OVS plugin]) +else + AC_DEFINE(WITH_OPENVSWITCH, 0, [Whether we build with OVS plugin]) +fi # DHCP client support AC_ARG_WITH([dhclient], diff --git a/meson.build b/meson.build index 3c4be61509..40337b0e1b 100644 --- a/meson.build +++ b/meson.build @@ -644,6 +644,7 @@ enable_ovs = get_option('ovs') if enable_ovs assert(jansson_dep.found(), 'jansson is needed for Open vSwitch integration. Use -Dovs=false to disable it') endif +config_h.set10('WITH_OPENVSWITCH', enable_ovs) # DNS resolv.conf managers config_dns_rc_manager_default = get_option('config_dns_rc_manager_default') diff --git a/src/core/meson.build b/src/core/meson.build index f935ed1606..1a3f334fd8 100644 --- a/src/core/meson.build +++ b/src/core/meson.build @@ -271,17 +271,6 @@ endif subdir('devices') subdir('settings/plugins') -# NetworkManager binary also must contain symbols that are not used by the binary -# itself, but by the plugins (that are dlopened). We need to explicitly include -# them during linking. -networkmanager_undefined_symbols_args = [] -foreach s: [ - 'nm_sudo_call_get_fd', - 'nm_sudo_utils_open_fd', - ] - networkmanager_undefined_symbols_args += ['-u', s] -endforeach - # NetworkManager binary # libNetworkManager.a, as built by meson doesn't contain all symbols @@ -296,9 +285,7 @@ NetworkManager_all_sym = executable( nm_deps, libudev_dep, ], - link_args: [ - '-Wl,--no-gc-sections', - ] + networkmanager_undefined_symbols_args, + link_args: '-Wl,--no-gc-sections', link_whole: [ libNetworkManager, libNetworkManagerBase, @@ -359,7 +346,7 @@ NetworkManager = executable( link_args: [ '-rdynamic', '-Wl,--version-script,@0@'.format(ver_script.full_path()), - ] + networkmanager_undefined_symbols_args, + ], link_depends: ver_script, install: true, install_dir: nm_sbindir, diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c index d2ac7185f0..49c56bf68f 100644 --- a/src/core/nm-manager.c +++ b/src/core/nm-manager.c @@ -44,6 +44,7 @@ #include "nm-rfkill-manager.h" #include "nm-session-monitor.h" #include "nm-sleep-monitor.h" +#include "nm-sudo-call.h" #include "settings/nm-settings-connection.h" #include "settings/nm-settings.h" #include "vpn/nm-vpn-manager.h" @@ -212,6 +213,13 @@ struct _NMManager { typedef struct { NMDBusObjectClass parent; + +#if WITH_OPENVSWITCH + /* these fields only serve the purpose to use the symbols.*/ + void (*_use_symbol_nm_sudo_call_get_fd)(void); + void (*_use_symbol_nm_sudo_utils_open_fd)(void); +#endif + } NMManagerClass; G_DEFINE_TYPE(NMManager, nm_manager, NM_TYPE_DBUS_OBJECT) @@ -8528,6 +8536,14 @@ nm_manager_class_init(NMManagerClass *manager_class) GObjectClass * object_class = G_OBJECT_CLASS(manager_class); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(manager_class); +#if WITH_OPENVSWITCH + /* Use the symbols. These symbols are in NetworkManager binary but will be + * used by the OVS device plugin. If we don't use the symbol here, it will + * be wrongly dropped. */ + manager_class->_use_symbol_nm_sudo_call_get_fd = (void (*)(void)) nm_sudo_call_get_fd; + manager_class->_use_symbol_nm_sudo_utils_open_fd = (void (*)(void)) nm_sudo_utils_open_fd; +#endif + dbus_object_class->export_path = NM_DBUS_EXPORT_PATH_STATIC(NM_DBUS_PATH); dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS(&interface_info_manager);