Commit graph

17889 commits

Author SHA1 Message Date
Jan Vaclav
3a769bca67 n-acd: re-import git-subtree for 'src/n-acd'
git subtree pull --prefix src/n-acd git@github.com:nettools/n-acd.git master --squash
2025-10-22 20:09:16 +02:00
Jan Vaclav
0530af60b3 Squashed 'src/n-acd/' changes from a600afc870..6ac6f7e105
6ac6f7e105 n-acd: runtime eBPF support detection

git-subtree-dir: src/n-acd
git-subtree-split: 6ac6f7e105c06e0c352b78b5a136f87fcb5c7432
2025-10-22 20:09:16 +02:00
Jiri Slaby (SUSE)
a0482a4e35 core: nm-dns-dnsmasq: listen on ipv6 localhost too
Trying to resolve hosts using localhost errors out for ipv6 attempts:
  $ host www.seznam.cz localhost
  ;; communications error to ::1#53: connection refused
  ;; communications error to ::1#53: connection refused
  Using domain server:
  Name: localhost
  Address: 127.0.0.1#53
  Aliases:

  www.seznam.cz has address 77.75.77.222
  www.seznam.cz has address 77.75.79.222
  ;; communications error to ::1#53: connection refused
  ;; communications error to ::1#53: connection refused
  www.seznam.cz has IPv6 address 2a02:598:a::79:222
  www.seznam.cz has IPv6 address 2a02:598:2::1222
  ;; communications error to ::1#53: connection refused
  ;; communications error to ::1#53: connection refused

It's because on some distros (like openSUSE), localhost is defined both
as 127.0.0.1 and ::1.

So listen on ::1 too. This makes ipv4-switchoff easier.
/etc/resolv.conf should likely be updated to contain ::1 eventually too
(see update_dns()).

Fixes https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1188
2025-10-22 15:42:57 +02:00
Beniamino Galvani
2d438ebef8 dns: specify a temporary file name when writing no-stub-resolv.conf
Using g_file_set_contents() makes it impossible to write a proper
SELinux policy because the function creates a file with a random
suffix, and SELinux file transitions can't match on wildcards.

Use a fixed temporary file name. In this case it's fine because
/run/NetworkManager is only writable by root and NetworkManager is the
only process writing into it.
2025-10-22 09:56:39 +02:00
Beniamino Galvani
c312390932 libnm-glib-aux: add temp name argument to nm_utils_file_set_contents()
In some cases it's useful to specify the name of the temporary file to
be used.
2025-10-22 09:56:39 +02:00
Íñigo Huguet
2a63c33712 ovs: print clearer logs of the ovsdb "update" event
These lines says things like "changed a bridge", what seems to mean that
NM is doing the change. Actually, these logs indicate changes that NM is
being notified of, and they may even be external changes.

- Add the "monitor:" prefix to show that it's something that NM is
  monitoring, not doing.
- Say "bridge changed" instead of "changed a bridge", which sounds an
  action that we're doing.
- Print the bridge/port/iface name first, instead of the uuid-like key which
  is not useful for a quick look by a human.
- Print `connection=conn-uuid` instead of just `conn-uuid`, as it's not
  obvious that the uuid refers to the connection.

Before:
  ovsdb: obj[bridge:8c975244-cb0a-4add-8901-c398dcbc27d6]: changed a bridge: br-int, b1ef934d...

After:
  ovsdb: monitor: br-int: bridge changed: obj[bridge:8c975244-cb0a-4add-8901-c398dcbc27d6], connection=b1ef934d...
2025-10-22 06:07:25 +00:00
Beniamino Galvani
1e81aaa153 settings: document some data structures 2025-10-21 15:31:58 +02:00
Beniamino Galvani
c1baf09bf9 settings: ignore unsupported connections when they are loaded
In addition to rejecting new connections added via D-Bus when they are
unsupported, also ignore the existing on-disk ones.
2025-10-21 15:31:58 +02:00
Beniamino Galvani
247000deed core: reject new connections if the feature is disabled or removed
If a feature like Wi-Fi, OVS, team, etc. is disabled or no longer
supported, it is better to report an error when the connection is
added via nmcli than accepting the connection and complaining later
about a "missing plugin"; there is no plugin and the connection will
never be able to activate.

Example errors now:
  # nmcli connection add type team
  Error: Failed to add 'team-nm-team' connection: team support is disabled in this build

  # nmcli connection add type gsm
  Error: Failed to add 'gsm' connection: WWAN support is disabled in this build

  # nmcli connection add type wimax nsp 00:99:88:77:66:55
  Error: Failed to add 'wimax' connection: WiMAX is no longer supported

