Commit Graph

15047 Commits

Author SHA1 Message Date
Thomas Haller
39aa27c32f wifi/libnm: merge branch 'mtl/wifi-ap-last-seen'
https://mail.gnome.org/archives/networkmanager-list/2015-April/msg00053.html
2015-04-29 07:52:23 +02:00
Dan Williams
1e85c35846 libnm: add Wi-Fi AP 'last-seen' property 2015-04-29 07:51:26 +02:00
Mathieu Trudel-Lapierre
f3b8285be5 wifi: expose the last_seen property for a NMAccessPoint
https://mail.gnome.org/archives/networkmanager-list/2015-April/msg00053.html
2015-04-29 07:49:23 +02:00
Thomas Haller
967376b840 core: add nm_utils_monotonic_timestamp_as_boottime() function 2015-04-29 07:32:42 +02:00
Thomas Haller
b5beaef8fa utils: add nm_clear_g_source() helper
Utility function to simplify the following common code:

    if (priv->timeout_id) {
        g_source_remove (priv->timeout_id);
        priv->timeout_id = 0;
    }

to

    nm_clear_g_source (&priv->timeout_id);
2015-04-28 18:25:43 +02:00
Thomas Haller
af2c0ef771 platform: ignore routes with non-zero TOS
The identifying properties of a route are (in libnl)

    .o_id_attrs = (ROUTE_ATTR_FAMILY | ROUTE_ATTR_TOS |
                   ROUTE_ATTR_TABLE | ROUTE_ATTR_DST |
                   ROUTE_ATTR_PRIO),

NM ignores routes other then in table RT_TABLE_MAIN and considers
only the tuple 'family,network/plen,metric' as identifying for a route.

We must also ignore routes with TOS non-zero as we cannot
handle those, i.e. we cannot distinguish between them.
2015-04-28 17:11:28 +02:00
Lubomir Rintel
0ea1fb4e5e libnm: set error when failing registration of old secret agent
We return FALSE, we ought to return a meaningful error.
2015-04-28 12:28:36 +02:00
David Ward
db4d83d5a4 nm-iface-helper: set last_config properly
Update last_config outside of the conditional; otherwise it will
always remain set to NULL.

Signed-off-by: David Ward <david.ward@ll.mit.edu>
Acked-By: Thomas Haller <thaller@redhat.com>
2015-04-27 19:18:21 +02:00
Lubomir Rintel
2b097fdce5 settings,manager: merge branch 'lr/james-bond-rh1183424'
https://bugzilla.gnome.org/show_bug.cgi?id=744812
2015-04-27 11:35:45 +02:00
Dan Williams
bbcf5444fd settings: remove 'do_export' argument from claim_connection()
It was always TRUE, and unused anyway.
2015-04-27 11:33:59 +02:00
Dan Williams
fe96dbc0ee settings/dbus: harden connection removal and object unexport
None of these functions was checking if the same operation had already
been performed, or if the object being removed/unexported was known.
2015-04-27 11:33:59 +02:00
Lubomir Rintel
74ed416d84 manager: don't try to delete generated connection if it's already gone
Move the cleanup of the generated assumed connection to active connection
dispose. If the connection vanishes earlier (explicit deletion from client),
tear down the reference so that we don't try to remove it redundantly.

  NetworkManager[9221]: <info>  (eth2): device state change: deactivating -> disconnected (reason 'connection-removed') [110 30 38]
  NetworkManager[9221]: <info>  (eth2): deactivating device (reason 'connection-removed') [38]

  (NetworkManager:9221): GLib-GObject-WARNING **: g_object_weak_unref: couldn't find weak ref 0x496610(0x7c2ba0)

  Program received signal SIGTRAP, Trace/breakpoint trap.
  g_logv (log_domain=0x7ffff4d4f1a4 "GLib-GObject", log_level=G_LOG_LEVEL_WARNING, format=<optimized out>, args=args@entry=0x7fffffffd860) at gmessages.c:1046
  1046              g_private_set (&g_log_depth, GUINT_TO_POINTER (depth));
  (gdb) bt
  #0  0x00007ffff4a2cc60 in g_logv (log_domain=0x7ffff4d4f1a4 "GLib-GObject", log_level=G_LOG_LEVEL_WARNING, format=<optimized out>, args=args@entry=0x7fffffffd860) at gmessages.c:1046
  #1  0x00007ffff4a2ce9f in g_log (log_domain=<optimized out>, log_level=<optimized out>, format=<optimized out>) at gmessages.c:1079
  #2  0x000000000049780b in nm_dbus_manager_unregister_object (self=0x7c2ba0 [NMDBusManager], object=0x80f3e0) at nm-dbus-manager.c:921
  #3  0x000000000047cc83 in nm_settings_connection_signal_remove (self=self@entry=0x80f3e0 [NMIfcfgConnection]) at settings/nm-settings-connection.c:1752
  #4  0x000000000047cd22 in do_delete (connection=0x80f3e0 [NMIfcfgConnection], callback=0x479d60 <ignore_cb>, user_data=0x0) at settings/nm-settings-connection.c:687
  #5  0x00000000004b1eb6 in active_connection_remove (self=self@entry=0x8701c0 [NMManager], active=active@entry=0x8b02f0) at nm-manager.c:292
  #6  0x00000000004b2174 in _active_connection_cleanup (user_data=<optimized out>) at nm-manager.c:316
  #7  0x00007ffff4a25aeb in g_main_context_dispatch (context=0x7be3a0) at gmain.c:3111
  #8  0x00007ffff4a25aeb in g_main_context_dispatch (context=context@entry=0x7be3a0) at gmain.c:3710
  #9  0x00007ffff4a25e88 in g_main_context_iterate (context=0x7be3a0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3781
  #10 0x00007ffff4a261b2 in g_main_loop_run (loop=0x7be460) at gmain.c:3975
  #11 0x0000000000432f55 in main (argc=1, argv=0x7fffffffded8) at main.c:460
  (gdb)

