Commit graph

16611 commits

Author SHA1 Message Date
Fernando Fernandez Mancera
43f244ef2e manager: allow controller activation if device is deactivating
When activating a port connection it will require the controller
connection is active or a valid controller device candidate is available
for activation.

One of the conditions we consider for a controller device to be a valid
candidate for the connection is that it is not active, therefore we
should also consider as valid a device that is currently deactivating.
Otherwise, we could fail during the port activation just because the
deactivation of the controller device candidate didn't finish yet.

https://bugzilla.redhat.com/show_bug.cgi?id=2125615

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1693
(cherry picked from commit fb362e0583)
2023-07-19 12:16:23 +02:00
Fernando Fernandez Mancera
5ca93db692 utils: extend connection matching function for UUID in controller
When matching two connections one might be using UUID and the other one
could be using interface-name for the controller property. When
recovering from a fresh start NM does not have any context and when
generating a connection we are using UUID as the controller.

It is always hard to guess what is the right candidate to pick but at
least something NM can do is checking if the UUID matches a connection
with the same controller interface-name. If there are no other
conflicts, then we can assume that is a good canditate to activate.

This is a follow up to `dc254f90e2b306700a0b81f7194e9b0438c62f4c`.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1684
(cherry picked from commit 5b8fdd25ab)
2023-07-13 13:23:19 +02:00
Thomas Haller
10e493bbe8 core: add nm_settings_connection_get_setting() helper
For efficiently and conveniently lookup an NMSetting from the
NMConnection inside the NMSettingsConnection.

Note that this uses the NMMetaSettingType as lookup key. That is a novel
approach, compared to lookup by name (nm_connection_get_setting_by_name())
or GType (nm_connection_get_setting()).

Using the NMMetaSettingType enum is however faster, because it does not
require resolving the name/GType first. This is perfecly fine internal API,
we should use it.

(cherry picked from commit 429cf416fd)
2023-07-13 12:25:49 +02:00
Thomas Haller
50b6c2d622 libnm: expose _nm_connection_get_setting_by_metatype() in internal header
We have several variants to get the NMSetting from an NMConnection. Some
of them are public API (nm_connection_get_setting(), nm_connection_get_setting_by_name()).

The most efficient way is lookup by NMMetaSettingType. Expose that as
internal API, so it can be used. The NMMetaSettingType is internal, but
it exists because it's a very useful enum. Allow others to make use of
it.

Also, add a static assert which prevents various wrong uses at compile
time, for example

  _nm_connection_get_setting_by_metatype(connection, NM_TYPE_SETTING_CONNECTION)

(cherry picked from commit db5946ac2f)
2023-07-13 12:25:49 +02:00
Thomas Haller
eebbd36270 libnm: cleanup redundant nm_connection_get_setting functions
Refactor and cleanup the functions to get a setting from a connection.

As the NMConnection tracks the settings in an array indexed by
NMMetaSettingType, the most direct and efficient way is to look up via
that enum.

Previously, nm_connection_get_setting_by_name() would first look up the GType
(which already involved looking up the NMMetaSettingInfo), then based on the
GType it would look up the NMMetaSettingInfo again to get the meta_type. That
is unnecessary. Directly look up the NMMetaSettingInfo, which directly
gives the meta_type.

(cherry picked from commit c60a4649b8)
2023-07-13 12:25:49 +02:00
Thomas Haller
c194db5755 libnm/trivial: rename internal connection-get-setting methods
This function will be exposed on the internal header. Rename to
_nm_connection_get_setting_by_metatype().

(cherry picked from commit 27cbf584bd)
2023-07-13 12:25:48 +02:00
Thomas Haller
8e7d94b10c core/tests: add test for nm_firewall_nft_stdio_mlag()
If only to hit some of the code paths in our test, and to have valgrind
check (some of) the code paths.

(cherry picked from commit a20d4a7a91)
2023-07-11 22:49:21 +02:00
Thomas Haller
7bb285abb7 bond: don't configure "counter" on nft rules for slb-bonding/mlag
Counters are convenient for debugging, but have a performance overhead.
Configure them only when debug logging in NetworkManager is enabled.

