Commit graph

17991 commits

Author SHA1 Message Date
Beniamino Galvani
1905cfdbfe core: emit warning for unreachable gateways 2026-03-05 09:40:06 +01:00
Beniamino Galvani
40aa164fdd nmtui: emit warning for unreachable gateways 2026-03-05 09:40:05 +01:00
Beniamino Galvani
7765e5cc33 nmcli: emit warning for unreachable gateways 2026-03-05 09:40:05 +01:00
Beniamino Galvani
b62bbdfc3a libnm-core: add function to get a warning message for unreachable gateways
We are going to print the same warning message in different places
(the daemon, nmcli, nmtui). Add a function to return the message. Note
that the message needs to be translated in clients but not in the
daemon logs.
2026-03-05 09:40:05 +01:00
Beniamino Galvani
c7bbf9d3b3 libnm-core: add function to detect directly-unreachable gateways
nm_connection_get_unreachable_gateways() is a non-public function,
available in the daemon and clients, which detects gateways in the
static configuration that are not directly reachable.

Unreachable gateways are often the consequence of user mistakes; we
want to catch them early. In the following commits, warnings will be
emitted when a connection is created/modified/activated and has
unreachable gateways.
2026-03-05 09:35:21 +01:00
Íñigo Huguet
cdd38f7cdf nmcli: replace SLAVE for PORT, still accepting SLAVE as alias
With `nmcli -f SLAVE` the PORT column will be shown. In this case we
don't duplicate the field because it's typically shown in columns and
having duplicated columns is more annoying than a duplicated row.
2026-03-05 07:08:14 +00:00
Íñigo Huguet
c6b6c7164b libnmc: allow to define an alias to match fields to show 2026-03-05 07:08:14 +00:00
Íñigo Huguet
ff1d435096 nmcli: add BRIDGE.PORTS, TEAM.PORTS and GENERAL.CONTROLLER-PATH fields
They show the same than the old BRIDGE/TEAM.SLAVES and GENERAL.MASTER-PATH.
We missed this when we did the changes in favour of conscious language.
Instead of replacing them, we add a new field that will show the same
value with the new name. This way we avoid breaking users doing
`nmcli -f BRIDGE.SLAVES` or `nmcli ... | grep SLAVES`.
2026-03-05 07:08:14 +00:00
Beniamino Galvani
fddda02825 platform: drop ioctl fallback for finding veth's peer
The peer ifindex of a veth interface is available via netlink since
kernel 4.1 released in 2015. Drop the code that falls back to ioctl.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1881
2026-03-04 16:51:57 +00:00
Beniamino Galvani
7651ef0386 dhcp: ignore the Router option when there are Classless Static Routes
RFC 3442 says:

   If the DHCP server returns both a Classless Static Routes option and
   a Router option, the DHCP client MUST ignore the Router option.

Currently the internal client is ignoring the Router option only if
the Classless Static Routes option doesn't include a default route,
which is different from what is recommended in the RFC. Fix the behavior.

Fixes: 6adade6f21 ('dhcp: add nettools dhcp4 client')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/834
2026-03-04 15:26:11 +00:00
Lubomir Rintel
818cf77cb5 device: do not set MTU twice in stage3
The pair of _commit_mtu() calls in activate_stage3_ip_config() are very
heavily commented, but it is still not clear why would there be two of
them.

Remove one, and try to clarify the situation in an updated comment.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2231
2026-03-04 11:15:01 +00:00
Jan Vaclav
d564a0c3f9 platform: track onlink flag per-nexthop for IPv4 routes
In kernel, the onlink flag (RTNH_F_ONLINK) is associated with each
nexthop (rtnh_flags) rather than the route as a whole. NM previously
stored it only per-route in NMPlatformIPRoute.r_rtm_flags, which meant
that two nexthops only differing with the onlink flag were combined
as one entry in the platform cache.

Fix this by tracking the onlink flag per-nexthop.

Resolves: https://issues.redhat.com/browse/NMT-1486
2026-03-02 10:57:56 +00:00
Rahul Rajesh
04f7ca5029 device: fix vxlan create_and_realize
Assert that remote and local will be valid in this function since it
will be verified in verify function in connection profile.
2026-02-27 16:26:16 +00:00
Vladislav Tsisyk
dbeb7fa0f6 nmtui: accept tilde in search domains
Closes #1862
2026-02-27 08:57:20 +00:00
François HORTA
03a3a449f6 vpn: set search domains
dns-search parameters set on VPN connections should be merged with
domains received through the VPN (which may be empty if the connection
sets ignore-auto-dns).

