Commit graph

14908 commits

Author SHA1 Message Date
Thomas Haller
2deee52867 dns: log when dnsmasq process exits normally
(cherry picked from commit a64d70f0df)
2016-06-02 19:02:54 +02:00
Beniamino Galvani
84b0bb5ec8 core: introduce nm_utils_dnsmasq_status_to_string()
(cherry picked from commit c0d322720a)
2016-06-02 19:02:48 +02:00
Beniamino Galvani
70d194c159 core: fix some memory leaks
(cherry picked from commit ec53ed2cba)
2016-06-01 12:00:12 +02:00
Beniamino Galvani
30f53e7e22 dhcp: let users override FQDN dhclient options
When the ipv4.dhcp-fqdn property is set, NM adds the following options
to dhclient.conf:

  send fqdn.fqdn "foo.bar";
  send fqdn.encoded on;
  send fqdn.server-update on;

which enable the S (server-update) and E (encoded) flags in DHCP
option 81, since they are sensible default values and dhclient
requires a "send fqdn.server-update [on|off]" directive in order to
send the option.

Users may want to change these flags according to their server's
configuration, but this is not possible at the moment since NM options
are placed after user's ones, overriding them.

To fix this, collect user's fqdn options and add them after NM
configuration; note that the fqdn.fqdn option still can't be
overridden by users, as NM must control the FQDN sent to server.

Fixes: c3573ebf2b
(cherry picked from commit f940428c65)
2016-05-31 14:36:41 +02:00
Thomas Haller
951013d1e1 device: reconfigure IP addressing after bringing up device
For changing the hardware address, we must bring the device down. When doing
that, IP addressing is lost and it must be re-configured after bringing the
device up again.

We already do something similar in device_link_changed(), but that might
not be sufficient, because device_link_changed() is run on an idle
handler, thus, while changing the hardware address it has no chance to
run (or notice that the device was shortly down).

https://bugzilla.redhat.com/show_bug.cgi?id=1309899
(cherry picked from commit 63571b2666)
2016-05-30 18:14:06 +02:00
Nikolay Martynov
68122212e0 Remove dns VPN/DEVICE DNS config before adding different one
It turnes out that 'nm_dns_manager_add_ip{4,6}_config' can be called to add VPN/DEVICE
config for device that already has one. On this case old config gets overwritten in
'priv->ip{4,6}_{vpn,device}_config' but is not removed from 'priv->configs'.
The result of that is that old config still being applyed but is treated as 'other'
config.

Apart from being a slight memory leak this has user facing consequences: if old config
was a split DNS VPN config 'split DNS' part will no longer work and those DNS servers
will be used as 'global' DNS servers.

This patch addresses the problem by making sure old values in 'priv->ip{4,6}_{vpn,device}_config'
are removed from 'priv->configs' before new values are applyed.

Signed-off-by: Nikolay Martynov <mar.kolya@gmail.com>
2016-05-29 13:50:09 +02:00
Beniamino Galvani
a701e5b7ba dns: clear dnsmasq cache after an update
When the list of DNS servers changes, old DNS entries cached by
dnsmasq must be invalidated as the answers returned by new servers may
be different (especially, old NXDOMAIN entries may now be valid). Call
the dnsmasq "ClearCache" D-Bus method to achieve this.

https://bugzilla.redhat.com/show_bug.cgi?id=1338731
(cherry picked from commit 4feb58b50b)
2016-05-28 09:41:33 +02:00
Beniamino Galvani
7541ca0692 dns/dnsmasq: cancel pending update on dispose
There might be a pending "SetServersEx" D-Bus call when the plugin is
destroyed, ensure it gets canceled.

(cherry picked from commit d376787ce1)
2016-05-28 09:41:31 +02:00
Beniamino Galvani
dd3dfad583 dns/dnsmasq: use servers without split DNS if no domain was received
When a VPN server doesn't push any DNS domain, we want to use the
received servers for all queries.

https://bugzilla.gnome.org/show_bug.cgi?id=766769
2016-05-26 09:53:22 +02:00
Cosimo Cecchi
be96610020 nm-device-wifi: add TURBONETT to no-roaming WiFi networks
TURBONETT is the default network name of a very popular internet
provider in Guatemala, so roaming should be disabled.

https://bugzilla.gnome.org/show_bug.cgi?id=766845
(cherry picked from commit 3df3e46d64)
2016-05-25 22:54:16 +02:00
Thomas Haller
5e77626b0f platform: handle missing netlink attribute IFLA_ADDRESS by cache-lookup
Sometimes the netlink event lacks the IFLA_ADDRESS attribute with
the MAC address of the link. In this case, take the value from
the cached link instance. A missing netlink attribute should have the
meaning of reusing the previous value, not clearing the address.