https://bugzilla.gnome.org/show_bug.cgi?id=744812
2015-04-27 11:33:58 +02:00
Lubomir Rintel
8a00bb36ec nm-settings: add nm_settings_has_connection()
Useful for checking if a connection is already deleted.

https://bugzilla.gnome.org/show_bug.cgi?id=744812
https://bugzilla.redhat.com/show_bug.cgi?id=1174164
2015-04-27 11:33:58 +02:00
Lubomir Rintel
cd2cef9cab utils: match a cloned mac address with a connection that does not specify it
We do the same for the original MAC address.

A device enslaved to a bond it inherits the bond's MAC address. When
NetworkManager tries to assume a connection the generated cloned-mac property
causes a mismatch with the connection that originally brought up the device,
causing the generated connection to be used instead:

  NetworkManager[14190]: <debug> [1424355817.112154] [NetworkManagerUtils.c:1641]
         nm_utils_match_connection(): Connection 'eth2' differs from candidate
         'bond-slave-eth2' in 802-3-ethernet.cloned-mac-address

https://bugzilla.gnome.org/show_bug.cgi?id=744812
2015-04-27 11:33:58 +02:00
Thomas Haller
cb6bafb9af logging: define _LOGT() macro to check valid arguments
With NM_MORE_LOGGING disabled, we still want the compiler to evaluate
the argument list. By wrapping it in "if(FALSE)", we get compile time
checks, but the logging statement will be optimized out.
2015-04-24 13:51:43 +02:00
Dan Williams
9b07ea77b8 dbus-manager: harden registering/unregistering object
Saw some g_warning() about g_object_weak_unref() trying to unref a non
registed reference. While this does not fix it, let's assert that
situation a step earlier to ease debugging.

Also, move g_object_weak_ref() closer to adding the object into the
@exported hash.

