Commit Graph

333 Commits

Author SHA1 Message Date
Thomas Haller
0700815d63 cli: implement NM_SETTING_VPN_SECRETS with the optionlist setter 2019-03-25 09:12:32 +01:00
Thomas Haller
e58ec47d1b cli: implement NM_SETTING_VPN_DATA with the optionlist setter 2019-03-25 09:12:32 +01:00
Thomas Haller
bcee2d7cc9 cli: add optionlist setter for bond options 2019-03-25 09:12:32 +01:00
Thomas Haller
1b0ee63a18 cli: remove DEFINE_REMOVER_OPTION() macro
Instead of having a trivial macro that defines a function, define the
function directly.

Having such a macro would make sense if DEFINE_REMOVER_OPTION() would do
the right thing and we would reuse the (preferred) implementation.
That's not the case, because these remove_fcn() implementations don't
mirror the way how set_fcn() splits and sets options. They are
inconsistent (wrong), and should will later get merged with set_fcn().
2019-03-25 09:12:32 +01:00
Thomas Haller
8e7b23e11a cli: merge IPv4 and IPv6 implementation for NMSettingIPConfig (pt8) 2019-03-25 09:12:32 +01:00
Thomas Haller
0f3252e0da cli: merge IPv4 and IPv6 implementation for NMSettingIPConfig (pt7) 2019-03-25 09:12:32 +01:00
Thomas Haller
cecf110f63 cli: merge IPv4 and IPv6 implementation for NMSettingIPConfig (pt6) 2019-03-25 09:12:32 +01:00
Thomas Haller
9c83bf5593 cli: merge IPv4 and IPv6 implementation for NMSettingIPConfig (pt5) 2019-03-25 09:12:32 +01:00
Thomas Haller
46eb783fcd cli: merge IPv4 and IPv6 implementation for NMSettingIPConfig (pt4) 2019-03-25 09:12:32 +01:00
Thomas Haller
574f1cf1a4 cli: merge IPv4 and IPv6 implementation for NMSettingIPConfig (pt3) 2019-03-25 09:12:32 +01:00
Thomas Haller
9876c334f4 cli: merge IPv4 and IPv6 implementation for NMSettingIPConfig (pt2) 2019-03-25 09:12:32 +01:00
Thomas Haller
4f0a629c1e cli: merge IPv4 and IPv6 implementation for NMSettingIPConfig (pt1) 2019-03-25 09:12:32 +01:00
Thomas Haller
05080816f0 cli/dcb: merge DCB uint setters 2019-03-25 09:12:32 +01:00
Thomas Haller
1fa1b01546 cli/dcb: rework DCB uint getters 2019-03-25 09:12:32 +01:00
Thomas Haller
ca38ce95ee cli/dcb: merge handling NM_SETTING_DCB_PRIORITY_FLOW_CONTROL and NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH 2019-03-25 09:12:32 +01:00
Thomas Haller
fa4ed3ac0d cli/dcb: merge getter for dcb flags 2019-03-25 09:12:32 +01:00
Thomas Haller
d1016cfade cli/trivial: drop unused macro 2019-03-25 09:12:32 +01:00
Thomas Haller
da4648d48f cli: implement DEFINE_SETTER_STR_LIST() as _pt_multilist type 2019-03-25 09:12:32 +01:00
Thomas Haller
74f922b64f cli: implement str-list-multi properties as property type and not via macros
Instead of using a macro to define the individual set/remove functions,
add a new property type _pt_multilist.

This way, we have more the concept of a property having a type, instead
of a property having a set of handlers how to implement something.

Also, this is only the first step. There are several similar properties
that also can be implemented as the same type.
2019-03-25 09:12:32 +01:00
Thomas Haller
03502cf5bf cli/trivial: add code comment about nmc_value_transforms_register() 2019-03-25 09:12:32 +01:00
Thomas Haller
3c82db710f cli: reset default value of properties via set_fcn()
The property implementation must itself decide how to reset a value.
We must not rely on properties being plain GObject properties.

Let set_fcn() accept %NULL value to indicate resetting the default.
2019-03-25 09:12:32 +01:00
Thomas Haller
20afdeb19a cli: let DEFINE_REMOVER_INDEX_OR_VALUE_DIRECT handle static value list
Previously we had DEFINE_REMOVER_INDEX_OR_VALUE_DIRECT() and
DEFINE_REMOVER_INDEX_OR_VALUE_VALIDATING_STATIC().

Note that all property-infos of DEFINE_REMOVER_INDEX_OR_VALUE_VALIDATING_STATIC()
would also define values_static list, while DEFINE_REMOVER_INDEX_OR_VALUE_DIRECT()
would not.