(cherry picked from commit 791cbd0817)
2016-05-25 15:13:51 +02:00
Beniamino Galvani
c1353a16b0 core: merge branch 'bg/disconnect-on-suspend-rh1330694-v2'
Let devices go through the disconnected state before sleeping so that
applications are notified of the change in connectivity and dispatcher
scripts are run.

https://bugzilla.redhat.com/show_bug.cgi?id=1330694
https://bugzilla.gnome.org/show_bug.cgi?id=748531
(cherry picked from commit 3fdffab955)
2016-05-24 15:18:56 +02:00
Beniamino Galvani
c81887ae6c manager: disconnect devices before unmanaging them on suspend/sleep
So that dispatcher scripts are run and other applications notified of
the change in connectivity.

https://bugzilla.redhat.com/show_bug.cgi?id=1330694
https://bugzilla.gnome.org/show_bug.cgi?id=748531
(cherry picked from commit 81ea812362)
2016-05-24 15:18:32 +02:00
Beniamino Galvani
69c1395317 sleep-monitor: add functions for delaying the suspension
To allow the execution of asynchronous actions before the system is
suspended, add a mechanism for delaying the drop of inhibitor lock.
Clients can supend the suspension by calling inhibit_take() in their
handler for SLEEPING signal and use inhibit_release() later when they
are done.

We take a "delay" type inhibitor lock, which means that the system
will proceed anyway after a certain amount of time.

Co-Authored-By: Thomas Haller <thaller@redhat.com>
(cherry picked from commit 69ab984fed)
2016-05-24 15:18:29 +02:00
Beniamino Galvani
4efed78a6c device: add nm_device_set_unmanaged_by_flags_queue()
Useful for setting a device as unmanaged during another state change.

(cherry picked from commit 31c2e0b57c)
2016-05-24 15:18:27 +02:00
Beniamino Galvani
f5e0eae6af sleep-monitor: merge branch 'th/sleep-monitor-merge-bgo765682'
https://bugzilla.gnome.org/show_bug.cgi?id=765682
(cherry picked from commit e0cf9319b7)
2016-05-24 15:15:51 +02:00
Thomas Haller
df245d7977 sleep-monitor: make sleep-monitor not a singleton
The only user of the sleep-monitor singleton was NMManager anyway.
Also, even if we ever get more users that are interested in the SLEEPING
signal, we would hook them onto NMManager -- because NMManager should
collect, coordinate and possibly forward the SLEEPING signal. In no case,
another object should react on the SLEEPING signal and thus bypassing the
NMManager.

(cherry picked from commit 1e3b2cbb77)
2016-05-24 15:15:25 +02:00
Thomas Haller
ee561f8e89 sleep-monitor: merge RESUMING signal into NMSleepMonitor's SLEEPING signal
Having two signals is more complicated and everybody who cares about
one signal also cares about the other.

(cherry picked from commit 07db1217a9)
2016-05-24 15:15:25 +02:00
Thomas Haller
af36df2262 sleep-monitor: unify and cleanup logging
(cherry picked from commit 2208ca3726)
2016-05-24 15:15:25 +02:00
Thomas Haller
546b161367 sleep-monitor: create D-Bus proxy asynchronously for upower sleep-monitor
(cherry picked from commit a22851dc59)
2016-05-24 15:15:25 +02:00
Thomas Haller
90733d970d sleep-monitor: cleanup #if usage by using USE_UPOWER in "nm-sleep-monitor.c"
(cherry picked from commit 2b087b4782)
2016-05-24 15:15:25 +02:00
Thomas Haller
1242147efa sleep-monitor: use defines for D-Bus paths for upower's sleep-monitor
(cherry picked from commit 400e9fc9fb)
2016-05-24 15:15:25 +02:00
Thomas Haller
4e7d3b0546 sleep-monitor: use dispose() method for upower's sleep-monitor
(cherry picked from commit 6864a7036f)
2016-05-24 15:15:25 +02:00
Beniamino Galvani
6b1431b9ac sleep-monitor: merge "nm-sleep-monitor-upower.c" into "nm-sleep-monitor.c"
Both files do very similar things, with "nm-sleep-monitor-upower.c"
being suboptimal, for example by creating the proxy synchronously.

Clean that up in the next steps. Just basic merging for now.

(cherry picked from commit c76eb3e8f7)
2016-05-24 15:15:07 +02:00
Thomas Haller
025af2a55f sleep-monitor: rename file "nm-sleep-monitor-systemd.c" to "nm-sleep-monitor.c"
Next, we will merge "nm-sleep-monitor-upower.c" into "nm-sleep-monitor.c".

