Commit graph

6291 commits

Author SHA1 Message Date
Thomas Haller
45c85a0d6b logging: declare default logging macros in "nm-logging.h"
The logging macros _LOGD(), etc. are specific to each
file as they format the message according to their context.

Still, they were cumbersome to define and their implementation
was repeated over and over (slightly different at times).

Move the declaration of these macros to "nm-logging.h".
The source file now only needs to define _NMLOG(), and either
_NMLOG_ENABLED() or _NMLOG_DOMAIN.

This reduces code duplication and encourages a common implementation
and usage of these macros.

(cherry picked from commit ad7cdfc766)
2015-08-20 18:05:43 +02:00
Thomas Haller
d7e36972c7 core: print connection path in nm_utils_log_connection_diff()
(cherry picked from commit 4c48f66d3d)
2015-08-20 18:05:43 +02:00
Thomas Haller
f202a16026 settings: use _LOG() macros in "nm-settings-connection.c"
(cherry picked from commit a6e7b96963)
2015-08-20 18:05:43 +02:00
Thomas Haller
6a2c021559 settings: refactor logging statement in nm_settings_connection_get_secrets()
(cherry picked from commit 0dcd7b2208)
2015-08-20 18:05:43 +02:00
Thomas Haller
494b52a832 settings: add _LOG() macros to "nm-settings-connection.h"
(cherry picked from commit 5fb56a1df9)
2015-08-20 18:05:43 +02:00
Thomas Haller
1b3bb295c5 settings/trivial: consistently name @self argument in NMSettingsConnection
(cherry picked from commit 0a160116d7)
2015-08-20 18:05:43 +02:00
Thomas Haller
462b955516 active-connection: make use of logging macro _LOGD()
(cherry picked from commit 97c971b4e4)
2015-08-20 18:05:24 +02:00
Thomas Haller
0621b8b839 active-connection: add logging macros _LOG*()
(cherry picked from commit c6cbd652ba)
2015-08-20 17:54:17 +02:00
Beniamino Galvani
8482f06090 device: don't clear @master on cleanup when the link is still enslaved
Don't clear NMDevice @master in nm_device_cleanup() if the device link
is still enslaved because this causes an inconsistent state in which
the slave in included in the @slaves field of master device but
@master of slave device is NULL.

In such state, if the master link gets deleted, NM receives a change
event for each slave and a deletion event for the master; the change
events should also remove slaves from @slaves of master device, but
since their @master field is NULL the removal can't be performed.

Later, when the master deletion event is received, @slaves is not empty
in dispose() of NMDevice and the following assertion is triggered:

  dispose: runtime check failed: (priv->slaves == NULL)

https://bugzilla.redhat.com/show_bug.cgi?id=1243371
(cherry picked from commit b557f91a1b)
2015-08-20 08:58:29 +02:00
Thomas Haller
0cbe203d7c supplicant: don't log a warning when scan request fails
This downgrades the following warning down to debug-level.

  <warn>  Could not get scan request result: GDBus.Error:fi.w1.wpa_supplicant1.Interface.ScanError: Scan request rejected

It seems this ~error~ happens regularly, so warning about it is overly
alarming.

(cherry picked from commit ebc387638a)
2015-08-19 12:59:40 +02:00
Thomas Haller
e04c3139ef manager: fix memleak in system_hostname_changed_cb()
Also, no need to clone the hostname again.

Fixes: c9067d8fed
(cherry picked from commit 58a2e99294)
2015-08-18 15:16:33 +02:00
Jiří Klimeš
7706b99250 core: accept 'ssids':aay option in RequestScan() dictionary parameter
It allows specifying SSIDs that should be probe-scanned, which is useful
for APs with hidden SSID, for example.

