Commit graph

33893 commits

Author SHA1 Message Date
Lubomir Rintel
548e27ef5f cloud-setup: configure disconnected wired devices on OCI
On OCI VMs (virtual machines, as opposed to BM -- bare metal), the VNICs
don't get their addresses via DHCP and need us to get the address from
the metadata and apply it.

https://issues.redhat.com/browse/NMT-1432
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2180
2025-04-11 11:44:05 +02:00
Lubomir Rintel
0540b3c9bc cloud-setup: add a chicken bit variable for creation of new connections
Make it possible to opt in or out of the behavior of creating
connections for disconnected devices. It's not clear why such policy was
in place, and the feature might come useful outside OCI.

Let's add an (undocumented) knob to configure the behavior. We might
remove it (and perhaps make the behaviour default everywhere), or
document and keep it if it turns out we need to use it.
2025-04-11 11:43:28 +02:00
Lubomir Rintel
93960639e8 cloud-setup: factor out creation of new connection
We're going to create connections on wired devices for OCI VM VNICs, and
they're going to also need the same user setting. Factor it out.
2025-04-11 11:43:20 +02:00
Lubomir Rintel
9895540a24 cloud-setup: add device argument to nmcs_add_and_activate()
This will allow us to add & complete connections for existing devices,
such as VNICs on OCI VMs.
2025-04-11 11:43:00 +02:00
Lubomir Rintel
961be7d971 cloud-setup: split up _nmc_skip_connection_by_type()
Split _nmc_skip_connection_by_type() so that we can get a little
more finely grained error reporting.
2025-04-11 11:42:54 +02:00
Íñigo Huguet
95b9b4b678 merge: branch 'ih/coverity'
Fix some defects detected by Coverity

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2174
2025-04-07 14:15:27 +00:00
Íñigo Huguet
9edfc0438c n-dhcp4: fix resource leaks
The function n_dhcp4_c_connection_send_request does not release or take
ownership of its request argument. Because of that, setting it to NULL
in the caller prevents the auto-cleanup of the variable to be executed,
causing a resource leak. Fix it.

Fixes: e23b3c9c3a ('Squashed 'shared/n-dhcp4/' content from commit fb1d43449')
Fixes: 243cc433fb ('n-dhcp4: add new client probe function to send RELEASE message')
2025-04-07 14:15:09 +00:00
Íñigo Huguet
ae7de5b353 core: fix use after free in ping operations
Detected by coverity, the ping_op pointers are used after being freed in
cleanup_ping_operations. Although calling to g_list_remove is probably
safe because it only needs the value of the pointer, not to dereference
it, better to follow best practices. One of the use after free was
actually an error because we dereference ping_op->log_domain.

Fixes: 658aef0fa1 ('connection: Support connection.ip-ping-addresses')
2025-04-07 14:15:09 +00:00
Íñigo Huguet
42edb37499 bond-slb: initialize dest hw address in GARP packets
Detected by Coverity:
    1. NetworkManager-1.53.1/src/core/nm-bond-manager.c:885:5: var_decl: Declaring variable "data" without initializer.
    7. NetworkManager-1.53.1/src/core/nm-bond-manager.c:948:13: uninit_use_in_call: Using uninitialized value "data". Field "data.d_hw_addr" is uninitialized when calling "sendto".
       946|               unaligned_write_ne32(data.s_ip_addr, tmp_addr);
       947|               unaligned_write_ne32(data.d_ip_addr, tmp_addr);
       948|->             if (sendto(sockfd, &data, sizeof(data), 0, (struct sockaddr *) &addr, sizeof(addr)) < 0)
       949|                   return FALSE;
       950|           }

Fixes: 3f2f922dd9 ('bonding: send ARP announcement on bonding-slb link/carrier down')
2025-04-07 14:15:09 +00:00
Lubomir Rintel
cc0222ba01 nmcli/connections: fix build with libedit
This has always been broken (libedit-0:3.1-17.20160618cvs.fc26 is too
old to work and libedit-0:3.1-20.20170329cvs.fc27.x86_64 has this type
mismatch), but new GCC complains (14, 15).

  ../src/nmcli/connections.c: In function ‘nmcli_editor_tab_completion’:
  ../src/nmcli/connections.c:6862:64: error: assignment to ‘void (*)(char **, int,  int)’ from incompatible pointer type ‘void (*)(void)’ [-Wincompatible-pointer-types]
   6862 |                             rl_completion_display_matches_hook = uuid_display_hook;
        |                                                                ^
  ../src/nmcli/connections.c:6909:60: error: assignment to ‘void (*)(char **, int,  int)’ from incompatible pointer type ‘void (*)(void)’ [-Wincompatible-pointer-types]
   6909 |                         rl_completion_display_matches_hook = uuid_display_hook;
        |                                                            ^

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2172
2025-04-07 15:27:59 +02:00
Herman Semenov
7ab3f0999f nm-cloud-setup: removed excess validation check fields
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2150
2025-04-07 15:25:49 +02:00
Íñigo Huguet
a4401ae0a6 merge: branch 'ih/fec-uninit-var'
core: fail early if we cannot get current FEC value

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2177
2025-04-07 11:05:25 +00:00
Íñigo Huguet
245f0e0b35 core: optimize hash table search in _ethtool_fec_set
Break the loop as soon as we've found the value.

