Advantages:
- use current best-pratice
- registers a weak-ref to clear @singleton_instance when the
instance gets destroyed
- logs creation and destruction of singleton
- on shutdown, destroy the singleton instance via
_nm_singleton_instance_register_destruction(). Note, that
we now have yet another reference to the singleton that is
owned by register-destruction.
We already avoid loading duplicate plugins by checking find_plugin().
That iterates the plugins @list and checks for duplicate names.
Additionally, also reject duplicates based on the @plugins list.
Also, move the check for "keyfile" before, so that all explicit
checks for (statically) known names are early and together.
There is no need to have a static @singleton variable.
The only caller of nm_settings_keyfile_plugin_new() is
NMSettings which owns the singleton instance.
A *_new() function should just create a new instance and
that's it. It's unexpected to reuse the same instance.
Register the singleton instance of NMManager as we do for other
singletons. That way, we get automatic destruction and the singleton
instance get's properly cleared (when the instance gets destroyed).
Singletons that refer to other singletons in their destructor
should own a reference to those other singletons to ensure that
the lifetimes are handle correctly.
We want to create the platform instance rather late (especially after
claiming the D-Bus service). But we also want to destroy it very late,
because NMPlatform does not make use of any other singletons, but
other singletons make use of NMPlatform.
Some functions from nm-session-monitor.c have an implicit access to
nm_session_monitor_get(). This is non-obvious behavior.
Instead require the explicit session-monitor instance to be
provided -- where needed.
WiMAX support was dropped in commit 721e917cb6.
Also, remove support for the WiMAX rfkill flag and only preserve the
D-Bus property for backward compatibility.
We can dispose the manager before loading the factories:
NetworkManager[20214]: <error> [1439391976.738579] [nm-bus-manager.c:764] nm_bus_manager_start_service(): Could not acquire the NetworkManager service as it is already taken.
NetworkManager[20214]: <error> [1439391976.738617] [main.c:424] main(): failed to start the dbus service.
NetworkManager[20214]: nm_device_factory_manager_for_each_factory: assertion 'factories_by_link' failed
Program received signal SIGTRAP, Trace/breakpoint trap.
g_logv (log_domain=0x5a5028 "NetworkManager", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffd750) at gmessages.c:1046
1046 g_private_set (&g_log_depth, GUINT_TO_POINTER (depth));
(gdb) bt
#0 0x00007ffff4a738c3 in g_logv (log_domain=0x5a5028 "NetworkManager", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffd750) at gmessages.c:1046
#1 0x00007ffff4a73a3f in g_log (log_domain=log_domain@entry=0x5a5028 "NetworkManager", log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0x7ffff4ae173d "%s: assertion '%s' failed")
at gmessages.c:1079
#2 0x00007ffff4a73a79 in g_return_if_fail_warning (log_domain=log_domain@entry=0x5a5028 "NetworkManager", pretty_function=pretty_function@entry=0x5a5420 <__FUNCTION__.26921> "nm_device_factory_manager_for_each_factory", expression=expression@entry=0x5a4f25 "factories_by_link") at gmessages.c:1088
#3 0x00000000004704e4 in nm_device_factory_manager_for_each_factory (callback=callback@entry=0x4d29a0 <_deinit_device_factory>, user_data=user_data@entry=0x8802b0) at devices/nm-device-factory.c:306
#4 0x00000000004d2927 in dispose (object=0x8802b0 [NMManager]) at nm-manager.c:5086
#5 0x00007ffff4d6ea82 in g_object_unref (_object=0x8802b0) at gobject.c:3133
#6 0x00000000004459f6 in main (argc=1, argv=0x7fffffffda88) at main.c:468
(gdb)
The config-tests contain a NMTestDevice which derives from NMDevice.
However, for testing, it just skips the constructor and destructor of
NMDevice. This caused also the destructors of NMExportedObject to be skipped
and thus valgrind complained about leaked memory.
Fixes: 6fcc1deee0
Performing an ioctl on a non existent device may cause the automatic
load of a kernel module if the device name matches a module
alias. Check if the device actually exists before calling the ioctl.
For delete-events, we only need a shallow object with the key fields
set. That sufficies to lookup in the cache and find the object to
delete.
One other issue is that _nmp_vt_cmd_plobj_init_from_nl_link() and
link_extract_type() might call to ethtool for the already deleted
instance. Just avoid that.
https://bugzilla.redhat.com/show_bug.cgi?id=1247156
Move the check for a platform link before devtimeout_from_file(). The
check in the platform cache should be more performant and yield success
in most cases.
This can save reading and parsing the ifcfg-rh file.
If NIC related initialization takes a long time in udev processing, but we have
an ifindex from kernel, we still want to wait until udev is finished and the
device is really usable.
Check that by calling nm_platform_link_get_by_ifname() and checking @initialized,
which means udev is finished.
Based on a patch by t-nishimura@hf.jp.nec.com
Improved by thaller@redhat.comhttps://bugzilla.redhat.com/show_bug.cgi?id=1192633
Port remaining bits to gdbus and remove stray dbus-glib references
Drop the dbus-glib version check from configure, since nothing depends
on new dbus-glib any more.
Move nm-dbus-glib-types.h and nm-gvaluearray-compat.h from include/ to
libnm-util/ since they are now only used by libnm-util and libnm-glib.
The existing code was somewhat confusing because it used
string->GValue hash tables in some places, and string->string hash
tables in other places. In the new version, the string->GValue hash
tables become GVariants, but the string->string hash tables stay as
hash tables, so you can tell them apart more easily.
Port NMExportedObject to gdbus, and make
nm_exported_object_class_add_interface() deal with generating D-Bus
skeleton objects and attaching signal handlers and property bindings
as needed to properly handle methods, signals, and properties.
Rename nm_manager_new() to nm_manager_setup(), and change the local
@singleton variable to @singleton_instance. (Also, add a local @self
variable inside nm_manager_setup().)
Also, make NMManager own NMSettings rather than having them both owned
by main().
NM was calling nm_bus_manager_start_service() to claim its bus name
before it exported any of its objects, but this didn't matter under
dbus-glib, because no client connections would be accepted until the
main loop was started later on, by which point we would have exported
everything.
But with gdbus, method calls are initially received in the gdbus
worker thread, which means that clients would be able to connect right
away and then be told that the expected interfaces don't exist.
So move the nm_bus_manager_start_service() call to occur after
creating NMSettings and NMManager (and, indirectly, NMAgentManager).
This requires splitting out the slow parts of nm_settings_new() into a
new nm_settings_start(), so that we can create and export it first,
and then read the connections, etc afterward. (Likewise, there were
still a few potentially-slow bits in nm_manager_new() which are now
moved into nm_manager_start().)
NMManager was failing to initialize if there was only a private bus,
despite the fact that this is exactly the use case that the private
bus was added for.
The only other potentially-failing code in nm_manager_new() was adding
prop_filter to the D-Bus connection, but this can't really fail, so
just assert that it doesn't. And now, nm_manager_new() always
succeeds, so update the caller for that.
If !HAVE_LIBAUDIT then sizeof(NMAuditManagerPrivate) was 0, which
upset g_type_class_add_private(). (It's also not valid C.)
Fix things up so that NMAuditManagerPrivate as a whole only exists if
HAVE_LIBAUDIT.
During merge_and_apply(), we merge several NMIPxConfig into a new
@composite. For 'ignore-auto-routes' and 'ignore-auto-dns', we want to
prevent certain routes/dns-settings to be merged.
But it is wrong to reject settings from all partial configs.
For example, especially ext_ipx_config and vpn_ipx_config contain
routes that we still must merge and preserve.
This was recently changed by 79630c11e5
and previously by ab6548c62134518ba2871306397e7fb9c84260ca. But it was
wrong for a long time already.
Also note, that nm_ip4_config_merge() now also ignores NIS, WINS, and
dns-options.
https://bugzilla.gnome.org/show_bug.cgi?id=752546
Fixes: 79630c11e5
The new flags are not yet used, so there is no change in functionality.
The flags NM_IP_CONFIG_MERGE_NO_ROUTES and NM_IP_CONFIG_MERGE_NO_DNS go
together with the 'ignore-auto-routes' and 'ignore-auto-dns' setting.
Note that for IPv4, NM_IP_CONFIG_MERGE_NO_DNS also ignores NIS, WINS, and dns-options.
This is different from current other places that handle 'ignore-auto-dns'
and only care about nameservers, domains, and searches.
If linklocal6_start() finds that the device already has an IPv6
link-local address and returns NM_ACT_STAGE_RETURN_FINISH, we don't
need to fill @out_config with an empty configuration. A non-NULL
@out_config is required only for ret = NM_ACT_STAGE_RETURN_SUCCESS.
Fixes: 396dc2b3b4
The localization headers are now included via "nm-default.h".
Also fixes several places, where we wrongly included <glib/gi18n-lib.h>
instead of <glib/gi18n.h>. For example under "clients/" directory.