This is currently not the case because domains received by the VPN
connection are only added through nm_l3_config_data_add_domain.

If dns-search is unset, this behaves correctly because the structure
built in _mgr_configs_data_construct in src/core/dns/nm-dns-manager.c
correctly uses the domains from nm_l3_config_data_get_domains.

However if dns-search is set, nm_l3_config_data_get_searches is no
longer empty and it takes precedence because of the "n_searches > 0"
condition.
2026-02-26 16:40:59 +00:00
Beniamino Galvani
024360bffa settings: fix check on existing system secrets
The previous check was based only on the presence of a non-NULL
"existing_secrets" GVariant. That GVariant is created via:

  nm_connection_to_dbus(nm_settings_connection_get_connection(self),
                        NM_CONNECTION_SERIALIZE_WITH_SECRETS_SYSTEM_OWNED)

The function returns a GVariant containing a first-level dictionary
for each setting, even for those that doesn't contain any secrets. As
a result, the check was requiring the system.modify permission even if
there weren't any cached secrets to send to the agent.

Fix the check to actually check for the presence of any secrets in the
cached dictionary. Some connection types have a third-level
dictionary that can be empty, for example VPNs have vpn.secrets.
2026-02-25 09:05:04 +01:00
Beniamino Galvani
db0825a110 settings: accept not-saved secrets from agents without modify-system
The "modify.system" polkit permission allows a user to modify settings
for connection profiles that belong to all users.

For this reason, when an agent returns system secrets (i.e. secrets
that are going to be stored to disk), NetworkManager checks that the
agent has the modify.system permission.

If a secret has the AGENT_OWNED flag, it's stored in the agent
itself. If the secret has the NOT_SAVED flag, it will be asked to
users at the beginning of every connection attempt.

In both those cases the profile is not modified and there is no need
for the modify.system permission. Fix the check to also consider the
NOT_SAVED flag.
2026-02-24 08:46:32 +01:00
Beniamino Galvani
eff8330b57 libnm-core: add missing flags check in .to_dbus_function()
Properties that define a .to_dbus_function() as a D-Bus override, need
to return early if the flags only ask to serialize secrets.

Fixes: 7fb23b0a62 ('libnm: add NMIPRoutingRule API')
2026-02-24 08:46:32 +01:00
Rahul Rajesh
0bfb8fa89d geneve: added GENEVE device support
Support device type geneve in libnm and nmcli.
2026-02-17 15:21:03 -05:00
Rahul Rajesh
2aaf88375e geneve: add connection profile settings
Added support for the following properties in connection profile:
id (VNI), remote IPv4/IPv6, ttl, tos, df, destination port.

See IP-LINK(8) manual page with command `man 8 ip-link` for more details
on the properties. See also previous commit for nm supported attributes.

id and remote are mandatory attributes:
```
$ nmcli connection add type geneve save no
Error: 'id' argument is required.
$ nmcli connection add type geneve id 42 save no
Error: 'remote' argument is required.
```
2026-02-17 15:21:03 -05:00
Rahul Rajesh
29c8bbe21a platform: add support for GENEVE tunnels
GENEVE (Generic Network Virtualization Encapsulation) is a network
tunneling protocol that provides a flexible encapsulation format for
overlay networks. It uses UDP as the transport protocol and supports
variable-length metadata in the tunnel header.

This patch adds GENEVE tunnel to NM's platform layer:

- Add platform API functions (nm_platform_link_geneve_add,
  nm_platform_link_get_lnk_geneve)

- Netlink message parsing for the following attributes:
  * IFLA_GENEVE_ID - VNI (Virtual Network Identifier)
  IPv4 and IPv6 remote
  * IFLA_GENEVE_REMOTE
  * IFLA_GENEVE_REMOTE6
  TTL, TOS, and DF flags
  * IFLA_GENEVE_TTL
  * IFLA_GENEVE_TOS
  * IFLA_GENEVE_DF
  UDP destination port
  * IFLA_GENEVE_PORT

