summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2021-06-23tools: merge branch 'fm/suppress-duplicate-line-in-stub'HEADmasterThomas Haller1-6/+2
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/891
2021-06-23tools: correct NetworkManager top object set_state functionFrederic Martinsons1-2/+2
Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2021-06-23tools: suppress duplicate state change in deactivation step of active connectionFrederic Martinsons1-4/+0
Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2021-06-23systemd: merge branch systemd into mainThomas Haller24-140/+225
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/897
2021-06-23dhcp: merge branch 'th/dhcp-factory-cleanup'Thomas Haller8-56/+44
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/896
2021-06-23dhcp/trivial: rename "NMDhcpClientFactory.experimental" to ↵Thomas Haller4-4/+6
"NMDhcpClientFactory.undocumented" It's not experimental. It's not officially documented. Rename.
2021-06-23dhcp: refactor GType handling for NMDhcpClientFactoryThomas Haller7-47/+32
In NetworkManager.conf, we can only configure one "[main].dhcp=" for both address families. Consequently, NMDhcpClientFactory represents also both address families. However, most plugins don't support IPv4 and IPv6 together. Thus, if a plugin does not support an address family, we fallback to the implementation of the "internal" plugin. Slightly rework the code how that is done. Instead of having a "get_type()" and "get_type_per_addr_family()" callback, have an IPv4 and IPv6 getter.
2021-06-23dhcp: minor cleanup of DHCP plugin factoryThomas Haller2-5/+6
2021-06-23glib-aux: merge branch 'th/fix-hash-combine-bool'Thomas Haller4-17/+38
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/903
2021-06-23glib-aux: rework NM_HASH_COMBINE_BOOLS() macro to avoid expression statementThomas Haller2-12/+8
clang 3.4.2-9.el7 dislikes expressions in the form int v; struct { typeof(({ v; })) _field; } x; error: statement expression not allowed at file scope typeof( ({ v; }) ) _field; ^ That is, if the argument to typeof() is an expression statement. But this is what nm_hash_update_val(&h, ..., NM_HASH_COMBINE_BOOLS(...)) expands to. Rework NM_HASH_COMBINE_BOOLS() to avoid the expression statement. We still have the static assertion for the size of the return type. We no longer have the _nm_hash_combine_bools_type typedef. It really wasn't needed, and the current variant is always safe without it. Fixes: 23adeed24463 ('glib-aux: use NM_VA_ARGS_FOREACH() to implement NM_HASH_COMBINE_BOOLS()')
2021-06-23std-aux: rework NM_STATIC_ASSERT_EXPR() macroThomas Haller2-5/+30
Replace NM_STATIC_ASSERT_EXPR() by NM_STATIC_ASSERT_EXPR_1() and NM_STATIC_ASSERT_EXPR_VOID(). NM_STATIC_ASSERT_EXPR_VOID() can be used as an expression that returns void (that is, a simple statement). On the other hand, NM_STATIC_ASSERT_EXPR_1() itself retuns a compile time constant of int value 1. The latter is useful, because we can use the 1 to combine static assertions in expressions that are themself compile time constants, like #define STATIC_CHECK_AND_GET(cond, value) \ (NM_STATIC_ASSERT_EXPR_1(cond) ? (value) : (value)) This is itself a compile time constant if value is a compile time constant. Also, it does the compile time check that "cond" is true.
2021-06-23libnm: merge branch 'th/setting-to-dbus-fcn'Thomas Haller36-802/+1260
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/900
2021-06-23libnm: use _nm_setting_property_define_string() for string NMSetting propertiesThomas Haller8-178/+214
2021-06-23libnm: use _nm_setting_property_define_boolean() for boolean NMSetting ↵Thomas Haller17-293/+410
properties
2021-06-23libnm: use new including_default flag and boolean getter for ↵Thomas Haller1-22/+8
"ethernet.auto-negotiate" property
2021-06-23libnm: add flag to control whether to_dbus_fcn() should handle default valuesThomas Haller3-2/+22
Usually, properties that are set to their default are not serialized on D-Bus. That is, to_dbus_fcn() returns NULL. In some cases, we explicitly want to always serialize the property. For example, if we changed behavior and the libnm default value changed. Then we want that the message on D-Bus is always clear about the used value and not rely on the default value on the receiving side.
2021-06-23libnm: extend to_dbus_fcn() property type for efficiently converting string ↵Thomas Haller5-6/+102
property
2021-06-23libnm: extend to_dbus_fcn() property type for efficiently converting boolean ↵Thomas Haller5-7/+108
property Most of our NMSetting properties are based around GObject properties, and thus the tooling to convert a NMSetting to/from GVariant consists of getting/setting a GValue. We can do better. For most of such properties we also define a C getter function, which we can call with less overhead. All we need is to hook the C getter with the property meta data. As example, implement it for "connection.autoconnect". The immediate goal of this is to reduce the overhead of to_dbus. But note that also for comparison of two properties, there is the default implementation which is used by the majority of properties. This implementation converts the properties first to GVariant (via to_dbus_fcn) and then compares the variants. What this commit also does, is to hook up the property meta data with the C-getters. This is one step towards also more efficiently compare properties using the naive C getters. Likewise, the keyfile writer use g_object_get_property(). It also could do better.
2021-06-23libnm: move gprop_to_dbus_fcn hook to NMSettInfoPropertyThomas Haller8-29/+40
For each property we have meta data in form of NMSettInfoProperty. Each meta data also has a NMSettInfoProperty.property_type (NMSettInfoPropertType). The property type is supposed to define common behaviors for properties, while the property meta data has individual properties. The idea is that several properties can share the same property-type, and that per-property meta data is part of NMSettInfoProperty. The distinction is not very strong, but note that all remaining uses of NMSettInfoPropertType.gprop_to_dbus_fcn were part of a property type that was only used for one single property. That lack of reusability hints to a wrong use. Move gprop_to_dbus_fcn to the property meta data as a new field NMSettInfoProperty.to_dbus_data. Note that NMSettInfoPropertType.gprop_from_dbus_fcn still suffers from the same problem. But the from-dbus side is not yet addressed.
2021-06-23libnm: change "nm_sett_info_propert_type_mac_address" to use gprop_type for ↵Thomas Haller4-10/+11
to_dbus_fcn()
2021-06-23libnm: change "nm_sett_info_propert_type_strdict" to use gprop_type for ↵Thomas Haller4-8/+10
to_dbus_fcn()
2021-06-23libnm: change "nm_sett_info_propert_type_dcb_au" to use gprop_type for ↵Thomas Haller4-12/+15
to_dbus_fcn()
2021-06-23libnm: add type enum for handling gprop differences in to_dbus_fcnThomas Haller3-32/+60
For GBytes, GEnum, GFlags and others, we need special converters from the default GObject properties to GVariant. Previously, those were implemented by providing a special gprop_to_dbus_fcn hook. But gprop_to_dbus_fcn should move from NMSettInfoPropertType to NMSettInfoProperty, because it's usually a per-property meta data, and not a per-property-type meta data. The difference is whether the meta data can be shared between different properties (of the same "type). In these cases, this extra information is indeed part of the type. We want to have a generic NM_SETT_INFO_PROPERT_TYPE_GPROP() property (using _nm_setting_property_to_dbus_fcn_gprop()), but then we would like to distinguish between special cases. So this was fine. However, I find the approach of providing a gprop_to_dbus_fcn in this case cumbersome. It makes it harder to understand what happens. Instead, introduce a new "gprop_type" for the different types that _nm_setting_property_to_dbus_fcn_gprop() can handle. This new "gprop_type" is extra data of the property type, so introduce a new field "typdata_to_dbus".
2021-06-23libnm: add and use NM_SETT_INFO_PROPERT_TYPE_*_INIT() macrosThomas Haller5-93/+88
The advantage is that we use similar macros for initializing the static structs like const NMSettInfoPropertType nm_sett_info_propert_type_cloned_mac_address; and the ad-hoc locations that use NM_SETT_INFO_PROPERT_TYPE(). The former exist for property types that are used more than once. The latter exist for convenience, where a property type is implemented at only one place. Also, there are few direct references to _nm_setting_property_to_dbus_fcn_gprop(). all users use NM_SETT_INFO_PROPERT_TYPE_GPROP() or NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT().
2021-06-23libnm: add and use NM_SETT_INFO_PROPERT_TYPE_DBUS() macroThomas Haller12-67/+74
2021-06-23libnm: let all property types implement to_dbus_fcn() handlerThomas Haller11-66/+100
If a property can be converted to D-Bus, then always set the to_dbus_fcn() handler. The only caller of to_dbus_fcn() is property_to_dbus(), so this means that property_to_dbus() has no more default implementation and always delegates to to_dbus_fcn(). The code is easier to understand if all properties implement to_dbus_fcn() the same way. Also, there is supposed to be a split between NMSettInfoProperty (info about the property) and NMSettInfoPropertType (the type). The idea is that each property (obviously) requires its distinct NMSettInfoProperty, but they can share a common type implementation. With NMSettInfoPropertType.gprop_to_dbus_fcn that is often violated because many properties that implement NMSettInfoPropertType.gprop_to_dbus_fcn require a special type implementation. As such, gprop_to_dbus_fcn should be part of the property info and not the property type. The first step towards that is unifying all properties to use to_dbus_fcn().
2021-06-23libnm: add NM_SETTING_PARAM_NONE defineThomas Haller1-0/+4
This completes other NM_SETTING_PARAM_* flags.
2021-06-23libnm: drop unused parameter "ignored_default" from property_to_dbus()Thomas Haller1-7/+3
2021-06-23libnm: simplify assertions for valid NMSettInfoPropertyThomas Haller1-19/+15
2021-06-23libnm: expose internal helper nm_utils_hwaddr_to_dbus()Thomas Haller2-4/+8
2021-06-23glib-aux: add NM_G_PARAM_SPEC_GET_DEFAULT_STRING() helperThomas Haller1-0/+4
2021-06-23glib-aux: add nm_g_variant_singleton_s_empty() helperThomas Haller2-0/+7
2021-06-23glib-aux: add nm_g_variant_singleton_b() helperThomas Haller2-18/+28
2021-06-22libnm/docs: better explain "connection.autoconnect{,-priority}"Thomas Haller3-7/+14
2021-06-22std-aux/glib-aux: minor cleanup of nm_ip_addr_*()/nm_utils_addr_family_*()Thomas Haller2-21/+26
- let nm_ip_addr_is_null() work for unaligned addresses. - drop redundant nm_assert_addr_family(). - move code around.
2021-06-22contrib: extend "test-create-many-device-setup.sh" scriptThomas Haller1-7/+26
2021-06-22examples: rework nm-up-many.py for ratelimiting parallel activationsThomas Haller1-174/+147
The previous implementation did some ratelimiting, namely how many parallel ActivateConnection D-Bus calls are in fly. This way we are able to kick off many parallel calls, but the activations themselves were not ratelimited. Rework the code. Now there are two rate limits (that can be set via environment variables): NUM_PARALLEL_STARTING NUM_PARALLEL_IN_PROGRESS This allows more control about how much is happening in parallel. If we are going to activate 1000 profiles, then it matters that we do things in parallel, but not everything at the same time.
2021-06-21config: merge branch 'th/config-match-lookup'Thomas Haller7-201/+270
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/894
2021-06-21config: avoid cloning string during nm_config_data_get_connection_default() ↵Thomas Haller6-172/+128
et al. NMConfigData is immutable and with the previous commit are the strings already cached internally. There is no need to clone it. Of course, the callers must not assume that the string stays alive after a config reload (SIGHUP), where the NMConfigData might change. So they are not always alive, but long enough for all callers to avoid cloning the string.
2021-06-21config: add lookup index for _match_section_infos_lookup()Thomas Haller1-13/+96
Previously, we would call g_key_file_get_string(), which requires two hash lookups (one for the group and one for the key). We can do better. Especially since NMConfigData is immutable, it's simple to build a lookup index of the values we have and then do binary search. Note that we call nm_config_data_get_connection_default() and similar API *a lot*, so this is measurable.
2021-06-21core: use nm_config_data_get_device_config_int64() for getting integer settingThomas Haller1-15/+19
2021-06-21config: add nm_config_data_get_device_config_int64() helperThomas Haller2-0/+29
2021-06-21glib-aux: cleanup nm_utils_named_value_clear_with_g_free() implementationThomas Haller1-5/+2
2021-06-21dhcp/systemd: ignore FORCERENEW requests for DHCPV4 to workaround CVE-2020-13529Thomas Haller1-0/+9
The FORCERENEW reqest was not authenticated (because neither rfc3118 nor rfc6704) is implemented. That is a potential security issue. As workaround, patch the source to ignore those requests. Note that also nettools implementation ignores FORCERENEW requests, so if there would be a need to handle them, then it would be important to improve the nettools code (which is the main implementation). The systemd DHCP plugin is no longer used by default. The user explicitly has to enable it via the undocumented "[main].dhcp=systemd" option in NetworkManager.conf. Hence, this change is probably not very important either way. See-also: https://bugzilla.redhat.com/show_bug.cgi?id=1959398 See-also: https://github.com/systemd/systemd/issues/16774 https://bugzilla.redhat.com/show_bug.cgi?id=1966123 CVE-2020-13529 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/898
2021-06-21libnm: pre-allocate buffer in _nm_sett_info_property_override_create_array()Thomas Haller2-15/+27
The buffer created here is only temporary to construct the property info by _nm_setting_class_commit_full(). We can afford to allocate more than necessary, if we thereby avoid several reallocations.
2021-06-21merge: branch 'bg/rh1820770'Beniamino Galvani7-61/+100
https://bugzilla.redhat.com/show_bug.cgi?id=1820770 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/889
2021-06-21device: prefer IPv6 not-deprecated addresses for hostname lookupBeniamino Galvani1-4/+27
In presence of a IPv6 deprecated address and a non-deprecated one, the latter will be used by kernel for new connections according to RFC 6724 section 5 (Source Address Selection). Prefer it also to lookup a hostname via reverse DNS. While at it, also prefer non-link-local addresses over link-local ones.
2021-06-21libnm-platform: add NM_PLATFORM_MATCH_WITH_ADDRSTATE_DEPRECATEDBeniamino Galvani2-6/+10
Add a new flag to match deprecated addresses. An address is deprecated when its preferred lifetime has expired but its valid lifetime has not. Address deprecation is one of the criteria for source address selection in IPv6. For IPv4 the deprecation doesn't have any real effect. Note that this commit changes the behavior of nm_ip_config_get_first_address(WITH_ADDRSTATE_NORMAL), since now deprecated addresses are not returned. However this should not impact existing callers since they either: - request a IPv6 (WITH_ADDRTYPE_LINKLOCAL | WITH_ADDRSTATE_NORMAL) address; IPv6 link-local addresses are supposed to have infinite lifetimes; or - request a IPv6 (WITH_ADDRTYPE_NORMAL | WITH_ADDRSTATE__ANY) address.
2021-06-21core: add nm_ip_config_find_first_address()Beniamino Galvani5-40/+39
Replace nm_ip6_config_find_first_address() with a version generic for IPv4 and IPv6.
2021-06-21libnm-platform: add nm_platform_ip_address_match()Beniamino Galvani3-12/+25
Replace nm_platform_ip6_address_match() with a version generic for IPv4 and IPv6.