Commit Graph

26038 Commits

Author SHA1 Message Date
Thomas Haller
41d431e0f8 license: add Thomas to RELICENSE.md
https://mail.gnome.org/archives/networkmanager-list/2020-May/msg00015.html
2020-05-23 16:59:14 +02:00
Thomas Haller
e4ad30a011 license: add Florian to RELICENSE.md
As confirmed via private email:

  From: Florian Echtler <floe(at)butterbrot.org>
  To:   Thomas Haller <thaller(at)redhat.com>
  Date: Fri, 22 May 2020 16:17:52 +0200
2020-05-22 16:33:24 +02:00
Thomas Haller
b8d947333c libnm,core: merge branch 'th/setting-option-and-ethtool'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/506
2020-05-22 15:58:22 +02:00
Thomas Haller
16c8555b24 libnm: check options in NMSettingEthtool.verify() in defined order
Iterating the hash gives the entries in undefined order. That
means, when validation would fail for more than one option,
then the error message arbitrarily points out one or the other.

Instead, process the entries in a defined order.
2020-05-22 15:58:09 +02:00
Thomas Haller
280600f0be libnm: remove redundant nm_setting_ethtool_*_coalesce() API
Note that nm_setting_ethtool_set_coalesce() used to coerce
"coalesce-adaptive-[rt]x" values to 0 or 1. The alternative
API doesn't do that. But so does nm_setting_option_set()
not tell you whether the value you set is valid. That is
not the options of the setters, for that we have verify().
2020-05-22 15:58:09 +02:00
Thomas Haller
482f9c574e libnm: deprecated nm_setting_ethtool_*_feature() API
These are just aliases for the more general nm_setting_option_*() API.
2020-05-22 15:58:09 +02:00
Thomas Haller
0533ab3c79 all: avoid (soon to be) deprecated API instead of nm_setting_option*() 2020-05-22 15:58:09 +02:00
Thomas Haller
614f5f5a88 libnm: use nm_setting_option_*() API in NMSettingEthtool 2020-05-22 15:58:09 +02:00
Thomas Haller
49db9d8d78 libnm: add nm_setting_option_clear_by_name()
More general purpose API for generic options of settings.

The predicate function is also nicely usable via bindings.

One question is about the form of the predicate. In this case,
it is convenient to pass nm_ethtool_optname_is_coalesce(). On the
other hand, it's not very flexible as it does not accept a user
data argument. Use NMUtilsPredicateStr here, which is not flexible
but convenient for where it's used.
2020-05-22 15:58:09 +02:00
Thomas Haller
1a56a2105c libnm: add nm_setting_option_get_names()
More general purpose API for generic options of settings.
2020-05-22 15:58:09 +02:00
Thomas Haller
150af44e10 libnm: add nm_setting_option_get_uint32(), nm_setting_option_set_uint32()
More general purpose API for generic options of settings.
2020-05-22 15:58:09 +02:00
Thomas Haller
d0192b698e libnm: add nm_setting_option_set(), nm_setting_option_get_boolean(), nm_setting_option_set_boolean()
More general purpose API for generic options of settings.
2020-05-22 15:58:08 +02:00
Thomas Haller
9655dff5cb libnm: add API for setting gendata options to NMSetting (nm_setting_option_get())
NMSettingEthtool is implemented using "gendata", meaning a hash
of GVariant. This is different from most other settings that have
properties implemented as GObject properties. There are two reasons
for this approach:

  - The setting is transferred via D-Bus as "a{sv}" dictionary.
    By unpacking the dictionary into GObject properties, the setting
    cannot handle unknown properties. To be forward compatible (and
    due to sloppy programming), unknown dictionary keys are silently
    ignored when parsing a NMSetting. That is error prone and also
    prevents settings to be treated loss-less.
    Instead, we should at first accept all values from the dictionary.
    Only in a second step, nm_connection_verify() rejects invalid settings
    with an error reason. This way, the user can create a NMSetting,
    but in a separate step handle if the setting doesn't verify.
    "gendata" solves this by tracking the full GVariant dictionary.
    This is still not entirely lossless, because multiple keys are
    combined.
    This is for example interesting if an libnm client fetches a connection
    from a newer NetworkManager version. Now the user can modify the
    properties that she knows about, while leaving all unknown
    properties (from newer versions) in place.

  - the approach aims to reduce the necessary boiler plate to create
    GObject properties. Adding a new property should require less new code.