- Add test cases for GENEVE tunnel creation and detection with two test
  modes covering IPv4 and IPv6.

The implementation tries to follow the same patterns as other tunnel
types (GRE, VXLAN, etc.) and integrates with the existing platform
abstraction layer.
2026-02-17 15:21:03 -05:00
Rahul Rajesh
ad78bd8570 platform: expand nmp object type flags to guint64
To allow for more than 32 NMP_OBJECT_* types.
2026-02-17 15:21:03 -05:00
Beniamino Galvani
a4e30ee849 clat: print translation statistics during deactivation
Print some statistics about the translation when the connection goes
down:

  clat: stats: egress (v4 to v6): tcp 1275, udp 191, icmp 9, other 0, dropped 2; ingress (v6 to v4): tcp 1669, udp 272, icmp 0, other 0, fragment 136, dropped 0

Those counters can be used to better understand what's going wrong in
case of problems; for example, if the packets are being dropped in the
ingress path or in the egress one.
2026-02-06 17:47:33 +01:00
Beniamino Galvani
112190d09a clat: support layer3 interfaces
When running the CLAT over an interface that doesn't use the Ethernet
header, like an IP tunnel, there are some changes needed. The BPF
program must compute offsets differently. Also, the DAD packet should
not include an Ethernet header.
2026-02-06 17:47:30 +01:00
Beniamino Galvani
d7edc806b6 core: clat: add the "nm" prefix to ebpf program names
The program names are displayed in the "bpftool prog" output. It is
easier to recognize NM programs if they have the "nm" prefix.
2026-02-06 10:38:07 +01:00
Beniamino Galvani
f9b2083394 l3cd: rename "clat" to "clat_config"
The member indicates if CLAT is enabled in the configuration. Use a
clearer name.
2026-02-06 10:38:06 +01:00
Beniamino Galvani
e2cdd5c4dc build: don't require libndp >= 1.9 if CLAT is disabled
libndp >= 1.9 is only required to parse the PREF64 option needed for
CLAT. When building NM in an enviroment with an older libndp, still
allow building without CLAT support.
2026-02-06 10:38:05 +01:00
Beniamino Galvani
c86d234516 nmcli: show the CLAT state
It is useful to show that the CLAT is enabled and which addresses and
prefix it is using. Add this information to the overview and to the
device/connection output. Example:

$ nmcli
  veth0: connected to clat
          "veth0"
          ethernet (veth), 4A:37:01:56:9D:AE, sw, mtu 1500
          ip4 default
          inet4 192.0.0.5/32
          route4 default metric 101
          inet6 2002:aaaa::64d4:2932:3585:7c89/64
          inet6 fe80::c060:8caf:f69b:e41a/64
          route6 fe80::/64 metric 1024
          route6 2002:aaaa::/64 metric 101
          route6 default via fe80::871:7ff:fe14:b7b9 metric 101
          clat inet4 192.0.0.5 inet6 2002:aaaa::2c0d:1e71:ef87:fac7 pref64 64:ff9b::/96

$ nmcli connection show clat
   ...
  IP4.ADDRESS[1]:                         192.0.0.5/32
  IP4.GATEWAY:                            0.0.0.0
  IP4.ROUTE[1]:                           dst = 0.0.0.0/0, nh = 0.0.0.0, mt = 101
  IP4.CLAT-ADDRESS:                       192.0.0.5
  IP6.ADDRESS[1]:                         2002:aaaa::64d4:2932:3585:7c89/64
  IP6.ADDRESS[2]:                         fe80::c060:8caf:f69b:e41a/64
  IP6.GATEWAY:                            fe80::871:7ff:fe14:b7b9
  IP6.ROUTE[1]:                           dst = fe80::/64, nh = ::, mt = 1024
  IP6.ROUTE[2]:                           dst = 2002:aaaa::/64, nh = ::, mt = 101
  IP6.ROUTE[3]:                           dst = ::/0, nh = fe80::871:7ff:fe14:b7b9, mt = 101
  IP6.CLAT-ADDRESS:                       2002:aaaa::2c0d:1e71:ef87:fac7
  IP6.CLAT-PREF64:                        64:ff9b::/96

