Commit graph

31187 commits

Author SHA1 Message Date
Fernando Fernandez Mancera
401f153dfb 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)
(cherry picked from commit 43f244ef2e)
2023-10-04 12:02:21 +02:00
Fernando Fernandez Mancera
04ef92fc12 Revert "bond,bridge,team: use uuid for con.master when generating connection"
This reverts commit 836d7511e8.
2023-10-04 12:01:12 +02:00
Fernando Fernandez Mancera
8c0f262549 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)
(cherry picked from commit 5ca93db692)
2023-07-13 13:27:12 +02:00
Thomas Haller
cf5d8a41e3 libnm: merge branch 'th/connection-get-setting-cleanup'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1618

(cherry picked from commit 20cf4ff31a)

(cherry picked from commit 4f6ba7f601)
2023-07-13 13:27:04 +02:00
Thomas Haller
c2cf898c19 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)
(cherry picked from commit 10e493bbe8)
2023-07-13 13:27:04 +02:00
Thomas Haller
1cd4f675c8 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)
(cherry picked from commit 50b6c2d622)
2023-07-13 13:27:04 +02:00
Thomas Haller
58fd65c37e 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)
(cherry picked from commit eebbd36270)
2023-07-13 13:27:04 +02:00
Thomas Haller
3922761238 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)
(cherry picked from commit c194db5755)
2023-07-13 13:27:04 +02:00
Beniamino Galvani
9cb9dfa77b 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)
(cherry picked from commit 2ddb4e5942)
2023-06-29 15:20:47 +02:00
Thomas Haller
a33c4c1f51
ppp: merge branch 'th/pppd-so-rename'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1312

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

(cherry picked from commit 6f9f90417e)

(cherry picked from commit 695b60a6cc)
2023-06-28 13:25:10 +02:00
Thomas Haller
5b421193fe
ppp/autotools: add missing check for symbols of libnm-ppp-plugin
(cherry picked from commit 0a7145a061)
(cherry picked from commit 8083bf1c7d)
2023-06-28 13:25:09 +02:00
Thomas Haller
21f96f7357
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)
(cherry picked from commit 1c736a44b4)
2023-06-28 13:25:09 +02:00
Thomas Haller
de39f67d72
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)
(cherry picked from commit 65756dca7f)
2023-06-28 13:25:09 +02:00
Gris Ge
2695396939 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)
(cherry picked from commit 18ce5f43bd)
2023-06-27 19:57:55 +08:00
Thomas Haller
533310ca09
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)
(cherry picked from commit e06432cc7f)
2023-06-13 16:00:08 +02:00
Thomas Haller
edf23f434e
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)
(cherry picked from commit c66ae93415)
2023-06-13 16:00:04 +02:00
Thomas Haller
d2e1c8bee0
cloud-setup: merge branch 'th/cloud-setup-fix-cancellation'
https://bugzilla.redhat.com/show_bug.cgi?id=2207812

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

(cherry picked from commit 7e6a6dd275)

(cherry picked from commit 268819367e)
2023-06-12 11:20:11 +02:00
Thomas Haller
5cc38d1c6b
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)
(cherry picked from commit 98be3dd5ac)
2023-06-12 11:20:10 +02:00
Thomas Haller
fe243025e5
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)
(cherry picked from commit 0a033798ac)
2023-06-12 11:20:10 +02:00
Thomas Haller
b0ba72b4ac
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)
(cherry picked from commit 707febe83b)
2023-06-12 11:19:56 +02:00
Thomas Haller
d008eb154e
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)
(cherry picked from commit f578051b40)
2023-06-12 10:44:40 +02:00
Thomas Haller
9e92709ca8
platform/tests: fix infiniband_partition_delete() in fake platform
Fixes: 9c323261ea ('platform: use nm_utils_new_infiniband_name()')
(cherry picked from commit 6b28c2867b)
(cherry picked from commit 26e789bdcf)
2023-06-08 10:46:18 +02:00
Thomas Haller
beb83e8e38
cloud-setup: fix _aliyun_base() initializing base URL
Fixes: f3404435a9 ('cloud-setup: configure secondary ip in Aliyun cloud')
(cherry picked from commit 62104477c3)
(cherry picked from commit c6977592c3)
2023-06-08 10:46:18 +02:00
Thomas Haller
b96980b129
ppp: merge branch 'th/ppp25'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1272
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1558

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

(cherry picked from commit 5df19f5b26)

(cherry picked from commit d4b1cb7276)
2023-06-05 11:44:56 +02:00
Thomas Haller
a45806f982
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)
(cherry picked from commit facd2ae916)
2023-06-05 11:44:56 +02:00
Eivind Næss
cc1771cfef
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)
(cherry picked from commit 521f936567)
2023-06-05 11:44:55 +02:00
Eivind Næss
f19c9d2097
build: detect pppd version via pkg-config for PPPD_PLUGIN_DIR
Ppp 2.5 adds a pkg-config file, so we can detect the version.
Use it.

