Commit Graph

17169 Commits

Author SHA1 Message Date
Beniamino Galvani
6f3569a58a cli: remove duplicate duplicate check on nmc->complete
Fixes: a3b61303f8
2016-12-14 10:12:18 +01:00
Beniamino Galvani
a7938a5b2c manager: merge branch 'bg/manager-state-bgo776001'
https://bugzilla.gnome.org/show_bug.cgi?id=776001
2016-12-14 10:09:33 +01:00
Beniamino Galvani
7375822c95 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
2016-12-14 10:07:04 +01:00
Beniamino Galvani
4cc45ee291 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().
2016-12-14 10:07:04 +01:00
Thomas Haller
eb77d4ed28 libnm-core/utils: remove unused code from nm_utils_hwaddr_matches()
Makes coverity complain.
2016-12-13 18:49:34 +01:00
Thomas Haller
f2355633a9 man: clarify NMSettingIPConfig:dns-options in documentation 2016-12-13 12:55:07 +01:00
Thomas Haller
0d7bf7dee3 core: merge branch 'th/sysctl-ifname-race-bgo775613'
https://bugzilla.gnome.org/show_bug.cgi?id=775613
2016-12-13 12:03:46 +01:00
Thomas Haller
396d90e744 platform: assume ifname is present in _linktype_get_type()
_linktype_get_type() only has one caller, and ifname is *never*
NULL.
2016-12-13 11:26:59 +01:00
Thomas Haller
d32fb8158b platform: avoid copying arguments for nmp_utils_ethtool_get_driver_info()
We call nmp_utils_ethtool_get_driver_info() twice when receiving a
netlink message, but we don't need a clone of the string values.
Instead, expose a data structure that should be stack allocated
by the caller.
2016-12-13 11:26:59 +01:00
Thomas Haller
16ad046c87 platform: remove unused nmp_utils_device_exists() util 2016-12-13 11:26:59 +01:00
Thomas Haller
3641178508 platform: lookup ifname for ethtool/mii ioctl immediately before use
The ioctl APIs ethtool/mii require an interface ifname. That is inherrently
racy as interfaces can be renamed. This cannot be fixed, we can only
minimize the time between verifying the ifname and calling ioctl.

We already had problems with that when ethtool would access an interface
by name that didn't exists. See commit ab41c13b06 .
Checking for an existing interface only helps avoiding races when an interface
gets deleted. It does not help against renaming.

Go one step further, and instead of checking whether such an ifname
exists, try to get the ifname based on the ifindex immediately before
we need it.

This brings an additional overhead for each ethtool access.
2016-12-13 11:26:59 +01:00
Thomas Haller
da7b8dd850 wifi: remove check for existing device in wifi_wext_is_wifi()
See also commit ab41c13b06.
2016-12-13 11:26:59 +01:00
Thomas Haller
4bdee37771 all: use O_CLOEXEC for file descriptors 2016-12-13 11:26:59 +01:00
Thomas Haller
e332c27824 platform/tests: add tests for nmp_utils_sysctl_open_netdir() 2016-12-13 11:26:59 +01:00
Thomas Haller
6b132a2bd0 platform/tests: use nmtstp_netns_select_random() util 2016-12-13 11:26:59 +01:00
Thomas Haller
5eb4dfe7ab platform/tests: add nmtstp_netns_select_random() util 2016-12-13 11:26:59 +01:00
Thomas Haller
22be2ae865 core: use nmp_utils_sysctl_open_netdir() for platform master/slave options 2016-12-13 11:26:59 +01:00
Thomas Haller
a9a41edcbd core: use nmp_utils_sysctl_open_netdir() in platform link operations 2016-12-13 11:26:59 +01:00
Thomas Haller
7fc3eace31 core: use nmp_utils_sysctl_open_netdir() to detect link-type 2016-12-13 11:26:59 +01:00
Thomas Haller
d3af925b91 core: use nmp_utils_sysctl_open_netdir() to read tun/tap sysctl 2016-12-13 11:26:59 +01:00
Thomas Haller
89a2169b98 core: use nmp_utils_sysctl_open_netdir() to set infiniband sysctl 2016-12-13 11:26:58 +01:00
Thomas Haller
e933a2ff87 core: use nmp_utils_sysctl_open_netdir() to read infiniband sysctl 2016-12-13 11:26:58 +01:00
Thomas Haller
c85418746c platform: implement sysctl access via relative path to sysctl_open_netdir() 2016-12-13 11:26:58 +01:00
Thomas Haller
d8cefd57fb platform: add optional dirfd argument to sysctl functions
Still unused.
2016-12-13 11:26:58 +01:00
Thomas Haller
1d9bdad1df core: add nm_utils_file_get_contents() and nm_utils_fd_get_contents()
A reimplementation of g_file_get_contents() to overcome two limitations:

 - nm_utils_file_get_contents() accepts a @dirfd argument to open the
   file relative using openat().
 - nm_utils_fd_get_contents() allows to read the content from a file
   filedescriptor.
 - both support a max_length argument, to fail gracefully if we
   get tricked into loading a huge file.
