Commit graph

18895 commits

Author SHA1 Message Date
Thomas Haller
b0ef5dad2c libnm: cache lookup index for nm_setting_bond_get_option()
(cherry picked from commit 7ce8a1e677)
2017-11-21 14:15:27 +01:00
Thomas Haller
3366b8f6c6 libnm: stable order in _nm_utils_strdict_to_dbus()
(cherry picked from commit 3c8c63dcca)
2017-11-21 14:15:26 +01:00
Thomas Haller
628d292be7 ifcfg-rh: avoid duplicate lookup of bond-option in write_bond_setting()
Now that nm_setting_bond_get_option() has a stable order
(alphabetically), we no longer need to sort it.

(cherry picked from commit 6b319cd072)
2017-11-21 14:15:26 +01:00
Thomas Haller
bc34ed6382 libnm: sort entries in nm_setting_bond_get_option()
Since the order was arbitrary before, we can also sort it.

Also rework it, to avoid the creating a temporary GList of keys.

(cherry picked from commit d5b3c6ee53)
2017-11-21 14:15:26 +01:00
Thomas Haller
ceb9648fbe libnm/trivial: reorder code in libnm-core/nm-setting-bond.c
(cherry picked from commit 02d1ffa9ca)
2017-11-21 14:14:59 +01:00
Thomas Haller
7e1e1c1f7f shared: add NMUtilsNamedEntry
It is common to have some data indexed by a name.
If you want to sort a list of such data, you would
have to re-implement your own compare function each time.

Instead, add NMUtilsNamedEntry which as first field has
the name. So, you can create your own struct:

  struct my_data {
    const char *name;
    ... other fields
  }

and compare them with with nm_utils_named_entry_cmp().

For convenience, add another struct NMUtilsNamedValue, which
has only one data field, a pointer.

(cherry picked from commit 3adce12898)
2017-11-21 14:14:25 +01:00
Thomas Haller
fae12cf956 ifcfg-rh/tests: test writing multiple bond options
(cherry picked from commit 7328976a02)
2017-11-21 14:14:25 +01:00
Beniamino Galvani
0bd8b34725 settings: preserve agent-owned secrets on connection add
Settings plugins now return the connection that was reread from file
when adding a connection, which means that any agent-owned secret is
lost. Ensure that we don't forget agent-owned secrets by caching them
and readding them to the new connection returned by plugins.

Fixes: 8a1d483ca8
Fixes: b4594af55e