(cherry picked from commit 2c716f04f9)
2023-07-11 22:49:21 +02:00
Thomas Haller
4ec00efca9 glib-aux: add nmtst_assert_cmpmem() helper
g_assert_cmpmem() exists, but it does not print the actual buffer
content on test failure.  It is useful to see what actually failed in
the test output.

Also, nmtst_assert_cmpmem() prints a backslash escaped output, that you
can unescape in the terminal with `echo -e`. You can also directly copy
and paste the output to C source code.

(cherry picked from commit 3c3938406d)
2023-07-11 22:49:21 +02:00
Thomas Haller
18848c77c7 glib-aux: add NM_UTILS_STR_UTF8_SAFE_FLAG_ESCAPE_DOUBLE_QUOTE flag to escape double quotes
This is useful when printing a string for debugging. Then we can
printf("v=\"%s\"", utf8safe_escaped_text), which can be safely unescaped
with `echo -e`.

(cherry picked from commit c26a94e955)
2023-07-11 22:49:21 +02:00
Beniamino Galvani
2ddb4e5942 dns: fix tracking of best ip config
When a IP configuration has type "best", it is the configuration with
the best (lowest) metric default route for the specific address
family. Therefore, there can be only one best configuration for
address family.

When a new configuration is added as best, make sure it is the only
one for the address family.

This reverts commit 0abc14b3a0.

Fixes: 0abc14b3a0 ('core: remove unused best_ip_config_[46] field in NMDnsManager')

https://lists.freedesktop.org/archives/networkmanager/2023-June/000123.html
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1331
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1683
(cherry picked from commit 646e041523)
2023-06-29 15:17:53 +02:00
Gris Ge
18ce5f43bd setting-connection: Unblock autoconnect upon finish of Reapply
The activation of a connection will clear the block of autoconnect,
we should do the same for reapply.

Signed-off-by: Gris Ge <fge@redhat.com>
(cherry picked from commit 0486efd358)
2023-06-27 19:53:54 +08:00
Thomas Haller
1c736a44b4
ppp: fix plugin name for "rp-pppoe.so" with ppp 2.5
Between ppp 2.4.8 and 2.4.9, "rp-pppoe.so" was renamed to "pppoe.so" (and a
symlink created). Between 2.4.9 and 2.5.0, the symlink was dropped.

See-also: b2c36e6c0e

I guess, NetworkManager always meant to use ppp's "(rp-)pppoe.so"
plugin, and never the library from the rp-pppoe project.
If a user actually wants to use the plugin from rp-pppoe project, then
this is going to break.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1312

Fixes: afe80171b2 ('ppp: move ppp code to "nm-pppd-compat.c"')
(cherry picked from commit 84e21d8bbc)
2023-06-27 12:35:01 +02:00
Thomas Haller
65756dca7f
ppp: detect the ppp version in the configure script
Previously, the ppp version was only detected (and used) at one place,
in "nm-pppd-compat.c", after including the ppp headers. That was nice
and easy.

However, with that way, we could only detect it after including ppp
headers, and given the ugliness of ppp headers, we only want to include
them in "nm-pppd-compat.c" (and nowhere else).

In particular, 'nm-pppd-compat.c" uses symbols from the ppp daemon, it
thus can only be linked into a ppp plugin, not in NetworkManager core
itself. But at some places we will need to know the ppp version, outside
of the ppp plugin and "nm-pppd-compat.c".

Additionally, detect it at configure time and place it in "config.h".
There is a static assert that we are in agreement with the two ways of
detection.

(cherry picked from commit 3e66c0bde1)
2023-06-27 12:35:00 +02:00
Thomas Haller
c66ae93415
platform/tests: check errno on failure to umount() in test_netns_bind_to_path()
The umount() call failed in a test. Rework the assertion, so
we might see the errno of the problem.

(cherry picked from commit 1a0fa85397)
2023-06-13 15:59:28 +02:00
Thomas Haller
e06432cc7f
platform/tests: skip test_netns_bind_to_path() test on failure
Our copr builds start to fail, since the copr builds updated to Fedora
38 ([1]).

  ERROR: src/core/platform/tests/test-link-linux - Bail out! nm:ERROR:src/core/platform/tests/test-link.c:3486:test_netns_bind_to_path: assertion failed (nmtstp_run_command("ip netns exec " P_NETNS_BINDNAME " true") == 0): (65280 == 0)

