Commit Graph

333 Commits

Author SHA1 Message Date
Thomas Haller
fcb7001302 cli: avoid "-Wmissing-braces" warning for INT_VALUE_INFOS() and ENUM_VALUE_INFOS()
Also fix indentations and enforce that each block is terminated by a
trailing comma.
2019-02-08 20:14:50 +01:00
Thomas Haller
e95cf643c3 cli: drop invalid validation for default-routes in nmcli
Currently, default-routes cannot be added like regular static-routes
as ipv4.routes setting.
Instead, one has to configure "ipv4.gateway" and "ipv4.never-default".
That of course should be fixed, for example to configure a default-route
in different routing tables.

As it is, both nmcli's parse function and libnm's
NMSettingIPConfig:verify() functions reject default-routes.

But nmcli goes way beyond that, it also rejects all networks with
"0.0.0.0"/"::" even if their prefix length is not zero. Such routes are
not default-routes, and nmcli has no business rejecting them. The
correct way for checking for a default-route is to check the prefix-length
for zero.

Drop the wrong validation in nmcli.

Note, it may still not be the best idea to add catch-all routes like
"0.0.0.0/1" and "128.0.0.0/1". It just defeats what counts as a default-route.
NM has other means (like configuring the route-metric) to handle routing
in face of multiple interfaces. But sure, whatever works for you.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/114
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/75
2019-02-07 17:21:40 +01:00
Lubomir Rintel
fd64417f1d clients/meta-setting-desc: allow setting wifi-sec.key-mgmt to SAE 2019-02-05 10:20:27 +01:00
Lubomir Rintel
49ac11f84b clients/common: drop unuseful wifi-sec.psk validation
The generic connection validation produces a good result:
  Error: failed to modify 802-11-wireless-security.psk: ':(' is not a valid PSK.
vs.:
  Error: Failed to add 'wifi666' connection: 802-11-wireless-security.psk: property is invalid
2019-02-05 10:20:27 +01:00
Thomas Haller
0ec30f8904 clients/trivial: move code in nm-meta-setting-desc around
Sort by name.
2019-02-01 17:02:57 +01:00
Thomas Haller
09090f2669 wifi-p2p: rename Wi-Fi P2P
After renaming the files, also rename all the content
to follow the "Wi-Fi P2P" naming scheme.
2019-02-01 17:02:57 +01:00
Thomas Haller
2d649305f8 cli/trivial: order code in "nm-meta-setting-desc.c" alphabetically 2019-02-01 17:02:57 +01:00
Beniamino Galvani
a68b1827ec clients: fix string list setter
Fixes: 5d3736ac65

https://bugzilla.redhat.com/show_bug.cgi?id=1671200
2019-01-31 08:55:19 +01:00
Benjamin Berg
42e60e327f core: Add basic P2P Wi-Fi Settings
The support is rather basic and only allows connecting to a specific
peer. However, this is actually already enough for many usecases.
2019-01-27 23:45:11 +01:00
Beniamino Galvani
b11a20ded0 clients: remove the same dns-option before adding it
nmcli connection modify t ipv4.dns-options ndots:2
 nmcli connection modify t +ipv4.dns-options ndots:4

should set dns-options to 'ndots:4', so we must remove other
occurences of the same option before adding it, otherwise the setting
refuses to set the same option again.
2019-01-12 22:57:37 +01:00
Beniamino Galvani
bcb91f4f65 clients: fix appending to dns-property variable
Appending to the ipvx.dns-options property:

  nmcli connection modify con +ipv4.dns-options rotate

currently is buggy because it resets the list to contain only
'rotate'. The setter function should not clear the list.

https://bugzilla.redhat.com/show_bug.cgi?id=1665649
2019-01-12 22:57:37 +01:00
Beniamino Galvani
1f32e417a8 clients: unify IPv4 and IPv6 accessors for dns-search, dns-options 2019-01-12 22:57:37 +01:00
Aleksander Morgado
6ed21e8342 settings,gsm: deprecate and stop using 'number' property
The 'number' property in GSM settings is a legacy thing that comes
from when ModemManager used user-provided numbers, if any, to connect
3GPP modems.

Since ModemManager 1.0, this property is completely unused for 3GPP
modems, and so it doesn't make sense to use it in the NetworkManager
settings. Ofono does not use it either.