[thaller@redhat.com: split out patch]

(cherry picked from commit 0324098afa)
(cherry picked from commit 89bde5c9ca)
2023-06-05 11:44:55 +02:00
Thomas Haller
4faad49487
ifcfg: merge branch 'th/fix-ifcfg-infiniband-p-key'
https://bugzilla.redhat.com/show_bug.cgi?id=2209164

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

(cherry picked from commit 01ab5ce4a8)
(cherry picked from commit 46bf0ed6e7)
2023-06-05 11:09:22 +02:00
Thomas Haller
cb73ae3f0b
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)
(cherry picked from commit d8f7fec9e0)
2023-06-05 11:05:16 +02:00
Thomas Haller
2cc34244e1
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)
(cherry picked from commit 0b56618b19)
2023-06-05 11:04:53 +02:00
Thomas Haller
80860bcfb8
infiniband: merge branch 'th/ifcfg-infiniband-p-key-rh2209164'
https://bugzilla.redhat.com/show_bug.cgi?id=2209164

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

(cherry picked from commit d16ac4b774)
(cherry picked from commit 1b7d30a7b3)
2023-05-25 22:53:31 +02:00
Thomas Haller
a6316c61f0
ifcfg-rh: adjust infiniband p-key for later normalization when writing to file
(cherry picked from commit 82f5bff882)
2023-05-25 22:51:12 +02:00
Thomas Haller
37994cef35
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:51:12 +02:00
Thomas Haller
e0ed06edef
libnm: add nm_setting_infiniband_create_virtual_interface_name() helper
(cherry picked from commit fa05d1c169)
2023-05-25 22:47:24 +02:00
Thomas Haller
8b2612bfe6
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:47:24 +02:00
Thomas Haller
1e014d466a
libnm/docs: clarify behavior of infiniband.p-key property
(cherry picked from commit ea18e66ef6)
2023-05-25 22:47:24 +02:00
Thomas Haller
a1b73d823f
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:47:24 +02:00
Beniamino Galvani
4a13b5f522 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)
(cherry picked from commit 2976e4c3b7)
2023-05-23 21:53:54 +02:00
Beniamino Galvani
f6f1a44559 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)
(cherry picked from commit b60f0dd0a2)
2023-05-17 14:08:18 +02:00
Fernando Fernandez Mancera
ca41be98a0 tests: adjust test-gir.py to allow extra elements in section name
(cherry picked from commit 9b8220c9fa)
(cherry picked from commit 56e19bdf68)
2023-05-15 16:03:42 +02:00
Fernando Fernandez Mancera
fdedaa6c92 merge: branch 'ff/backport_1_40_bond_port' 2023-05-15 16:03:03 +02:00
Fernando Fernandez Mancera
d36620e654 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)
(cherry picked from commit 748f6388aa)
2023-05-15 16:02:01 +02:00
Fernando Fernandez Mancera
4fd186bbf6 libnm: add NM_VERSION_1_40_20 2023-05-15 15:44:46 +02:00
Fernando Fernandez Mancera
c787d22fc8 platform: add support to prio property in bond ports
(cherry picked from commit e200b16291)
(cherry picked from commit 84f17a2fbb)
2023-05-15 15:44:39 +02:00
Fernando Fernandez Mancera
ee592c02dd 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)
(cherry picked from commit 1bce7f0dec)
2023-05-15 15:44:18 +02:00
Lubomir Rintel
836d7511e8 bond,bridge,team: use uuid for con.master when generating connection
If we're generating a connection for an externally configured slave,
refer the master by the UUID instead of the device name.

This doesn't matter most of the time. However, on a checkpoint restore
we need to make sure that a connection that is unambiguously the original
master is up.

Otherwise it could happen that a different connection was activated on the
same master device and the slaves being restored don't agree on which master
connection to bring up.

I can't think of any thing that would rely on this but I've been wrong
about more serious things before.

Fixes-test: @libnm_snapshot_reattach_unmanaged_ports_to_bridge

https://bugzilla.redhat.com/show_bug.cgi?id=2125615
(cherry picked from commit dc254f90e2)
2023-05-15 15:44:09 +02:00
Beniamino Galvani
0a158141d3 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)
(cherry picked from commit 9ae85f6541)
2023-05-15 15:44:00 +02:00
Fernando Fernandez Mancera
40c523cd78 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)
(cherry picked from commit 87316737f3)
2023-05-15 15:43:54 +02:00
Thomas Haller
26ce6f5062
NEWS: belatedly mention default for ipv6.addr-gen-mode
Fixes: e6a33c04eb ('all: make "ipv6.addr-gen-mode" configurable by global default')
(cherry picked from commit 48a3682a75)
(cherry picked from commit 987f98197b)
2023-05-03 10:19:54 +02:00
Beniamino Galvani
4a81802e85 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)
(cherry picked from commit b3584ae994)
2023-04-19 10:03:59 +02:00