[thaller@redhat.com: rewrote commit message, change to register_object()]
2015-04-23 19:49:34 +02:00
Lubomir Rintel
72f264ad9b ifcfg-rh: don't try to read DEVTIMEOUT from file for in-memory connections
#0  0x00007ffff4a2c970 in g_logv (log_domain=0x7fffe9201115 "NetworkManager-ifcfg-rh", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffd710) at gmessages.c:1046
  #1  0x00007ffff4a2cbaf in g_log (log_domain=log_domain@entry=0x7fffe9201115 "NetworkManager-ifcfg-rh", log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0x7ffff4a9bc1d "%s: assertion '%s' failed") at gmessages.c:1079
  #2  0x00007ffff4a2cbe9 in g_return_if_fail_warning (log_domain=log_domain@entry=0x7fffe9201115 "NetworkManager-ifcfg-rh", pretty_function=pretty_function@entry=0x7fffe9204b70 <__FUNCTION__.30626> "devtimeout_from_file", expression=expression@entry=0x7fffe9202d97 "filename != NULL") at gmessages.c:1088
  #3  0x00007fffe91fbfa2 in devtimeout_from_file (filename=<optimized out>) at reader.c:4884
  #4  0x00007fffe91ef845 in nm_ifcfg_connection_new (self=0x8d2200 [NMIfcfgConnection]) at nm-ifcfg-connection.c:159
  #5  0x00007fffe91ef845 in nm_ifcfg_connection_new (source=source@entry=0x83ba40, full_path=full_path@entry=0x0, error=error@entry=0x7fffffffd980) at nm-ifcfg-connection.c:240
  #6  0x00007fffe91ec7e6 in update_connection (self=self@entry=0x80c2a0 [SCPluginIfcfg], source=source@entry=0x83ba40, full_path=0x0, connection=connection@entry=0x0, protect_existing_connection=protect_existing_connection@entry=0, protected_connections=protected_connections@entry=0x0, error=0x7fffffffd980) at plugin.c:225
  #7  0x00007fffe91eddf2 in add_connection (config=<optimized out>, connection=0x83ba40, save_to_disk=<optimized out>, error=0x7fffffffd980) at plugin.c:715
  #8  0x000000000048fc1d in nm_settings_add_connection (self=<optimized out>, connection=0x83ba40, save_to_disk=0, error=<optimized out>) at settings/nm-settings.c:1045
  #9  0x0000000000490858 in pk_add_cb (chain=0x8b1fc0, chain_error=<optimized out>, context=<optimized out>, user_data=<optimized out>) at settings/nm-settings.c:1151
  #10 0x00000000004ca98c in auth_chain_finish (user_data=0x8b1fc0) at nm-auth-utils.c:82
  #11 0x00007ffff4a257fb in g_main_context_dispatch (context=0x7cd3e0) at gmain.c:3111
  #12 0x00007ffff4a257fb in g_main_context_dispatch (context=context@entry=0x7cd3e0) at gmain.c:3710
  #13 0x00007ffff4a25b98 in g_main_context_iterate (context=0x7cd3e0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3781
  #14 0x00007ffff4a25ec2 in g_main_loop_run (loop=0x7cd4a0) at gmain.c:3975
  #15 0x0000000000444c81 in main (argc=<optimized out>, argv=<optimized out>) at main.c:486
2015-04-23 17:14:03 +02:00
Thomas Haller
842ec6163d core: refactor nm_ethernet_address_is_valid() and reject invalid addresses
nm_ethernet_address_is_valid() did not check whether @addr was a valid
address in the first place. It only checked whether the address was not
equal to a few notorious MAC addresses.

At the same time, be more forgiving and accept %NULL as argument.
This fixes an assertion nm_ap_match_in_hash().
2015-04-23 16:38:51 +02:00
Thomas Haller
dbb3b44ca6 core/test: add test for nm_ethernet_address_is_valid() 2015-04-23 16:38:51 +02:00
Thomas Haller
7f8149bdb7 wifi: avoid assertion in request_wireless_scan() passing NULL to nm_utils_ssid_to_utf8() 2015-04-23 16:38:51 +02:00
Thomas Haller
8f080747c6 platform: remove wrong assertion
This is a well known issue that we cannot convert some libnl
objects to NMPlatformObject. The to-string function for libnl
objects is only used for debug logging. No need to assert.
2015-04-23 16:38:51 +02:00
Lubomir Rintel
29fe1abf0d cli: stop waiting for deactivation if device reaches unmanaged state
default-unmanaged devices enter unmanaged state right after they're
disconnected.
2015-04-23 10:22:26 -04:00
Thomas Haller
245720819e build/trivial: reorder and break lines in Makefile.am 2015-04-22 22:30:46 +02:00
Thomas Haller
2316d233e3 platform: merge branch 'th/platform-div-bgo748131'
https://bugzilla.gnome.org/show_bug.cgi?id=748131
2015-04-22 16:54:53 +02:00
Thomas Haller
ea5865cf45 platform: add NM_PLATFORM_SIGNAL_NONE enum value 2015-04-22 16:54:23 +02:00
Thomas Haller
f15a27f9c1 platform: refactor detection of support_user_ipv6ll
Move detection of @support_user_ipv6ll to a separate function
_support_user_ipv6ll_detect() and call it immediately after the
places where we receive libnl objects from kernel, i.e.
get_kernel_object(), event_notification(), and cache_repopulate_all().

Also, whether we have support depends on the kernel and is per-system,
not per-platform-instance. Make @_support_user_ipv6ll a global variable.
This way, we don't need to pass around a NMLinuxPlatform instance.
2015-04-22 16:53:46 +02:00
Thomas Haller
a319aea9f4 platform: don't assert against success of nl_msg_parse() 2015-04-22 16:51:11 +02:00
Thomas Haller
0c03db4e8e platform: use new _LOG() logging macros in nm-linux-platform.c 2015-04-22 16:51:11 +02:00
Thomas Haller
7db9306aa3 platform: add _LOG() logging macros to linux platform 2015-04-22 16:51:11 +02:00
Thomas Haller
90caa93582 platform: add nm_platform_try_get() function 2015-04-22 16:51:11 +02:00
Thomas Haller
04ed48e5a0 platform: drop nm_platform_free() and register weak-ref
Instead of having a nm_platform_free() function, use NM_DEFINE_SINGLETON_WEAK_REF()
and register a weak reference. That way, users who want to free the platform
instance can just unref it.
2015-04-22 16:51:11 +02:00
Thomas Haller
fe2608c903 platform: drop virtual setup() initalization function
We already have nm_*_platform_setup() that gets specified
via -DSETUP. This SETUP() hook gives us all the flexiblity
we need to customize our singleton, so just do any required
setup there.

