Commit graph

920 commits

Author SHA1 Message Date
Thomas Haller
f13b97a9e4 keyfile: reject team properties in parser
We don't properly coordinate reading the team properties from keyfile.
They must be ignored, at least for now.

(cherry picked from commit 1b8ae83967)
2017-12-08 11:32:41 +01:00
Francesco Giudici
78d10c9d18 libnm-core: add test cases for NMSettingTeamPort
(cherry picked from commit b5f0d61d03)
2017-12-08 04:00:09 +01:00
Francesco Giudici
7abcede5bb libnm-core: add test cases for NMSettingTeam
(cherry picked from commit 1248969342)
2017-12-08 04:00:09 +01:00
Lubomir Rintel
bb3fc9769b libnm-core: merge the settings tests into a single one
Thomas likes this more and who am I to argue.

(cherry picked from commit 9bb30f86ec)
2017-12-08 04:00:09 +01:00
Francesco Giudici
bc92380a76 libnm-core: team: skip writing in the keyfile all the exposed properties
Their values are already saved in the team.config and team-port.config
properties, from which they are synced.

(cherry picked from commit bb4c95e168)
2017-12-08 04:00:09 +01:00
Francesco Giudici
4525b7e208 libnm-core: team: change tx-hash APIs idx type from int to guint
(cherry picked from commit 4c7a841823)
2017-12-08 04:00:09 +01:00
Francesco Giudici
5d79b6cc42 libnm-core: team: rework defaults management on runner properties
till now when no explicit value was set on a property, the default value
for that property was returned, also if the property was not applicable
to the selected runner.
Fix this, showing default values for properties only when relevant and
showing instead -1 or null when the property is not relevant for the
selected runner.
Moreover, reset all the properties but the link-watchers when the team.runner
is changed: this is required to clean up the properties unrelated to the
new runner and start with the runner-specific defaults.

(cherry picked from commit a5642fd93a)
2017-12-08 04:00:08 +01:00
Francesco Giudici
07a49b30af libnm-core: team: use the correct name for teamd property 'balancing_interval'
the teamd 'runner.tx_balancer.balancing_interval' property was wrongly
set and searched as 'runner.tx_balancer.interval'. Fixed.

Fixes: fc3b7d61e2
(cherry picked from commit ed2a1a153b)
2017-12-08 04:00:08 +01:00
Francesco Giudici
dd18259c63 libnm-core: json: share code to load defaults in team(-port).config
Move code from _nm_utils_team_config_get to the brand new
_json_team_add_defaults function without any change.
Then remove the duplicated code from _nm_utils_team_config_equal and
leverage the new function. Here the only functional change is that
the defaults for "notify_peers" and "mcast_rejoin" for the
"activebackup" runner are added (the only case in which their default
values are different than 0).

(cherry picked from commit fdd41852ee)
2017-12-08 04:00:08 +01:00
Francesco Giudici
a2357fea43 libnm-core: trivial: just move static json functions
(cherry picked from commit f0ae71e7d6)
2017-12-08 04:00:08 +01:00
Francesco Giudici
ad1be3a472 libnm-core: trivial: move json key deletion code to a separate function
(cherry picked from commit 8648aa576e)
2017-12-08 04:00:08 +01:00
Francesco Giudici
e8eb416675 libnm-core: use proper writer for team-port link-watchers
(cherry picked from commit 16c9435c5b)
2017-12-08 04:00:08 +01:00
Francesco Giudici
704f0acb77 libnm-core: team-port: expose the new link-watchers property
It will allow explicit configuration of link-watchers in the team port
configuration.

(cherry picked from commit f094837d73)
2017-12-08 04:00:08 +01:00
Francesco Giudici
10745107f2 libnm-core: add keyfile writer for team link watcher
Allow tests to dump the content of the property when getting a failure.

(cherry picked from commit 0d8fcc39ab)
2017-12-08 04:00:08 +01:00
Francesco Giudici
62876cee9a libnm-core: synchronize team.link_watchers when team.config is set.
(cherry picked from commit 363a2cfe95)
2017-12-08 04:00:07 +01:00
Francesco Giudici
a1c25edfe8 libnm-core: synchronize team.config when team.link_watchers is set.
(cherry picked from commit e59878ce19)
2017-12-08 04:00:07 +01:00
Francesco Giudici
466f8e0dd5 libnm-core: team: expose the new link-watchers property
It will allow explicit configuration of link-watchers in the team
configuration.

(cherry picked from commit ca816ae10e)
2017-12-08 04:00:07 +01:00
Francesco Giudici
574d70b2eb libnm-core: add backend for GVariant de/serialization of link_watchers.
(cherry picked from commit ba4ce843fa)
2017-12-08 04:00:07 +01:00
Francesco Giudici
e9d5836937 libnm-core: team: add NMTeamLinkWatcher boxed type
Team allows to specify multiple link watchers for each link.
Define a link watcher object in order to allow to specify multiple ones
for each Team configuration.