Merge the two macros. The property-info should define how the
implementation behaves, we should not have two implementations.
2019-03-25 09:12:32 +01:00
Thomas Haller
f933fb3cfb cli: validate remove_fcn() for NM_SETTING_802_1X_EAP against allowed values
set_fcn() of NM_SETTING_802_1X_EAP is implemented via
DEFINE_SETTER_STR_LIST_MULTI() -- thus, considering valid values
from the static list.

The remove_fcn() should do that too, to be consistent.
2019-03-25 09:12:32 +01:00
Thomas Haller
18c22443f3 cli: reuse property info in DEFINE_REMOVER_INDEX_OR_VALUE_VALIDATING_STATIC()
The property-info already tracks the "values_static" list. No need to pass
it on redundantly.
2019-03-25 09:12:32 +01:00
Thomas Haller
10aa2fafab cli: directly define setter function via DEFINE_SETTER_STR_LIST_MULTI()
We don't need DEFINE_SETTER_STR_LIST_MULTI() to define a static function
that is called by the set_fcn() implementation. Instead, let the macro
define the actual set_fcn() function.
2019-03-25 09:12:32 +01:00
Thomas Haller
70c99d176b cli: merge property implementations for vlan.ingress-priority-map and egress-priority-map 2019-03-25 09:12:32 +01:00
Thomas Haller
67b64ce868 cli: minor cleanup parsing dcb priorities 2019-03-25 09:12:32 +01:00
Thomas Haller
d8043664eb cli: use cleanup attributes in "nm-meta-setting-desc.c" 2019-03-25 09:12:32 +01:00
Thomas Haller
2b20b13e27 cli: don't use bogus error domains for GError 2019-03-25 09:12:32 +01:00
Thomas Haller
2bc29453bd cli: avoid unnecessary string clones for stripping whitespace for property values 2019-03-25 09:12:32 +01:00
Thomas Haller
cb5a81399a cli: don't interpret value as index too early for nmc_setting_remove_property_option()
Not all implementations support having the value being an index.
For example, the implementations that are done via DEFINE_REMOVER_OPTION() macro.

The meaning of the "value" string must not be determined by
nmc_setting_remove_property_option(). It's up to the implementation
to decide whether to allow an index and how to interpret it.
2019-03-25 09:12:32 +01:00
Thomas Haller
d3cfe20598 cli: support removing multiple vlan ingress/egress priority mappings
$ nmcli connection add type vlan autoconnect no con-name v dev vlan.1 id 1
    $ nmcli connection modify v +vlan.ingress-priority-map 1:2,2:3
    $ nmcli connection modify v +vlan.ingress-priority-map 2:3,4:5
    $ nmcli connection modify v -vlan.ingress-priority-map 1:2,4:5
    Warning: only one mapping at a time is supported; taking the first one (1:2)
2019-03-25 09:12:32 +01:00
Thomas Haller
626aed64e7 cli: don't fail removing non-existing option (pt6)
Part 6, which addresses the issue for VLAN priority maps.
2019-03-25 09:12:32 +01:00
Thomas Haller
eff01cd256 cli: don't fail removing non-existing option (pt5)
Part 5, which addresses the issue for DEFINE_REMOVER_OPTION(),
which are simple properties.
2019-03-25 09:12:32 +01:00
Thomas Haller
6baaa20763 cli: don't fail removing non-existing option (pt4)
Part 4, which addresses the issue for properties that have
complex values.
2019-03-25 09:12:32 +01:00
Thomas Haller
936912cad0 cli: don't fail removing non-existing option (pt3)
Part 3, which addresses the issue for properties that have
a simple validation function.
2019-03-25 09:12:32 +01:00
Thomas Haller
83fb6bcb42 cli: don't fail removing non-existing option (pt2)
Part 2, which addresses the issue for properties with a static
list of valid values.
2019-03-25 09:12:32 +01:00
Thomas Haller
0055d8ed58 cli: don't fail removing non-existing option (pt1)
Part 1, which addresses the issue for simple properties that have
a plain remove-by-value function.

Rationale:

Removing a value/index that does not exist should not be a failure.

Woule you like:

    $ nmcli connection modify "$PROFILE" autoconnect no
    $ nmcli connection modify "$PROFILE" autoconnect no
    Error: autoconnect is already disabled

So, why would it be a good idea to fail during

    $ nmcli connection modify "$PROFILE" -vpn.data ca
    $ nmcli connection modify "$PROFILE" -vpn.data ca
    Error: failed to remove a value from vpn.data: invalid option 'ca'.

Generally, it should not be an error to remove an option, as long
as the option itself is valid. For example,

    $ nmcli connection modify "$PROFILE" -vlan.ingress-priority-map bogus