For AT+PPP-based 3GPP modems, the 'number' to call to establish the
data connection is decided by ModemManager itself, e.g. for standard
GSM/UMTS/LTE modems it will connect a given predefined PDP context,
and for other modems like Iridium it will have the number to call
hardcoded in the plugin itself.

https://github.com/NetworkManager/NetworkManager/pull/261
2018-12-19 08:54:50 +01:00
Patrick Talbert
f44c793f6c team: add support for 'vlanid' link-watchers property
Add support for the teaming arp_ping link watcher 'vlanid' property.

Signed-off-by: Patrick Talbert <ptalbert@redhat.com>

[thaller@redhat.com: minor fixes to original patch]

https://bugzilla.redhat.com/show_bug.cgi?id=1652931
2018-12-12 14:07:30 +01:00
Thomas Haller
92efe8a53c clients: use NM_MAKE_STRV() instead of VALUES_STATIC()
VALUES_STATIC() was a macro to initialize the values_static pointer with
a (static) strv array.

For one, it lacked a "const" in "(const char *[])", which means
the data is not put in a read only section by the linker. That should
be fixed.

Anyway, we already have a macro for creating such constant strv arrays:
NM_MAKE_STRV().

I think it is good to the concept of "initializing values_static" a
name (VALUES_STATIC()). But it also hides (for better or worse), that
this is a strv array. Let's use NM_MAKE_STRV() instead. By looking at
the code, it's still clear that this initializes the "values_static"
array, but it also makes it clear that this is a plain strv array.
2018-12-01 15:16:48 +01:00
Thomas Haller
de3f6cfb98 doc,all: fix spelling of Open vSwitch (instead of OpenVSwitch)
Also affects documentation and translated strings.

Reported-by: Flavio Leitner <fbl@redhat.com>
2018-11-28 14:26:42 +01:00
Patrick Talbert
25a0739658 clients: Fix typo in _dump_team_link_watcher output
This makes the output of a 'con show' for a team device look suspect.

Signed-off-by: Patrick Talbert <ptalbert@redhat.com>

Fixes: 4657390d45

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/53
2018-11-23 17:37:44 +01:00
Thomas Haller
085105fc0e cli: minor cleanup of _set_fcn_gobject_enum()
No need to check again the gtype_class. We did it above already.
2018-10-17 16:22:34 +02:00
Thomas Haller
127ac25ef8 cli: fix setting "serial.parity" enum
The meta data type descriptor must set .get_gtype only for
GObject properties which are of type int or uint. That is, when
the enum type cannot be automatically detected.

However, NM_SETTING_SERIAL_PARITY is a g_param_spec_enum()
of type NM_TYPE_SETTING_SERIAL_PARITY, so setting the get_gtype()
hook is wrong and leads to a crash

   $ /bin/nmcli connection add type gsm autoconnect no con-name t ifname '*' apn xyz serial.parity 5

   (process:11086): libnmc-CRITICAL **: 15:04:35.180: file clients/common/nm-meta-setting-desc.c: line 1283 (_set_fcn_gobject_enum): should not be reached
   Segmentation fault (core dumped)

