Commit graph

15774 commits

Author SHA1 Message Date
Beniamino Galvani
fc56eff0ae settings: fix assertion when changing connection managed state
When a ifcfg-rh connection becomes unamanaged it is removed from the
connection list in NMSettings and marked as removed; it is however
kept alive in the plugin and can become managed again later. To avoid
failed assertions, the @removed flag of the NMSettingsConnection must
be cleared if the connection is not being disposed.

(cherry picked from commit a9384452ed)
2017-01-10 14:28:14 +01:00
Thomas Haller
2a960d3936 keyfile: fix interpreting missing wifi.mac-address-randomization as permanent address
With commit 4f6c91d696, we aimed to
enable mac-address-randomization by default for Wi-Fi. That however
is not possible by default because it breaks various scenarios.
Also, later wifi.mac-address-randomization was deprecated in favor
of wifi.cloned-mac-address setting.

Both wifi.mac-address-randomization and wifi.cloned-mac-address support
global default values, so it is wrong to read a missing
mac-address-randomization as "NEVER" -- which due to
normalization also results in cloned-mac-address=permanent.

(cherry picked from commit 46d53e1101)
2017-01-09 17:32:27 +01:00
Beniamino Galvani
48db5806f3 vpn: add device route to VPN gateway if parent has no gateway
We set a dedicated route to reach the VPN gateway only if the parent
device has a gateway. If the parent device doesn't have a gateway (for
example in case of GSM connections) and the VPN gets the default
route, the VPN gateway will be contacted through the VPN itself, which
obviously doesn't work.

Set up a device route if the parent device doesn't provide a gateway.

https://bugzilla.redhat.com/show_bug.cgi?id=1403660
(cherry picked from commit ae5adc9e21)
2017-01-07 15:07:29 +01:00
Thomas Haller
8a281bf7b4 keyfile: fix memleak in keyfile reader's read_array_of_uint()
Fixes: 9559a7a260
(cherry picked from commit 8239edbb9b)
2017-01-05 12:33:21 +01:00
Lubomir Rintel
479a64a5b7 device: avoid a crash when L3 configuration fails
Don't call the IP check until at either IPv4 or IPv6 is actually
configured.