The cause is not understood, but it seems not worth investigating.
Just skip the test.

[1] https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/KOR3HE2VHHIPDBLDLXTYRMON6JQXCHMW/#J4K5VB5SA6I5P2ZLI65OHNQ6X7SINSHA

(cherry picked from commit 8dfca3d552)
2023-06-12 12:28:04 +02:00
Thomas Haller
98be3dd5ac
cloud-setup: clear error variable in nmcs_device_reapply()
This is rather bad, because if we reach the "goto again" case,
the error variable is not cleared. Subsequently passing the
error location to nm_device_reapply_finish() will trigger a glib
warning.

Fixes: 29b0420be7 ('nm-cloud-setup: set preserve-external-ip flag during reapply')
(cherry picked from commit c70a5470be)
2023-06-12 10:40:19 +02:00
Thomas Haller
0a033798ac
cloud-setup: fix terminating in the middle of reconfiguring the system
Once we start reconfiguring the system, we need to finish on all
interfaces. Otherwise, we might reconfigure some interfaces, abort
and leave the network broken. When that happens, a subsequent run
might also be unable to recover, because we are unable to reach the
HTTP meta data service.

https://bugzilla.redhat.com/show_bug.cgi?id=2207812

Fixes: 69f048bf0c ('cloud-setup: add tool for automatic IP configuration in cloud')
(cherry picked from commit dab114f038)
2023-06-12 10:40:19 +02:00
Thomas Haller
707febe83b
device: only remember "forwarding" sysctl the first time in _dev_ipac6_start()
Fixes: 4c48301594 ('device: don't reset "net.ipv6.conf.$IFACE.forwarding"')
(cherry picked from commit 6050da93bd)
2023-06-08 15:08:12 +02:00
Thomas Haller
f578051b40
device: don't reset "net.ipv6.conf.$IFACE.forwarding"
According to systemd, IPv6 forwarding is special anyway, and they only
enable forwarding for "net.ipv6.conf.all.forwarding" ([1]).

Since commit 46e63e03af ('device: announce the managed IPv6
configuration with ipv6.method=shared') we support "ipv6.method=shared"
and enable forwarding for IPv6, on the interface. Whether that makes
sense is questionable, given [1] and the claim that setting it
per-interface is not useful.

Anyway, since that change we always reset the "forwarding" sysctl to
zero, when we don't enable shared mode. That is not right, because the
user didn't explicitly ask for that (and there is no configuration
option like systemd-networkd's "IPForward=" setting to control that).

What we instead should do, not touch/reset the sysctl, unless we really
want to.

No longer set "forwarding" to zero by default. And only restore the
previous value (_dev_sysctl_save_ip6_properties()) if we actually
changed the value to "1".

[1] b8fba0cded/src/network/networkd-sysctl.c (L79)

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/923

Fixes: 46e63e03af ('device: announce the managed IPv6 configuration with ipv6.method=shared')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1616
(cherry picked from commit 4c48301594)
2023-06-08 15:07:51 +02:00
Thomas Haller
26e789bdcf
platform/tests: fix infiniband_partition_delete() in fake platform
Fixes: 9c323261ea ('platform: use nm_utils_new_infiniband_name()')
(cherry picked from commit 6b28c2867b)
2023-06-08 10:44:42 +02:00
Thomas Haller
c6977592c3
cloud-setup: fix _aliyun_base() initializing base URL
Fixes: f3404435a9 ('cloud-setup: configure secondary ip in Aliyun cloud')
(cherry picked from commit 62104477c3)
2023-06-08 10:43:09 +02:00
Thomas Haller
facd2ae916
ppp: move ppp code to "nm-pppd-compat.c"
Using the ppp code is rather ugly.

Historically, the pppd headers don't follow a good naming convention,
and define things that cause conflicts with our headers:

  /usr/include/pppd/patchlevel.h:#define VERSION          "2.4.9"
  /usr/include/pppd/pppd.h:typedef unsigned char  bool;

Hence we had to include the pppd headers in certain order, and be
careful.

ppp 2.5 changes API and cleans that up. But since we need to support
also old versions, it does not immediately simplify anything.

Only include "pppd" headers in "nm-pppd-compat.c" and expose a wrapper
API from "nm-pppd-compat.h". The purpose is that "nm-pppd-compat.h"
exposes clean names, while all the handling of ppp is in the source
file.

(cherry picked from commit afe80171b2)
2023-06-05 11:40:19 +02:00
Eivind Næss
521f936567
ppp, adding support for compiling against pppd-2.5.0
This change does the following
* Adding in nm-pppd-compat.h to mask details regarding different
  versions of pppd.
* Fix the nm-pppd-plugin.c regarding differences in API between
  2.4.9 (current) and latet pppd 2.5.0 in master branch
* Additional fixes to the configure.ac to appropriately set defines used
  for compilation

(cherry picked from commit 8469c09a50)
2023-06-05 11:40:19 +02:00
Thomas Haller
d8f7fec9e0
ifcfg: better handle non-full-membership PKEY_ID with new PKEY_ID_NM variable
Infiniband profiles can have a p-key set. Both in kernel API
("create_child" sysctl) and in NetworkManager API, that key can range
from 0x0001 to 0xFFFF (0x8000 excluded). NetworkManager does not support
renaming the interface, so kernel always assigns the interface name
"$PHYSDEV.$PKEY_ID" (with $PKEY_ID as 4 character hex digits).

Note that the highest bit in the p-key (0x8000) is the full-membership
flag. Internally, kernel only supports full-membership so when we create
for example "ib0.00c1" and "ib0.80c1" interfaces, their actually used
p-key is in both cases 0x80c1 and you can see it with `ip -d link`.
Nonetheless, kernel and NetworkManager allow to configure the p-key
without the highest bit set, and the result differs in the interface
name.

Note that initscripts' ifup-ib0 would always internally coerce the
PKEY_ID variable to have the high bit set ([1]). It also would require
that the `DEVICE=` variable is specified and matches the expected
interface name. So both these configurations are identical and valid:

  DEVICE=ib0.80c1
  PHYSDEV=ib0
  PKEY_ID=0x80c1

and

  DEVICE=ib0.80c1
  PHYSDEV=ib0
  PKEY_ID=0x00c1

Historically, NetworkManager would also implement the same restrictions
([2], [3], [4]). That meant, not all valid NetworkManager infiniband
profiles could be expressed as  ifcfg file. For example, NetworkManager
allows to have "connection.interface-name" (`DEVICE=`) unset (which
ifup-ib and ifcfg reader did not allow). Also, NetworkManager would
allow configuring a "infiniband.p-key" without full membership flag, and
the reader would mangle that.

This caused various problems to the point that when you configure an
infiniband.p-key with a non-full-membership key, the ifcfg-rh written by
NetworkManager was invalid. Either, you could leave
"connection.interface-name" unset, but then the reader would complain
about missing `DEVICE=`. Or, we could write `DEVICE=ib0.00c1;
PKEY_ID=0x00c1`, which was invalid as we expected `DEVICE=ib0.80c1`.

This was addressed by rhbz 2122703 ([5]). The fix was to

  - not require a `DEVICE=` ([6]).
  - don't mangle the `PKEY_ID=` in the reader ([7]).

which happened in 1.41.2 and 1.40.2 (rhel-8.8).

With this change, we could persist any valid infiniband profile to ifcfg
format. We also could read back any valid ifcfg file that NetworkManager
would have written in the past (note that it could not write valid ifcfg
files previously, if the p-key didn't have the full-membership key set).

The problem is, that users were used to edit ifcfg files by hand, and
users would have files with:

  DEVICE=ib0.80c1
  PHYSDEV=ib0
  PKEY_ID=0x00c1

This files had worked before, but now failed to verify as we would
expect `DEVICE=ib0.00c1`. Also, there was a change in behavior that
PKEY_ID is now interpreted without the high bit set. This is reported as
rhbz 2209164 ([8]).

We will do several things to fix that:

1) we now normalize the "connection.interface-name" to be valid. It was
  not useful to set it anyway, as it was redundant. Complaining about a
  redundant setting, which makes little sense to configure, is not useful.
  This is done by [9].

2) we now again treat PKEY_ID= as if it had 0x8000 flag set. This was done by
  [10].

With step 1) and 2), we are able to read any existing ifcfg files out
there in the way we did before 1.41.2.

