Commit graph

28913 commits

Author SHA1 Message Date
Thomas Haller 641f4473b7
build: fix calling test "check-local-devices-ovs" to check OVS device plugin 2021-07-26 15:30:10 +02:00
Thomas Haller f57679dd93
all: use nm_g_idle_add() instead of g_idle_add()
g_idle_add() is discouraged, because we shouldn't use guint source
IDs.
2021-07-26 15:30:09 +02:00
Thomas Haller a99ac7ccd8
glib-aux: add nm_g_idle_add()
g_idle_add() is discouraged, and the checkpatch.pl script warns
about it.

Sometimes there is a legitimate use of it, when you want to always
schedule an idle action (without intent to cancel or track it). That
makes more sense for g_idle_add() than it does for g_timeout_add(),
because a timeout really should be tracked and cancelled if necessary.

Add a wrapper to rename the legitimate uses. This way, we can avoid the
checkpatch.pl warnings, and can grep for the remaining illegitimate uses.
2021-07-26 15:30:04 +02:00
Beniamino Galvani 9060c14ccf initrd: support infiniband pkeys
Introduce a new "ib.pkey=<parent>.<pkey>" command line argument to
create a Infiniband partition.

The new connection has IPv4 and IPv6 enabled by default. Unlike for
VLANs, the generator doesn't create a connection for the parent
Infiniband interface.

See also: https://github.com/dracutdevs/dracut/pull/1538

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/884
2021-07-26 14:56:18 +02:00
xiangnian 109d561bed wifi: change auth-alg form "open" to NULL when authentication is wpa3
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/931
2021-07-26 10:58:09 +02:00
Thomas Haller 8887358383
libnm: merge branch 'th/setting-more-direct'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/933
2021-07-23 19:53:16 +02:00
Thomas Haller c1157d73ad
libnm: add from_dbus_fcn for direct NMSettingIPConfig.gateway property 2021-07-23 17:02:04 +02:00
Thomas Haller e6562493ef
libnm: add from_dbus_fcn for direct properties
There is a quest to move away from the GObject/GValue based setters.
Add _nm_setting_property_from_dbus_fcn_direct(), which can parse
the GVariant and use the direct_type to set the property.

Note that for backward compatibility, we still need
_nm_property_variant_to_gvalue() to convert alternative GVariant
types to the destination value. This means, as before, on the D-Bus
API a property of a certain type can be represented as various D-Bus
types.
2021-07-23 17:02:04 +02:00
Thomas Haller ed8e098c30
libnm: add from_dbus_fcn for direct mac-address properties 2021-07-23 17:02:04 +02:00
Thomas Haller 525b7e2a58
libnm: add _nm_property_variant_to_gvalue() helper 2021-07-23 17:02:03 +02:00
Thomas Haller 6d07afaa8d
libnm: implement special setter for direct string property for ip address
This is a normalization employed by NMSettingIPConfig.gateway.

Also rework NMSettingIPConfig.set_property() to no longer assert against
valid input. We want to pass there untrusted strings from D-Bus,
asserting is a horrible idea. Instead, either normalize the string or
keep the invalid text that will be rejected by verify().
2021-07-23 17:02:03 +02:00
Thomas Haller 0c7286a855
libnm: implement special setter for direct string property for mac address 2021-07-23 17:02:03 +02:00
Thomas Haller 96657b1556
libnm: implement special setter for direct string property via g_ascii_strdown() 2021-07-23 17:02:03 +02:00
Thomas Haller d5f08f4a1e
libnm: use direct properties for NMSettingTun 2021-07-23 17:02:03 +02:00
Thomas Haller de13b9eec1
libnm: use direct properties for NMSettingConnection 2021-07-23 17:02:02 +02:00
Thomas Haller 932ba13592
libnm: use direct properties for NMSettingOvsPort 2021-07-23 17:02:02 +02:00
Thomas Haller 6cc3b00060
libnm: use direct properties for NMSettingWpan 2021-07-23 17:02:02 +02:00
Thomas Haller b688fc3da4
libnm: use direct properties for NMSettingBluetooth 2021-07-23 17:02:02 +02:00
Thomas Haller e399fda04c
libnm: add nm_sett_info_propert_type_direct_int32 property type 2021-07-23 17:02:02 +02:00
Thomas Haller 82e9f43289
libnm: add nm_sett_info_propert_type_direct_mac_address
A MAC address is a relatively common "type". The GObject property is of type string,
but the D-Bus type is a bytestring ("ay"). We will need a special NMSettInfoPropertType.