Note how the IPv4 CLAT address is displayed both in IP4.ADDRESS and
IP4.CLAT-ADDRESS. That's because it is also configured in kernel. The
IPv6 CLAT address is not displayed in IP6.ADDRESS because it's not
configured in kernel.
2026-02-06 10:38:04 +01:00
Beniamino Galvani
d1598a10ec libnm: support the CLAT state
Make available the CLAT state in the NMIPConfig libnm objects.
2026-02-06 10:38:03 +01:00
Beniamino Galvani
f00030d79a core: export the CLAT state over D-Bus
Export over D-Bus the CLAT state: the IPv4 and IPv6 CLAT addresses and
the NAT64 prefix.
2026-02-06 10:38:02 +01:00
Beniamino Galvani
72cb5839fc core: l3cd: store the CLAT state
In the l3cd we already stored the CLAT administrative state (whether
we want to enable it or not) and the selected PREF64. Also store the
other current CLAT parameters, so that we can export them to clients
via D-Bus.
2026-02-06 10:38:00 +01:00
Beniamino Galvani
5c041cb891 l3cfg: send DAD solicitation for the IPv6 CLAT address
As per draft-ietf-v6ops-claton-14, hosts must perform duplicate
addresses detection (DAD) on the generated CLAT IPv6 address. This is
necessary not only to avoid address collisions but also because some
networks drop traffic from addresses that have not done DAD.

Since doing true DAD adds complexity, adopt the same approach as
Android: start DAD by sending a neighbor solicitation and don't wait
for any reply. This avoids the problem with dropped traffic; it
doesn't help with collisions, but collisions are anyway very unlikely
because the interface identifier is a random 64-bit value.

 5ae193ae36/clatd/main.c (363)
2026-02-06 10:37:59 +01:00
Beniamino Galvani
6d44237ed3 ndisc: track multiple PREF64 options
Previously the NMNDisc instance always used the last received NAT64
prefix. If a network advertises multiple NAT64 prefixes,
NetworkManager would constantly flip between them.  Change this and
keep a list of valid PREF64. Most importantly, stick with the same
PREF64 unless a new one appears from a router with higher priority, or
the current PREF64 expires.
2026-02-06 10:37:58 +01:00
Beniamino Galvani
aeeb52ab66 core: log message if CLAT is enabled but not supported
If CLAT is not supported (disabled at build time) and the
configuration enables it, log a message.
2026-02-06 10:37:57 +01:00
Beniamino Galvani
de42acd3fd core: print whether CLAT support is compiled in
At startup, print whether CLAT support is compiled in; it is useful
when debugging.
2026-02-06 10:37:57 +01:00
Beniamino Galvani
f2ced1e115 l3cfg: split updating CLAT config to a separate function
Split the CLAT code from _l3cfg_update_combined_config() so that the
function can be followed more easily.
2026-02-06 10:37:57 +01:00
Beniamino Galvani
cb09291635 nmcli: fix hiding default values
A property should be hidden when it has the default value and one of the
following conditions is met:

 - nmcli is called in "overview" mode (with flag -o)
 - the property has the HIDE flag

Previously, properties with the HIDE flag were always hidden. Fix
that.
2026-02-06 10:37:56 +01:00
Jan Fooken
b4fc8550f5
man: wifi: Document connection.auth-retry for WPA connections
Remove the mentioned limitation of limiting authentication retires to
802.1X connections and add information about the introduced secret
prompting behaviour.
2026-01-28 15:46:32 +01:00
Jan Fooken
746a5902ad
wifi: use authentication retry mechanism
While NetworkManager tries it's best to determine whether a new PSK is
needed, it can still run into edge cases.  One of these edge cases is that
a device can leave the range of an access point and therefore fail a 4-way
handshake.  Because these cases can't be confidently detected, a device
which was previously connected, should try to exhaust it's authentication
retries before requesting new secrets.  This leads to less user-facing
prompts while increasing the time from PSK change to prompt.
2026-01-28 15:46:26 +01:00
Jan Fooken
6dc51ddf01
device: add public method nm_device_auth_retries_has_next
Devices don't know whether they have authentication retries left,
so they can only make decisions ad-hoc after calling
nm_device_auth_retries_try_next.