(cherry picked from commit aa71dbc6c4)
2017-01-05 09:39:41 +01:00
Thomas Haller
c5650d3500 libnm/docs: merge fix for generating API documentation fro enums (bgo#776848)
https://bugzilla.gnome.org/show_bug.cgi?id=776848

(cherry picked from commit 44ab504cf7)
2017-01-04 09:43:22 +01:00
Thomas Haller
4369f102f6 libnm: explicitly set enum values in public nm-dbus-interface.h headers
Previously, due to a bug in "tools/enums-to-docbook.pl", enum values
without explicit numeric value were wrongly parsed. That is fixed,
but still explicitly set the value in the public header.

(cherry picked from commit 9d2207b46d)
2017-01-04 09:42:59 +01:00
Thomas Haller
26f0d68e82 docs: fix handling enums without explicit numeric value in "tools/enums-to-docbook.pl"
Previously, an enum that didn't explicitly specify a numeric value
would wrongly start counting at 1.

E.g.

  typedef enum {
     MY_VAL,
  } Name;

would result in documentation with MY_VAL=1.

https://bugzilla.gnome.org/show_bug.cgi?id=776848
(cherry picked from commit 36ec46e8f8)
2017-01-04 09:42:58 +01:00
Dan Williams
28cd59a016 wifi: don't request new PSK for locally-generated WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY errors
This usually indicates that the driver missed beacons from the AP, due to driver bugs
or faulty power-save management.  It doesn't mean that the PSK is wrong.

(cherry picked from commit 0c5aa6e48b)
2016-12-20 10:07:12 -06:00
Lubomir Rintel
64a8a61822 release: bump version to 1.4.5 (development) 2016-12-16 13:31:38 +01:00
Lubomir Rintel
3c70a03cf5 release: bump version to 1.4.4 2016-12-16 11:38:36 +01:00
Thomas Haller
969bb5eead NEWS: clearify news entry and mention th/preserve-fake-perm-hwaddr-bgo772880 2016-12-16 10:09:31 +01:00
Lubomir Rintel
084a7c3a86 release: update NEWS 2016-12-15 20:47:15 +01:00
Thomas Haller
ea944d5b4c core: merge branch 'th/sysctl-ifname-race-bgo775613' (early part)
Backport some of the patches from "th/sysctl-ifname-race-bgo775613"
branch.

https://bugzilla.gnome.org/show_bug.cgi?id=775613
2016-12-15 19:38:19 +01:00
Thomas Haller
f0d20c945e all: use O_CLOEXEC for file descriptors
(cherry picked from commit 4bdee37771)
2016-12-15 17:52:33 +01:00
Thomas Haller
fea11a91a3 platform: refactor nmp_utils_sysctl_open_netdir()
- use nm_auto_close cleanup attribute
- optionally, return the found ifname
- don't stat "phy80211". If such an entity can be opened,
  just assume it's a directory.

(cherry picked from commit 76876e896c)
2016-12-15 17:52:33 +01:00
Kai-Heng Feng
e196ff7553 platform: wifi: use nmp_utils_open_sysctl() to check if device is wifi
Since function nmp_utils_open_sysctl() can avoid race condition, use it
in wifi_utils_is_wifi() to open sysfs and correctly check if it's a wifi
device.

https://bugzilla.gnome.org/show_bug.cgi?id=775613
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
(cherry picked from commit b95556eb78)
2016-12-15 17:52:33 +01:00
Kai-Heng Feng
8705a16d48 platform: add a new function nmp_utils_open_sysctl()
A race condition may happen when NetworkManager opens sysfs and udev
renames interface name at the same time. Thomas Haller provides a new
function [1] which can avoid the race condition when opening sysfs.

This patch is a direct copy from [1].

[1] https://mail.gnome.org/archives/networkmanager-list/2016-December/msg00004.html

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
(cherry picked from commit 713c74f6e4)
2016-12-15 17:52:32 +01:00
Thomas Haller
f16a9a2299 device/wwan: use nm_auto_close instead of gs_fd_close
(cherry picked from commit ed299cc860)
2016-12-15 17:52:32 +01:00
Thomas Haller
f39138ea48 shared: add nm_auto_close and nm_auto_fclose
We already have gs_fd_close, which however doesn't preserve
errno and only checks for fd != -1. Add our own define.

Downside is, we have to include stdio.h and errno.h,
which effectively ends up to be included *everywhere*.

(cherry picked from commit 312cea870d)
2016-12-15 17:51:04 +01:00
Beniamino Galvani
9afbaa86ce manager: merge branch 'bg/manager-state-bgo776001'
https://bugzilla.gnome.org/show_bug.cgi?id=776001

(cherry picked from commit a7938a5b2c)
2016-12-14 10:22:23 +01:00
Beniamino Galvani
c7167c9088 manager: don't upgrade the state when connectivity check fails
If a connection is ACTIVATED and another one is ACTIVATING but there
is no global connectivity, we currently set the manager state to
CONNECTING and start a connectivity check to verify whether the
manager state can be promoted to CONNECTED_GLOBAL.

If this connectivity check fails, we shouldn't promote a CONNECTING
state to CONNECTED_SITE.

Fixes: 084da69a30
(cherry picked from commit 7375822c95)
2016-12-14 10:21:53 +01:00
Beniamino Galvani
151dbe10b1 manager: don't update the manager state in get_property()
The manager state is already computed every time an active connection
changes state, it is not necessary to call nm_manager_update_state()
also when the property is read.

Moreover, nm_manager_update_state() emits a "notify::state" signal
which causes a re-read of the property by the nm-exported-object,
resulting in a nested execution of nm_manager_update_state().

(cherry picked from commit 4cc45ee291)
2016-12-14 10:21:50 +01:00
Beniamino Galvani
a9135e983d core: merge branch 'bg/ip-order-rh1394500'
https://bugzilla.redhat.com/show_bug.cgi?id=1394500
(cherry picked from commit 207a747064)
2016-12-09 23:31:02 +01:00
Beniamino Galvani
2ea42eee5a ip6-config: sort addresses only when reading the property value
Don't change the address order from configuration, but instead sort
addresses just before returning them to clients.

(cherry picked from commit 0a0bca9c7f)
2016-12-09 14:30:57 +01:00
Beniamino Galvani
450572cff4 ip6-config: add nm_ip6_config_set_privacy()
(cherry picked from commit 803a79f778)
2016-12-09 14:30:46 +01:00
Beniamino Galvani
6633eaf75c ip6-config: cache addresses variants
(cherry picked from commit ed4d5889c7)
2016-12-09 14:18:58 +01:00
Beniamino Galvani
6fdea664a4 ip4-config: sort addresses only when reading the property value
Don't change the address order from configuration, but instead sort
addresses just before returning them to clients.

(cherry picked from commit 9609d4da1d)
2016-12-09 14:18:56 +01:00
Beniamino Galvani
996f325f67 ip4-config: cache addresses variants
(cherry picked from commit 5ce81e23b7)
2016-12-09 14:18:54 +01:00
Beniamino Galvani
56cebecd41 ip4-config: don't change order of addresses in the same subnet
When multiple address are assigned to an interface and the kernel must
decide which one should be used to communicate with a given IP, it
chooses the most specific one in the same subnet as the
destination. In case there are multiple addresses in the same subnet,
the primary address is choosen, which is basically the first one that
was added.

With commit 7197425137 ("device: expose NMIP4Config:addresses in
stable/defined sort order") we sorted all the addresses before
committing the configuration, with the side effect that the order no
longer respected the one in the user configuration.

Instead, change the sort function to keep the subnet order unchanged.

(cherry picked from commit e02752c2ed)
2016-12-09 14:18:53 +01:00
Thomas Haller
8bcf1a6e3d ip-config: cleanup integer types for nm_ip4_config_get_num_*()
(cherry picked from commit 510626bf74)
2016-12-09 14:18:47 +01:00
Thomas Haller
baac746abb device: fix activation_source_schedule() for rescheduling the same function
Fixes: 78ca961c0f
(cherry picked from commit 994f1ca96e)
2016-12-08 13:56:21 +01:00
Lubomir Rintel
9cef2f5e83 libnm: order the property updates
Don't let a later property update finish than the sooner one.

This wouldn't happen most of time, apart from a special case when the
latter update of a object array property is to an empty list.
In that case the latter update would complete sooner and when the
earlier update finishes the list would contain objects which are
supposed to be gone already.

(cherry picked from commit 7007c9853c)
2016-12-02 17:31:09 +01:00
Thomas Haller
5f2b0abdd2 platform: increase initial buffer size of libnl's nl_recvmsg() to 32K
Since commit 9fafb382db, we would
explicitly set libnl's socket buffer size to 4*getpagesize().
That is also the default of libnl itself. Additionally, we would
workaround too small buffers by increasing the buffer size up to 512K.

A too small buffer causes messages to be lost. Usually, that only
results in a cache-resync, which isn't too bad. Lost messages are however
a problem if the lost message was an ACK that we were waiting for.
However, it is rather unlikely to happen, because it's expected that
the buffer size gets adjusted already when the cache is filled initially,
before any other requests are pending.

Still, let's increase the default buffer size to 32K, hoping that this
initial value is already large enough to avoid the problem altogether.

Note that iproute2 also uses a buffer size of 32K [1] [2].

Alternatively, we could use MSG_PEEK like systemd does [3]. However,
that requires two syscalls per message.

[1] https://patchwork.ozlabs.org/patch/592178/
[2] https://git.kernel.org/cgit/linux/kernel/git/shemminger/iproute2.git/tree/lib/libnetlink.c?id=f5f760b81250630da23a4021c30e802695be79d2#n274
[3] cd66af2274/src/libsystemd/sd-netlink/netlink-socket.c (L323)

(cherry picked from commit ed82b6bcb3)
2016-12-02 15:32:45 +01:00
Thomas Haller
74ff792956 device: allow device reapply of a connection with differing connection.autoconnect
Autoconnect property doesn't really matter for the applied
connection. Whitelist it from the properties and allow changing
it during reapply.

(cherry picked from commit d29839c430)
2016-12-02 11:43:28 +01:00
Thomas Haller
5dbd54552d platform: workaround NLE_MSG_TRUNC failure of nl_recv() with too small buffer size
We don't want to enable MSG_PEEK due to the overhead. But when we detect
that we just lost a message due to MSG_TRUNC, increase the buffer size and
retry.

See-also: 55ea6e6b6c
(cherry picked from commit 9fafb382db)
2016-11-30 17:23:00 +01:00
Piotr Drąg
c7a873e1a9 po: update Polish (pl) translation (bgo #775181)
https://bugzilla.gnome.org/show_bug.cgi?id=775181
(cherry picked from commit b08dd30b09)
2016-11-28 18:53:38 +01:00
Jiří Klimeš
eb9b2de778 agent: don't clear "error", g_simple_async_result_take_error() overtakes it
From valgrind:
==21921== Invalid free() / delete / delete[] / realloc()
==21921==    at 0x4C2CD5A: free (vg_replace_malloc.c:530)
==21921==    by 0x81C4F2D: g_free (gmem.c:189)
==21921==    by 0x81AB021: g_error_free (gerror.c:491)
==21921==    by 0x81AB325: g_clear_error (gerror.c:674)
==21921==    by 0x767B555: reg_request_cb (nm-secret-agent-old.c:616)
==21921==    by 0x7A211F2: g_task_return_now (gtask.c:1107)
==21921==    by 0x7A21228: complete_in_idle_cb (gtask.c:1121)
==21921==    by 0x81BF6B9: g_main_dispatch (gmain.c:3154)
==21921==    by 0x81BF6B9: g_main_context_dispatch (gmain.c:3769)
==21921==    by 0x81BFA6F: g_main_context_iterate.isra.29 (gmain.c:3840)
==21921==    by 0x81BFB1B: g_main_context_iteration (gmain.c:3901)
==21921==    by 0x7A4748C: g_application_run (gapplication.c:2381)
==21921==    by 0x118AEF: main (main.c:81)

It caused memory corruption and may result in strange nm-applet crashes.

(cherry picked from commit 544f7d3683)
2016-11-25 14:34:21 +01:00
Lubomir Rintel
8f8b43880f libnm/vpn-service-plugin: transition to STOPPED state from INIT too
We may want to stop the plugin before we started connecting e.g. when the
plugin NeedsSecrets but we can't supply them.

(cherry picked from commit 743d372d72)
2016-11-24 14:18:47 +01:00
Lubomir Rintel
8ab9634fdb vpn-manager: ignore ip configs from disconnected plugins
Plugins could be already failed or disconnected when the helper fires.
E.g. they could send in an invalid IP4Config that would cause them to
fail and then follow with an IP6Config before they realize it's of no
use. We'd hit an assertion failure in that case, because the
NMVpnConnection would already be cleaned up.

(cherry picked from commit bf70ed2e86)
2016-11-24 14:18:47 +01:00
Lubomir Rintel
fa68e17abe libnm/tests: increase timeout in nm-client test
Otherwise the test may fail in valgrind.

(cherry picked from commit dfa90861e8)
2016-11-24 14:18:47 +01:00
Lubomir Rintel
2fab21ad49 valgrind: adjust one gdbus suppression
In Fedora 25 the actual frame was called "fun:g_main_context_iterate.isra.24".

(cherry picked from commit afd48fbdbe)
2016-11-24 14:18:47 +01:00
Lubomir Rintel
3dbf86f197 man: use <filename> to mark file names
This gives the templates a chance to do something extra clever with the
formatting. The templates, of course, choose not to :(

(cherry picked from commit 7b589e2b72)
2016-11-24 14:18:47 +01:00
Lubomir Rintel
af1e6decde man: link to some online resources
(cherry picked from commit 42e1e669bc)
2016-11-24 14:18:47 +01:00
Lubomir Rintel
af6d220921 man: get rid of the extra capitalization in docbook source
The temaplates capitalize the names if they wish.

(cherry picked from commit 063d714a3c)
2016-11-24 14:18:47 +01:00
Lubomir Rintel
f7a0b36f03 client: don't do g_criticals
Also, be a bit more careful about the layers of errors. Just don't do this:

   (process:236): nmcli-CRITICAL **: Error: Could not create NMClient object:
     Permissions request failed: Authorization check failed:
     The name org.freedesktop.PolicyKit1 was not provided by any .service files.

(cherry picked from commit 7279ea1317)
2016-11-24 14:18:47 +01:00
Lubomir Rintel
676d16293f wifi: notify the AccessPoint change after an AP is removed
Otherwise its path remains visible on D-Bus despite the object is gone,
making libnm sad and grumpy:

  libnm-WARNING **: no object known for /org/freedesktop/NetworkManager/AccessPoint/666

(cherry picked from commit d0c01cc79d)
2016-11-24 14:12:40 +01:00
Beniamino Galvani
ad4d3ba008 manager: fix state transition on resuming from sleep
When going to sleep, we unmanage devices setting the unmanaged flags
immediately but delaying the state transition (because we do it from
another state transition). The signal handler can be executed after
the wake and, especially, after we have already re-managed the device,
making the device unmanaged again.

Detect such situation and force the state to UNMANAGED (which will
also clear any pending state change), so that later we manage the
device again and it will try to activate any available connection.

Fixes: 81ea812362
(cherry picked from commit 3cc06c3db679c1ff2f61a301396393300d36adbb)
2016-11-24 14:12:33 +01:00
Beniamino Galvani
561a0a428d manager: force connectivity check when there is a default active connection
The interaction between the manager state and connectivity check code
is tricky. When there is an active connection with a default route and
NMConnectivity reports full connectivity, we set the CONNECTED_GLOBAL
state. However, if the connectivity check hasn't run yet, we stay in
CONNECTED_SITE state. If there are also other connections that are
activating, the state is set to CONNECTING.

This is a problem, because in CONNECTING we never run the connectivity
check and thus we fail to recognize that there is full connectivity
until a periodic check is run.

To solve this, schedule the connectivity check every time there is an
active connection with default route, even if other connection are
still activating, so that the check result can make the state progress
to CONNECTED_GLOBAL.

(cherry picked from commit 084da69a30)
2016-11-07 14:25:46 +01:00
Thomas Haller
221851436b device: merge branch 'th/preserve-fake-perm-hwaddr-bgo772880'
https://bugzilla.gnome.org/show_bug.cgi?id=772880
https://bugzilla.redhat.com/show_bug.cgi?id=1388286

(cherry picked from commit e2b7da7b82)
2016-11-03 12:33:11 +01:00