(cherry picked from commit 72f6d08714)
2017-12-08 03:59:59 +01:00
Francesco Giudici
5cbe512fd3 libnm-core: preserve keys order in team.config with old jansson libs
When jansson lib version is < 2.8 the order of the keys of json objects
is not preserved automatically. In particular, when loading the json
string, parsing it and dumping it back to a string the key order will be
lost if the now deprecated JSON_PRESERVE_ORDER flag is not set.
Add the flag: will do nothing on recent jansson versions but will fix
behavior for legacy ones.

(cherry picked from commit 5e6f7de4be)
2017-12-08 02:16:52 +01:00
Francesco Giudici
921635d3ae libnm-core: enforce team and team-port defaults
Rework a bit the way default values are check, set and aligned.

(cherry picked from commit 3e34e404b4)
2017-12-08 02:10:27 +01:00
Francesco Giudici
8b171fd8ae libnm-core: enforce team-port config and properties alignment
Ensure .config is aligned when an explicit team-port is set and vice
versa

(cherry picked from commit ec60e01d39)
2017-12-08 02:10:26 +01:00
Francesco Giudici
7d9553da50 libnm-core: add explicit team properties to NMSettingTeamPort
(cherry picked from commit 1c99d379eb)
2017-12-08 02:10:22 +01:00
Francesco Giudici
4926ca42e7 libnm-core: enforce team config and properties alignment
Ensure .config is aligned when an explicit team property is set and vice versa.

(cherry picked from commit fc3b7d61e2)
2017-12-08 02:08:57 +01:00
Francesco Giudici
b42ad17e2d libnm-core: add explicit team properties to NMSettingTeam
(cherry picked from commit 9715969b77)
2017-12-08 02:08:49 +01:00
Francesco Giudici
6812997c38 libnm-core: add inline functions to update team json config
Add functions and structure to simplify json config and team property
enforcement. These will be used in both NMSettingTeam and
NMSettingTeamPort.

(cherry picked from commit b4c9bcd49f)
2017-12-08 01:59:46 +01:00
Francesco Giudici
4831edaa78 libnm-core: add functions to align team json config to exposed properties
(cherry picked from commit dadf710ee3)
2017-12-08 01:59:41 +01:00
Beniamino Galvani
b2a9e2f326 ifcfg-rh: use separate variables for DNS searches
DNS searches from the ipv4 and ipv6 settings were joined and written
to the same ifcfg-rh "DOMAIN" variable and so the connection read back
from disk was different from the one written.

Instead, introduce a separate variable for ipv6 searches; to preserve
backwards compatibility, still read the "DOMAIN" variable for ipv6
when ipv4 is disabled so that we don't lose DNS searches on upgrade.

https://bugzilla.redhat.com/show_bug.cgi?id=1517794
(cherry picked from commit a9b5079324)
2017-12-07 10:00:22 +01:00
Thomas Haller
a0a4722432 settings: support setting a connection as volatile via Update2()
Extend the Update2 flags to allow marking a connection as volatile.
Making a connection as volatile means that the connection stays alive
as long as an active connection references it.

It is correct that Update2() returns before the connection is actually
deleted. It might take an arbitrary long time until the volatile
mechanism cleans up the connection.

Also add two more IN_MEMORY flags: "detached" and "only".

The existing NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY would not detach nor
delete the possible file on disk. That is, the mode only changes what NM
thinks is the current content of the connection profile. It would not delete
the file on disk nor would it detach the profile in-memory from the file.
As such, later persisting the connection again to disk would overwrite
the file, and deleting the profile, would delete the file.

Now add two new IN_MEMORY modes.

NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY_DETACH is like making the connection
in-memory only, but forgetting that there might be any profile on disk.
That means, a later Delete() would not delete the file. Similarly, a
later Update2() that persists the connection again, would not overwrite
the existing file on disk, instead it would choose a new file name.

On the other hand, NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY_ONLY would delete
a potential file from disk right away.

It's clear that "volatile" only makes sense with either "in-memory-detached"
or "in-memory-only". That is, the file on disk should be deleted right away
(before the in-memory part is garbage collected) or the file on disk should
be forgotten.

(cherry picked from commit 35dc6421de)
2017-12-06 09:35:43 +01:00
Thomas Haller
448157ccd0 settings: add NM_SETTINGS_UPDATE2_FLAG_BLOCK_AUTOCONNECT flag
(cherry picked from commit 8bb95a8365)
2017-12-06 09:32:26 +01:00
Thomas Haller
4d7a0642f3 all: add new D-Bus API org.freedesktop.NetworkManager.Settings.Connection.Update2()
We already have Update(), UpdateUnsaved() and Save(), which serve
similar purposes. We will need a form of update with another argument.

Most notably, to block autoconnect while doing the update.