This approach was always be intended to be suitable for all settings, not only
NMSettingEthtool. We should not once again try to add API like
nm_setting_ethtool_set_feature(), nm_setting_ethtool_set_coalesce(), etc.
Note that the option name already fully encodes whether it is a feature,
a coalesce option, or whatever. We should not have
"nm_setting_set_$SUB_GROUP (setting, $ONE_NAME_FROM_GROUP)" API, but
simply "nm_setting_option_set (setting, $OPTION)" accessors.

Also, when parsing a NMSettingEthtool from a GVariant, then a feature
option can be any kind of variant. Only nm_setting_verify() rejects
variants of the wrong type. As such, nm_setting_option_set*() also
doesn't validate whether the variant type matches the option. Of course,
if you set a value of wrong type, verify() will reject the setting.

Add new general purpose API for this and expose it for NMSetting.
2020-05-22 15:58:08 +02:00
Thomas Haller
618ae93b94 libnm: rename nm_setting_gendata_*() API to nm_setting_option_*()
We are going to expose some of this API in libnm.

The name "gendata" (for "generic data") is not very suited. Instead,
call the public API nm_setting_option_*(). This also brings no naming
conflict, because currently no API exists with such naming.

Rename the internal API, so that it matches the API that we are going
to expose next.
2020-05-22 15:58:08 +02:00
Thomas Haller
bfe05b48f2 libnm: drop unused internal API _nm_setting_gendata_reset_from_hash() and _nm_setting_gendata_to_gvalue()
This was intended for when the gendata hash should be converted
to/from a GValue/GHashTable. This would have been used, if
we also would have added a GObject property that exposes
the hash. But that was never done (at least not for NMSettingEthtool
and not yet).

This code is not used. If you ever need it, revert the patch
or implement it anew.
2020-05-22 15:58:08 +02:00
Thomas Haller
34fc68f20a libnm: drop unused internal function nm_setting_gendata_get_all_values()
This function is not used nor does it seem useful.

Either you only need the names (nm_setting_gendata_get_all_names())
or you need the names and values together (_nm_setting_gendata_get_all()).
Getting the values without knowing the corresponding name makes
little sense. If you need it, call _nm_setting_gendata_get_all()
instead.
2020-05-22 15:58:08 +02:00
Thomas Haller
20a2399aa9 libnm: verify that ethtool coalesce options "adaptive-[rt]x" are boolean
nm_setting_ethtool_set_coalesce() coerces the values to be either 0 or
1. Verification of NMSettingEthtool should ensure the same.
2020-05-22 15:58:08 +02:00
Thomas Haller
501554732c libnm: avoid duplicate type checks in "nm-setting-ethtool.c"
Don't duplicate the code that maps the option to the variant type.