(cherry picked from commit b97ae18379)
2016-05-24 15:12:17 +02:00
Thomas Haller
aa67e0c005 sleep-monitor/trivial: rename "sd_proxy" instance to "proxy"
It's not only relevant for systemd (sd).

(cherry picked from commit 6e45909f79)
2016-05-24 15:12:14 +02:00
Thomas Haller
bd509b5ea2 po: remove file "src/nm-sleep-monitor-systemd.c" from POTFILES.in as it has no translations
Fixes: 753f727af5
(cherry picked from commit bf9a74c69f)
2016-05-24 15:12:12 +02:00
Thomas Haller
f8a7e32eba manager: use _LOGx() macros in nm-manager
They give each logging message a "manager: " prefix.

(cherry picked from commit e0c272c153)
2016-05-24 15:11:17 +02:00
Beniamino Galvani
ee72e66c13 sleep-monitor-systemd: merge branch 'th/sleep-monitor-sd-cleanup'
Some cleanup of "nm-sleep-monitor-systemd.c"
(cherry picked from commit 64e8f0076d)
2016-05-24 15:10:08 +02:00
Thomas Haller
5293991255 sleep-monitor: disconnect signal handlers from D-Bus proxy on destroy
The lifetime of the proxy is not necesarily the same as the lifetime
of the NMSleepMonitor instance. Disconnect the signals during dispose().

(cherry picked from commit a09a5f7fc1)
2016-05-24 15:09:03 +02:00
Thomas Haller
3f30283a76 sleep-monitor: don't localize messages in core daemon
The daemon does not run with a particular locale of a user. Localizing
makes no sense (at least, we don't do it usually and it would make
logging localized).

(cherry picked from commit 753f727af5)
2016-05-24 15:09:01 +02:00
Thomas Haller
331f571dff sleep-monitor: properly handle cancelling of "Inhibit" D-Bus call
As we don't take a reference on @self during the asynchronous
request, we must properly support cancelling in case of early
destruction.

I think, it's gdbus' responsibility not to leak any file descriptors
when cancelling a D-Bus request that returns file descriptors. Thus,
our usual pattern works here too.

(cherry picked from commit 2e3ff56cdc)
2016-05-24 15:08:59 +02:00
Thomas Haller
eaa068cfb3 sleep-monitor: handle early destruction of NMSleepMonitor instance
When destroing the sleep monitor before the D-Bus proxy is created,
we must cancel creation of the proxy.

(cherry picked from commit 3fa3dba1b1)
2016-05-24 15:08:57 +02:00
Thomas Haller
23bd466af6 sleep-monitor: drop unused class methods for signals
(cherry picked from commit 2919b9271d)
2016-05-24 15:08:56 +02:00
Thomas Haller
a61ff3de97 sleep-monitor: implement dispose() instead of finalize()
To release resources, dispose() is preferred over finalize()
because it is called earlier.

(cherry picked from commit a7308bbe9c)
2016-05-24 15:08:54 +02:00
Thomas Haller
f8fc8b3302 sleep-monitor: don't return value from drop_inhibitor()
(cherry picked from commit fc14d32e99)
2016-05-24 15:08:52 +02:00
Thomas Haller
1648fd3c14 sleep-monitor: use LOG macros in "nm-sleep-monitor-systemd.c"
(cherry picked from commit d0a6f6f34c)
2016-05-24 15:08:48 +02:00
Beniamino Galvani
d6861b5b04 core: merge branch 'th/settings-cleanup-bgo765000'
https://bugzilla.gnome.org/show_bug.cgi?id=765000
(cherry picked from commit de2fa9b647)
2016-05-24 15:05:02 +02:00
Thomas Haller
ed050337b3 active-connection: update D-Bus properties of active-connection when settings-connection changes
$ nmcli connection up my-connection
  Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/42)

  $ nmcli connection modify my-connection connection.id other-name

  $ nmcli -f connection.id connection show other-name
  connection.id: other-name

  $ nmcli -f GENERAL.CONNECTION device show enp0s25
  GENERAL.CONNECTION: my-connection

  $ nmcli connection down other-name
  Error: 'other-name' is not an active connection.
  Error: no active connection provided.

  $ nmcli connection down my-connection
  Connection 'my-connection' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/13)

When modifying a connection, NMActiveConnection must update the D-Bus
properties that belong to the settings-connection.

