Commit graph

18925 commits

Author SHA1 Message Date
Thomas Haller
2af8036b58 core/trivial: unify names of internal NMSettingsConnectionCallId as "call_id"
(cherry picked from commit 4e11be5ecf)
2017-11-27 15:59:58 +01:00
Thomas Haller
adca290d31 core: drop internal typedef GetSecretsInfo for NMSettingsConnectionCallId
Using an internal alias for the type is just confusing. Drop it.

(cherry picked from commit fc918049de)
2017-11-27 15:59:58 +01:00
Thomas Haller
2addde633c core: refactor NMSettingsConnectionCallId typedef not to be a pointer to struct
Typedefs to structs are fine, but a typedef for a pointer seems confusing to
me. Let's avoid it.

(cherry picked from commit 616976d6a8)
2017-11-27 15:59:58 +01:00
Thomas Haller
06ac0b6d96 core/vpn: mark secret hints as const
(cherry picked from commit f76dbfc1a6)
2017-11-27 15:59:39 +01:00
Thomas Haller
f000c76be4 core: replace "dup()" by "fcntl(fd, F_DUPFD_CLOEXEC, 0)"
(cherry picked from commit 1e572ebf87)
2017-11-27 14:03:51 +01:00
Beniamino Galvani
a792a7f9c3 ifcfg-rh: close file descriptor only when necessary
If the file was read-only, we already closed it.

This fixes the following valgrind warnings:

 Warning: invalid file descriptor -1 in syscall close()

(cherry picked from commit 174da8f922)
2017-11-27 10:19:29 +01:00
Francesco Giudici
9c634e13c3 device: update device mtu from ip interface when required
If the tracked device is a control device only (has no network interface)
like in the case of a cdc-wdm device, get the mtu from the ip interface
(the exposed wwan network interface in this case).

https://bugzilla.redhat.com/show_bug.cgi?id=1460217
(cherry picked from commit efed5254cd)
2017-11-24 17:38:14 +01:00
Thomas Haller
af4fbf97f5 device: merge branch 'th/shared-mode-failure-bgo790726'
https://bugzilla.gnome.org/show_bug.cgi?id=790726

(cherry picked from commit 3d0c5b3bb8)
2017-11-24 17:14:05 +01:00
Thomas Haller
a6b388d7d5 device: only set ip_forward sysctl if necessary
/proc/sys might be read-only but we want to set it for
enabling shared mode.

Check first if the sysctl already has the expected value,
and if so, do nothing.

https://bugzilla.gnome.org/show_bug.cgi?id=790726
(cherry picked from commit d841930d67)
2017-11-24 17:13:45 +01:00
Thomas Haller
26ca80ebf5 device: return and log failure reason for start_sharing()
Also downgrade a few intermediate error logging messages
for failures that happen while start_sharing(). A debug
message is enough in this case, because we propagate now
the error to the caller, which logs a warning anyway.

(cherry picked from commit 3369a2c0b0)
2017-11-24 17:13:45 +01:00
Thomas Haller
1725c7136f platform: preserve errno in nm_platform_sysctl_get_int_checked()
It's not clear whether free() changes errno. Be sure about it.

https://bugzilla.gnome.org/show_bug.cgi?id=790726
(cherry picked from commit 653aab70ac)
2017-11-24 17:13:45 +01:00
Thomas Haller
b61ed232f0 core: merge branch 'th/call-id-cleanup'
(cherry picked from commit 8060c2a930)
2017-11-24 17:05:25 +01:00
Thomas Haller
d586bc0304 core: use CList to track NMActRequestGetSecretsCallId in NMActRequest
Gives O(1) insert and remove. Also saves the overhead of the GSlice
allocation for the GSList node.

(cherry picked from commit a3569eddf2)
2017-11-24 17:05:03 +01:00
Thomas Haller
2776fe6cb4 core/trivial: unify names of internal NMActRequestGetSecretsCallId as "call_id"
(cherry picked from commit 1cbbefcddd)
2017-11-24 17:05:03 +01:00
Thomas Haller
4a7fa0c4c4 core: drop internal typedef Result for NMSecretAgentCallId
Using an internal alias for the type is just confusing. Drop it.

(cherry picked from commit 966ac03668)
2017-11-24 17:05:03 +01:00
Thomas Haller
b652f492a1 core: drop internal typedef GetSecretsInfo for NMSecretAgentCallId
Using an internal alias for the type is just confusing. Drop it.

(cherry picked from commit 370dc8883f)
2017-11-24 17:05:03 +01:00
Thomas Haller
26905105bf core: refactor NMActRequestGetSecretsCallId typedef not to be a pointer to struct
Typedefs to structs are fine, but a typedef for a pointer seems confusing to
me. Let's avoid it.