There is however one piece missing. When we now create a profile using
nmcli/libnm/D-Bus, which has a non-full-membership p-key, then the
profile gets mangled in the process.

If the user uses NetworkManager API to configure an interface and
chooses a non-full-membership p-key, then this should work the same as
with keyfile plugin (or on rhel-9, where keyfile is the default). Note
that before 1.41.2 it didn't work at all, when the user used ifcfg-rh
backend. Likely(?) there are no users who rely on creating such a profile
with nmcli/libnm/D-Bus and expect to automatically have the p-key
normalized. That didn't work before 1.41.2 and didn't behave that way
between 1.41.2 and now.

This patch fixes that by introducing a new key PKEY_ID_NM= for holding
the real p-key. Now ifcfg backend is consistent with handling infiniband
profiles, and old, hand-written ifcfg files still work as before.

There is of course change in behavior, that ifcfg files between 1.41.2
and now were interpreted differently. But that is bug 2209164 ([8]) and
what we fix here.

For now strong reasons, we keep writing the PKEY_ID to file too. It's
redundant, but that is what a human might expect there.

[1]  05333c3602/f/rdma.ifup-ib (_75)
[2]  https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/1.40.0/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c#L5386
[3]  cb5606cf1c (a7a78fccb2c8c945fd09038656ae734c1b0349ab_3493_3532)
[4]  cb5606cf1c (a7a78fccb2c8c945fd09038656ae734c1b0349ab_3493_3506)
[5]  https://bugzilla.redhat.com/show_bug.cgi?id=2122703
[6]  4c32dd9d25
[7]  a4fe16a426
[8]  https://bugzilla.redhat.com/show_bug.cgi?id=2209164
[9]  4610fd67e6
[10] f8e5e07355