2016-12-13 11:26:58 +01:00
Thomas Haller
76876e896c 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.
2016-12-13 11:26:58 +01:00
Kai-Heng Feng
b95556eb78 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>
2016-12-13 11:26:58 +01:00
Kai-Heng Feng
713c74f6e4 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>
2016-12-13 11:26:58 +01:00
Thomas Haller
99e1e4d6a1 shared: add NM_AUTO_PROTECT_ERRNO
Similar to systemd's PROTECT_ERRNO. The difference it, that it doesn't
treat the auto-variable as internal, so it is allowed to use it. E.g.

    if (!(fd = open (...)) {
        NM_AUTO_PROTECT_ERRNO (errno_saved);
        printf ("error: %s", g_strerror (errno_saved));
        return FALSE;
    }
2016-12-13 11:26:58 +01:00
Thomas Haller
215c50922d logging: preserve errno in logging functions
It would be nice that our logging functions are guaranteed to
preserve errno. We are currently not very consistent about handling
errno, let's improve on that.
2016-12-13 11:26:58 +01:00
Thomas Haller
ccf766f659 platform: preserve errno in nm_auto_pop_netns 2016-12-13 11:26:58 +01:00
Thomas Haller
ed299cc860 device/wwan: use nm_auto_close instead of gs_fd_close 2016-12-13 11:26:58 +01:00
Thomas Haller
312cea870d 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*.
2016-12-13 11:26:58 +01:00
Thomas Haller
7744fdd00f platform: rename _assert_netns_current() to a ASSERT_NETNS_CURRENT()
This assert, although being a regular function has more the character
of a macro as it only contains asserts itself.
2016-12-13 11:26:58 +01:00
Beniamino Galvani
597f327b20 dns: merge branch 'bg/dns-dbus-bgo603321'
https://bugzilla.gnome.org/show_bug.cgi?id=603321
2016-12-12 22:27:39 +01:00
Thomas Haller
3206b72964 dns: split collecting resolv-conf data out of update_dns()
update_dns() is rather complicated. The part where we collect
resolv-conf data can be moved out. That is nice, because
_collect_resolv_conf_data() has no side-effects (except logging)
and it's only purpose is to return the out-arguments.
2016-12-12 22:06:24 +01:00
Thomas Haller
916a0e7cad dns: use cleanup attributes for update_dns()'s strv arrays 2016-12-12 22:06:24 +01:00
Beniamino Galvani
8af465d579 examples: add DNS example with python and GObject introspection 2016-12-12 22:06:24 +01:00
Beniamino Galvani
20bf5ce359 cli: add DNS information to overview output
Example:

   $ nmcli
   [...]
   DNS configuration:
   	servers: 10.0.0.1
   	domains: foobar.com
   	interface: tun0
   	type: vpn

   	servers: 192.168.10.1
   	domains: home
   	interface: ens3

   	servers: fd01🔡:21
   	interface: ens3
2016-12-12 22:06:24 +01:00
Beniamino Galvani
a8d6005256 libnm: implement support for DNS manager properties 2016-12-12 22:06:24 +01:00
Beniamino Galvani
e3c67177ac dns: export current configuration through D-Bus
It is useful to let clients retrieve the current DNS configuration,
which can be displayed to users or used (together with dns=none) to
implement custom DNS configuration logic through external tools.
2016-12-12 22:06:23 +01:00
Beniamino Galvani
14105ece56 dns: export DNS manager D-Bus object
Extend the D-Bus API and introduce a new NMDnsManager interface that
contains all the information related to DNS configuration.

At the moment the new DnsManager object only contains basic properties
describing the current DNS mode and resolv.conf manager.
2016-12-12 21:49:15 +01:00
Beniamino Galvani
5307e07e3b dns: don't print empty configurations
Previously we printed the DNS configuration for all devices including
unmanaged and unconfigured ones:

  dns-mgr: config:      100 best    v4 ens3             : 192.168.10.1
  dns-mgr: config:      100 default v6 ens3             : fd01🔡:3681:c4ff:fec0:fe94
  dns-mgr: config:      100 default v4 lo               :
  dns-mgr: config:      100 default v6 lo               :
  dns-mgr: config:      100 default v4 ens9             :
  dns-mgr: config:      100 default v6 ens9             :

Instead, print only devices that have name servers set.
2016-12-12 21:41:23 +01:00
Beniamino Galvani
8c4e824997 exported-object: don't assert the presence of PropertiesChanged signal
For new interfaces we don't define a PropertiesChanged signal as we
rely on GDBus to generate one on the standard
org.freedesktop.DBus.Properties interface.
2016-12-12 21:41:23 +01:00
Thomas Haller
a2402acfed build: fix dependency of NetworkManager.ver for libnm-ppp-plugin
Fixes: 025235e00f
2016-12-12 21:38:26 +01:00
Beniamino Galvani
a3b61303f8 cli: implement 'networking' subcommand using nmc_do_cmd()
It simplifies the code and doesn't require that NM is running to
display the help.
2016-12-09 17:57:49 +01:00
Francesco Giudici
c5fe886a36 trivial: fix indentation 2016-12-09 07:26:04 +01:00
Thomas Haller
994f1ca96e device: fix activation_source_schedule() for rescheduling the same function
Fixes: 78ca961c0f
2016-12-08 13:26:04 +01:00
Thomas Haller
92ea1bdb06 proxy: stricter validate the proxy pac script in NMSettingProxy 2016-12-06 22:01:41 +01:00
Beniamino Galvani
d7c4807737 ppp: merge branch 'bg/ppp-manager-split-bgo773482-squashed'
https://bugzilla.gnome.org/show_bug.cgi?id=773482
2016-12-06 14:51:14 +01:00