That is because the enum property setter does:

    »···if (   has_gtype
    »···    && NM_IN_SET (gtype_prop,
    »···                  G_TYPE_INT,
    »···                  G_TYPE_UINT)
    »···    && G_TYPE_IS_CLASSED (gtype)
    »···    && (gtype_class = g_type_class_ref (gtype))
    »···    && (   (is_flags = G_IS_FLAGS_CLASS (gtype_class))
    »···        || G_IS_ENUM_CLASS (gtype_class))) {
    »···»···/* valid */

meaning, it only allows "has_gtype" if the native "gtype_prop" is
G_TYPE_INT or G_TYPE_UINT.

Fixes: 9a68123827
2018-10-17 16:22:34 +02:00
Thomas Haller
a600b3a3b2 cli: fix handling uint64 connection property "serial.send-delay"
libnm currently has only one GObject property of type uint64:
"serial.send-delay". However, it's broken because uint64 handling
is not implemented.

    $ nmcli connection add type gsm autoconnect no con-name t ifname '*' apn 'xyz' serial.baud 5
    Connection 't' (4c929f17-9fda-41d6-8f90-897f6d46b078) successfully added.

    $ nmcli connection show t
    ...
    ipv6.dhcp-duid:                         --
    ipv6.dhcp-send-hostname:                yes
    ipv6.dhcp-hostname:                     --
    ipv6.token:                             --

    (process:14016): libnmc-CRITICAL **: 14:08:32.591: file clients/common/nm-meta-setting-desc.c: line 811 (_get_fcn_gobject_int): should not be reached
    serial.baud:                            5
    serial.bits:                            8
    serial.parity:                          none
    serial.stopbits:                        1
    serial.send-delay:                      --
    gsm.number:                             *99#
    ...

    $ nmcli connection add type gsm autoconnect no con-name t ifname '*' apn 'xyz' serial.baud 5 serial.send-delay 100

    (process:14852): libnmc-CRITICAL **: 14:12:24.259: file clients/common/nm-meta-setting-desc.c: line 1131 (_set_fcn_gobject_int): should not be reached
    Segmentation fault (core dumped)

Fixes: b6d9bdcee8
2018-10-17 16:22:34 +02:00
Lubomir Rintel
c21b4c3d0a cli: add support for wpan.page and wpan.channel properties 2018-10-07 15:46:02 +02:00
Thomas Haller
c09081dd2c cli: cleanup of error handling in nmc_property_set_bytes() 2018-09-29 11:20:28 +02:00
Beniamino Galvani
6a9d2740ac clients: fix memory leak when parsing routes
The new hash table should destroy elements stolen from the hash table
returned by nm_utils_parse_variant_attributes().

Fixes: d094914120
(cherry picked from commit 31bda1b837)
2018-09-14 17:29:05 +02:00
Beniamino Galvani
481fce62bf cli: add support for connection.llmnr 2018-09-06 09:07:41 +02:00
Beniamino Galvani
2f60fdf19e cli: autocomplete connection type even if it has an alias
Before, we would not autocomplete connection types that have an alias:

Connection type: <TAB><TAB>
6lowpan           cdma              macvlan           vlan
802-11-olpc-mesh  dummy             olpc-mesh         vpn
802-11-wireless   ethernet          ovs-bridge        vxlan
802-3-ethernet    generic           ovs-interface     wifi
adsl              gsm               ovs-port          wimax
bluetooth         infiniband        pppoe             wpan
bond              ip-tunnel         team
bridge            macsec            tun
Connection type: 8<TAB> [-> no completion]

Don't treat the default connection type (for example,
"802-3-ethernet") in a special way and allow it to be autocompleted,
because we already display it when the user did not enter any text.
2018-08-27 15:14:01 +02:00
Beniamino Galvani
9b9dce9486 all: add 'match' setting
Add a new 'match' setting containing properties to match a connection
to devices. At the moment only the interface-name property is present
and, contrary to connection.interface-name, it allows the use of
wildcards.
2018-08-11 09:41:07 +02:00
Beniamino Galvani
6a51d393b2 shared: add @allow_escaping argument to @nm_utils_strsplit_set 2018-08-11 09:41:07 +02:00
Thomas Haller
da109a291c all/ethtool: add support for all currently supported kernel features
As of upstream kernel v4.18-rc8.

Note that we name the features like they are called in ethtool's
ioctl API ETH_SS_FEATURES.

Except, for features like "tx-gro", which ethtool utility aliases
as "gro". So, for those features where ethtool has a built-in,
alternative name, we prefer the alias.

And again, note that a few aliases of ethtool utility ("sg", "tso", "tx")
actually affect more than one underlying kernel feature.

Note that 3 kernel features which are announced via ETH_SS_FEATURES are
explicitly exluded because kernel marks them as "never_changed":

    #define NETIF_F_NEVER_CHANGE (NETIF_F_VLAN_CHALLENGED | \
                                  NETIF_F_LLTX | NETIF_F_NETNS_LOCAL)
2018-08-10 10:38:19 +02:00
Thomas Haller
9e7c960fad cli: hide ethtool options form nmcli connection show "$PROFILE" output
We will add a large number of offload features. That means, the output
of `nmcli connection show "$PROFILE"` would be very verbose, in case
the profile has a [ethtool] option.

Since this is newly added API, don't do that. Don't show ethtool properties
that are left unset.

A minor problem here is, that it becomes no longer obvious which
properties exist. We should however counter that by documentation.
Also, one could do:

  $ nmcli connection modify "$PROFILE" ethtool.xxx x
  Error: invalid property 'xxx': 'xxx' not among [feature-gro, feature-gso, feature-lro, feature-ntuple, feature-rx, feature-rxhash, feature-rxvlan, feature-sg, feature-tso, feature-tx, feature-txvlan, feature-tx-tcp6-segmentation, feature-tx-tcp-segmentation].

