Commit Graph

21088 Commits

Author SHA1 Message Date
Jiří Klimeš
f9648e39dd cli: enable TAB-completion for connection.lldp in interactive editor 2016-12-15 15:05:55 +01:00
Jiří Klimeš
8008770192 cli: enable TAB-completion for connection.metered in interactive editor 2016-12-15 15:05:55 +01:00
Jiří Klimeš
58a328aafc cli: add SLAVE field for 'nmcli con show' output
It helps listing or searching for slave connections. For example, one can do
$ nmcli -f name,uuid,type,slave connection show | awk '$NF == "bridge"'
to show all bridge slave connections.
2016-12-15 15:03:41 +01:00
Francesco Giudici
f124048b80 ifcfg-rh/tests: avoid using g_assert_null() API
Fixes: 2852b50945
2016-12-15 13:34:54 +01:00
Lubomir Rintel
80e4339031 merge: branch 'lr/ifcfg-device-rh1369008'
https://bugzilla.redhat.com/show_bug.cgi?id=1369008
2016-12-15 11:47:20 +01:00
Lubomir Rintel
8b7b0d3fc2 ifcfg-rh: write the master device name even if the master property is an UUID
We used MASTER, BRIDGE and TEAM_MASTER keys for a differnet purpose than the
network.service did, confusing the legacy tooling. Let's do our best to write
compatible configuration files:

* Add *_UUID properties that won't clash with initscripts
* Ignore non-*_UUID keys on read if *_UUID is present
* If the connection.master is an UUID of a connection with a
  connection.interface-name, write the uuid into the *_UUID key while setting
  the non-*_UUID key to the interface name for compatibility

https://bugzilla.redhat.com/show_bug.cgi?id=1369091
2016-12-15 11:45:34 +01:00
Lubomir Rintel
96988f8deb ifcfg-rh: add test case for remembering the unset values
Validates the previous commit.
2016-12-15 11:45:34 +01:00
Lubomir Rintel
d36c6d2892 ifcfg-rh: remember where the keys have been when we remove them
We may want to re-add them right away, let's remember the original
contents so that we can add it at the right place.
2016-12-15 11:45:34 +01:00
Francesco Giudici
2ee6b7bf82 ifcfg-rh: merge branch 'fg/dhcp_hostname_bgo775622'
https://bugzilla.gnome.org/show_bug.cgi?id=775622
2016-12-15 11:29:05 +01:00
Thomas Haller
c1c5149ced platform/trivial: rename macro offset_plus_sizeof() to offsetofend()
Linux kernel names this very macor offsetofend(), so name it the
same name to be more recognizable.
2016-12-14 23:16:06 +01:00
Thomas Haller
6070fe697a build: allow specifying the python interpreter for building
As build-requirement, we either require
  - python2 with python-gobject-base
  - python3 with python3-gobject-base
Previously, we would require that a plain `python` gives the desired
interpreter version.

If somebody's "/usr/bin/env python" however points to a different
python version, there was no easy way to change it -- aside
resetting the $PATH variable to some desired "python" binary.

Now, you can specify it during configure:

  ./configure PYTHON=python3 ...

This especially matters, if you only have python3-gobject-base
installed, you /usr/bin/python is a symlink to python2.

https://bugzilla.gnome.org/show_bug.cgi?id=775768
2016-12-14 19:00:42 +01:00
Thomas Haller
dfeebfb3e1 python: make test-secret-agent.py python3 ready
Co-authored-by: Lubomir Rintel <lkundrak@v3.sk>
2016-12-14 19:00:42 +01:00
Francesco Giudici
6bf69d0fa1 ifcfg-rh/tests: add ipv6 hostname legacy support read test 2016-12-14 16:21:26 +01:00
Francesco Giudici
2852b50945 ifcfg-rh: add DHCPV6_HOSTNAME and DHCPV6_SEND_HOSTNAME vars
Currently ipv4 and ipv6 settings share the ifcfg plugin vars for the
dhcp-hostname and dhcp-send-hostname options (DHCP_HOSTNAME and
DHCP_SEND_HOSTNAME). Add brand new vars DHCPV6_HOSTNAME and
DHCPV6_SEND_HOSTNAME to have var-property one to one mappings.
2016-12-14 16:21:26 +01:00
Francesco Giudici
08bd3feed0 ifcfg-rh: write [IPV6_]PEERDNS and [IPV6_]PEERROUTES only when they are "no"
When those values are missing they are already considered as TRUE.
As they are written also when DHCP is not enabled, write them only
if they have a value different from the default.
2016-12-14 16:14:24 +01:00
Francesco Giudici
dbb9cd3ca8 ifcfg-rh: save/restore dhcp related properties also when ip method != DHCP/AUTO
affected properties are: ipv4.dhcp-client-id, ipv4.fqdn,
ipv4.dhcp-timeout, ipvX.ignore-auto-routes, ipvX.ignore-auto-dns,
ipvX.dhcp-hostname and ipvX.dhcp-send-hostname.
2016-12-14 15:27:42 +01:00
Thomas Haller
de5ce89494 tests: improve run-nm-test.sh to weak valgrind usage
- also when called from makefile, allow enabling valgrind even if it was not
  enabled via configure option. That is, even if you configured --without-valgrind,
  you can run tests via `NMTST_USE_VALGRIND=1 make check`. Previously, there
  was no way to run on valgrind during `make check` unless you also had
  configured --with-valgrind.
- Use $NMTST_VALGRIND variable to override the valgrind path. This now
  always takes precedence. For `make check`, the path can be determined
  by the configure script.
  If all unspecified, as last fallback "valgrind" is searched in the current
  $PATH.
- Allow to specify the suppressions file via $NMTST_SUPPRESSIONS.
  If unset, fall back to the default. The default during `make check`
  is determined by the configure options. The default for manual
  invocation is our one valgrind.suppressions file.
  To use no suppressions file, set NMTST_SUPPRESSIONS to empty.

Now, regardless of what you enabled during ./configure, you can
overwrite it via:

  $ NMTST_USE_VALGRIND=1 \
    NMTST_VALGRIND=~/bin/valgrind \
    NMTST_SUPPRESSIONS=my-suppressions \
    make check
2016-12-14 14:11:42 +01:00
Thomas Haller
fee104621e libnm/dns: fix memleak in demarshal_dns_configuration
Fixes: a8d6005256
2016-12-14 13:19:37 +01:00
Thomas Haller
0fce208a8b contrib/rpm: add note to NetworkManager.conf about rate-limiting in logging 2016-12-14 12:51:06 +01:00
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