Commit Graph

327 Commits

Author SHA1 Message Date
Thomas Haller
84f2037648 shared: add flags argument to nm_utils_strsplit_set()
It will be useful to extend nm_utils_strsplit_set() with various
flavors and subtly different behaviors. Add a flags argument to
support these.
2019-04-10 15:05:57 +02:00
Thomas Haller
610aa5c432 cli: use nm_strstrip_avoid_copy_a() to avoid heap allocation 2019-04-04 21:01:15 +02:00
Lubomir Rintel
4ddc2bb766 clients: do not require gsm.apn
The server doesn't require it either.
2019-04-03 11:50:35 +02:00
Thomas Haller
ba59c7c3c0 cli: add support for routing rules to nmcli 2019-03-27 16:23:30 +01:00
Thomas Haller
71e40f519d cli: support escaping for splitting for objlist properties 2019-03-27 16:23:30 +01:00
Beniamino Galvani
4848ad7c77 nmcli: add bridge vlans support 2019-03-26 17:19:39 +01:00
Beniamino Galvani
96fab7b462 all: add vlan-filtering and vlan-default-pvid bridge properties 2019-03-26 17:18:29 +01:00
Thomas Haller
8b0461380f cli/trivial: add comment about partially modifying settings when failing set_fcn() 2019-03-25 09:12:33 +01:00
Thomas Haller
3a77201361 cli: workaround libnm issue for setting team.runner-tx-hash
This workaround was dropped when refactoring the property handling.
Restore the workaround (at least) until libnm is fixed.
2019-03-25 09:12:33 +01:00
Thomas Haller
a1c7b04664 nmcli: add clear_all_fcn() hook for mutllist property types 2019-03-25 09:12:33 +01:00
Thomas Haller
3a8fe7ad45 cli: consistently validate multilist options for add and remove
There is no reason to validate only in certain cases. Either we
validate, or we don't (always the same).

This is a change in behavior, but the cases should be sensible.
2019-03-25 09:12:33 +01:00
Thomas Haller
96c4f51208 cli: distinguish between resetting GObject property to default and NULL
Most GObject properties default to FALSE/NULL/0. In that case, there
is no difference between setting the default or clearing the value.

During

     if (_SET_FCN_DO_RESET_DEFAULT (property_info, modifier, value))
         return _gobject_property_reset_default (setting, property_info->property_name);

it is correct to reset the default.

However for list-typed properties, we want to clear the list. So,
it should be

     if (_SET_FCN_DO_SET_ALL (modifier, value))
         _gobject_property_reset (setting, property_info->property_name, FALSE);
2019-03-25 09:12:33 +01:00
Thomas Haller
166e04799d cli: accept ',' as delimiter for match.interface-names
"match.interface-names" is the only property that uses VALUE_STRSPLIT_MODE_MULTILIST_WITH_ESCAPE.

    $ nmcli connection modify "$PROFILE" match.interface-name ' 5, \,\  4\,  '

results in

    [match]
    interface-name=5;, ;4,;

and

    $ echo ">$(nmcli -g match.interface-name -escape=no connection show "$PROFILE")<"
    >5 \,\  4\,<

Yes, plain --get leads to a wrong double-escaping:

    $ echo ">$(nmcli -g match.interface-name connection show "$PROFILE")<"
    >5 \\,\\  4\\,<
2019-03-25 09:12:33 +01:00
Thomas Haller
65c8c19fa7 cli: don't support removing sriov vfs by index
The VFs already can be parsed as plain number (to indicate the
ifindex). We should not also support accepting the plain number
as index to be removed.

Fixes: a2f12994b7 ('cli: add support for configuring SR-IOV')
2019-03-25 09:12:33 +01:00
Thomas Haller
70bad5c74d cli: support list of indexes for removing objlist property
$ nmcli connection modify "$PROFILE" -ipv4.addresses 1,3

Already before, nmcli would support removing items by index. But only
one number was supported.

- indexes are zero based (as before).

- duplicate indexes or indexes out of bounds are silently ignored.

Maybe certain properties should not support removal by index.
2019-03-25 09:12:33 +01:00
Thomas Haller
28f0153350 cli: cleanup parsing of VLAN ingress/egress priority map
Use new ValueStrsplitMode "VALUE_STRSPLIT_MODE_STRIPPED".

Note that this is not exactly what we did before. For example, empty
tokens are now silently removed.

Also, we accept now whitespace as separators.
2019-03-25 09:12:33 +01:00
Thomas Haller
c0d83ef522 cli: refactor splitting the string when parsing the property values
Have one function that gets all the nonesense right. "nonesense", because
we have inconsistent behaviors, and the function is supposed to help with
that.
2019-03-25 09:12:33 +01:00
Thomas Haller
e2c95014c2 cli: merge remove-by-value and add functions of objlist property types 2019-03-25 09:12:33 +01:00
Thomas Haller
18fac0407e cli: merge set_fcn() and remove_fcn()
set_fcn() and remove_fcn() are strongly related. They should accept
arguments in the same format, hence the parsing of the arguments should
be done at one place.