Also, only resolve the name to NMEthtoolID once. Multiple calls
to nm_ethtool_optname_is_*() unnecessarily need to convert the
string to the ethtool id multiple times.
2020-05-22 15:58:08 +02:00
Thomas Haller
dcb4ed2cb1 ethtool: add and use _NM_ETHTOOL_ID_FEATURE_AS_IDX() macro 2020-05-22 15:58:08 +02:00
Thomas Haller
1f4b190934 platform: make states of NMEthtoolCoalesceState indexed by ethtool_id
We already have NMEthtoolID to handle coalesce options in a way that is
convenient programmatically. That is, we can iterate over all valid
coalesce options (it's just an integer) and use that in a more generic
way.

If NMEthtoolCoalesceState names all fields explicitly, we need explicit
code that names each coalesce option. Especially since NMEthtoolCoalesceState
is an internal and intermediate data structure, this is cumbersome
and unnecessary.

Thereby it also fixes the issue that nm_platform_ethtool_init_coalesce() has a
NMPlatform argument without actually needing it.
nm_platform_ethtool_init_coalesce() does not operate on a NMPlatform
instance, and should not have the appearance of being a method of
NMPlatform.
2020-05-22 15:58:08 +02:00
Thomas Haller
1f5f840818 device: in _ethtool_coalesce_set() only fetch current coalesce settings if needed
In the common case, the user doesn't set any coalesce options. Avoid always
fetching the current settings, unless they are actually needed.
2020-05-22 15:58:01 +02:00
Thomas Haller
94a603a1bc platform/trivial: rename NMEthtoolCoalesceState variables to "coalesce"
All other users name a similar variable "coalesce" (or "coalesce_new",
"coalesce_old"). Rename the variables, to don't use different names for
similar uses.
2020-05-22 15:58:01 +02:00
Thomas Haller
adcb935089 ifcfg-rh: avoid setting empty "-C/-K/-G" options for ethtool settings
If no options are set, we should not generate -C/-K/-G options
without parameter.
2020-05-22 15:58:01 +02:00
Thomas Haller
c48bfdf584 libnm: add NMUtilsPredicateStr typedef
This will be used for nm_setting_option_clear_by_name(), to
filter based on a name. But it is a general purpose typedef
for a predicate, not tied to NMSetting or option.
2020-05-22 15:58:01 +02:00
Thomas Haller
332cf1ad9d license: add Rafael to RELICENSE.md
As confirmed via private email:

  From: Rafael Fontenelle <rafaelff(at)gnome.org>
  To:   Thomas Haller <thaller(at)redhat.com>
  Date: Fri, 22 May 2020 10:28:59 -0300
2020-05-22 15:54:43 +02:00
Thomas Haller
4cbb4a9dff license: add Ikey to RELICENSE.md
As confirmed via private email:

  From: Ikey Doherty <ikey.doherty(at)lispysnake.com>
  To:   Thomas Haller <thaller(at)redhat.com>
  Date: Fri, 22 May 2020 14:43:18 +0100
2020-05-22 15:51:01 +02:00
Thomas Haller
9fd0867acb license: add Yuri to RELICENSE.md
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/514#note_507841
2020-05-22 15:36:04 +02:00
Thomas Haller
7b9cb1f952 libnm: fix documentation for value argument of nm_client_dbus_call()
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/451
2020-05-22 08:51:21 +02:00
Thomas Haller
7774d837d7 license: add Alfonso to RELICENSE.md
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/390#note_502713
2020-05-20 21:25:40 +02:00
Thomas Haller
316719c5f7 license: add Canonical, Ltd. to RELICENSE.md
As discussed via email:

  From: Andrew Sinclair <andrew.sinclair(at)canonical.com>
  To:   Thomas Haller <thaller(at)redhat.com>
  Cc:   Legal(at)canonical.com <legal(at)canonical.com>, Loïc Minier <loic.minier(at)canonical.com>, Alfonso Sanchez-Beato <alfonso.sanchez-beato(at)canonical.com>
  Date: Wed, 20 May 2020 12:08:20 -0400
2020-05-20 21:17:05 +02:00
Thomas Haller
1373fd0a9b license: fix obsolete line in RELICENSE.md 2020-05-20 21:16:41 +02:00
Thomas Haller
eb500fe077 license: add David to RELICENSE.md
https://mail.gnome.org/archives/networkmanager-list/2020-May/msg00014.html
2020-05-20 17:19:43 +02:00
Thomas Haller
6a464e3302 license: add Jan and Pengutronix to RELICENSE.md
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/390#note_504926
2020-05-20 11:43:00 +02:00
Thomas Haller
0ae7b6d956 license: add Timothy to RELICENSE.md
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/397#note_504980
2020-05-20 11:36:42 +02:00
Antonio Cardace
2eccd19b91 ethtool: merge branch 'ac/ethtool_opts_ring'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/508
2020-05-20 10:55:57 +02:00
Antonio Cardace
2ce0e714b6 nm-device: apply ethtool ring settings when activating a connection
nm-device now applies ethtool ring settings during stage 2 "device
config" of the connection activation.

ring settings will be then restored (according to what the state
was before the connection got activated on the device) when the
connection is deactivated during the device cleanup.

One thing to be noted is that unset ring settings (in the profile)
will not be touched at all by NetworkManager so that if the NIC driver
sets some default values these will be preserved unless specifically
overridden by the connection profile.

https://bugzilla.redhat.com/show_bug.cgi?id=1614700
2020-05-20 10:55:02 +02:00
Antonio Cardace
2d2c111304 platform: add support for ring settings using ioctl()
https://bugzilla.redhat.com/show_bug.cgi?id=1614700
2020-05-20 10:55:02 +02:00
Antonio Cardace
126995a4d8 clients: add support for ethtool ring settings
https://bugzilla.redhat.com/show_bug.cgi?id=1614700
2020-05-20 10:55:02 +02:00
Antonio Cardace
e04e5a5c2a ifcfg-rh: add support for ethtool ring settings
Also update unit tests.

https://bugzilla.redhat.com/show_bug.cgi?id=1614700
2020-05-20 10:55:01 +02:00
Antonio Cardace
7109ac667a ethtool: add ring settings
This is the initial support for ring settings and only allows
getting/setting, nothing is yet implemented in nm-device.

Also add unit test.

https://bugzilla.redhat.com/show_bug.cgi?id=1614700
2020-05-20 10:55:01 +02:00
Antonio Cardace
3e50221d7e ethtool: refactor coalesce settings using gendata APIs
https://bugzilla.redhat.com/show_bug.cgi?id=1614700
2020-05-20 10:55:01 +02:00
Antonio Cardace
55d2df6658 nm-setting: use nm_setting_gendata_clear_all() to clear features
https://bugzilla.redhat.com/show_bug.cgi?id=1614700
2020-05-20 10:55:01 +02:00
Antonio Cardace
e08c3a6e18 nm-setting: add internal gendata API to clear value(s)
The filter function in nm_setting_gendata_clear_all() is useful
for when you want to only clear values according to a predicate,
if no such function is supplied all values will be cleared.

https://bugzilla.redhat.com/show_bug.cgi?id=1614700
2020-05-20 10:55:01 +02:00
Antonio Cardace
572f82a77b nm-setting: add internal gendata API to get/set uint32
https://bugzilla.redhat.com/show_bug.cgi?id=1614700
2020-05-20 10:55:01 +02:00
Thomas Haller
12063d6cb6 platform: simplify NMEthtoolCoalesceState to only track one state
Only in one moment we need the old and requested settings together:
during _ethtool_coalesce_set(). But for that we shouldn't track both
states in "NMEthtoolCoalesceState".

Simplify "NMEthtoolCoalesceState" to only contain one set of options.
By tracking less state, the code becomes simpler, because you don't
need to wonder where the old and requested state is used.
2020-05-20 10:54:57 +02:00
Thomas Haller
d71f920f2e license: add Daniel and Endless OS LLC to RELICENSE.md
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/390#note_503229
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/390#note_504774
2020-05-20 09:09:37 +02:00
Beniamino Galvani
02ea74c920 core: signal parent-active only when the parent AC is activated
The parent-active signal is used by the manager to determine when the
parent active-connection is ready and a connection that depend on it
can proceed.

The AC state could transition from ACTIVATING directly to
DEACTIVATING; in such case we should not emit the signal but instead
just stop watching the parent AC.

Fixes: 6e382ea91d ('active-connection: add parent active connection tracking')
https://bugzilla.redhat.com/show_bug.cgi?id=1778073
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/510
2020-05-19 21:40:51 +02:00
Thomas Haller
18deaa39c7 mailmap: fix identity for gunchleoc 2020-05-19 18:19:51 +02:00
Thomas Haller
ecc5425bdd cli: merge branch 'th/wireguard-import-dns-search'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/502
2020-05-19 18:07:44 +02:00
Thomas Haller
753cc7b79b libnm: use correct free macro for buffer in nm_utils_base64secret_decode()
In practice, g_free() and free() are the same. Still, avoid mixing the
APIs and use free() as plain malloc() was used to allocate the buffer.
2020-05-19 18:07:31 +02:00