(cherry picked from commit 18019d55a1)
2016-05-24 15:03:26 +02:00
Thomas Haller
ab6d813e96 settings: merge "connection-updated" and "connection-updated-by-user" signals
This is mostly interesting of NMPolicy, which no longer needs to
subscribe to two almost identical signals (where the by-user signal
was always invoked together with the plain "updated" signal).

(cherry picked from commit 3164c026a2)
2016-05-24 15:03:24 +02:00
Thomas Haller
52644bfebd settings: combine "updated" and "updated-by-user" signal in NMSettingsConnection
Instead of connecting to two similar signals, combine them into one
and pass "by_user" argument.

We still need to keep the original NM_SETTINGS_CONNECTION_UPDATED signal,
because it is exposed on D-Bus.

(cherry picked from commit 65c55e2a78)
2016-05-24 15:03:22 +02:00
Thomas Haller
fba19c43ee settings: emit NM_SETTINGS_CONNECTION_UPDATED right away and not on an idle handler
I want to combine NM_SETTINGS_CONNECTION_UPDATED and NM_SETTINGS_CONNECTION_UPDATED_BY_USER
into one signal. Thus, they must have same behavior with respect as to whether they are
scheduled on idle.

Emit NM_SETTINGS_CONNECTION_UPDATED right away.

The "Updated" signal is exposed via D-Bus on the settings object.
Removing the idle handling has no bad consequences there.

Apart from that, the signal has only the listener NMSettings::connection_updated().
connection_updated() first emits NM_SETTINGS_SIGNAL_CONNECTION_UPDATED, which only
has listener: NMPolicy::connection_updated(), which already delegates to
an idle handler.

Second, NMSettings::connection_updated() emits
NM_CP_SIGNAL_CONNECTION_UPDATED which has the following listeners:

  - NMBluezDevice::cp_connection_updated(), which can cause the
    connection to be tracked/untracked. Any further changes are
    already delayed on an idle handler (check_emit_usable_schedule()).

  - NMDevice::cp_connection_added_or_updated(), which causes the
    connection to be tracked by the device. It also emits
    "notify::available-connections", which however is only relevant
    for the D-Bus bindings.
    At last, it does available_connections_check_delete_unrealized()
    which also is on an idle handler already.

(cherry picked from commit a4f1a1794f)
2016-05-24 15:03:20 +02:00
Thomas Haller
887fc983be device/bluez: delay check_emit_usable() for NM_CP_SIGNAL_CONNECTION_UPDATED
Currently, NM_CP_SIGNAL_CONNECTION_UPDATED signal will be invoked on an
idle handler. I want to change that, so to be save, delay actions that
matter on an idle handler.

(cherry picked from commit 640ef67cd7)
2016-05-24 15:03:18 +02:00
Thomas Haller
30590effc8 device/bluez: refactor registering to connections
No (intentional) change in behavior.

(cherry picked from commit 3325cd3d90)
2016-05-24 15:03:17 +02:00
Thomas Haller
946fb983f6 policy: handle schedule_activate_all() in an idle handler
schedule_activate_all() needs to iterate over all devices and is thus
relatively costly (and scales O(n^2)).

By scheduling the action on an idle handler we delay and combine
multiple redundant requests.

Another reason is that NM_SETTINGS_CONNECTION_UPDATED is currently
executed on an idle handler which first leads to
NM_SETTINGS_SIGNAL_CONNECTION_UPDATED signal and eventually calls
schedule_activate_all().
I want to change that to emit the connection update signal immediately,
thus to preserve the delay, we delay handling in NMPolicy.

(cherry picked from commit 920054d8aa)
2016-05-24 15:03:16 +02:00
Thomas Haller
8b357f43c6 settings: drop signal slots from NMSettings
NMSettings has no derived classes and obviously nobody is using
those slots. Just drop them.

(cherry picked from commit d571933505)
2016-05-24 15:03:13 +02:00
Thomas Haller
480e69cc82 settings: refactor connection_changed()
Again, no functional change.

(cherry picked from commit f7e7df772d)
2016-05-24 15:03:12 +02:00
Thomas Haller
6359213ea4 settings: refactor connection-changed handler
No change in behavior, just not pass on this GUINT_TO_POINTER (TRUE).

(cherry picked from commit 866df17e97)
2016-05-24 15:03:11 +02:00
Thomas Haller
c70d6bf498 settings: use NM_GOBJECT_PROPERTIES_DEFINE in NMSettings/NMSettingsConnection/NMActiveConnection
(cherry picked from commit 30b8842a48)
2016-05-24 15:03:09 +02:00
Thomas Haller
a6634183e1 device: drop available_connections_notify() and call _notify() directly
(cherry picked from commit 8c86648313)
2016-05-24 15:03:08 +02:00