Note that like most implementations, the from-dbus implementation still is based
on GObject setters. This will change in the future.

Also note that the previous compare function was
_nm_setting_property_compare_fcn_default(). That is, it used to convert
the property to GVariant and compare those. The conversion to GVariant
in that case normalizes the string (e.g. it is case insensitive). Also,
only properties could be compared which were also convertible to D-Bus
(which is probably fine, because there is no guarantee the profiles that
don't verify can be compared).

The code now uses the direct comparison of the strings. That mostly
preserves the case-insensitivity of the previous comparison, because
the property setters for mac addresses all use
_nm_utils_hwaddr_canonical_or_invalid() to normalize the strings.
This is subtle, but still correct. Note that this will improve later,
by ensuring that the property setters for mac addresses automatically
perform the right normalization.
2021-07-23 17:02:01 +02:00
Thomas Haller dc2e4d04f1
libnm: normalize mac-address properties in GObject property setter
The aim is that properties have a "type", that is, that similar
properties share a common behavior and appearance.

Most properties of type "mac-address" normalize the string in the
GObject property setter. Three don't. Let them also do that.

This is also relevant, because the compare function for mac-addresses
(_nm_setting_property_compare_fcn_default()) converts the properties
first to a "ay" GVariant. Which means the comparison is case
insensitive. Normalizing the values in the setter avoids that
inconsistency.
2021-07-23 17:02:01 +02:00
Thomas Haller abf5d01583
glib-aux: add NM_G_PARAM_SPEC_GET_DEFAULT_INT() helper 2021-07-23 17:02:01 +02:00
Thomas Haller faf315148b
cloud-setup,glib-aux: merge branch 'th/cloud-setup-logging'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/937
2021-07-23 16:49:20 +02:00
Thomas Haller 443f348776
glib-aux: use nm_vsprintf_buf_or_alloc() to stack allocate logging message in _nm_log_simple_printf()
Also take the timestamp first.
2021-07-23 16:43:37 +02:00
Thomas Haller 6c030ed923
glib-aux,cloud-setup: add _nm_logging_enabled*() helper API
Will also be used outside of nm-cloud-setup.
2021-07-23 16:43:37 +02:00
Thomas Haller 32b2d15021
cloud-setup: link with libnm-log-null 2021-07-23 16:43:36 +02:00
Thomas Haller 391d714b19
cloud-setup: use _nm_log_simple_printf() for plain logging 2021-07-23 16:43:36 +02:00
Thomas Haller 764ca7462f
glib-aux: add _nm_log_simple_printf() helper 2021-07-23 16:43:36 +02:00
Thomas Haller 22d6be54f3
initrd: fix handling "ip=single-dhcp:..." in reader_parse_ip()
Fixes: bf7530ccc1 ('initrd: honor "ip=single-dhcp" option as alias for "dhcp"')
2021-07-23 11:36:41 +02:00
Thomas Haller bf7530ccc1
initrd: honor "ip=single-dhcp" option as alias for "dhcp"
This mode was added to network-legacy in [1]. NetworkManager anyway always
does DHCP in parallel, so this is basically an alias for "dhcp".
Note that network-legacy's "single-dhcp" will stop waiting for DHCP
once the first device gets an address. NetworkManager currently cannot
do that. While it runs DHCP in parallel, all devices need to settle
and there is no concept where completing one device makes the overall
"startup complete" process finish early. That could however be added.

Anyway, while not being exactly the same, it's still more useful to do
something similar instead of not working at all.

See-also: https://github.com/dracutdevs/dracut/pull/853
See-also: https://github.com/dracutdevs/dracut/pull/961
See-also: https://github.com/dracutdevs/dracut/pull/1048

[1] 4026cd3b01
2021-07-23 11:06:06 +02:00
Thomas Haller cf1b726157
gitlab-ci: regenerate ci-templates's containers 2021-07-21 10:11:55 +02:00
Thomas Haller 4ad4db6cf1
core: merge branch 'th/external-routes-no-sync'
https://bugzilla.redhat.com/show_bug.cgi?id=1979192

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/935
2021-07-21 09:57:30 +02:00
Thomas Haller 13d749942f
platform: don't add routes that are tracked as external routes
Due to something that really should be fixed, NetworkManager merges the routes
that it wants to configure, with the routes that are configured externally.
This includes a subtract and merge dance, which is wrong.

Anyway. If we are in nm_platform_ip_route_sync(), then we never want to
actively configure a route, that we only have in the list because it is
(or was) present on the interface.

Otherwise we have a problem. Note that we make a plan which
routes/addresses to add/remove before starting. So, if we start with an
IPv4 address configured in kernel, then there is also a corresponding
local route. We would track that local route as external.
During sync, we first remove the IP address, and kernel automatically
also removes the local route. However, as we already made the plan to
keep that route, NetworkManager would wrongly configure it again.

This should fix that bug. It is anyway wrong to even try to explicitly
configure a route, that is purely in the list as being external.

https://bugzilla.redhat.com/show_bug.cgi?id=1979192#c11
2021-07-21 09:54:58 +02:00
Thomas Haller 1f1c7b82fd
platform: mark routes in NMPlatform cache as "external" 2021-07-21 09:54:58 +02:00
Thomas Haller a6649ef87b
core: preserve "is_external" route flag during _nm_ip_config_add_obj() 2021-07-21 09:54:58 +02:00
Thomas Haller dc0ac73780
platform: add is-external flag to NMPlatformIPRoute
We will need to track whether a route is externally added or not.
We maybe could use rt_source for that, but instead add a boolean flag.
2021-07-21 09:54:58 +02:00
Wen Liang f3404435a9
cloud-setup: configure secondary ip in Aliyun cloud
This is a tool for automatically configuring networking in Aliyun
cloud environment.

This add a provider implementation for Aliyun that when detected fetches
the private ip addressess and the subnet prefix of IPv4 CIDR block.

Once this information is fetched from the metadata server, it instructs
NetworkManager to add private ip addressess and subnet prefix for each
interface detected.

It is inspired by SuSE's cloud-netconfig ([1], [2]) and Aliyun Instance Metadata [3].

[1] https://www.suse.com/c/multi-nic-cloud-netconfig-ec2-azure/
[2] https://github.com/SUSE-Enceladus/cloud-netconfig
[3] https://www.alibabacloud.com/help/doc-detail/49122.htm

It is also intended to work without configuration. The main point is
that you boot an image with NetworkManager and nm-cloud-setup enabled,
and it just works.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/885

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-07-19 17:41:52 +02:00
Thomas Haller 09daf5dd92
glib-aux: add nm_g_unix_signal_add_source() helper 2021-07-19 09:25:42 +02:00
Thomas Haller 7ae2f842ae
build: merge branch 'th/build-libreadline'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/930
2021-07-19 09:11:30 +02:00
Thomas Haller 55fa00f05b
build/meson: cleanup handling of libreadline build option
- add "required:false" to dependency() and find_library(),
  otherwise autodetection will fail.

- rename variable "enable_readline" to "with_readline" for
  consistency with autotools.

- with -Dlibreadline=auto, once we detect a library, update
  "with_readline" variable to reflect the detected choice.
  This will also be printed in the summary output.
  This is also important for the nmcli check
  `assert(with_readline != 'none', 'readline ...`.
2021-07-19 09:10:43 +02:00
Thomas Haller bf86f51c9e
build: rework libreadline detection in autotools
- `m4/ax_lib_readline.m4` was already aware of "$with_readline".
  Move the entire handling of the parameter inside the AX_LIB_READLINE
  macro.
  This lets our fork of ax_lib_readline.m4 further deviate from upstream
  version, but it's already so different that this is no new problem.

- raise an error if the user requested --with-readline=libreadline|libedit
  but the library was not found.

- only allow yes|no for --with-nmcli argument. But still default to
  "yes", which will always require one libreadline library to be
  detected. In particular, don't automatically disable nmcli if
  libreadline is not available, because building without nmcli
  should be an explicit choice. That is like before.

- update the "$with_readline" variable for the "auto" case to reflect
  what was detected.
2021-07-19 09:08:06 +02:00
Thomas Haller 299117f619
all: merge branch 'th/ascii-control-chars'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/932
2021-07-19 09:06:21 +02:00
Thomas Haller cf9e7ee5aa
libnm: use nm_ascii_is_regular() in _keyfile_key_encode()
No change in behavior.
2021-07-19 09:04:49 +02:00
Thomas Haller fb3e6cb0dc
libnm: use nm_ascii_is_ctrl_or_del() in nm_utils_fixup_product_string() to preserve UTF-8
On architectures where "char" is signed, the check "ch < ' '" is also
TRUE for characters greater than 127 (that is, UTF-8 characters).

Let's preserve valid UTF-8 characters and don't clear them.

Also note that already before we filtered out invalid UTF-8 sequences,
so if we encounter here a character > 127, it is part of a valid UTF-8
sequence.
2021-07-19 09:04:49 +02:00
Thomas Haller 17bdd3a40d
libnm: fix clearing parentheses in nm_utils_fixup_product_string()
Previously, once in_parent was TRUE it was never reset, thus the
remainder of the string was cleared. That was most likely not intended.

If the intent really was to clear all the remainder, then the code could
have simply truncated the string at the first '('.
2021-07-19 09:04:49 +02:00
Thomas Haller fc2f758af5
ifcfg: also ANSIC escape DEL character in ifcfg writer
This is like using nm_ascii_is_ctrl_or_del() instead of
nm_ascii_is_ctrl() in the previous version of the patch.
We thus now always will switch to ANSIC escaping if we see
a ASCII DEL character. That is probable desirable, but either
way should not make a big difference (because we can parse
the DEL character both in regular quotation and in ANSIC quotation).

The patch is however larger, to also take the opportunity to only check
for nm_ascii_is_regular() in the "fast path". The behavior is the same
as changing nm_ascii_is_ctrl() to nm_ascii_is_ctrl_or_del().
2021-07-19 09:03:52 +02:00
Thomas Haller 6841bb1b26
ifcfg: use nm_ascii_is_ctrl() helper in shvar.c
No change in behavior.
2021-07-19 08:59:34 +02:00
Thomas Haller 4b21056fde
glib-aux: also backslash escape ASCII DEL character in nm_utils_buf_utf8safe_escape() 2021-07-19 08:59:34 +02:00
Thomas Haller 83f888054b
glib-aux: fix handling ASCII control characters in nm_utils_buf_utf8safe_escape()
On architectures where "char" is signed, the check "ch < ' '" is
also TRUE for non-ASCII characters greater than 127. This is an
easy mistake to make. Fix it by using nm_ascii_is_control() which
gets this right.

It's a bug, but possibly not too bad because unnecesarily escaping
a UTF-8 characters is not a severe problem, because the user anyway must
be prepared to unescape the string.
2021-07-19 08:59:33 +02:00
Thomas Haller 5f54270d93
libnm/tests: add test for broken behavior of nm_utils_bin_utf8safe_escape() 2021-07-19 08:59:33 +02:00