(cherry picked from commit 5e3e38f291)
2023-06-05 10:59:13 +02:00
Thomas Haller
0b56618b19
ifcfg-rh/tests: add test for infiniband profile with PKEY_ID in ifcfg format
https://bugzilla.redhat.com/show_bug.cgi?id=2209164
(cherry picked from commit 0d0704eaa0)
2023-06-05 10:53:29 +02:00
Thomas Haller
8a4c0e1851
ifcfg-rh: adjust infiniband p-key for later normalization when writing to file
(cherry picked from commit 82f5bff882)
2023-05-25 22:25:11 +02:00
Thomas Haller
00c44d743f
libnm: truncate too long interface name in nm_setting_infiniband_create_virtual_interface_name()
This is the same what kernel does, when the parent name is so long
that it would result in a too long overall name.

We need that the result is still a valid interface name.

(cherry picked from commit 1009f1f11f)
2023-05-25 22:25:11 +02:00
Thomas Haller
5f097f0c96
libnm: add nm_setting_infiniband_create_virtual_interface_name() helper
(cherry picked from commit fa05d1c169)
2023-05-25 22:25:11 +02:00
Thomas Haller
30f0429d12
libnm: normalize interface-name for infiniband profiles
NetworkManager does not support changing the interface name for
infiniband interfaces. Consequently, we verify that
"connection.interface-name" is either unset or set to the expected
"$parent.$p_key".  Anything else wouldn't work anyway and is rejected as
invalid configuration. That brings problems however.

Rejecting invalid configuration seems fine at first:

  $ nmcli --offline connection add type infiniband infiniband.parent ib0 infiniband.p-key 0x8010 connection.interface-name xxx
  Error: Error writing connection: connection.interface-name: interface name of software infiniband device must be 'ib0.8010' or unset (instead it is 'xxx')

However, when we modify the p-key, we also get an error message:

  $ nmcli --offline connection add type infiniband infiniband.parent ib0 infiniband.p-key 0x8010 connection.interface-name ib0.8010 |
    nmcli --offline connection modify infiniband.p-key 5
  Error: Error writing connection: connection.interface-name: interface name of software infiniband device must be 'ib0.0005' or unset (instead it is 'ib0.8010')

It's worse, because ifcfg-rh reader will mangle the PKEY_ID with |=0x8000 to set
the full membership flag. That means, if you add a profile like

  $ nmcli --offline connection add type infiniband infiniband.parent ib0 infiniband.p-key 0x0010 connection.interface-name ib0.0010