In fact, previously the parsing was separate, leading to ugly
inconsistencies:

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

or

  $ nmcli connection modify "$PROFILE" +ipv4.addresses 192.168.1.5/24,192.168.2.5/24
  $ nmcli connection modify "$PROFILE" -ipv4.addresses 192.168.1.5/24,192.168.2.5/24
  Error: failed to remove a value from ipv4.addresses: invalid prefix '24,192.168.2.5/24'; <1-32> allowed.

Let set_fcn() handle set-default, set-all, add, and subtract.
2019-03-25 09:12:33 +01:00
Thomas Haller
eb0cfefe52 cli: allow resetting all values via set_fcn() property handler
Previously, set_fcn() could only append values. Now, pass on the modifier
so that it may append, set all, or reset the default.

These operations are strongly related and should be handled by the same
set_fcn() function.
2019-03-25 09:12:33 +01:00
Thomas Haller
22382c4e82 cli: implement remove-fcn for objlist types 2019-03-25 09:12:33 +01:00
Thomas Haller
923a79554c cli: implement add-fcn for objlist types 2019-03-25 09:12:33 +01:00
Thomas Haller
2a50729c6f cli: add clear-all-fcn for objlist properties 2019-03-25 09:12:33 +01:00
Thomas Haller
ad15b2505b cli: add objlist property type and implement get_fcn() for all types 2019-03-25 09:12:33 +01:00
Thomas Haller
126348d4be cli: implement team:runner-tx-hash as multilist property 2019-03-25 09:12:33 +01:00
Thomas Haller
1b1ef52ff8 cli: implement match:interface-names as multilist property 2019-03-25 09:12:33 +01:00
Thomas Haller
e3fa570c1b shared: add "strip" argument to _nm_utils_unescape_spaces()
It's usually not necessary, because _nm_utils_unescape_spaces()
gets called after nm_utils_strsplit_set(), which already removes
the non-escaped spaces.

Still, for completeness, this should be here. Also, because with
this the function is useful for individual options (not delimiter
separate list values), to support automatically dropping leading or
trailing whitespace, but also support escaping them.
2019-03-25 09:12:33 +01:00
Thomas Haller
b91f21aa23 cli: implement connection:permissions as multilist property 2019-03-25 09:12:32 +01:00
Thomas Haller
ecd0e34fe9 cli: minor cleanup of _get_fcn_connection_permissions() 2019-03-25 09:12:32 +01:00
Thomas Haller
cb310a061b cli: implement connection:secondaries as multilist property 2019-03-25 09:12:32 +01:00
Thomas Haller
b9cd9c8dc8 cli: implement mac-address-blacklist properties as mulitlist types 2019-03-25 09:12:32 +01:00
Thomas Haller
0cb1c20f93 cli: first validate all values in _set_fcn_multilist() before modifying the setting 2019-03-25 09:12:32 +01:00
Thomas Haller
b63620e67c cli: implement DNS property as multilist type 2019-03-25 09:12:32 +01:00
Thomas Haller
d9c8794338 cli: support validating multilist entries for remove-by-value 2019-03-25 09:12:32 +01:00
Thomas Haller
0bf55f097e cli: implement DNS option property as multilist type 2019-03-25 09:12:32 +01:00
Thomas Haller
3d1206e878 cli: make get_with_default property-type-data generally available
A property-info can only have one property-typ-data. That means,
all functions (get_fcn(), set_fcn()) need to either take not
property-typ-data, or they must all accept the same.

That made it hard to mix _get_fcn_nmc_with_default() with setters
that do require a certain property-typ-data. Instead, move the
is_default_func() to the general portion, and let _get_fcn_gobject()
handle it.
2019-03-25 09:12:32 +01:00
Thomas Haller
180925ff0c cli: implement DNS search property as multilist type 2019-03-25 09:12:32 +01:00
Thomas Haller
89cc1d1822 cli: add property type for 802-1x certificate properties (pt5) 2019-03-25 09:12:32 +01:00
Thomas Haller
8aa19e3f2c cli: add property type for 802-1x certificate properties (pt4) 2019-03-25 09:12:32 +01:00
Thomas Haller
fe390556ab cli: add property type for 802-1x certificate properties (pt3) 2019-03-25 09:12:32 +01:00
Thomas Haller
99711579ed cli: add property type for 802-1x certificate properties (pt2) 2019-03-25 09:12:32 +01:00
Thomas Haller
df0d5f8dee cli: add property type for 802-1x certificate properties (pt1) 2019-03-25 09:12:32 +01:00
Thomas Haller
cc2971a3d3 cli: merge mac_address_blacklist setters 2019-03-25 09:12:32 +01:00
Thomas Haller
c91e201689 cli: implement NM_SETTING_WIRED_S390_OPTIONS with the optionlist setter 2019-03-25 09:12:32 +01:00
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