should fail, but

    $ nmcli connection modify "$PROFILE" -vlan.ingress-priority-map 1:5

should succeed even if there was nothing to remove.
2019-03-25 09:12:32 +01:00
Thomas Haller
25ef45ff3d libnm/cli: support deleting VLAN egress/ingress priority map by "from"
The "from" part is like a key for the egress/ingress priority map.

Extend nm_setting_vlan_remove_priority_str_by_value() to accept only the
"from" part when finding and deleting value. This allows for:

    $ nmcli connection modify "$PROFILE" -vlan.ingress-priority-map '4:'
    $ nmcli connection modify "$PROFILE" -vlan.ingress-priority-map '4:*'

to fuzzy match the value to remove.
2019-03-25 09:12:32 +01:00
Thomas Haller
b56e430da9 cli: reuse nm_utils_vlan_priority_map_parse_str() in _parse_vlan_priority_maps() 2019-03-25 09:12:32 +01:00
Thomas Haller
e187bd08fe cli: fix leaking error variables setting vfs, qdiscs and tfilters 2019-03-25 09:12:32 +01:00
Thomas Haller
4e7eadd6d3 cli: fix appending team link-watchers
The set_fcn() function is supposed to only append. For the set-all
mode, the caller ensures to clear the array first.
2019-03-25 09:12:32 +01:00
Lubomir Rintel
4251f4e476 all: codespell fixes
Codespel run with the same arguments as described in
commit 58510ed566 ('docs: misc. typos pt2').

(cherry picked from commit bf0c4e6ac2)
2019-03-11 12:03:46 +01:00
Thomas Haller
2d34d06e5f wireguard: add "peer-routes" setting for WireGuard profiles
This setting is not yet implemented.

This adds new API for 1.16.0 and is an ABI break since 1.16-rc1.

(cherry picked from commit d719ad31f0)
2019-03-05 12:23:59 +01:00
Thomas Haller
89d40d6579 wireguard: add "mtu" setting for WireGuard profiles
This adds new API for 1.16.0 and is an ABI break since 1.16-rc1.

(cherry picked from commit d5e93ae613)
2019-03-05 12:23:59 +01:00
Thomas Haller
95c8f74f8c cli: support NM_SETTING_WIFI_P2P_WFD_IES property 2019-02-22 14:04:13 +01:00
Thomas Haller
0e7e8adc12 cli: rework NM_SETTING_802_1X_PASSWORD_RAW property functions to operate on generic GBytes
Rework the explicit implementation of NM_SETTING_802_1X_PASSWORD_RAW
handling to generically handle GBytes properties.

Note that the NM_SETTING_802_1X_PASSWORD_RAW setter accepts a legacy
format where hex-words are separated by space. I don't think we want
to support this format for new options.

So, there are two possibilities:

1) either leave _set_fcn_802_1x_password_raw() as-is, with the special
   handling.

2) interpret a property-data gobject_bytes.legacy_format.

1) seems to make more sense, because there is only one such property,
and we won't use this for new properties. However let's do 2), because
it shows nicely the two styles side-by-side. In other words, let's
password-raw also be a _pt_gobject_bytes typed property, with some
special legacy handling. Instead, of having it an entirely separate
property type (with a different setter implementation). I think it's
better to have the parts where they differ pushed down (the "stack") as
much as possible.
2019-02-22 14:04:13 +01:00
Thomas Haller
3059a30da9 cli: use nm_utils_bin2hexstr_full() in nmcli to convert bytes to string
- it's less lines of code (for the caller).

 - it's a function that can be easier unit-tested on its own.
   Possibly there are already other unit-tests that cover it.

 - it's more efficient than the GString based implementation.

 - it reuses our one and only bin-to-hexstr implementation.
2019-02-22 14:04:13 +01:00
Thomas Haller
974a010d80 cli: use correct define for NM_SETTING_WIFI_P2P_WPS_METHOD name
There is no change in behavior, because NM_SETTING_WIFI_P2P_WPS_METHOD
and NM_SETTING_WIRELESS_SECURITY_WPS_METHOD both are "wps-method".
2019-02-22 14:04:13 +01:00
Thomas Haller
b521f426ab libnm,cli: add NMSettingWireGuard
For now only add the core settings, no peers' data.

To support peers and the allowed-ips of the peers is more complicated
and will be done later. It's more complicated because these are nested
lists (allowed-ips) inside a list (peers). That is quite unusual and to
conveniently support that in D-Bus API, in keyfile format, in libnm,
and nmcli, is a effort.
Also, it's further complicated by the fact that each peer has a secret (the
preshared-key). Thus we probably need secret flags for each peer, which
is a novelty as well (until now we require a fixed set of secrets per
profile that is well known).
2019-02-22 11:00:10 +01:00