summaryrefslogtreecommitdiff
path: root/libnm-core
Commit message (Collapse)AuthorAgeFilesLines
* libnm: check options in NMSettingEthtool.verify() in defined orderThomas Haller2020-05-221-9/+10
| | | | | | | | 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.
* libnm: remove redundant nm_setting_ethtool_*_coalesce() APIThomas Haller2020-05-222-243/+0
| | | | | | | | 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().
* libnm: deprecated nm_setting_ethtool_*_feature() APIThomas Haller2020-05-222-4/+16
| | | | These are just aliases for the more general nm_setting_option_*() API.
* all: avoid (soon to be) deprecated API instead of nm_setting_option*()Thomas Haller2020-05-221-52/+98
|
* libnm: use nm_setting_option_*() API in NMSettingEthtoolThomas Haller2020-05-221-43/+18
|
* libnm: add nm_setting_option_clear_by_name()Thomas Haller2020-05-224-29/+43
| | | | | | | | | | | | 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.
* libnm: add nm_setting_option_get_names()Thomas Haller2020-05-223-11/+10
| | | | More general purpose API for generic options of settings.
* libnm: add nm_setting_option_get_uint32(), nm_setting_option_set_uint32()Thomas Haller2020-05-224-53/+89
| | | | More general purpose API for generic options of settings.
* libnm: add nm_setting_option_set(), nm_setting_option_get_boolean(), ↵Thomas Haller2020-05-222-0/+154
| | | | | | nm_setting_option_set_boolean() More general purpose API for generic options of settings.
* libnm: add API for setting gendata options to NMSetting ↵Thomas Haller2020-05-224-18/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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.
* libnm: rename nm_setting_gendata_*() API to nm_setting_option_*()Thomas Haller2020-05-223-53/+53
| | | | | | | | | | | 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.
* libnm: drop unused internal API _nm_setting_gendata_reset_from_hash() and ↵Thomas Haller2020-05-222-71/+0
| | | | | | | | | | | | | _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.
* libnm: drop unused internal function nm_setting_gendata_get_all_values()Thomas Haller2020-05-222-29/+0
| | | | | | | | | | 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.
* libnm: verify that ethtool coalesce options "adaptive-[rt]x" are booleanThomas Haller2020-05-221-0/+13
| | | | | nm_setting_ethtool_set_coalesce() coerces the values to be either 0 or 1. Verification of NMSettingEthtool should ensure the same.
* libnm: avoid duplicate type checks in "nm-setting-ethtool.c"Thomas Haller2020-05-221-35/+43
| | | | | | | | 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.
* ethtool: add and use _NM_ETHTOOL_ID_FEATURE_AS_IDX() macroThomas Haller2020-05-221-3/+3
|
* libnm: add NMUtilsPredicateStr typedefThomas Haller2020-05-222-0/+17
| | | | | | 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.
* ethtool: add ring settingsAntonio Cardace2020-05-203-6/+231
| | | | | | | | | 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
* ethtool: refactor coalesce settings using gendata APIsAntonio Cardace2020-05-201-40/+11
| | | | https://bugzilla.redhat.com/show_bug.cgi?id=1614700
* nm-setting: use nm_setting_gendata_clear_all() to clear featuresAntonio Cardace2020-05-201-18/+2
| | | | https://bugzilla.redhat.com/show_bug.cgi?id=1614700
* nm-setting: add internal gendata API to clear value(s)Antonio Cardace2020-05-202-0/+50
| | | | | | | | 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
* nm-setting: add internal gendata API to get/set uint32Antonio Cardace2020-05-202-0/+41
| | | | https://bugzilla.redhat.com/show_bug.cgi?id=1614700
* libnm: use correct free macro for buffer in nm_utils_base64secret_decode()Thomas Haller2020-05-191-1/+1
| | | | | 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.
* libnm-core: add _nm_ip_tunnel_mode_is_layer2()Beniamino Galvani2020-05-152-3/+14
|
* shared: move _nm_utils_format_variant_attributes*() API to "shared/nm-glib-aux"Thomas Haller2020-05-142-90/+3
| | | | | This has no dependency on libnm, libnm-core, or src. Move it to the general purpose toolbox.
* tests: fix uint32 integer constants for TC_H_MAKE()Thomas Haller2020-05-141-10/+10
| | | | | | | UBSan marks these: libnm-core/tests/test-setting.c:2146:2: runtime error: left shift of 65521 by 16 places cannot be represented in type 'int' #0 0x561739bed935 in test_tc_config_qdisc libnm-core/tests/test-setting.c:2146
* libnm: don't compare invalid mac addresses as equal in nm_utils_hwaddr_matches()Thomas Haller2020-05-142-4/+13
| | | | | | | | | | | | | | By passing as length of the MAC addresses -1 for both arguments, one could get through to compare empty strings, NULL, and addresses longer than the maximum. Such addresses are not valid, and they should never compare equal (not even to themselves). This is a change in behavior of public API, but it never made sense to claim two addresses are equal, when they are not even valid addresses. Also, avoid undefined behavior with "NULL, -1, NULL, -1" arguments, where we would call memcmp() with zero length and NULL arguments. UBSan flags that too.
* shared: support stripping whitespace from nm_utils_buf_utf8safe_unescape()Thomas Haller2020-05-133-8/+8
| | | | | | | | | | | | | When parsing user input if is often convenient to allow stripping whitespace. Especially with escaped strings, the user could still escape the whitespace, if the space should be taken literally. Add support for that to nm_utils_buf_utf8safe_unescape(). Note that this is not the same as calling g_strstrip() before/after unescape. That is, because nm_utils_buf_utf8safe_unescape() correctly preserves escaped whitespace. If you call g_strstrip() before/after the unescape, you don't know whether the whitespace is escaped.
* ethtool: add coalesce settingsAntonio Cardace2020-05-133-10/+304
| | | | | | | | | This is the initial support for coalesce 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
* libnm: add comment and assertions for handling gendata based setting in ↵Thomas Haller2020-05-111-0/+11
| | | | init_from_dbus()
* all: use "int/char" instead of "gint/gchar" typedefsThomas Haller2020-05-081-1/+1
| | | | This is also recommended by our checkpatch.pl script.
* libnm: use nm_str_is_empty() in "nm-setting-match.c"Thomas Haller2020-05-081-3/+3
|
* libnm: adjust bridge defines NM_BRIDGE_VLAN_DEFAULT_PVID_DEFThomas Haller2020-05-082-3/+3
|
* libnm: adjust bridge defines NM_BRIDGE_VLAN_STATS_ENABLED_DEFThomas Haller2020-05-082-3/+4
|
* libnm: adjust bridge defines NM_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL_*Thomas Haller2020-05-082-3/+6
|
* libnm: adjust bridge defines NM_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT_*Thomas Haller2020-05-082-3/+6
|
* libnm: adjust bridge defines NM_BRIDGE_MULTICAST_SNOOPING_DEFThomas Haller2020-05-082-3/+4
|
* libnm: adjust bridge defines NM_BRIDGE_MULTICAST_QUERY_USE_IFADDR_DEFThomas Haller2020-05-082-4/+5
|
* libnm: adjust bridge defines NM_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL_*Thomas Haller2020-05-082-3/+6
|
* libnm: adjust bridge defines NM_BRIDGE_MULTICAST_QUERY_INTERVAL_*Thomas Haller2020-05-082-3/+6
|
* libnm: adjust bridge defines NM_BRIDGE_MULTICAST_QUERIER_DEFThomas Haller2020-05-082-3/+5
|
* libnm: adjust bridge defines NM_BRIDGE_MULTICAST_QUERIER_INTERVAL_*Thomas Haller2020-05-082-3/+6
|
* libnm: adjust bridge defines NM_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL_*Thomas Haller2020-05-082-3/+6
|
* libnm: adjust bridge defines NM_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL_*Thomas Haller2020-05-082-3/+6
|
* libnm: adjust bridge defines NM_BRIDGE_MULTICAST_LAST_MEMBER_COUNT_*Thomas Haller2020-05-082-3/+6
|
* libnm: adjust bridge defines NM_BRIDGE_PORT_PATH_COST_*Thomas Haller2020-05-082-4/+5
|
* libnm: adjust bridge defines NM_BRIDGE_PORT_PRIORITY_*Thomas Haller2020-05-082-4/+5
|
* libnm: adjust bridge defines NM_BRIDGE_PRIORITY_*Thomas Haller2020-05-082-3/+6
|
* libnm: adjust bridge defines NM_BRIDGE_MAX_AGE_*Thomas Haller2020-05-082-7/+7
|
* libnm: adjust bridge defines NM_BRIDGE_HELLO_TIME_*Thomas Haller2020-05-082-7/+7
|