Likewise, bash completion still works as one would expect.

  $ nmcli --complete-args connection modify "$PROFILE" ethtool.
  ethtool.feature-gro
  ethtool.feature-gso
  ethtool.feature-lro
  [...]

Note the output of

  $ nmcli -f ethtool.feature-gro connection show "$PROFILE"

gives now nothing (if there is an ethtool section, but not this
particular feature). Maybe this shouldn't be like that. On the other
hand, specifying a connection setting that doesn't exist also gives
no output:

  $ nmcli -f bond connection show "$PROFILE"

So, maybe this behavior is fine.
2018-08-10 10:38:19 +02:00
Thomas Haller
c085b6e3a7 platform/ethtool: add code to get/set offload features via ethtool
Also, add two more features "tx-tcp-segmentation" and
"tx-tcp6-segmentation". There are two reasons for that:

 - systemd-networkd supports setting these two features,
   so lets support them too (apparently they are important
   enough for networkd).

 - these two features are already implicitly covered by "tso".
   Like for the "ethtool" program, "tso" is an alias for several
   actual features. By adding two features that are already
   also covered by an alias (which sets multiple kernel names
   at once), we showcase how aliases for the same feature can
   coexist. In particular, note how setting
   "tso on tx-tcp6-segmentation off" will behave as one would
   expect: all 4 tso features covered by the alias are enabled,
   except that particular one.
2018-08-10 10:38:19 +02:00
Thomas Haller
df30651b89 libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.

The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.

Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.

The functionality is not yet implemented server-side.
2018-08-10 10:38:19 +02:00
Thomas Haller
64f1e78e28 cli: drop NMCTriStateValue for NMTernary 2018-08-10 10:38:19 +02:00
Thomas Haller
852abf3d3d all/style: write elvis operator ?: without space
By far most of the time, we write "?:" and not "? :". Adjust
the few places that don't.
2018-08-09 17:06:18 +02:00
Thomas Haller
55ae69233d all: add connection.multi-connect property for wildcard profiles
Add a new option that allows to activate a profile multiple times
(at the same time). Previoulsy, all profiles were implicitly
NM_SETTING_CONNECTION_MULTI_CONNECT_SINGLE, meaning, that activating
a profile that is already active will deactivate it first.

This will make more sense, as we also add more match-options how
profiles can be restricted to particular devices. We already have
connection.type, connection.interface-name, and (ethernet|wifi).mac-address
to restrict a profile to particular devices. For example, it is however
not possible to specify a wildcard like "eth*" to match a profile to
a set of devices by interface-name. That is another missing feature,
and once we extend the matching capabilities, it makes more sense to
activate a profile multiple times.

See also https://bugzilla.redhat.com/show_bug.cgi?id=997998, which
previously changed that a connection is restricted to a single activation
at a time. This work relaxes that again.

This only adds the new property, it is not used nor implemented yet.

https://bugzilla.redhat.com/show_bug.cgi?id=1555012
2018-08-08 11:24:29 +02:00
Thomas Haller
41810aad48 cli: don't explicitly unset out_to_free argument in NMMetaType.get_nested()
The virtual function NMMetaType.get_nested() has only one caller:
nm_meta_abstract_info_get_nested(). That caller makes sure to
always pass in an @out_to_free argument, and that it is initialized
to NULL.
2018-07-25 17:08:37 +02:00
Beniamino Galvani
a2f12994b7 cli: add support for configuring SR-IOV 2018-07-11 16:16:22 +02:00
Thomas Haller
e1c7a2b5d0 all: don't use gchar/gshort/gint/glong but C types
We commonly don't use the glib typedefs for char/short/int/long,
but their C types directly.

    $ git grep '\<g\(char\|short\|int\|long\|float\|double\)\>' | wc -l
    587
    $ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l
    21114

One could argue that using the glib typedefs is preferable in
public API (of our glib based libnm library) or where it clearly
is related to glib, like during

  g_object_set (obj, PROPERTY, (gint) value, NULL);

However, that argument does not seem strong, because in practice we don't
follow that argument today, and seldomly use the glib typedefs.
Also, the style guide for this would be hard to formalize, because
"using them where clearly related to a glib" is a very loose suggestion.