it gets written to ifcfg-rh file. Then upon reload it's invalid (as the
interface name mismatches).

There are multiple solutions for this. For example, ifcfg-rh reader could also
mangle the connection.interface-name, so that the overall result is valid. Or
we could just not validate at all, and accept any bogus interface-name.

With this patch instead we will just normalize the invalid configuration to
make it right.

  $ nmcli --offline connection add type infiniband infiniband.parent ib0 infiniband.p-key 0x8010 connection.interface-name ib0.8010 |
    nmcli --offline connection modify infiniband.p-key 5
  ...

The downside is that this happens silently, so a user doesn't
notice that configuration is ignored:

  $ nmcli --offline connection add type infiniband infiniband.parent ib0 infiniband.p-key 0x8010 connection.interface-name foo
  ...
  interface-name=ib0.8010

This approach still seems preferable, because setting
"connection.interface-name" for infiniband profiles makes little sense,
so what we care here is to avoid problems.

(cherry picked from commit 4610fd67e6)
2023-05-25 22:25:10 +02:00
Thomas Haller
2945254e29
libnm/docs: clarify behavior of infiniband.p-key property
(cherry picked from commit ea18e66ef6)
2023-05-25 22:24:43 +02:00
Thomas Haller
76de1b7ec2
Revert "infiniband: avoid normalizing the p-key when reading from ifcfg"
Historically, initscripts' ifup-ib would set the highest bit of
PKEY_ID=. That changed and needs to be restored.

Note that it probably makes little sense to ever configure p-keys
without the highest bit set, because that flag indicates full membership
and kernel will automatically add it. At least, kernel will add the flag
for the p-key, but not for the automatically chosen interface name.

Meaning, writing 0x00f0 to create_child sysctl, results in an interface
"$parent.00f0", but `ip -d link` shows pkey 0x80f0.

As NetworkManager otherwise supports p-keys without the highest bit set,
and since that high bit is honored for the interface name, we cannot
just always add the high bit. NetworkManager always assuming the highest
bit is set, would change the interface names of existing configuration.

With this revert, when a user configures a small p-key and the profile
is stored in ifcfg-rh format, the settings backend will automatically
mangle the profile and set 0x8000. That is different from when the
profile is stored in keyfile format. Since using small p-keys is
probably an odd case, we don't try to workaround that any other way
(like that ifcfg format could represent the orignal value of the profile
and not doing such mangling, or to add the high bit throughout
NetworkManager to the p-key). It's an inconsistency, but given the
existing behaviors it seems best to stick (revert) to it.

This reverts commit a4fe16a426.

Affected versions were 1.42.2+ and 1.40.2+.

See-also: 05333c3602/f/rdma.ifup-ib (_75)

https://bugzilla.redhat.com/show_bug.cgi?id=2209164
(cherry picked from commit f8e5e07355)
2023-05-25 22:22:02 +02:00
Benjamin Berg
62a5e5eea5
wifi: fix IP address assignment by group owner
When a fixed address is assigned by the P2P group owner, then the code
would set the IPv4 configuration method to DISABLED internally. However,
this causes issues, because it means that IPv4 is considered to not have
come up internally which can cause the connection to later time out even
though it was configured properly.

As such, map this method to MANUAL in this case. The AUTO mapping
becomes then:
 * MANUAL: If the remote part is the GO and assigned an IP address
 * DHCP: If the remote part is the GO and did not assign an address
 * SHARED: If we are the GO

This fixes an issue where the connection established by GNOME Network
Displays would fail once IPv6 configuration also times out.

See-also: https://gitlab.gnome.org/GNOME/gnome-network-displays/-/issues/279

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1636
(cherry picked from commit d07383d3f3)
2023-05-23 22:16:57 +02:00
Beniamino Galvani
b60f0dd0a2 team: don't try to connect to teamd in update_connection()
In constructed(), NMDevice starts watching the D-Bus name owner or
monitoring the unix socket, and so it is always aware if teamd is
running. When it is, NMDevice connects to it and initializes
priv->tdc.