Fixes: 19bed3121f ('ethtool: support Forward Error Correction(fec)')
2025-04-03 09:44:59 +02:00
Íñigo Huguet
cbdd0d9cca core: fail early if we cannot get current FEC value
If we cannot get current FEC value probably we won't be able to set it a
few lines later. Also, if it fails to set, we try to use the value of
the old one that we tried to retrieve without success. In that case, the
variable old_fec_mode would be uninitialized. Fix it by returning early
if we cannot get the current value.

Fixes: 19bed3121f ('ethtool: support Forward Error Correction(fec)')
2025-04-03 09:44:54 +02:00
Beniamino Galvani
355edef8b5 merge: branch 'bg/prefix-delegation'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2162
2025-04-02 17:05:57 +02:00
Beniamino Galvani
b6386b3d27 core: support prefix-delegation.subnet-id 2025-04-02 11:21:59 +02:00
Beniamino Galvani
b372caf0c4 libnm, nmcli: introduce new "prefix-delegation" setting
Introduce a new "prefix-delegation" setting. It contains properties
related to the configuration of downstream interfaces using IPv6
prefix-delegation. The only property at the moment is "subnet-id",
which specifies which prefix to choose when the delegation contains
multiple /64 networks.
2025-04-02 11:21:59 +02:00
Beniamino Galvani
4a8bedcd89 device: remove the prefix-delegation IP configuration on cleanup
When a device in IPv6 shared mode obtains a prefix, it adds a new l3cd
of type L3_CONFIG_DATA_TYPE_PD_6 for that prefix. However, that l3cd
is never removed later and so the address lingers on the interface
even after the connection goes down. Remove the l3cd on cleanup.
2025-04-02 11:18:02 +02:00
Beniamino Galvani
037b14965e libnmc-setting: add new flag for property descriptors
Add a new flag "print_hex_negative_as_base10" in the property
descriptor _NMMetaPropertyTypData.

Normally, when a property has "base = 16", it is printed as unsigned
even if the gtype is signed.

For some properties, we want to print the hexadecimal representation
for positive values, and the base10 representation with minus sign for
negative values. A typical use case is to encode the default value as
"-1" and use positive values as a hexadecimal number.
2025-04-02 11:18:02 +02:00
Beniamino Galvani
dbc4ff0a1d libnm-glib-aux: add nm_ip6_addr_get_subnet_id()
Add function nm_ip6_addr_get_subnet_id() to get the subnet ID of a
IPv6 address.
2025-04-02 11:18:02 +02:00
Beniamino Galvani
4ed1d04aff libnm-glib-aux: add nm_puint64_hash()/nm_puint64_equal()
The two new functions can be used as GHashFunc and GEqualFunc when
creating hash tables whose keys are pointers to a guint64.
2025-04-02 11:18:02 +02:00
Beniamino Galvani
0e4330f2b4 ovs: introduce new "ovs-dpdk.lsc-interrupt" property
Introduce a new "ovs-dpdk.lsc-interrupt", used to configure the Link
State Change (LSC) detection mode.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2149
2025-04-02 11:13:31 +02:00
Beniamino Galvani
4b572a1a4a device: forget about carrier deferred action when ifindex changes
When the carrier of an interface goes down, we defer the handling of
that event by some time (by default 6 seconds), to detect if the
carrier change was a spurious event.

It was observed that in some conditions the carrier goes down and we
register the timer for the deferred action on the device. Then the
link is deleted and recreated. At this point the timer fires and
aborts the new activation of the device.

Once the ifindex changes, cancel the timer for the deferred
carrier-down action.
2025-04-02 10:01:38 +02:00
Beniamino Galvani
ba86c208e0 Revert "core: prevent the activation of unavailable OVS interfaces only"
This was a workaround until the real cause of the issue was found.