(cherry picked from commit e5e291b65f)
2017-11-24 17:05:03 +01:00
Thomas Haller
f842831059 core: refactor NMSecretAgentCallId typedef not to be a pointer to struct
Typedefs to structs are fine, but a typedef for a pointer seems confusing to
me. Let's avoid it.

(cherry picked from commit 6cb40da2f0)
2017-11-24 17:05:03 +01:00
Thomas Haller
3b1be2b4cd libnm: be more accepting parsing boolean values in nm_utils_parse_variant_attributes()
We should use the same str2bool parser everywhere: _nm_utils_ascii_str_to_bool().
Incidentally, this function allows more forms of expressing a boolean
value.

  $ nmcli connection modify "$CON" ipv4.routes '1.2.3.4/32 1.2.3.1 onlink=1'
  Error: failed to modify ipv4.routes: invalid option 'onlink=1': invalid boolean value '1' for attribute 'onlink'.

(cherry picked from commit 26e7abc65e)
2017-11-24 13:30:53 +01:00
Beniamino Galvani
00bc168307 ifcfg-rh: merge branch 'bg/ifcfg-rh-bridge-mac-rh1516659'
https://bugzilla.redhat.com/show_bug.cgi?id=1516659
(cherry picked from commit bcf374e75f)
2017-11-24 08:29:43 +01:00
Thomas Haller
539a2835b2 ifcfg-rh: check integer value for other bridge options
(cherry picked from commit b074fd23b4)
2017-11-24 08:29:27 +01:00
Thomas Haller
c42913f5b1 ifcfg-rh: check integer value when reading handle_bridge_option()
We cannot just call g_object_set() with an integer that is out of bound.
Otherwise, glib will warn. We can use nm_g_object_set_property*() to return
an error without asserting.

(cherry picked from commit ff239c1652)
2017-11-24 08:29:24 +01:00
Thomas Haller
1ec51d02bd shared: add nm_g_object_set_property_*() helper
(cherry picked from commit 5befde7d7d)
2017-11-24 08:29:23 +01:00
Thomas Haller
ab04849978 libnm: move bridge min/max defines to header file
(cherry picked from commit 901520af85)
2017-11-24 08:29:22 +01:00
Thomas Haller
3d6d54676d ifcfg-rh: fix range and size when parsing integer values in reader
(cherry picked from commit 30ce598fb5)
2017-11-24 08:29:21 +01:00
Thomas Haller
0219368a77 ifcfg-rh/trivial: rename get_uint() to get_uint32()
(cherry picked from commit 12788db4ee)
2017-11-24 08:29:19 +01:00
Thomas Haller
f147f490dd ifcfg-rh: avoid string copies in make_bridge_setting()
Also, don't g_strstrip(value) for BRIDGE_MACADDR.

(cherry picked from commit 3a67b496ca)
2017-11-24 08:29:18 +01:00
Beniamino Galvani
1d5f060098 ifcfg-rh: use distinct variables for bridge and wired mac address
Currently both bridge.mac-address and ethernet.cloned-mac-address get
written to the same MACADDR ifcfg-rh variable; the ethernet property
wins if both are present.

When one property is set and the connection is saved (and thus reread)
both properties are populated with the same value. This is wrong
because, even if the properties have the same meaning, the setting
plugin should not read something different from what was written. Also
consider that after the following steps:

 $ nmcli con mod c ethernet.cloned-mac-address 00:11:22:33:44:55
 $ nmcli con mod c ethernet.cloned-mac-address ""

the connection will still have the new mac address set in the
bridge.mac-address property, which is certainly unexpected.

In general, mapping multiple properties to the same variable is
harmful and must be avoided. Therefore, let's use a different variable
for bridge.mac-address. This changes behavior, but not so much:

 - connections that have MACADDR set will behave as before; the only
   difference will be that the MAC will be present in the wired
   setting instead of the bridge one;

 - initscripts compatibility is not relevant because MACADDR for
   bridges was a NM extension;

 - if someone creates a new connection and sets bridge.mac-address NM
   will set the BRIDGE_MACADDR property instead of MACADDR. But this
   shouldn't be a big concern as bridge.mac-address is documented as
   deprecated and should not be used for new connections.

https://bugzilla.redhat.com/show_bug.cgi?id=1516659
(cherry picked from commit fb191fc282)
2017-11-24 08:28:47 +01:00
Beniamino Galvani
3a623c2d1f ifcfg-rh: read wired properties for bridge connections
A bridge connection can have ethernet settings, read them from the
ifcfg file.

(cherry picked from commit 56a02c9baf)
2017-11-24 08:28:43 +01:00
Thomas Haller
d5dc3df20c libnm: merge branch 'th/bond-stable-strdict-order'
(cherry picked from commit 6fe2bf9cc7)
2017-11-21 14:16:43 +01:00
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