Also, it would be easier to add an alternative (hypotetical)
nm_fake_platform_setup_custom() to customize the singleton then to
parametrize the NMPlatform:setup() implementation. So this virtual
function is less flexible and redundant.
2015-04-22 16:50:52 +02:00
Thomas Haller
a50d77d952 platform: pass singleton instance to nm_platform_setup()
We have two hooks to modify setup of the platform singleton:
nm_linux_platform_setup() and the virtual setup() function.

On the other hand, nm_platform_setup() limits us by accepting
only a GType, instead of a prepeared platform instance.
Make the nm_platform_setup() method more flexible, so that we can
later drop the setup() hook.
2015-04-22 11:26:54 +02:00
Thomas Haller
dc9b25f161 platform: initialize NMLinuxPlatform in constructed() method
setup() can be used to initialize a NMPlatform instance that is
registered as singleton via nm_platform_setup(). It should not
be used to initialize the object.

Prior to c6529a9d74, this change was
not possible because constructed() will call back into nm_platform_*()
functions, without having the singleton instance setup.
2015-04-22 11:26:54 +02:00
Thomas Haller
4526b55a51 logging: use _nm_log() to avoid duplicate check of whether logging is enabled
Use _nm_log() in places that already checked whether logging
is enabled. No need to check again as done by nm_log().
2015-04-22 11:22:19 +02:00
Thomas Haller
fb9f8c69f7 logging: add logging macro _nm_log() that logs unconditionally 2015-04-22 11:22:19 +02:00
Thomas Haller
211d241ab0 logging/trivial: rename _nm_log() to _nm_log_impl()
The actual logging implementation is not supposed to be called
directly, because there are macros that capture the call site
information __FILE__, __LINE__, and G_STRFUNC.

Rename the function to make clear that this is the actual
implementation.
2015-04-22 11:06:49 +02:00
Thomas Haller
2458ddf5e9 logging: ensure that the first argument of the logging statement is a C string
We don't want to pass unknown format strings to the logging
macro. Catch that by concatenating "" with the format string.
2015-04-22 10:26:35 +02:00
Thomas Haller
bdec5e2e53 logging: always pass a static format string to logging functions 2015-04-22 10:26:35 +02:00
Thomas Haller
b04c99da0b ibft/logging: don't localize logging stagements
We don't localize any other nm-logging messages either.
2015-04-22 10:26:34 +02:00
Lubomir Rintel
d231162fbc nm-ip[64]-config: set ifindex when replacing a duplicate route
Otherwise it stays zero and hits an assertion when the route is applied:

  NetworkManager:ERROR:nm-route-manager.c:179:nm_route_manager_ip4_route_sync:
    assertion failed: (known_route->ifindex)

https://bugzilla.gnome.org/show_bug.cgi?id=745844
2015-04-22 09:59:24 +02:00
Jiří Klimeš
7271e168b0 cli: fix allowed slave-types 2015-04-22 08:51:29 +02:00
Thomas Haller
313af401d3 platform/test: refactor detection of root-test 2015-04-21 18:04:37 +02:00
Thomas Haller
bdb2f94519 platform: pass @platform instance to build_rtnl_addr() 2015-04-21 17:52:10 +02:00
Thomas Haller
c6529a9d74 platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.

While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.

With this change, NMPlatform instances can be used individually, not
only as a singleton instance.

Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.

Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.

Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.

This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-21 17:51:34 +02:00
Thomas Haller
ccba1b1e2d trivial: fix spelling in comments 2015-04-20 11:27:56 +02:00
Jiří Klimeš
80a72a4092 merge: add new nm-plugin-missing property for devices (bgo #747851)
The property indicates that a device type is supported by NetworkManager, but
the plugin for handling the device is missing.
The property is accessible through D-Bus API, libnm and nmcli.

https://bugzilla.gnome.org/show_bug.cgi?id=747851
2015-04-20 10:13:12 +02:00
Jiří Klimeš
1b9c1ed6d3 cli: add NM-PLUGIN-MISSING to devices 2015-04-20 10:04:26 +02:00
Jiří Klimeš
560e19514e core: set nm-plugin-missing device property 2015-04-20 10:04:15 +02:00
Jiří Klimeš
4c398ab03f libnm: add nm-plugin-missing property indicating NM device plugin not available 2015-04-20 10:04:15 +02:00