This reverts commit a1c05d2ce6.
2025-04-02 10:01:38 +02:00
Wen Liang
40ddff9cc9 merge: branch 'wl/per_iface_ip_forward'
ip-config: Support configuring per-device IPv4 sysctl forwarding option

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2071
2025-04-01 13:43:11 +00:00
Wen Liang
2ad5fbf025 policy: refresh IPv4 forwarding after connection activation and disconnection
Previously, IPv4 shared method will automatically enable the IPv4
global forwarding, all the per-interface level IPv4 forwarding settings
may be changed to match the global setting. Also, all the per-inteface
level forwarding settings can not be restored when deactivating the
shared connection. This is problematic as it may disrupt custom
configurations and lead to inconsistent forwarding behavior across
different network interfaces.

To address this, the implementation now ensures that the original
per-interface forwarding settings are preserved. Upon activating a
shared connection, instead of enabling IPv4 global forwarding
automatically, the per-interface forwarding is enabled on all other
connections unless a connection explicitly has the forwarding set to
"no" in its configuration. Upon deactivating all shared connection,
per-interface forwarding settings are restored to sysctl's default
value. Furthermore, deactivating any connection explicitly sets the
forwarding to sysctl's default value ensuring that network forwarding
behavior remains consistent.
2025-04-01 09:32:46 -04:00
Wen Liang
a8a2e6d727 ip-config: Support configuring per-device IPv4 sysctl forwarding option
Add support for configuring per-interface IPv4 sysctl forwarding setting
in NetworkManager. The feature allows users to configure the
net.ipv4.conf.<interface>.forward setting directly through
NetworkManager, enabling targeted forwarding configurations for
interfaces. This is particularly useful for cases such as enabling
forwarding for MetalLB load balancing without requiring a global
ip_forward=1 setting.

While forwarding setting can be managed via /etc/sysctl.conf,
configuring sysctl options for dynamically created or
software-configured interfaces (e.g., bridges) poses challenges. With
this feature, NetworkManager can configure these settings when
interfaces are created or updated, users no longer need to rely on
nm-dispatcher scripts for per-interface sysctl configuration, which can
be error-prone and complex. This feature ensures a more seamless and
integrated way to manage per-interface forwarding configurations,
reducing user overhead and improving usability in complex network
setups.

We do not support configuring per-device IPv6 sysctl forwarding because
in order to make per-device IPv6 sysctl forwarding work, we also need to
enable the IPv6 global sysctl forwarding setting, but this has potential
security concerns because it changes the behavior of the system to
function as a router, which expose the system to new risks and
unintended traffic flows, especially when enabling forwarding on the
interface the user previously explicitly disabled. Also enabling
per-device IPv6 sysctl setting will change the behavior of router
advertisement (accept_ra), which is not expected. Therefore, we
only support configuring per-device IPv4 sysctl forwarding option in
NetworkManager.

Resolves: https://issues.redhat.com/browse/RHEL-60237
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2071
https://gitlab.freedesktop.org/NetworkManager/NetworkManager-ci/-/merge_requests/1833
2025-04-01 09:32:46 -04:00
Jan Vaclav
5e17b52810 merge: branch 'jv/wg-nftables'
wireguard: add connmark and filtering firewall rules

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2158
2025-04-01 08:09:17 +00:00
Jan Vaclav
2106251e46 firewall/utils: replace ipv4 iptables macro with ipxtables macro 2025-04-01 08:08:52 +00:00
Jan Vaclav
18d5b7d641 firewall/utils: remove _share prefix from iptables_get_name
It's no longer used just for shared mode.
2025-04-01 08:08:52 +00:00
Jan Vaclav
a769c17af7 firewall/wireguard: drop packets received to wrong interface
If we receive a packet sent to the WG interface's address,
but it does not come from the WG tunnel, let's assume something
is broken and drop the packet.

This is also inspired by wg-quick firewall rules:
https://git.zx2c4.com/wireguard-tools/tree/src/wg-quick/linux.bash?id=17c78d31c27a3c311a2ff42a881057753c6ef2a4#n221
2025-04-01 08:08:52 +00:00
Jan Vaclav
db557908a2 wireguard: add firewall rules to copy mark
When a WG connection is connecting to an IPv6 endpoint, configures a
default route, and firewalld is active with IPv6_rpfilter=yes, it never
handshakes and doesn't pass traffic. This is because firewalld has a
IPv6 reverse path filter which is discarding these packets.

Thus, we add some firewall rules whenever a WG connection is brought up
that ensure the conntrack mark and packet mark are copied over.
These rules are largely inspired by wg-quick:

https://git.zx2c4.com/wireguard-tools/tree/src/wg-quick/linux.bash?id=17c78d31c27a3c311a2ff42a881057753c6ef2a4#n221
2025-04-01 08:08:52 +00:00
Jan Vaclav
0f469b30ad build: add path definition for ip6tables 2025-04-01 08:08:52 +00:00
Jan Vaclav
10c2892d57 firewall/utils: move logs from sharing to firewall domain 2025-04-01 08:08:52 +00:00
Jan Vaclav
e39e119636 firewall/utils: fix ntf -> nft typo
Fixes: 4badc1f33a ('firewall: fix signalling timeout error reason from _fw_nft_call()')
2025-04-01 08:08:52 +00:00
Herman Semenov
3aa6e689ec libnm-platform: fix not set MACVTAP when cache ops added or updated
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2151
2025-03-31 14:58:45 +02:00
Beniamino Galvani
7f381c9d68 merge: branch 'wip/jtojnar/pygobject-3.52-docs'
meson: Fix docs generation with PyGObject 3.52

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2164
2025-03-31 12:08:38 +00:00
Jan Tojnar
12eff9a7fd meson: Fix docs generation with PyGObject 3.52
PyGObject 3.52 switched from gobject-introspection’s libgirepository 1.0
to glib’s libgirepository 2.0. As a result, the Python script would
no longer be able to find the `GIRepository` 2.0 typelib:

    (process:1944): GLib-GIRepository-DEBUG: 15:25:14.521: Ignoring GIRepository-2.0.typelib because this libgirepository corresponds to GIRepository-3.0.typelib

We could update the script to support both versions of the typelib
but it is not really necessary. It was only used to add extra directories
from `$LD_LIBRARY_PATH` and the CLI argument to repository’s library path
but libgirepository already supports using `LD_LIBRARY_PATH` directly:
https://docs.gtk.org/girepository/method.Repository.prepend_library_path.html
2025-03-31 12:04:43 +00:00
Beniamino Galvani
ecce8fa461 vpn: fix logging message
Fixes: c4a7d6a06f ('vpn: honor the ipvX.method connection property')
2025-03-31 13:39:07 +02:00
Beniamino Galvani
ba0474ef06 merge: branch 'pr/2147'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2147
2025-03-31 10:02:43 +02:00
Michael Biebl
b5c81a9070 Regenerate files so it matches the expected output 2025-03-27 14:52:00 +01:00
Michael Biebl
0e83c595f3 Rephrase certain expressions to avoid the usage of the term "allows to" 2025-03-27 09:44:07 +01:00
Michael Biebl
898db303c3 typo fix: allow to -> allow one to
Detected by lintian:

Example:
I: network-manager: typo-in-manual-page "allow to" "allow one to" [usr/share/man/man5/NetworkManager.conf.5.gz:1392]
2025-03-26 19:22:56 +01:00
Michael Biebl
10e58f7c3c typo fix: allows to -> allows one to
Detected by lintian:

Example:
I: network-manager: typo-in-manual-page "allows to" "allows one to" [usr/share/man/man5/NetworkManager.conf.5.gz:1266]
2025-03-26 19:22:01 +01:00
Michael Biebl
a98d85af93 typo fix: succesfully -> successfully
Detected by lintian:
I: network-manager: spelling-error-in-binary succesfully successfully [usr/sbin/NetworkManager]
2025-03-26 18:38:56 +01:00
Beniamino Galvani
5ed963e054 build: remove -flto-partition=none when building with GCC
Older versions of GCC (< 12) have issues building NM with LTO because
they drop libnm symbols added via '_asm__(".symver " ...)', which we
use to support symbols backported to older versions of the DSO.

Nowadays, GCC supports a new "__symver__" attribute that is
LTO-friendly; use that when possible and remove the
-flto-partition=none hack, as it increases memory usage when
compiling.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1714
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2142
2025-03-26 09:25:53 +01:00
Beniamino Galvani
481afec6ea release: fix validation of gitlab token
If the token is wrong or expired, the command still returns
success. Check the content of the reply instead.

Fixes: f05192ada8 ('release.sh: release to freedesktop.org, not to GNOME')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2148
2025-03-25 14:35:55 +01:00
Beniamino Galvani
ea0be49451 merge: branch 'bg/secret-agent-gi'
examples: add secret agent example in python/gi

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2166
2025-03-25 13:34:33 +00:00
Beniamino Galvani
eb24d7cf03 examples: add secret agent example in python/gi
Add an example of a simple secret agent written in Python using
GObject introspection.
2025-03-25 14:32:27 +01:00
Beniamino Galvani
c01168f4f9 libnm: fix GObject introspection annotations for NMSecretAgentOld
Add some missing "(nullable)" annotations to parameters of the
callback functions in NMSecretAgentOld. Otherwise, PyGObject complains
that those parameters cannot be NULL when implementing a secret agent.

Fixes: d595f7843e ('libnm: add libnm/libnm-core (part 1)')
2025-03-25 14:31:26 +01:00