Also note that glib typedefs will always just be typedefs of the
underlying C types. There is no danger of glib changing the meaning
of these typedefs (because that would be a major API break of glib).

A simple style guide is instead: don't use these typedefs.

No manual actions, I only ran the bash script:

  FILES=($(git ls-files '*.[hc]'))
  sed -i \
      -e 's/\<g\(char\|short\|int\|long\|float\|double\)\>\( [^ ]\)/\1\2/g' \
      -e 's/\<g\(char\|short\|int\|long\|float\|double\)\>  /\1   /g' \
      -e 's/\<g\(char\|short\|int\|long\|float\|double\)\>/\1/g' \
      "${FILES[@]}"
2018-07-11 12:02:06 +02:00
Thomas Haller
ba350a3495 cli: add additional user-data argument to get_fcn()
The function nmc_print() receives a list of "targets". These are essentially
the rows that should be printed (while the "fields" list represents the columns).

When filling the cells with values, it calles repeatedly get_fcn() on the
column descriptors (fields), by passing each row (target).

The caller must be well aware that the fields and targets are
compatible. For example, in some cases the targets are NMDevice
instances and the target type must correspond to what get_fcn()
expects.

Add another user-data pointer that is passed on along with the
targets. That is useful, if we have a list of targets/rows, but
pass in additional data that applies to all rows alike.

It is still unused.
2018-07-09 15:43:55 +02:00
Beniamino Galvani
fc99aad378 ip-tunnel: allow wired setting for some tunnel modes
gretap and ip6gretap ip-tunnel interfaces encapsulate L2 packets over
IP. Allow adding a wired setting for such connections so that users
can change the interface MAC.
2018-07-02 17:55:14 +02:00
Lubomir Rintel
29636535b2 client: support 6lowpan setting 2018-06-26 16:21:55 +02:00
Lubomir Rintel
5da77c0e2c client: support wpan setting 2018-06-26 16:21:55 +02:00
Lubomir Rintel
8901193816 clients/meta: allow formatting 16-bit values formatted as 0x%04x
This is the preferred way to format WPAN short addresses and PAN IDs.
2018-06-26 16:21:55 +02:00
Alfonso Sánchez-Beato
cb8003c40d cli: add support for wake-on-wlan properties 2018-06-15 09:46:26 +02:00
Beniamino Galvani
bb20f2eb61 macsec: enable send-sci by default and make the option configurable
It is safer to enable send-sci by default because, at the cost of
8-byte overhead, it makes MACsec work over bridges (note that kernel
also enables it by default). While at it, also make the option
configurable.

https://bugzilla.redhat.com/show_bug.cgi?id=1588041
2018-06-14 15:13:11 +02:00
Francesco Giudici
02c4b2c9a8 cli: add dhcp-duid support 2018-06-09 22:20:39 +02:00
Lubomir Rintel
e69d386975 all: use the elvis operator wherever possible
Coccinelle:

  @@
  expression a, b;
  @@
  -a ? a : b
  +a ?: b

Applied with:

  spatch --sp-file ternary.cocci --in-place --smpl-spacing --dir .

With some manual adjustments on spots that Cocci didn't catch for
reasons unknown.

Thanks to the marvelous effort of the GNU compiler developer we can now
spare a couple of bits that could be used for more important things,
like this commit message. Standards commitees yet have to catch up.
2018-05-10 14:36:58 +02:00
Lubomir Rintel
f0c1efbf42 all: add and utilize nm_utils_is_separator()
It is meant to be rather similar in nature to isblank() or
g_ascii_isspace().

Sadly, isblank() is locale dependent while g_ascii_isspace() also considers
vertical whitespace as a space. That's no good for configuration files that
are strucutured into lines, which happens to be a pretty common case.
2018-05-10 14:35:52 +02:00
Beniamino Galvani
1b5925ce88 all: remove consecutive empty lines
Normalize coding style by removing consecutive empty lines from C
sources and headers.

https://github.com/NetworkManager/NetworkManager/pull/108
2018-04-30 16:24:52 +02:00
Thomas Haller
c9a574f12f clients: use nm_utils_strv_make_deep_copied() to deep copy const strv array 2018-04-13 17:02:55 +02:00
Beniamino Galvani
50414353e1 clients: set @out_is_default in property getters 2018-04-13 17:02:55 +02:00