(cherry picked from commit 87b2d783b6)
2015-08-14 13:30:11 +02:00
Lubomir Rintel
4956ac6475 device: avoid a crash during destruction
The ipv4_config might be gone already, _cleanup_generic_post() sets it to NULL.

  NetworkManager[30564]: <info>  caught SIGINT, shutting down normally.

  (NetworkManager:30564): GLib-GObject-CRITICAL **: g_type_instance_get_private: assertion 'instance != NULL && instance->g_class != NULL' failed

  Program received signal SIGTRAP, Trace/breakpoint trap.
  g_logv (log_domain=0x7ffff4d92f64 "GLib-GObject", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffd5e0) at gmessages.c:1046
  1046              g_private_set (&g_log_depth, GUINT_TO_POINTER (depth));
  (gdb) bt
  #0  0x00007ffff4a738c3 in g_logv (log_domain=0x7ffff4d92f64 "GLib-GObject", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffd5e0) at gmessages.c:1046
  #1  0x00007ffff4a73a3f in g_log (log_domain=log_domain@entry=0x7ffff4d92f64 "GLib-GObject", 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=0x7ffff4d92f64 "GLib-GObject", pretty_function=pretty_function@entry=0x7ffff4d9aad0 <__FUNCTION__.13620> "g_type_instance_get_private", expression=expression@entry=0x7ffff4d99db8 "instance != NULL && instance->g_class != NULL") at gmessages.c:1088
  #3  0x00007ffff4d8d2ba in g_type_instance_get_private (instance=instance@entry=0x0, private_type=<optimized out>) at gtype.c:4632
  #4  0x00000000004bf774 in nm_ip4_config_get_num_addresses (config=0x0) at nm-ip4-config.c:1418
  #5  0x0000000000458834 in _update_ip4_address (self=self@entry=0xa8a490 [NMDeviceBridge]) at devices/nm-device.c:6069
  #6  0x000000000045e740 in nm_device_set_ip4_config (self=self@entry=0xa8a490 [NMDeviceBridge], new_config=new_config@entry=0x0, default_route_metric=default_route_metric@entry=0, commit=commit@entry=1, routes_full_sync=routes_full_sync@entry=1, reason=reason@entry=0x7fffffffd7cc) at devices/nm-device.c:6558
  #7  0x0000000000466c56 in _cleanup_generic_post (self=self@entry=0xa8a490 [NMDeviceBridge], cleanup_type=cleanup_type@entry=CLEANUP_TYPE_KEEP) at devices/nm-device.c:8108
  #8  0x00000000004671af in dispose (object=0xa8a490 [NMDeviceBridge]) at devices/nm-device.c:9128
  #9  0x00007ffff4d6ea82 in g_object_unref (_object=0xa8a490) at gobject.c:3133
  #10 0x00000000004d1a53 in remove_device (manager=manager@entry=0x8822b0 [NMManager], device=0xa8a490 [NMDeviceBridge], quitting=quitting@entry=1, allow_unmanage=allow_unmanage@entry=1) at nm-manager.c:780
  #11 0x00000000004d7db1 in nm_manager_stop (self=self@entry=0x8822b0 [NMManager]) at nm-manager.c:4199
  #12 0x0000000000445aa9 in main (argc=1, argv=0x7fffffffda88) at main.c:465
  (gdb)

(cherry picked from commit 688e93fb2a)
2015-08-14 10:46:20 +02:00
Thomas Haller
7e2caa2146 ifcfg-rh: take reference to nm_inotifiy_helper_get() singleton in NMIfcfgConnection
https://bugzilla.redhat.com/show_bug.cgi?id=1253330
(cherry picked from commit 088e606fcc)
2015-08-13 16:23:26 +02:00
Dan Winship
431bbb01b4 core: fix NMManager in private-bus-only case
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.

(cherry picked from commit 1c11c5cff1)
2015-08-12 16:27:14 +02:00
Thomas Haller
5d6b1bce8e config/tests: fix tests after introducing NMExportedObject class
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

[thaller@redhat.com: although this branch doesn't have NMExportedObject,
the patch is still more correct, and thus backport it too]

(cherry picked from commit 3ae6f9d793)
2015-08-12 16:15:05 +02:00
Thomas Haller
fc22db0b85 dhcp/tests: fix memleaks in tests (test_vendor_option_metered)
Fixes: 1e39b2320d
(cherry picked from commit 641ca3d5d2)
2015-08-12 16:14:32 +02:00
Thomas Haller
8a40d75f32 dhcp/tests: fix memleaks in dhcp-tests
These are old leaks, reported by valgrind runs. Strange that they didn't
show up earlier...

(cherry picked from commit 286455bfda)
2015-08-12 16:14:31 +02:00
Beniamino Galvani
37877687bb core: avoid ioctls on non existent devices
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.

(cherry picked from commit ab41c13b06)
2015-08-11 18:38:56 +02:00
Beniamino Galvani
97076260ae device: don't call ioctl to update priv->ip4_address
Just take the first address in priv->ip4_config.

(cherry picked from commit bfb459f8ed)
2015-08-11 18:38:56 +02:00
Thomas Haller
c5569a4e11 utils: add nm_utils_is_valid_path_component()
(cherry picked from commit 633deb0a98)
2015-08-11 18:38:55 +02:00
Thomas Haller
30768c7240 platform: optimize event_notification() not to create full nmp-objects for delete-events
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
(cherry picked from commit a4c7176fe9)
2015-08-11 18:38:55 +02:00
Thomas Haller
796f78a04c platform: assert for valid ifname in ethtool_get()
Add an assert (g_return_val_if_reached()) that the interface name is
valid and shorter then 16 bytes. If it happened to be longer, strncpy()
would not have zero terminated the interface name.