Giving devices a way to determine whether the current attempt is their
last attempt, allows them to make decisions before failing a connection.
2026-01-28 15:42:20 +01:00
Jan Fooken
a3267aaf7b
device: add private getter for property auth-retries 2026-01-28 15:42:20 +01:00
Íñigo Huguet
f849163e82 nm-version: allow to define NM_VERSION_MAX_ALLOWED alone
Previously, if NM_VERSION_MIN_REQUIRED was not defined, it defaulted to
NM_VERSION. As a consequence, if NM_VERSION_MAX_ALLOWED was defined we
got a compilation error because MAX_ALLOWED < MIN_REQUIRED.

MAX_ALLOWED is used to get compilation warnings if you unintentionally
use a libnm's symbol introduced in a newer version. MIN_REQUIRED is used
to get rid of warnings about symbol deprecations.

Libnm users may want to use MAX_ALLOWED alone, because using a too new
symbol would fail to compile with older libnm. But they might want to
get deprecation warnings as soon as possible, so they want to leave
MIN_REQUIRED empty.
2026-01-26 06:44:00 +00:00
Íñigo Huguet
36275bc51c nm-version.h: use the right value of NM_API_VERSION
After the changes in release.sh in previous commits, during development
the value of NM_VERSION will always be the next version, not the latest
released one. As a consequence, we don't need to set MICRO+1 in
NM_API_VERSION, which was a temporary workaround.
2026-01-26 06:44:00 +00:00
Beniamino Galvani
c32f0fb71f l3cfg: fix the metric of the CLAT default route
Previously the metric of the CLAT default route was set to the IPv6
route metric plus 50. Instead:

 - If there is another non-CLAT default route on the device, use the
   same metric plus 1, so that native connectivity is always
   preferred.

 - Otherwise, use the metric from the "ipv4.route-metric" property of
   the connection profile.
2026-01-24 09:45:01 +01:00
Beniamino Galvani
2c896713b8 bpf: clat: add macros for header sizes
They make the code more compact and readable.
2026-01-24 09:44:59 +01:00
Beniamino Galvani
29eb48d7f9 bpf: clat: ensure data is pulled for direct packet access
There is no guarantee that the part of the packet we want to read or
write via direct packet access is linear. From the documentation of
bpf_skb_pull_data():

  For direct packet access, testing that offsets to access are within
  packet boundaries (test on skb->data_end) is susceptible to fail if
  offsets are invalid, or if the requested data is in non-linear parts
  of the skb. On failure the program can just bail out, or in the case
  of a non-linear buffer, use a helper to make the data available. The
  bpf_skb_load_bytes() helper is a first solution to access the
  data. Another one consists in using bpf_skb_pull_data to pull in
  once the non-linear parts, then retesting and eventually access the
  data.

See: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2107#note_3288979

Reported-by: DasSkelett <dasskelett@dasskelett.dev>
2026-01-24 09:44:57 +01:00
Beniamino Galvani
0731d8f3e0 bpf: clat: drop clat_handler()
Avoid the additional function call and perform the needed checks
directly in clat_handle_v4() and clat_handle_v6(). It will make easier
to check that the packet is linear is the next commit.
2026-01-24 09:44:55 +01:00
Beniamino Galvani
2d41711033 bpf: clat: support the IPv6 fragment header
Convert IPv6 fragments into IPv4.

The PLAT fragments IPv4 packets larger than the IPv6 MTU size into
smaller IPv6 packets. The safest IPv6 MTU value to configure on a PLAT
is the minimum IPv6 MTU, 1280. Therefore, we can expect IPv6 fragments
to be quite common.
2026-01-24 09:44:53 +01:00
Beniamino Galvani
616e18e61b l3cfg: fix CLAT MTU handling
The current code takes the IPv6 MTU value from the IPv6 default
route. However, that value is always zero because NM doesn't set it
usually. Instead, it should use the IPv6 MTU sysctl value. The problem
is that at this point NM hasn't written the sysctl yet, and we need
some logic to find the actual value.

Reported-by: DasSkelett <dasskelett@dasskelett.dev>
2026-01-24 09:44:50 +01:00
Beniamino Galvani
5cbd79a9ba core: introduce separate ipv6 mtu values in l3cd
The current "ip6_mtu" field of a l3cd is the IPv6 MTU received via
RA. Rename it accordingly and introduce another "ip6_mtu_static" field
that contains the value set in the ipv6.mtu connection property. It's
not used yet, but it will be in a following commit.
2026-01-24 09:44:48 +01:00