https://bugzilla.gnome.org/show_bug.cgi?id=789383
(cherry picked from commit 62141d59cb)
2017-11-21 13:37:53 +01:00
Beniamino Galvani
7225fdc5ae ifcfg-rh: sort bond options when writing a connection
Bond options are stored in a hash table and the order in which they
are returned by the API is not guaranteed. Sort them alphabetically so
that a connection will always be written in the same way, even if the
internal implementation of the hash table or the hashing function
changes, as it did in commit a6be2f4aa9 ("all: use nm_str_hash()
instead of g_str_hash()").

(cherry picked from commit 9a631a068e)
2017-11-21 11:29:32 +01:00
Beniamino Galvani
604c7de1c7 cli: fix connection type completion
Don't show completion for all setting types but only for base ones.

Before:
 $ nmcli connection add type <TAB>
 802-11-olpc-mesh          ethernet                  ppp
 802-11-wireless           generic                   pppoe
 802-11-wireless-security  gsm                       proxy
 802-1x                    infiniband                serial
 802-3-ethernet            ip-tunnel                 team
 adsl                      ipv4                      team-port
 bluetooth                 ipv6                      tun
 bond                      macsec                    user
 bridge                    macvlan                   vlan
 bridge-port               olpc-mesh                 vpn
 cdma                      ovs-bridge                vxlan
 connection                ovs-interface             wifi
 dcb                       ovs-patch                 wifi-sec
 dummy                     ovs-port                  wimax

After:
 $ nmcli connection add type <TAB>
 802-11-olpc-mesh  cdma              macsec            team
 802-11-wireless   dummy             macvlan           tun
 802-3-ethernet    ethernet          olpc-mesh         vlan
 adsl              generic           ovs-bridge        vpn
 bluetooth         gsm               ovs-interface     vxlan
 bond              infiniband        ovs-port          wifi
 bridge            ip-tunnel         pppoe             wimax
(cherry picked from commit 60f57ebe4a)
2017-11-20 22:19:51 +01:00
Thomas Haller
54dad379f3 keyfile: fix escaping ascii control characters in nm_keyfile_key_encode()
Matters when backslash escaping ascii charaters <= 0xF, to
produce "\\XX" instead of "\\ X". For example tabulator is "\\09".

This also can trigger an nm_assert() failure, when building with
--with-more-asserts=5 (or higher).

(cherry picked from commit 89c89143b5)
2017-11-20 15:41:23 +01:00
Beniamino Galvani
de66655f0a device: check captured IPv6 configuration in check_and_add_ipv6ll_addr()
check_and_add_ipv6ll_addr() checks whether a link-local address is
already present in priv->ip6_config and if so, it returns with no
action.

priv->ip6_config is only updated after a merge-and-apply or (in an
idle source) when the external configuration changes and so there is
no guarantee that the addresses there are up-to-date.

priv->ext_ip6_config_captured should be checked instead, because it is
updated from platform right before starting the generation of a
link-local address. Note that also linklocal6_start() already checks
the captured external configuration rather than priv->ip6_config.

https://bugzilla.redhat.com/show_bug.cgi?id=1500350
(cherry picked from commit a7c97d58db)
2017-11-20 10:53:41 +01:00
Thomas Haller
cd30bc1246 dns: don't stat relative paths when detecting resolved use
NetworkManager daemon has no defined working directory.
It makes no sense to ever open or stat relative paths.
Just skip them.

https://bugzilla.gnome.org/show_bug.cgi?id=790446
(cherry picked from commit 25267f9d27)
2017-11-19 14:33:27 +01:00
Dimitri John Ledkov
4d77df7751 dns: check for relative paths and stub-resolve.conf when detecting systemd-resolved
Fix resolved detection, the symlink target is usually relative to the
root, such that in chroots the file points to a file inside the
chroot. But keep absolute targets too, as these may have been in use
with older version of systemd. Add support for stub-resolv.conf
detection.

https://bugzilla.gnome.org/show_bug.cgi?id=790446
(cherry picked from commit e09503dcc4)
2017-11-19 14:33:26 +01:00
Beniamino Galvani
a2e0c92901 device: don't touch external devices
If a device is 'external' (which means that NM generated an in-memory
connection to only to track the device state) we should not change its
IP configuration.

https://bugzilla.redhat.com/show_bug.cgi?id=1512316
(cherry picked from commit 60334a2893)
2017-11-17 18:22:37 +01:00
Beniamino Galvani
c516dca0d5 device: start managing external devices on reapply
In the next commit we will modify ipX_config_merge_and_apply to never
touch external devices. When a "reapply" call is issued on an external
device we are no longer simply tracking its state but we are actively
managing it and so its sys-iface-state must be promoted to managed.

https://bugzilla.redhat.com/show_bug.cgi?id=1512316
(cherry picked from commit 9e41ed4461)
2017-11-17 18:22:35 +01:00
Thomas Haller
3a8a9941df core/vpn: log capabilities of secret-agent
(cherry picked from commit 96d5d66460)
2017-11-17 17:14:51 +01:00
Beniamino Galvani
ba630b828b core: don't reset existing routes when merging IP setting
Don't reset existing routes if ipvx.ignore-auto-routes=yes: callers
should already avoid adding them when not needed.

Previously we would also reset the manual gateway route just added.

Fixes: 5c299454b4

https://bugzilla.gnome.org/show_bug.cgi?id=790423
(cherry picked from commit a0cd75b20c)
2017-11-17 13:44:47 +01:00
Beniamino Galvani
c7accc92d5 vpn: avoid adding unneeded routes when ipvx.ignore-auto-routes=yes
Instead of adding routes and then let nm_ipx_config_merge_setting()
remove them, don't add them in the first place when
ipvx.ignore-auto-routes=yes.

(cherry picked from commit 8f677a7772)
2017-11-17 13:44:46 +01:00
Thomas Haller
1770e9339b platform: merge branch 'th/platform-test-netns-bgo790214'
https://bugzilla.gnome.org/show_bug.cgi?id=790214

(cherry picked from commit 7d26f540ee)
2017-11-17 12:38:45 +01:00
Thomas Haller
c449d9fe07 platform/tests: skip netns tests if we fail to create a new NMPNetns instance
nmp_netns_new () might fail with:
  netns: failed mount --make-rslave: Invalid argument

Skip the test in that case.

https://bugzilla.gnome.org/show_bug.cgi?id=790214
(cherry picked from commit b20384fac7)
2017-11-17 12:38:26 +01:00
Thomas Haller
f4cd75d422 platform: preserve errno when creating netns fails
(cherry picked from commit 7a98ee78be)
2017-11-17 12:38:25 +01:00
Thomas Haller
9464fa0963 vpn: avoid coverity warning in print_vpn_config()
coverity thinks that @address4 might be NULL. Maybe it can. We
have an nm_assert(), but to be sure, check the value.

(cherry picked from commit 6df212ccb1)
2017-11-15 18:32:02 +01:00
Thomas Haller
2dcf08402c ifcfg-rh: avoid coverity false positive in write_secrets()
Comparing @secrets_keys indicates to coverity that it might be NULL.
Below, we access @secrets_keys without check, and coverity doesn't realize
that this cannot crash, because secrets_keys_n would be zero too.

Anyway, this way we safe the sorting, in case we only have
one element.

(cherry picked from commit cfdb962ebd)
2017-11-15 18:19:54 +01:00
Thomas Haller
ee77657727 clients: avoid crash in _complete_fcn_connection_master()
Found by coverity, but not a practical issue, because we
wouldn't actually call the function with text NULL.

(cherry picked from commit 8cb86d947c)
2017-11-15 18:13:34 +01:00
Thomas Haller
18e8f99eb3 valgrind: update glib2 suppression for Fedora 27
glib2 deprecated g_object_newv() for g_object_new_with_paramters()
in 2.52. Need to update the valgrind suppression.

(cherry picked from commit 3b85c7e05d)
2017-11-15 17:06:18 +01:00
Thomas Haller
39002a4e3c platform: fix double closing netlink socket
The file descriptor is owned by the netlink socket instance,
which we close in finalize. We most not close it when destroying
the IO channel, otherwise the file descriptor gets closed twice.

Closing an invalid file descriptor (or a descriptor that is already closed)
is a serious bug, because the integer values are re-used, so there is a race
that the close might affect an innocent file descriptor instead of just
failing with EBADF.

(cherry picked from commit 79482c9a9e)
2017-11-14 15:17:03 +01:00
Thomas Haller
fc2894508e all: use nm_close() instead of close()
(cherry picked from commit 5b29c2e5b9)
2017-11-14 15:17:02 +01:00
Thomas Haller
334846906e shared: always call close() from nm_close() wrapper
The nm_close() wrapper should behave exactly the same as calling
close() directly. This is well known, documented behavior.

The only addition on top of that, should be the nm_assert() to catch
double-closing.

Prevously, when passing a negative file descriptor, we wouldn't properly
set errno. Also, the call would not show up in strace, which it should
(at least, if libc's close actually makes the syscall).

I would argue, that passing a negative file descriptor is a bug already
and we should never do that. Maybe we should even assert non-negative
fds. I don't do that now, because I am not sufficiently confident.
Anyway, the change should have not practical effect, because we
shouldn't actually pass negative fds already.

(cherry picked from commit f4780f85ae)
2017-11-14 15:17:01 +01:00
Beniamino Galvani
8db2120979 core: allow slaves to autoactivate when master is available
When a master connection is deactivated by user, we set the
autoconnect-blocked reason 'user-request' for the connection and we
propagate the same reason to slaves. Doing so prevents the
autoactivation of slaves when the master is manually activated again,
because the only way to override the 'user-request' blocked reason is
through manual activation of slaves.

Instead what should happen is that the manual deactivation of a master
marks slaves as blocked for failed dependencies. When the master
becomes available again, slaves can autoactivate if the profile allows
it.

https://bugzilla.redhat.com/show_bug.cgi?id=1437598
(cherry picked from commit b31118cfd2)
2017-11-13 20:34:23 +01:00
Beniamino Galvani
200e714885 device: make nm_device_state_reason_to_str() public
(cherry picked from commit dcd7760eae)
2017-11-13 20:34:22 +01:00
Yuri Chornoivan
a859021815 po: update Ukrainian (uk) translation (bgo#790215)
https://bugzilla.gnome.org/show_bug.cgi?id=790215
(cherry picked from commit 1e02ee4dc0)
2017-11-13 14:43:59 +01:00
Thomas Haller
c2c1031a20 all: merge branch 'th/platform-routes-onlink-rh1428334'
https://bugzilla.redhat.com/show_bug.cgi?id=1428334

(cherry picked from commit d44a3eb80c)
2017-11-13 14:43:25 +01:00
Thomas Haller
648c580902 platform/tests: add test for onlink route attribute
(cherry picked from commit cb47ed0fcd)
2017-11-13 14:43:08 +01:00
Thomas Haller
4b890dead5 all: support route-attribute "onlink" for IPv4
Kernel doesn't support it for IPv6.

This is especially useful, if you combine static routes
with DHCP. In that case, you might want to get the device-route
to the gateway automatically, but add a static-route for it.

(cherry picked from commit 0ed49717ab)
2017-11-13 14:43:07 +01:00
Thomas Haller
b4c2219951 platform: consider RTNH_F_ONLINK onlink flag for IPv4 routes
The "onlink" flag for IPv4 routes is part of the route ID.
Consider it in nm_platform_ip4_route_cmp().

Also, allow configuring the flag when adding a route.

Note that for IPv6, the onlink flag is still ignored.
Pretty much like kernel does.

(cherry picked from commit 88a40f960c)
2017-11-13 14:43:07 +01:00
Thomas Haller
675bae5642 platform: track all rtm_flags for routes
(cherry picked from commit 81778f59f2)
2017-11-13 14:43:07 +01:00
Thomas Haller
f0bcf533f5 core: merge IPv4 and IPv6 version of _nm_ip_config_merge_route_attributes()
(cherry picked from commit 433d2f8659)
2017-11-13 14:43:07 +01:00
Thomas Haller
02b339f170 shared: add nm_ip_addr_set() helper
(cherry picked from commit a9d1f5e543)
2017-11-13 14:43:07 +01:00
Thomas Haller
cfe4d61a12 shared/trivial: move code
(cherry picked from commit 632e8ac885)
2017-11-13 14:43:07 +01:00
Thomas Haller
b3d3227c44 platform: add generic NM_PLATFORM_IP_ROUTE_CAST() macro
A cast macro, that does some static type checking (of the pointer).

(cherry picked from commit 8948dbe117)
2017-11-13 14:43:07 +01:00
Thomas Haller
6adeb5eb29 core: use NM_CONSTCAST() for NM_IP_CONFIG_CAST()
(cherry picked from commit d5c9c95e96)
2017-11-13 14:43:07 +01:00
Thomas Haller
d9c5f7c9fb build: detect compiler features _Generic() and __auto_type in configure script
There is still a fallback detection in "shared/nm-utils/nm-macros-internal.h",
so that VPN-plugins and applet don't need to bother about adding these
configure checks.

(cherry picked from commit 557d83bf2d)
2017-11-13 14:43:07 +01:00
Thomas Haller
5282469098 shared: propagate constness in _NM_GET_PRIVATE_PTR()
The _NM_GET_PRIVATE() macro already preserved and propagated
the constness of @self to the resulting private pointer.

_NM_GET_PRIVATE_PTR() didn't do that. Extend the macro,
to make that possible.

(cherry picked from commit bdfdabea51)
2017-11-13 14:43:07 +01:00
Thomas Haller
5d940b73fe shared: fix detection of _Generic() support
(cherry picked from commit 03efc9e2c9)
2017-11-13 14:43:07 +01:00
Thomas Haller
920f539d4c core: merge branch 'th/dns-ip-config-unify'
(cherry picked from commit a5b4850682)
2017-11-13 14:41:27 +01:00
Thomas Haller
384d557887 core: merge IPv4 and IPv6 implementations in NMDnsManager
(cherry picked from commit 54bcbb85d3)
2017-11-13 14:40:31 +01:00
Thomas Haller
5a9812f453 core: add NMIPConfig helpers
For now, hack some generic accessors to the NMIP4Config/NMIP6Config
type. Eventually, NMIP4Config and NMIP6Config should get merged in
one class.

(cherry picked from commit 9e25538ff5)
2017-11-13 14:40:31 +01:00
Thomas Haller
1356ba11e4 libnm: add internal helper function nm_utils_inet_ntop()
(cherry picked from commit ffcab3f653)
2017-11-13 14:40:31 +01:00
Francesco Giudici
dcdb1e5fd0 shared: trivial: add space before comment close
(cherry picked from commit 85cc5db7a4)
2017-11-13 14:37:37 +01:00