Other use cases could be to prevent reapplying connection.zone and
connection.metered, to to reapply all changes.

Instead of adding a specific update function that only serves that
new use-case, add a extensible Update2() function. It can be extended
to cope with future variants of update.

(cherry picked from commit 98ee18d888)
2017-12-06 09:32:26 +01:00
Thomas Haller
2129c1451c version: add NM_AVAILABLE_IN_1_10_2 define 2017-12-06 09:32:26 +01:00
Beniamino Galvani
020dcf5bc1 ifcfg-rh: persist the wep key type
The wireless-security setting has a 'wep-key-type' property that is
used to specify the WEP key type and is needed because some keys could
be interpreted both as a passphrase or a hex/ascii key.

The ifcfg-rh plugin currently stores the key type implicitly: if
wep-key-type is 'passphrase' it uses the KEY_PASSPHRASE%d variable, if
it's 'key' the KEY%d variable and when it's 'unknown' it uses either
variables depending on the detected type (preferring 'key' in case
both are compatible).

This means that some connections will be read differently from how
they were written, because once the KEY (or KEY_PASSPHRASE) is read
there is no way to know whether the 'wep-key-type' property was 'key'
(or 'passphrase') or 'unknown'.

Fix this by persisting the key type explicitly in the file. The new
variable is redundant in most cases because the variables used for
keys also determine the key type.

https://bugzilla.redhat.com/show_bug.cgi?id=1518177
(cherry picked from commit c6eb18ee05)
2017-12-04 16:01:54 +01:00
Beniamino Galvani
bd4754da05 ifcfg-rh: use different variables for IPv4 and IPv6 DNS options
Until now the ifcfg-rh plugin merged the values of 'ipv4.dns-options'
and 'ipv6.dns-options' and wrote the result to the RES_OPTIONS
variable. This is wrong because writing a connection and reading it
back gives a different connection compared to the original.

This behavior existed since when DNS options were introduced, but it
became more evident now that we reread the connection after write,
because after doing a:

 $ nmcli connection modify ethie ipv4.dns-options ndots:2

the connection has both ipv4.dns-options and ipv6.dns-options set. In
order to delete the option, an user has to delete it from both
settings:

 $ nmcli connection modify ethie ipv4.dns-options "" ipv6.dns-options ""

To improve this let's use different variables for IPv4 and IPv6. To
keep backwards compatibility IPv4 still uses RES_OPTIONS, while IPv6
uses a new IPV6_RES_OPTIONS variable.

https://bugzilla.redhat.com/show_bug.cgi?id=1517794
(cherry picked from commit 8379785560)
2017-12-01 00:02:32 +01:00
Beniamino Galvani
f3b08bf114 all: replace 'inital' with 'initial'
sed -i -e 's/inital/initial/g' $(git grep -l inital)

(cherry picked from commit d74e1bef36)
2017-12-01 00:02:29 +01:00
Thomas Haller
7a11dcfbd8 libnm: drop now unused helper function _nm_utils_strsplit_set()
(cherry picked from commit 15608713c4)
2017-11-29 19:15:30 +01:00
Thomas Haller
bf7661189e c-list: re-import latest version of c-list.h from upstream
Most notably, it renames
  c_list_unlink_init() -> c_list_unlink()
  c_list_unlink() -> c_list_unlink_stale()

  $ sed -e 's/\<c_list_unlink\>/c_list_unlink_old/g' \
        -e 's/\<c_list_unlink_init\>/c_list_unlink/g' \
        -e 's/\<c_list_unlink_old\>/c_list_unlink_stale/g' \
        $(git grep -l c_list_unlink -- ':(exclude)shared/nm-utils/c-list.h') \
        -i

(cherry picked from commit b6efac9ec2)
2017-11-28 12:04:15 +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
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
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
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
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
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
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
1356ba11e4 libnm: add internal helper function nm_utils_inet_ntop()
(cherry picked from commit ffcab3f653)
2017-11-13 14:40:31 +01:00
Thomas Haller
e2e4cdd2c1 doc: fix type on documentation for NMSettingOvsPort:bond-updelay
Fixes: 8a1ae40a80

https://bugzilla.gnome.org/show_bug.cgi?id=789880
(cherry picked from commit 5986d92053)
2017-11-06 12:27:21 +01:00
Thomas Haller
2730dc60de all: move setting 802-1x.auth-retries to connection.auth-retries
The number of authentication retires is useful also for passwords aside
802-1x settings. For example, src/devices/wifi/nm-device-wifi.c also has
a retry counter and uses a hard-coded value of 3.

Move the setting, so that it can be used in general. Although it is still
not implemented for other settings.

This is an API and ABI break.
2017-11-02 11:41:01 +01:00
Thomas Haller
89e518db5a libnm,cli,ifcfg-rh: add NMSetting8021x:auth-retries property 2017-10-31 19:35:33 +01:00