It is not useful to try to connect to teamd in update_connection()
because warnings will be generated by NM and by libteam if teamd is
not running. As explained above the connection is always initialized
when teamd is available, and so we can just check priv->tdc.

Fixes: ab586236e3 ('core: implement update_connection() for Team')

https://bugzilla.redhat.com/show_bug.cgi?id=2182029
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1631
(cherry picked from commit 93430627c2)
2023-05-17 13:36:01 +02:00
Fernando Fernandez Mancera
384b5f47e8 libnm: adjust symbol versioning of bond port prio in 1.40.20
This ABI was backported all the way to 1.42.8 and 1.40.20 and to rhel-8.9.
Move the ABI to a separate symbol version, which we have in all those
versions.

(cherry picked from commit bc0818fe13)
2023-05-15 15:34:00 +02:00
Fernando Fernandez Mancera
56e19bdf68 tests: adjust test-gir.py to allow extra elements in section name
(cherry picked from commit 9b8220c9fa)
2023-05-15 15:30:14 +02:00
Beniamino Galvani
2976e4c3b7 ipv6ll: don't regenerate the address when it's removed externally
Currently if the IPv6 link-local address is removed after it passed
DAD, NetworkManager tries to generate a new link-local address. If
this fails, which is always the case for EUI64, ipv6ll is considered
as failed and the connection can go down (depending on may-fail).

This is particularly bad for virtual interfaces because if somebody
removes the link-local address, the activation can fail and destroy
the interface, breaking all services that require it. Also, it's a
change in behavior introduced in 1.36.0.

It seems that a better approach here is to re-add the address that was
removed externally.