Note that we don't touch libnm-core (the part defining the settings
and properties), as that defines the API of NetworkManager. The API
should not change according to compile flags.
2025-10-21 15:31:58 +02:00
Antoine Lassagne
03791e8b2d Fix: unblock autoreconnect when a previously failed connection is now successful 2025-10-21 09:39:52 +00:00
Beniamino Galvani
965aa81027 device: set bridge in supplicant for 802.1X ethernet and macsec
When authenticating via 802.1X, the supplicant must be made aware of
the bridge the interface is attached to. This was already done for
wifi in commit ae31b4bf4e ('wifi: set the BridgeIfname supplicant
property when needed'). When setting the BridgeIfname property, the
supplicant opens an additional socket to listen on the bridge, to
ensure that all incoming EAPOL packets are received.

Without this patch, the initial authentication usually works because
it is started during stage2 (prepare), when the device is not yet
attached to the bridge, but then the re-authentication fails.

Note: I could reproduce the problem only when the bridge is configured
with bridge.group-forward-mask 8.

Resolves: https://issues.redhat.com/browse/RHEL-121153
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2301
2025-10-21 11:26:08 +02:00
Jan Vaclav
17efec8b06 platform: configure HSR interlink from property
Uses the `hsr.interlink` property defined in the previous
commit to configure the property in the kernel.
2025-10-08 22:52:03 +02:00
Jan Vaclav
69d0fb161e libnm: introduce hsr.interlink property
This property allows the user to optionally configure
an interlink name on a HSR interface, so that it could
serve as RedBox (Redundant Box) by connecting DAN (dual
attachment node) to SAN (single attachment node).
2025-10-08 22:52:03 +02:00
Robin Ebert
c6a6801b1e
ifcfg-rh: throw error if connection.dnssec is used 2025-10-13 11:57:54 +02:00
Robin Ebert
46306c1be0
cli: add support for connection.dnssec 2025-10-13 11:57:53 +02:00
Robin Ebert
1dcd63ab5d
core: add support for connection.dnssec 2025-10-13 11:57:53 +02:00
Robin Ebert
029f8be4c1
libnm-core: Add connection.dnssec property 2025-10-13 11:57:34 +02:00
Íñigo Huguet
93491d76ec ovs: don't remove unrelated external ports
The commit linked below introduced a bug that caused that OVS ports
added externally to NM are always deleted when we delete any OVS
interface. It affects to all externally added ports, including those
that are not related to the deleted interface and even those in
different OVS bridges.

Fix it by only modifying ports and bridges that are ascendants of the
deleted interface, leaving everything else untouched.

Note that bridges and ports still need to have at least one NM-managed
interface, otherwise they will also be purged. For example, an NM-owned
OVS bridge with 2 ports+iface, one NM-owned and one external: if we
delete the NM-owned iface, both ports and the bridge will be deleted.
For now, this is a known limitation that is not being fixed here.

Fixes: 476c89b6f2 ('ovs: only keep bridges and ports with NM interfaces attached')
2025-10-13 06:58:23 +00:00
Mary Strodl
52d08008b7
wwan: retry after no operator code
We've had a few rare instances where a modem stopped retrying
to autoconnect because it briefly didn't have an operator code.

This isn't a permanent failure, so we shouldn't abort completely
for it.
2025-10-10 08:16:57 -04:00
Christian Müller
018c5722ee Fix the exit test condition on modem state when creating the connection properties 2025-10-09 06:42:22 +00:00
Jan Vaclav
0b99629278 platform: configure HSR protocol version from property
Uses the `hsr.protocol-version` property defined in the previous
commit to configure the property in the kernel.
2025-09-30 14:28:49 +02:00
Jan Vaclav
9a2395c779 libnm: introduce hsr.protocol-version property
This property allows the user to set the protocol
version when using HSR. Currently, the property
supports two values - `2010` (referred to as HSRv0
in the kernel), and `2012` (HSRv1).
2025-09-30 14:28:48 +02:00
Michael Mokricky
820e56c5df add gsm device-uid setting to restrict the devices the connection applies to 2025-10-03 11:02:21 +00:00
Íñigo Huguet
9e0551aefd core: document CleanupType
We must do different cleanups depending on the CleanupType. Document the
meaning of the different types as it was very confusing to work on new
code without having very clear what do they mean.
2025-09-24 11:30:59 +02:00
Íñigo Huguet
48fc40e1ca core: rename unmanaged flag SLEEPING->MANAGER_DISABLED
The flag is used for both sleeping and networking disabled conditions.
This is because internally they share logic, but it's not obvious for
users and it has caused confusion in the past when investigating why
devices didn't become managed. Make it explicit that it can be because
of either reason.

It would be better to create two separate flags, actually, and it
doesn't seem complex, but better not to risk introducing bugs for that
little benefit.

Logs before:
  device (enp4s0): state change: disconnected -> unmanaged (reason 'unmanaged-sleeping' ...

Logs before:
  device (enp4s0): state change: disconnected -> unmanaged (reason 'unmanaged-nm-disabled' ...
2025-09-23 09:17:07 +02:00
Íñigo Huguet
f6d6a7e2eb core, libnm: add the "networking off" reason
When we disable networking with `nmcli networking off` the reason that
is logged is "sleeping". Explain instead that networking is disabled.

Before:
  device (lo): state change: activated -> deactivating (reason 'sleeping' ...

After:
  device (lo): state change: activated -> deactivating (reason 'networking-off' ...
2025-09-23 09:17:07 +02:00
Íñigo Huguet
3355ba9380 core: rename NM_STATE_ASLEEP to NM_STATE_DISABLED
When we do `nmcli networking off` it's shown as state "sleeping". This
is confusing, and the only reason is that we share internally code to
handle both situations in a similar way.

Rename the state to the more generic name "disabled", situation that can
happen either because of sleeping or networking off.

Clients cannot differentiate the exact reason only with the NMState value,
but better that they show "network off" as this is the most common reason
that they will be able to display. If the system is suspending, there will
be only a short period of time that they can show the state, and showing
"network off" is not wrong because that's what NM has done as a response
to suspend.

In the logs, let's make explicit the exact reason why state is changing
to DISABLED: sleeping or networking off.

Logs before:
  manager: disable requested (sleeping: no  enabled: yes)
  manager: NetworkManager state is now ASLEEP

Logs after:
  manager: disable requested (sleeping: no  enabled: yes)
  manager: NetworkManager state is now DISABLED (NEWORKING OFF)

State before:
  $ nmcli general
  STATE  ...
  asleep ...

State after:
  $ nmcli general
  STATE       ...
  network off ...
2025-09-23 09:17:03 +02:00
Beniamino Galvani
40aa27690c initrd: support setting the DHCP client-id
In some cases it is necessary to set a custom DHCP client-id during
early boot. For example, the firmware of some InfiniBand NIC uses a
48-bit MAC derived from the InfiniBand 20-byte MAC when doing
PXE. NetworkManager doesn't have any knowledge of that 48-bit MAC and
uses the full MAC as client-id, therefore getting a different lease.

Introduce a new option 'rd.net.dhcp.client-id' to specify a custom
client-id.

Resolves: https://issues.redhat.com/browse/RHEL-108454

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2277
2025-09-11 17:33:46 +02:00
Íñigo Huguet
4a46f454da core: keep empty groups from keyfile configs
When reading NetworkManager.conf and NetworkManager-intern.conf we might
need to know if a group is defined or not, even if it's empty. This is
the case, for example, for [global-dns]. If [global-dns] is defined in
NM.conf overwrites the config from NM-intern, and if it's defined in any
of them they overwrite the configs from connections.

Before this patch, defining it as an empty group was ignored:
```
[global-dns]
```

Instead, it was necessary to add at least one key-value to the group.
Otherwise the group was silently ignored.
```
[global-dns]
searches=
```

Keep empty groups so we can take better decissions about overwritting
configs from other sources.
2025-09-11 10:25:36 +00:00
Íñigo Huguet
7fb4724efa core: dns: show in D-Bus if [global-dns] is defined but empty
Clients like nmstate needs to know if the [global-dns] section is
defined or not, so they know if DNS configs from connections are
relevant or not. Expose it in D-Bus by always exposing "searches"
and "options" if it's defined, maybe as empty lists.
2025-09-11 10:25:36 +00:00
Íñigo Huguet
1cba0a3cca dns: make [global-dns] to overwrite configs from connections
According to the documentation, settings from [global-dns] (searches and
options) are always merged with those from connections. However this was
not happening if no [global-dns-domain-*] exists, in which case
connections were ignored. This happened because in the past both global
sections must de defined or undefined. When this was changed to allow
defining only [global-dns], allowing it in the function that generates
the resolv.conf file was forgotten. Fix that now.

Anyway, merging these configs doesn't make much sense. The searches and
options defined in connections probably make sense only for the nameservers
defined in that same connection.

Because of this, make the following change: if global nameservers are
defined, use searches and options from [global-dns] only, because those
defined in connections may not make sense for the global nameservers. If
[global-dns] is missing, assume an empty [global-dns] section.

Also, if no global nameservers are defined, but [global-dns] is, make
that it overwrites the searches and options defined in connections. This
is not ideal, but none of the alternatives is better and at least this
is easy to remember.

So, the resulting rules from above are:
- If [global-dns] is defined, it always overwrite searches and options
  from connections.
- If [global-dns-domain-*] is defined, it always overwrite nameservers
  from connections. It overwrites searches and options too.

Fixes: 1f0d1d78d2 ('dns-manager: always apply options from [global-dns]')
Fixes: f57a848da5 ('man: update documentation about global DNS configuration')
2025-09-11 10:25:36 +00:00
Íñigo Huguet
294131a2a4 core: dbus: accept global DNS configuration without a default domain
Since 1.44 we accept a global-dns section without any global-dns-domain
section, so users can define searches and options without defining any
global DNS servers.

When set from the D-Bus API it was still rejected. Fix it.

Fixes: 1f0d1d78d2 ('dns-manager: always apply options from [global-dns]')
2025-09-11 10:25:36 +00:00
Pradyumn Rahar
9c48bae3b2 bond: remove lacp_active option from reapply subset
NM_SETTING_BOND_OPTION_LACP_ACTIVE is flagged as BOND_OPTFLAG_IFDOWN in
the kernel and hence should not be in OPTIONS_REAPPLY_SUBSET.

Authored-by: Mohith Kumar Thummaluru <mohith.k.kumar.thummaluru@oracle.com>
Signed-off-by: Mohith Kumar Thummaluru <mohith.k.kumar.thummaluru@oracle.com>
Signed-off-by: Pradyumn Rahar <pradyumn.rahar@oracle.com>
2025-09-11 09:54:52 +00:00
Íñigo Huguet
0d3fef3bcd core: fix potential use after free
_LOGD uses 'self', so don't unref it until after the _LOGD. Discovered
by Coverity.
2025-09-11 09:47:17 +00:00
Beniamino Galvani
86c7f1ed14 libnm-core: honor secrets flags when serializing WireGuard peers to D-Bus
If "flags" indicate that only secrets should be serialized and a peer
doesn't contain any secrets, skip it. Otherwise the function would
return a non-empty result when the connection contains no secret,
which causes issues later in the agent manager.

Fixes: e148ec07d5 ('libnm: add NMWireGuardPeer and libnm support for peers')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2244
2025-09-09 16:56:26 +02:00
Beniamino Galvani
d3e4f3344e core: generalize IP reservation functions
Generalize the functions to reserve an IP address from the netns, so
that it becomes easy to define new IP ranges for different purposes.
2025-09-08 21:38:21 +02:00
Beniamino Galvani
1504d12714 core: add test for nm_netns_shared_ip_reserve() 2025-09-08 21:37:41 +02:00
Beniamino Galvani
d559f61423 libnm-client: fix memory leak
The test calls g_main_context_ref() on client_context, which must then
be unreferenced.

Fixes: 88724ff169 ('libnm: add nm_client_wait_shutdown() function for cleaning up NMClient')
2025-09-08 10:47:10 +00:00
Beniamino Galvani
5ad712974e test-client: fix quotation in expected message
With the newer glib and libc in F42 and Ubuntu devel, the
"{left,right} double quotation mark" characters are printed in the
output message. The double quotation marks are multi-byte characters
and they can't be matched using a character class []. Update the
regexp accordingly.
2025-09-08 10:47:10 +00:00
Beniamino Galvani
fcf9b60cc2 build: remove autotools leftovers 2025-09-08 10:46:44 +00:00
Beniamino Galvani
7242c478a1 manager: unrealize device again after failure
If the device was realized in _internal_activate_device() and the
activation failed to start, unrealize the device again so that it
doesn't stay around.

Fixes-test: @ovs_delete_connecting_interface

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2263
2025-09-02 10:16:58 +02:00
Íñigo Huguet
3904135150 wifi: don't recheck auto-activate on disposal
During disposal we're calling to remove_all_aps that in turns schedules
an auto-activate recheck. As the device is removed, this triggers an
assertion when trying to do the recheck.

Fix that by not scheduling the recheck.

Example of backtrace that this commits fix:
  0  __libc_do_syscall () at ../sysdeps/unix/sysv/linux/arm/libc-do-syscall.S:47
  1  0xf746e270 in __pthread_kill_implementation (threadid=<optimized out>, signo=6, no_tid=<optimized out>) at pthread_kill.c:43
  2  0xf743fbc6 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
  3  0xf7431614 in __GI_abort () at abort.c:79
  4  0xf775afea in g_assertion_message (domain=domain@entry=0x209a9f "nm", file=file@entry=0x1f7d59 "../NetworkManager-1.43.7/src/core/nm-policy.c", line=line@entry=1665,
     func=func@entry=0x1f94d9 <__func__.6> "nm_policy_device_recheck_auto_activate_schedule",
     message=message@entry=0x1d3e950 "assertion failed: (g_signal_handler_find(device, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, NM_POLICY_GET_PRIVATE(self)) != 0)")
     at ../glib-2.72.3/glib/gtestutils.c:3253
  5  0xf775b05e in g_assertion_message_expr (domain=0x209a9f "nm", file=0x1f7d59 "../NetworkManager-1.43.7/src/core/nm-policy.c", line=1665,
     func=0x1f94d9 <__func__.6> "nm_policy_device_recheck_auto_activate_schedule",
     expr=0x1f8afc "g_signal_handler_find(device, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, NM_POLICY_GET_PRIVATE(self)) != 0") at ../glib-2.72.3/glib/gtestutils.c:3279
  6  0x0005f27a in nm_policy_device_recheck_auto_activate_schedule (self=0x1d3e950, device=0x209a9f) at ../NetworkManager-1.43.7/src/core/nm-policy.c:1679
  7  0x000548ae in nm_manager_device_recheck_auto_activate_schedule (self=<optimized out>, device=<optimized out>) at ../NetworkManager-1.43.7/src/core/nm-manager.c:3113
  8  0x00070622 in nm_device_recheck_auto_activate_schedule (self=<optimized out>) at ../NetworkManager-1.43.7/src/core/devices/nm-device.c:9249
  9  0xf693aa8c in ap_add_remove (self=self@entry=0x1ceb0b0, is_adding=0, ap=<optimized out>, recheck_available_connections=0)
     at ../NetworkManager-1.43.7/src/core/devices/wifi/nm-device-wifi.c:846
  10 0xf693bcda in remove_all_aps (self=self@entry=0x1ceb0b0) at ../NetworkManager-1.43.7/src/core/devices/wifi/nm-device-wifi.c:863
  11 0xf693f83c in dispose (object=0x1ceb0b0) at ../NetworkManager-1.43.7/src/core/devices/wifi/nm-device-wifi.c:3809
  12 0xf7806e72 in g_object_unref (_object=<optimized out>) at ../glib-2.72.3/gobject/gobject.c:3636
  13 g_object_unref (_object=0x1ceb0b0) at ../glib-2.72.3/gobject/gobject.c:3553
  14 0x000f7fa4 in _nm_dbus_object_clear_and_unexport (location=location@entry=0xffa50644) at ../NetworkManager-1.43.7/src/core/nm-dbus-object.c:203
  15 0x000576e4 in remove_device (self=self@entry=0x1c9c900, device=<optimized out>, quitting=quitting@entry=1) at ../NetworkManager-1.43.7/src/core/nm-manager.c:2289
  16 0x0005a864 in nm_manager_stop (self=self@entry=0x1c9c900) at ../NetworkManager-1.43.7/src/core/nm-manager.c:7784
  17 0x00023438 in main (argc=<optimized out>, argv=<optimized out>) at ../NetworkManager-1.43.7/src/core/main.c:530

Fixes: 96f40dcdcd ('wifi/ap: explicitly unexport AP and refactor add/remove AP')
Fixes: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1791
2025-08-27 06:37:33 +00:00
Beniamino Galvani
0b03614b68 device: ensure that sw devices are unrealized after connection deletion
When a software device becomes deactivated, we check whether it can
be unrealized (= deleted in kernel), by calling function
delete_on_deactivate_check_and_schedule().

The function returns without doing anything if there is a new
activation enqueued on the device (priv->queued_act_request), because
in that case the device will be reused for the next activation.

This commit fixes a problem seen in NMCI test
@ovs_delete_connecting_interface: sometimes the device is not
unrealized after deleting the connection. That happens because if the
queued activation fails, we never try again to unrealize the device.

Fix that by calling delete_on_deactivate_check_and_schedule() when
there is a failure starting the queued activation.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2258
2025-08-26 20:51:32 +02:00
Beniamino Galvani
8b26cb35ee device: explicitly handle unrealized devices in is_available()
Unrealized software devices are always available for activation,
hardware devices never.

In nm_manager_get_best_device_for_activation() we call
nm_device_is_available() on candidate devices. Without this fix, any
unrealized software device would be not considered ready for
activation, which is wrong.

A software device can override the default implementation of
is_available(). For example NMDeviceOvsInterface does that and only
checks the OVSDB is ready.

Fixes: ba86c208e0 ('Revert "core: prevent the activation of unavailable OVS interfaces only"')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2253
2025-08-26 20:39:18 +02:00
Íñigo Huguet
b0b72dd2f1 dns: don't break existing configs with wrong separators in dns-search
The previous commit will raise an error if wrong list
separators are being used in an nmconnection file for dns-search to
avoid that they are all considered a single string.

However, existing users might have wrong values of dns-search that
currently are not preventing the connection of being activated. To avoid
that a NetworkManager update breaks existing configs, potentially even
cutting connectivity with remote machines, accept wrong separators in
keyfiles but emitting a warning.

Fixes: 919156552ede ('dns: ensure that no wrong separators are used for DNS search domains')
2025-08-26 08:59:37 +00:00
Íñigo Huguet
3266203bf1 dns: ensure that no wrong separators are used for DNS search domains
If wrong separators are used in they keyfile, like commas, the whole
line is considered as a single domain string, like "a.org,b.org".
Obviously this is invalid.

Ideally we should validate that the string is a valid domain, but this
gets quite complex if we want to support unicode characters, which are
valid for many top domains. For now, validate at least that no wrong
separators have been used.

Fixes https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1740
2025-08-26 08:59:37 +00:00
Tomas Bzatek
dce149352d nm-initrd-generator: add NBFT parser tests
This adds simple unit tests for most common NBFT deployments.
Sample data were mostly taken from the upstream libnvme repository.
2025-08-26 07:45:53 +00:00
Tomas Bzatek
592a4f077b nm-initrd-generator: fix a conn_name leak 2025-08-26 07:45:53 +00:00
Tomas Bzatek
6304d51440 nm-initrd-generator: rework NBFT HFI DHCP detection
There are several flags specified in the NVMe Boot Specification
that may indicate DHCP was used to acquire information during the
pre-OS phase. This commit considers these additional sources,
based on actual NBFT table contents from different systems.

Although we've seen slight variations in firmware implementations
regarding the HFI IP Origin values when DHCP was configured, the
new set of rules still align with expectations.
2025-08-26 07:45:53 +00:00
Beniamino Galvani
0c1fba5c95 wireguard: don't add peer routes if they duplicate prefix routes
With this configuration:

  [Interface]
  ...
  Address = 172.16.110.116/28,172.16.111.21/28

  [Peer]
  ...
  AllowedIPs = 172.16.110.112/28

  [Peer]
  ...
  AllowedIPs = 172.16.111.16/28

NetworkManager currently creates the following routes

  (1) 172.16.110.112/28 dev wg0 proto static scope link metric 50 <-- peer route
  (2) 172.16.110.112/28 dev wg0 proto kernel scope link src 172.16.110.116 metric 50 <-- prefix route
  (3) 172.16.111.16/28 dev wg0 proto static scope link metric 50 <-- peer route
  (4) 172.16.111.16/28 dev wg0 proto kernel scope link src 172.16.111.21 metric 50 <-- prefix route

If we try to reach a host in the second peer subnet, route (4)
matches. Route (4) doesn't specify a source IP and so the kernel will
use the first IP set on the interface (172.16.110.116), which is the
wrong one.

  # ip route get 172.16.111.17
  172.16.111.17 dev wg0 src 172.16.110.116 uid 0

To fix this problem, if the AllowedIP subnet is already reachable on
the interface via the prefix route of a static IP address, we should
skip adding the peer route.

wg-quick does something similar here:

  https://git.zx2c4.com/wireguard-tools/tree/src/wg-quick/linux.bash?h=v1.0.20250521#n177

The condition in wg-quick is a bit different because it checks that no
duplicate route exists on the interface. We can't do exactly the same
because in NMDeviceWireGuard we don't have visibility on all the
platform routes.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1790
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2254
2025-08-25 16:49:16 +02:00