(cherry picked from commit 5b123f2539)
2015-08-11 18:38:55 +02:00
Jiří Klimeš
5b71ec822a all: fix a compiler warning about function declarations
warning: function declaration isn’t a prototype [-Wstrict-prototypes]

In C function() and function(void) are two different prototypes (as opposed to
C++).
function()     accepts an arbitrary number of arguments
function(void) accepts zero arguments

(cherry picked from commit 94a393e9ed)
2015-08-11 18:36:53 +02:00
Thomas Haller
95443644c1 ifcfg-rh: reorder checks in nm_ifcfg_connection_check_devtimeout()
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.

(cherry picked from commit 6608331aec)
2015-08-11 18:27:44 +02:00
Jiří Klimeš
f3472ea4d8 ifcfg-rh: respect DEVTIMEOUT if link is not announced by udev yet (rh #1192633)
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.com

https://bugzilla.redhat.com/show_bug.cgi?id=1192633
(cherry picked from commit ecdf7cba6b)
2015-08-11 18:27:38 +02:00
Lubomir Rintel
042d0127f1 tests: don't use a local address for testing a gateway route
Doesn't work on RHEL 7 kernel:

https://bugzilla.redhat.com/show_bug.cgi?id=1252067
(cherry picked from commit 4b68c88023)
2015-08-10 17:47:02 +02:00
Lubomir Rintel
3af5403b3a device: avoid setting MTU to zero if undefined
(cherry picked from commit c44069c10a)
2015-08-10 14:10:45 +02:00
Mathieu Trudel-Lapierre
cdb8a44a6e wifi: expose the last_seen property for a NMAccessPoint
https://mail.gnome.org/archives/networkmanager-list/2015-April/msg00053.html
2015-08-07 12:38:24 -05:00
Thomas Haller
1b62ff1d24 core: add nm_utils_monotonic_timestamp_as_boottime() function 2015-08-07 12:33:09 -05:00
Beniamino Galvani
02b354023a device: fix memory leak in act_stage3_ip6_config_start()
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
(cherry picked from commit 54d10f0ec1)
2015-08-07 13:14:53 +02:00
Thomas Haller
dfb1c0301a platform/tests: fix assertion for test-link for team device
Seems that team changed to now also raise two change signals.
Relax the assertion that broke tests on Fedora 22.

(cherry picked from commit 1c2883c940)
2015-08-06 18:06:19 +02:00
Thomas Haller
1ee28ba989 device: only 'ignore-auto-routes' and 'ignore-auto-dns' for certain settings
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 ab6548c621. 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
(cherry picked from commit 43e6f6a178)
2015-08-06 18:00:44 +02:00
Thomas Haller
aadf202cf2 core: add @merge_flags argument to nm_ip4_config_merge() and nm_ip6_config_merge()
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.

(cherry picked from commit f7a8962dd4)
2015-08-06 18:00:44 +02:00
Lubomir Rintel
dee3dcf9c5 device: lower serverity of MTU adjustment logging
Warn is probably too harsh, but we still need to log the reason for the change.

(cherry picked from commit f7f9e734aa)
2015-08-04 13:46:02 +02:00
Lubomir Rintel
82da29746d device: don't modify the device MTU if it's unset
The MTU of 0 means default, not zero-length packets:

  <warn>  (wlp3s0): Lowering IPv6 MTU (1472) to match device MTU (0)
  <warn>  (wlp3s0): IPv6 MTU (0) smaller than 1280, adjusting
  <warn>  (wlp3s0): Raising device MTU (0) to match IPv6 MTU (1280)
  <error> [1437068831.306733] [platform/nm-linux-platform.c:2440] sysctl_set(): platform-linux: sysctl: failed to set '/proc/sys/net/ipv6/conf/wlp3s0/mtu' to '1472': (22) Invalid argument

Reported-by:  Jan Alexander Steffens <jan.steffens@gmail.com>

https://bugzilla.gnome.org/show_bug.cgi?id=752508
(cherry picked from commit a92d8b0c67)
2015-08-04 13:45:59 +02:00
Beniamino Galvani
375100715f device: set Ethernet MTU for PPPoE connections in stage2/config
Try to set the MTU of the parent Ethernet interface to match the
requested PPP MTU and MRU. This allows the negotiation of a PPP MTU
and MRU greater than 1492.

(cherry picked from commit 1d3eff45d2)
2015-08-04 12:43:17 +02:00
Beniamino Galvani
ecb93850c1 device: set MTU on IP interface
Fixes: 7ba2a058f2
(cherry picked from commit 0a04be41d4)
2015-08-04 12:43:17 +02:00
Lubomir Rintel
f11e4c31ee ip4-config: 0.0.0.0 is a valid gateway too
It makes sense for point-to point links.

https://bugzilla.redhat.com/show_bug.cgi?id=1244483
(cherry picked from commit 063677101a)
2015-07-22 14:50:49 +02:00
Lubomir Rintel
5e9dd4b267 default-route-manager: pick up platform changes after NMDevice
If a default route is configured externally, we want the device to pick the
change and register it with the default-route-manager first.

https://bugzilla.redhat.com/show_bug.cgi?id=1244483
(cherry picked from commit e67b52ed16)
2015-07-22 14:49:16 +02:00
Thomas Haller
0ab389e15c device: always assume default-route for generate-assumed-connections
Commit d51975e changed, that we treat assumed and non-assumed
connections the same with respect to the default route. This is
certainly wrong, if we have an nm-generated-assumed connection
at hand. In this case, NM just generated a connection based on what
was configured on the system. Looking at that result and re-enforcing
the default-route is wrong.

We want to manage the default-route for assumed, persistent connections.
If the connection was assumed and generated, we do not.

This commit reverts d51975ed for nm-generated-assumed connection and
restores the previous behavior.

https://bugzilla.redhat.com/show_bug.cgi?id=1244483

Fixes: d51975ed92
(cherry picked from commit bebeff69e8)
2015-07-22 14:49:16 +02:00
Thomas Haller
351a645ad6 device: move setting v4_commit_first_time/v6_commit_first_time to the end of merge_and_apply()
(cherry picked from commit cbd246c9b0)
2015-07-22 14:49:16 +02:00
Thomas Haller
83dadca08e device/trivial: rename private field in NMDevicePrivate
Rename "default_route.v4_configure_first_time" to "v4_commit_first_time".

For one, the name "commit" matches better to the @commit variable in ip4_config_merge_and_apply()
and ip6_config_merge_and_apply(). Then, we don't need this information
only for default-routes, so move the variable out of the @default_route
struct.

(cherry picked from commit ad03cdbc73)
2015-07-22 14:49:16 +02:00
Thomas Haller
3308114211 core: fix handling route-metric for nm_ip4_config_merge()
Fixes: bc75cd53a8
(cherry picked from commit 47cc91bef6)
2015-07-22 14:42:40 +02:00
Thomas Haller
9588c4633a core: detect route-metric when creating nm-generated-assumed connection
When generating a connection to assume it, also record the route-metric.
Do that by looking at the metric of the (best) default-route.

This is especially important since d51975ed92.
Now NM would also manage the default-route for assumed connections.
So the generated assumed connection would have a route metric based on
the device type, which might differ from the external configuration.
This caused NM to replace the externally configured default-route.

https://bugzilla.gnome.org/show_bug.cgi?id=750405
(cherry picked from commit bc75cd53a8)
2015-07-22 14:14:18 +02:00
Beniamino Galvani
5c11d26a2e nm-manager: add 'metered' property
This introduces a global metered property which makes easier for
clients to obtain the metered status of the current primary
connection.

(cherry picked from commit 04d5804dd5)
2015-07-22 13:52:46 +02:00
Beniamino Galvani
975afac6a4 ifcfg-rh: add support for CONNECTION_METERED
(cherry picked from commit 7e5e624daf)
2015-07-22 13:52:46 +02:00
Beniamino Galvani
1ab766b61b ifcfg-rh: change type of svTrueValue() return value and argument
Change type of return value and 'def' argument of svTrueValue() to
gint to make clear that it can be something different from TRUE and
FALSE.

(cherry picked from commit 862fd91df0)
2015-07-22 13:52:46 +02:00
Beniamino Galvani
afd1bf5642 core: update device 'metered' property on connection state change
The metered property of a NMDevice that reaches the activated state is
copied from the active connection and if its value is 'unknown' some
heuristics are used to guess the actual value.

When the connection is torn down the metered property is reset to
'unknown'.

(cherry picked from commit a86255a043)
2015-07-22 13:52:46 +02:00
Beniamino Galvani
c41fe4c659 dhcp: detect NMIP4Config 'metered' flag based on ANDROID_METERED DHCP option
Some versions of Android's DHCP server send option 43 (Vendor specific
information) with value "ANDROID_METERED" in Wi-Fi hotspot mode.

Mark the NMIP4Config as metered when such option is received.

(cherry picked from commit 1e39b2320d)
2015-07-22 13:52:46 +02:00