Commit graph

7870 commits

Author SHA1 Message Date
Beniamino Galvani
95310a5dec core: use default value for ipvx.dns-priority
Fall back to system default value for ipvx.dns-priority when it's zero
in the setting. For VPNs the default value is 50; for other
connections is 100, but it depends also on the content of
[connection*] sections in NetworkManager.conf.

(cherry picked from commit 77ded12da4)
2016-06-10 11:14:37 +02:00
Beniamino Galvani
c47882625f core: add DNS priority to NMIP6Config
(cherry picked from commit bfabfb05ae)
2016-06-10 11:14:36 +02:00
Beniamino Galvani
83908c5cec core: add DNS priority to NMIP4Config
(cherry picked from commit f09f5e1ec8)
2016-06-10 11:14:36 +02:00
Beniamino Galvani
41e6540141 dns: pass config data array to plugins
Export NMDnsIPConfigData to DNS plugins and use it to pass additional
information about configurations.

(cherry picked from commit e53aa0dcff)
2016-06-10 11:11:53 +02:00
Beniamino Galvani
a3401f0bf4 dns: use a single array for all configurations
In a following commit configurations will be ordered by their
priority; arrange them in a single array to make this simpler. Also,
instead of using g_object_set_data() to store metadata, introduce a
NMDnsIPConfigData structure.

(cherry picked from commit 8e6d442477)
2016-06-10 11:11:53 +02:00
Beniamino Galvani
21b520b469 dns: don't use the global configuration to compute initial hash
If the initial hash includes the global configuration, every update
attempt will be skipped because the configuration never changes, and
resolv.conf will never be updated. Instead, use a NULL global
configuration to compute the hash and force an initial update.

(cherry picked from commit 16d5c8222b)
2016-06-10 11:11:53 +02:00
Thomas Haller
b952f54cb1 dns: add new rc-manager=unmanaged
The following settings are effectively identical:

    dns=none,rc-manager=*any*
    dns=none,rc-manager=unmanaged
    dns=default,rc-manager=unmanaged

The new setting is only there for completeness and only
makes sense for a dns plugin.

(cherry picked from commit 2789345d5b)
2016-06-10 11:11:53 +02:00
Thomas Haller
6ae3119f86 dns: merge the dns "mode" and "rc-manager"
Already previously, the mode and rc-manager were intertwined in a complicated
way:

  - dns=none effectively disables rc-manager.

  - if resolv.conf was immutable, it would disable the rc-manager
    by setting "resolv_conf_mode=NM_DNS_MANAGER_RESOLV_CONF_UNMANAGED".

  - resolv_conf_mode was anyway a redundant piece of information to
    rc_manager.

Now there are only two relevant settings: priv->plugin and
priv->rc_manager. And they can be set independently from each other.
Before that was not possible. For example, you could not set a
dns plugin with rc-manager=unmanaged (the only way to achive that
was via an immutable resolv.conf or by having rc-manager=symlink
and let resolv.conf link somewhere else.

(cherry picked from commit 161f86b5b3)
2016-06-10 11:11:53 +02:00
Thomas Haller
5504af286d dns: when clearing "plugin" always disconnect signal handlers
(cherry picked from commit 83fd710005)
2016-06-10 11:11:53 +02:00
Thomas Haller
b36408d882 dns: initialize rc-manager in init_resolv_conf_mode()
The "dns" and "rc-manager" properties are strongly related. Initialize them
together in init_resolv_conf_mode().

One difference is, that we now set rc_manager before setting the mode.
But that shouldn't matter.

(cherry picked from commit a252dfdb9d)
2016-06-10 11:11:53 +02:00
Thomas Haller
25edbf3fb6 dns: split parsing of rc-manager out of init_resolv_conf_manager()
Makes more sense in the next commit, when init_resolv_conf_manager()
gets merged with init_resolv_conf_mode(). Bear with me.

(cherry picked from commit aea2d98e2d)
2016-06-10 11:11:53 +02:00
Thomas Haller
8a68c92956 dns: rename "rc-manager=none" to "symlink"
We already have "rc-manager=file", rename "rc-manager=none" to "symlink"
because that better describes what it is actually doing. Of course, the
old name is still accepted.

(cherry picked from commit cd6a469668)
2016-06-10 11:11:53 +02:00
Thomas Haller
5a24c74ebe dns: add trace logging when writing resolv.conf
It is interesting to find in the logfile when we write to "/etc/resolv.conf"
or our internal version "/var/run/NetworkManager/resolv.conf".

(cherry picked from commit c486c38962)
2016-06-10 11:11:53 +02:00
Beniamino Galvani
44f0a50d1a dns-manager: properly handle multiple VPN configurations
Now that we support multiple VPNs active at the same time, the DNS
manager must be able to keep a list of all the VPN configurations and
give them a higher priority than other configurations.

Before this commit all the VPN configuration except one were
considered as normal configurations.

https://bugzilla.gnome.org/show_bug.cgi?id=764689
(cherry picked from commit f439f05237)
2016-06-10 11:11:53 +02:00
Beniamino Galvani
38200371a8 dns-manager: add 'priv' pointer to object structure
(cherry picked from commit 89306ebb2e)
2016-06-10 11:11:53 +02:00
Beniamino Galvani
223b65f072 dns: fix debug message
Fixes: 5f9d348c20
(cherry picked from commit 317f70997b)
2016-06-10 11:11:53 +02:00
Beniamino Galvani
a845ab0197 dns: update caching plugins on configuration change signal
A HUP or USR1 signal forces the rewrite of DNS configuration, however
caching plugins are ignored when using dns=dnsmasq and so the real
servers are written to resolv.conf:

 $ cat /etc/resolv.conf
 nameserver 127.0.0.1

 # killall -USR1 NetworkManager

 $ cat /etc/resolv.conf
 nameserver 192.168.1.1

Set @no_caching to FALSE when calling update_dns() after a signal to
take caching plugins into account.

(cherry picked from commit b88ce6d044)
2016-06-10 11:11:53 +02:00
Thomas Haller
62b3d27e1d Revert "Remove dns VPN/DEVICE DNS config before adding different one"
This reverts commit 68122212e0.
2016-06-10 02:29:51 +02:00
Thomas Haller
1f8ba33d87 dnsmasq: properly handling respawning of dnsmask
Otherwise, when killing dnsmasq it does not get respawned:

    dnsmasq[0x560dd7e43cf0]: dnsmasq exited normally
    dns-mgr: plugin dnsmasq child quit unexpectedly
    dns-mgr: update-dns: updating resolv.conf
    dns-mgr: config:      100 best    v4 enp0s25
    dns-mgr: config:      100 best    v6 enp0s25
    dns-mgr: config:      100 default v6 lo
    dns-mgr: config:      100 default v4 lo
    dns-mgr: update-dns: updating plugin dnsmasq
    dnsmasq[0x560dd7e43cf0]: adding nameserver '192.168.0.2@enp0s25'
    dnsmasq[0x560dd7e43cf0]: trying to update dnsmasq nameservers
    dns-mgr: update-resolv-conf: write internal file /var/run/NetworkManager/resolv.conf succeeded but don't update /etc/resolv.conf as it points to resolv.conf.nm
    dnsmasq[0x560dd7e43cf0]: dnsmasq disappeared

Previously, we would create priv->dnsmasq proxy only once,
and not respawn the process at all.

https://bugzilla.gnome.org/show_bug.cgi?id=766996
(cherry picked from commit 2e7f4aeb60)
2016-06-02 19:03:00 +02:00
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
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
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
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
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