[bgalvani@redhat.com: since the branch is missing commit 7ca95cee15
('platform: always reconfigure IP routes even if removed externally'),
we need to set flag NM_L3CFG_CONFIG_FLAGS_FORCE_ONCE when committing
the address, otherwise it's not re-added]

Fixes: aa070fb821 ('core: add NML3IPv6LL helper')
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1622
(cherry picked from commit 53ba9f4701)
2023-05-15 11:16:52 +02:00
Fernando Fernandez Mancera
748f6388aa bonding: add support to prio property in bond ports
Add per port priority support for bond active port re-selection during
failover. A higher number means a higher priority in selection. The
primary port still has the highest priority. This option is only
compatible with active-backup, balance-tlb and balance-alb modes.

(cherry picked from commit 2f0571f193)
2023-05-08 18:08:21 +02:00
Fernando Fernandez Mancera
f499b9e026 libnm: add NM_VERSION_1_42_8 2023-05-08 17:59:13 +02:00
Fernando Fernandez Mancera
84f17a2fbb platform: add support to prio property in bond ports
(cherry picked from commit e200b16291)
2023-05-08 17:40:15 +02:00
Fernando Fernandez Mancera
1bce7f0dec platform: add netlink support for bond port options
sysfs is deprecated and kernel will not add new bond port options to
sysfs. Netlink is a stable API and therefore is the right method to
communicate with kernel in order to set the link options.

(cherry picked from commit bb435674b5)
2023-05-08 17:40:08 +02:00
Beniamino Galvani
9ae85f6541 platform: rename link_change() to link_change_extra()
There are many functions to replace properties of a link
(link_set_address, link_set_mtu, link_set_name, link_change,
etc.). Eventually, they will be replaced by a function that does
everything and removes all the code duplication.

That function will be named link_change(); rename the current
link_change() to link_change_extra().

(cherry picked from commit babe2bacd3)
2023-05-08 17:39:54 +02:00
Fernando Fernandez Mancera
87316737f3 libnm: fix ifcfg variable documentation at queue-id property
The correct variable for queue-id in ifcfg is BOND_PORT_QUEUE_ID.

(cherry picked from commit 762cd06ffa)
2023-05-08 17:39:46 +02:00
Thomas Haller
0d9d753523
firewall: create "dynamic" sets for nft rules for slb-bonding
A workaround for a nftables issue ([1]). I don't know why that matters.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=2177667

Fixes: e9268e3924 ('firewall: add mlag firewall utils for multi chassis link aggregation (MLAG) for bonding-slb')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1614
(cherry picked from commit d3b5496362)
2023-05-03 09:55:27 +02:00
Thomas Haller
e720f2f002 platform/tests: fix unit test creating ip6gre tunnel with old iproute2
Older versions of iproute2 don't support the "enclimit" argument. Work
around that from the unit tests.

Fixes: 1505ca3626 ('platform/tests: ip6gre & ip6gretap test cases (ip6 tunnel flags)')
(cherry picked from commit 640c82710f)
2023-04-19 23:31:28 +02:00
Beniamino Galvani
b3584ae994 device: emit dhcp-change dispatcher event also after a lease renewal
Fixes: e1648d0665 ('core: commit l3cd asynchronously on DHCP bound event')
Co-authored-by: Thomas Haller <thaller@redhat.com>

https://bugzilla.redhat.com/show_bug.cgi?id=2179537
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1609
(cherry picked from commit cab80c5129)
2023-04-19 09:48:36 +02:00
Beniamino Galvani
b2ed01efc9 device: stop activation when queueing the unmanaged state
When the unmanaged state is queued, we must ensure that the current
activation doesn't overwrite the queue stated with a new one. This can
happen for example if a dispatcher script or a firewall call
terminate, or if the next activation stage is dispatched.

Fixes-test: @preserve_master_and_ip_settings
https://bugzilla.redhat.com/show_bug.cgi?id=2178269
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1599
(cherry picked from commit 89a8f51235)
2023-04-11 09:53:01 +02:00
Beniamino Galvani
5019004bad
dhcp: reset IPv6 DAD flag on lease update
If the client was waiting for IPv6 DAD to complete and the lease was
updated or lost, `wait_ipv6_dad` needs to be cleared; otherwise, at
the next platform change the client will try to evaluate the DAD state
with a different or no lease. In particular if there is no lease the
client will try to decline it because there are no valid addresses,
leading to an assertion failure:

 ../src/core/dhcp/nm-dhcp-client.c:997:_dhcp_client_decline: assertion failed: (l3cd)

Backtrace:

  __GI_raise ()
  __GI_abort ()
  g_assertion_message ()
  g_assertion_message_expr ()
  _dhcp_client_decline (self=0x1af13b0, l3cd=0x0, error_message=0x8e25e1 "DAD failed", error=0x7ffec2c45cb0) at ../src/core/dhcp/nm-dhcp-client.c:997
  l3_cfg_notify_cb (l3cfg=0x1bc47f0, notify_data=0x7ffec2c46c60, self=0x1af13b0) at ../src/core/dhcp/nm-dhcp-client.c:1190
  g_closure_invoke ()
  g_signal_emit_valist ()
  g_signal_emit ()
  _nm_l3cfg_emit_signal_notify () at ../src/core/nm-l3cfg.c:629
  _nm_l3cfg_notify_platform_change_on_idle () at ../src/core/nm-l3cfg.c:1390
  _platform_signal_on_idle_cb () at ../src/core/nm-netns.c:411
  g_idle_dispatch ()

Fixes: 393bc628ff ('dhcp: wait DAD completion for DHCPv6 addresses')

https://bugzilla.redhat.com/show_bug.cgi?id=2179890
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1594
(cherry picked from commit 24461954d0)
2023-04-06 18:38:50 +02:00
Thomas Haller
92f22c013e core: fix setting non-blocking FD in nm_utils_spawn_helper()
Fixes: df1d214b2e ('clients: polkit-agent: implement polkit agent without using libpolkit')
(cherry picked from commit 20bd6b6803)
2023-04-06 13:02:33 +02:00
Thomas Haller
f91ccd984f core: fix setting FD flags in _rfkill_update_system()
F_SETFL will reset the flags. That is wrong, as we only want to add
O_NONBLOCK flag and leaving the other flags alone. Usually, we would
need to call F_GETFL first.

Note that on Linux, F_SETFL can only set certain flags, so the
O_RDWR|O_CLOEXEC flags were unaffected by this. That means, most likely
there are no other flags that our use of F_SETFL would wrongly clear.
Still, it's ugly, because it's not obvious whether there might be other
flags.

Avoid that altogether, by setting the flag already during open().

Fixes: 67e092abcb ('core: better handling of rfkill for WiMAX and WiFi (bgo #629589) (rh #599002)')
(cherry picked from commit 62a85fa845)
2023-04-06 13:02:33 +02:00