Commit graph

30983 commits

Author SHA1 Message Date
Lubomir Rintel
0a43082efa team: set port configuration even if it's empty
Call teamdctl_port_config_update_raw() when we're attaching a port even
if all of team-slave setting properties are default.

This is done to ensure teamd "knows" about the port (that is,
"teamdctl ...  port present" returns success) when we're done activating
the slave connection. It will pick it up anyway from netlink, but that
can happen after the activation is done, resulting in a possible race.

Fixes-test: @remove_active_team_profile

https://bugzilla.redhat.com/show_bug.cgi?id=2102375
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1421
(cherry picked from commit 6897f6e6df)
2022-11-28 08:51:59 +01:00
Lubomir Rintel
bcf11ebead team: restore port configuration after teamd respawn
If teamd crashes, we restore it. That's very nice, but if it really
crashed then it left ports attached and the slave connections are not
going to fail and the port configuration (e.g. priority or link watcher) in
teamd's memory will be gone.

This will restore the port configuration when the teamd connection is
re-established. This probably also fixes a race where a slave connection
would be enslaved (only possible externally and manually?) while we
didn't establish a connection to teamd yet. We'll just send the port
configuration in once're connected.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1361
(cherry picked from commit f3327835c1)
2022-11-28 08:51:48 +01:00
Lubomir Rintel
130691daff team: trivial: use a variable instead of nm_device_get_ip_iface() calls
This reads a little better and performs marginally better.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1361
(cherry picked from commit 38251ad59f)
2022-11-28 08:51:44 +01:00
Thomas Haller
25f9adb19e
release: bump version to 1.40.5 (development) 2022-11-18 10:01:06 +01:00
Thomas Haller
86b82bf358
release: bump version to 1.40.4 2022-11-18 10:01:06 +01:00
Thomas Haller
f70b4394a9
NEWS: update 2022-11-18 07:38:19 +01:00
Thomas Haller
e5e8515dd9
libnm/tests: check assigning same setting in nm_connection_add_setting()
Fixes: 3e3b629586 ('libnm: fix leak with self assignment in nm_connection_add_setting()')
(cherry picked from commit a87fd2e4d2)
2022-11-17 16:36:28 +01:00
Thomas Haller
ef29015d0b
libnm: fix leak with self assignment in nm_connection_add_setting()
We must consume the reference, like we would in the other case.

Interestingly, I am unable to reproduce a case where valgrind would
complain about the leak. But it is there nonetheless.

Fixes: 0a22f4e490 ('libnm: refactor tracking of NMSetting in NMConnection')
(cherry picked from commit 3e3b629586)
2022-11-17 16:34:01 +01:00
Thomas Haller
3e9b5217f3
libnm: workaround crash in nm_vpn_editor_plugin_import() for plugin requiring GError
The "GError **error" parameter in GLib API should be optional. Due to a
bug in at least nm-vpnc ([1]), this is not the case. Workaround in
libnm.

[1] c7d197477c/properties/nm-vpnc-editor-plugin.c (L281)

(cherry picked from commit 3b2eb689f3)
2022-11-16 13:37:52 +01:00
Fernando Fernandez Mancera
4e857e33fc core: set routing rule protocol properly
When creating NMPlatformRoutingRule from NMIPRouteRule object, the
protocol is being set to RTPROT_UNSPEC. According to linux kernel
documentation FRA_PROTOCOL indicates the originator of the rule.

In this case the route rule is coming from a connection and therefore
the originator of the rule is the user. The correct value is
RTPROT_STATIC which means the rule is installed by the administrator.

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

Fixes: 3f9347745b ('core: add handling of IP routing rules to NMDevice')
(cherry picked from commit 82009e21d2)
2022-11-14 22:46:04 +01:00
Lubomir Rintel
86a30b9900 libnm: test that Gir data matches actual exports
This verifies that what's in our public headers has version nodes, and
that they match Since: tags.

Not pretty (because python) but discovered a *lot* of issues.

(cherry picked from commit 133540763c)
2022-11-11 16:49:39 +01:00
Lubomir Rintel
1b24d4db47 docs/api: fix ugly things in Makefile
Turns out automake doesn't like either that we add dependencies to a
target conditionally. Not sure why, but it's a tasteless thing to do
nevertheless:

  gtk-doc.make:174: warning: $(DOC_MAIN_SGML_FILE) was already defined in condition BUILD_DOCS, which is included in condition TRUE ...
  docs/api/Makefile.am:112:   'gtk-doc.make' included from here
  docs/api/Makefile.am:14: ... '$(DOC_MAIN_SGML_FILE)' previously defined here

In any case, the dependency is wrong in the first place -- the source
document doesn't depend on other source. The target (which is a stamp
file, since the xslt processor produces multiple files) does! Moreover,
there's a dependency of the stamp file on $(content_files) already, so
including GENERATED_FILES (like we already do) in content_files should
be sufficient.

While at that, deal with other not-so-nice things; don't extend "all"
target needlessly and don't define a target conditionally.

(cherry picked from commit 4c49d67cc8)
2022-11-11 16:49:39 +01:00
Lubomir Rintel
8080aceb0f libnm: actually export a lot of routines that were supposed to be public
Add them to @libnm_1_40_4 as opposed to @libnm_1_42_0 because we now know
this is going to be backported to 1.40.4 first.

(cherry picked from commit 45d9f1c01c)

Compared to version in main branch, the Since tags and
NM_AVAILABLE_IN_* macros indicate the branched version.
2022-11-11 16:49:39 +01:00
Lubomir Rintel
78e94e63b6 libnm: export nm_utils_ip_{address,rout}es_{from,to}_variant
These are present in a public header yet are not properly commented,
versioned or exported.

Export them now. Another option would be to move them to a private
header; but I suspect someone has intended them to be exported at some
point.

Add them to @libnm_1_40_4 as opposed to @libnm_1_42_0 because we now know
this is going to be backported to 1.40.4 first.

(cherry picked from commit d78000d921)

Compared to version in main branch, the Since tags and
NM_AVAILABLE_IN_* macros indicate the branched version.
2022-11-11 16:49:39 +01:00
Lubomir Rintel
af6be92033 libnm/connection: fix a handful of versioning tags
These are marked as being available sooner than they actually appear in
libnm.ver.

(cherry picked from commit c0b2b5e3a8)
2022-11-11 16:49:39 +01:00
Lubomir Rintel
e401307bec libnm: fix a large amount of Since tags
Some comments are malformed, some are missing altogether.

(cherry picked from commit 117a440cd9)

Compared to version in main branch, the Since tags document the
branched version as well.

The backport omits changes to nm_client_wait_shutdown(), since that one
is not yet present in 1.40.
2022-11-11 16:49:39 +01:00
Lubomir Rintel
41306668e3 libnm: drop nm_vpn_plugin_old_set_{,ip6_}config()
Remove the functions from a public header. They were missing from
libnm.ver and thus never actually exported.

There's no point in salvaging them now as the whole NMVpnPluginOld has
been replaced NMVpnServicePlugin and new uses are discouraged.

(cherry picked from commit 1c6b0edb30)
2022-11-11 16:49:39 +01:00
Lubomir Rintel
8fb4da584c libnm: remove nm_device_wpan_get_hw_address()
Remove the function from a public header. It was missing from libnm.ver
and thus never actually exported.

There's no point in salvaging it now as it nm_device_get_hw_address()
exists as a better option.

(cherry picked from commit ecb9a48040)
2022-11-11 16:49:39 +01:00
Lubomir Rintel
ec500391d6 libnm: remove nm_device_6lowpan_get_hw_address()
Remove the function from a public header. It was missing from libnm.ver
and thus never actually exported.

There's no point in salvaging it now as it nm_device_get_hw_address()
exists as a better option.

(cherry picked from commit bd3239cf6c)
2022-11-11 16:49:39 +01:00
Lubomir Rintel
3c1471d9ca libnm: export nm_setting_ip_config_get_dhcp_iaid
The export was left out when the symbol was added; apparently by
accident.

Let's also bump the documented version of when is the symbol supposed to
be available, because it actually wasn't.

Fixes: 56a1a5426a ('all: add ipvX.dhcp-iaid properties')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1447
(cherry picked from commit 941e8b70f8)

Compared to version in main branch, the Since tags and
NM_AVAILABLE_IN_* macros indicate the branched version.

Backport also includes commit c7f6a506ef ('libnm: move
nm_setting_ip_config_get_dhcp_iaid() to @libnm_1_40_4 version node'),
it wouldn't be possible to backport both separately.
2022-11-11 16:49:39 +01:00
Lubomir Rintel
310b5c66bb libnm: add NM_VERSION_1_40_4 2022-11-11 16:49:39 +01:00
Thomas Haller
f0203ba8ac nm-setting: fix static assertions for NM_SETTING_PARAM_* flags and numeric values
- the static assertions were wrong, there was a "," instead of "==".

- the numeric values were wrong, as shown by the static assertions.

- move the code comment to the implementation. This does not seem
  relevant for the library user and should not be in the public header.

Fixes: 08e845f651 ('nm-setting: mangle public constant to make g-ir-scanner happy')
(cherry picked from commit c884d4d347)
2022-11-11 16:49:39 +01:00
Lubomir Rintel
bf9a1bedb8 nm-setting: mangle public constant to make g-ir-scanner happy
Some versions of g-ir-scanner's C parser silently coerce unrecognized
symbols into zeroes [1]. Let's avoid that so that we don't end up with
wrong constants in our Gir data.

[1] https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/366

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1446
(cherry picked from commit 08e845f651)
2022-11-11 16:49:39 +01:00
Thomas Haller
46c27a270f
ifcfg-rh: merge branch 'th/ethtool-ifcfg-fixes'
https://bugzilla.redhat.com/show_bug.cgi?id=2134569

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

(cherry picked from commit 954ca6b411)
2022-11-10 13:49:32 +01:00
Thomas Haller
ee6bf84559
core: filter out invalid Wake-On-Lan flags
NMSettingWired does not reject invalid flags. Filter them out in wake_on_lan_enable().
In practice, it makes no difference, the unknown flags were ignored anyway.

(cherry picked from commit c593834842)
2022-11-10 13:49:30 +01:00
Thomas Haller
40564c5d6a
ifcfg-rh: fix persisting all-default NMSettingEthtool with autoneg/wol flags
Fixes: 26ed9e6714 ('ifcfg-rh: fix persisting all-default NMSettingEthtool settings')
(cherry picked from commit 4303d33727)
2022-11-10 13:49:30 +01:00
Thomas Haller
553e037220
ifcfg-rh: fix persisting ethtool options
If there were any pause options and any non-pause options,
the created setting was invalid.

I don't think it's reasonably possible to parse the broken settings.
So there is no workaround trying to read the existing broken settings
from disk. Luckily, the broken setting was just silently ignored by
the parser, so you simply could not persist certain settings.

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

Fixes: 652ddca04c ('ethtool: Introducing PAUSE support')
(cherry picked from commit 21661c6f71)
2022-11-10 13:49:29 +01:00
Thomas Haller
3b3ed9f1cc
ifcfg-rh/tests: add test checking persisting ethtool settings to ifcfg-rh
There are still various failures. That will be fixed next.

(cherry picked from commit 3755e6b175)
2022-11-10 13:49:29 +01:00
Thomas Haller
a14aa08a43
ethtool: add and use nm_ethtool_id_get_variant_type() helper
(cherry picked from commit a0370e0efa)
2022-11-10 13:49:17 +01:00
Ratchanan Srirattanamet
a8813ff6fe
wwan/ofono: fix memory leak in handle_settings()
[thaller@redhat.com: modified original patch.]

Fixes: 58287cbcc0 ('core: rework IP configuration in NetworkManager using layer 3 configuration')
(cherry picked from commit 61e99ed715)
2022-11-10 09:16:13 +01:00
Thomas Haller
0797b26846
platform: fix nmp_object_copy(id_only) for object that don't implement cmd_plobj_id_copy()
The if-else-if was wrong. It meant that if an object did not implement
cmd_plobj_id_copy(), nothign was copied (for id-only).

I think this code path was not actually hit, because we never clone
an object only by ID.

Fixes: c91a4617a1 ('nmp-object: allow missing implementations for certain virtual functions')
(cherry picked from commit ee34eeafb9)
2022-11-10 08:05:13 +01:00
Lubomir Rintel
a18ec9df72
client: add_and_activate*() allow NULL device
Fix up the doc comment so that the gir data gets that right.

Fixes: 90d0ae0faf ('libnm: implement nm_client_activate_connection()/nm_client_add_and_activate_connection*() by using GDBusConnection directly')
(cherry picked from commit a0373a72db)
2022-11-10 08:02:38 +01:00
Beniamino Galvani
3fd8116646 std-aux: fix NM_LIKELY()/NM_UNLIKELY() macros
Fix this compile error when "defined(__GNUC__) && (__GNUC__ > 2) &&
defined(__OPTIMIZE__)" doesn't match:

  In file included from ../src/libnm-std-aux/nm-default-std.h:102,
                   from ../src/libnm-std-aux/nm-std-utils.c:3:
  ../src/libnm-std-aux/nm-std-aux.h: In function ‘NM_ALIGN_TO’:
  ../src/libnm-std-aux/nm-std-aux.h:160:6: error: expected expression before ‘{’ token
    160 |     ({                                 \
        |      ^
  ../src/libnm-std-aux/nm-std-aux.h:169:31: note: in expansion of macro ‘_NM_BOOLEAN_EXPR_IMPL’
    169 | #define NM_BOOLEAN_EXPR(expr) _NM_BOOLEAN_EXPR_IMPL(NM_UNIQ, expr)
        |                               ^~~~~~~~~~~~~~~~~~~~~
  ../src/libnm-std-aux/nm-std-aux.h:175:27: note: in expansion of macro ‘NM_BOOLEAN_EXPR’
    175 | #define NM_LIKELY(expr)   NM_BOOLEAN_EXPR(expr)
        |                           ^~~~~~~~~~~~~~~
  ../src/libnm-std-aux/nm-std-aux.h:238:19: note: in expansion of macro ‘NM_LIKELY’
    238 |         } else if NM_LIKELY (cond) {                                  \
        |                   ^~~~~~~~~
  ../src/libnm-std-aux/nm-std-aux.h:449:5: note: in expansion of macro ‘nm_assert’
    449 |     nm_assert(nm_utils_is_power_of_two(ali));
        |     ^~~~~~~~~

Fixes: 030d68aef7 ('shared: add nm_assert() to "nm-std-aux.h"')
(cherry picked from commit 8bd72d5f2e)
2022-11-04 09:19:08 +01:00
Thomas Haller
de7696789e
tests: add tests for generating stable UUIDs for keyfile/initrd
(cherry picked from commit dc26e65928)
2022-11-03 21:05:36 +01:00
Thomas Haller
6de49febc3
initrd/tests: add unit test for autoconnect-priority setting
Fixes: 98575bd513 ('initrd: generate initrd generator profiles with autoconnect-priority -100')
(cherry picked from commit 28ab535617)
2022-11-03 20:55:15 +01:00
Thomas Haller
8f92a51305
gitignore: ignore "po/.Makefile.patched" file
Fixes: 7ee0da3eaf ('build: don't "update-po" during make dist')
(cherry picked from commit 1d767bb1cd)
2022-11-03 20:54:58 +01:00
Thomas Haller
9c5d413f3f
build/meson fix "gen-metadata-nm-settings-nmcli.xml.in" without enable_docs
Fixes: ab8fdb73e6 ('build: commit pre-generated "generate-docs-nm-settings-nmcli.xml" to git')
(cherry picked from commit 489f65bf9c)
2022-11-03 20:54:47 +01:00
Thomas Haller
1fe66209e9
build/autotools: adjust hack for gettext() for other Makefile versions
On rhel-8.7, we use a different gettext version, so the Makefile
looks different. Adjust patch the source.

Fixes: 7ee0da3eaf ('build: don't "update-po" during make dist')
(cherry picked from commit b2d1d14772)
2022-11-03 20:54:35 +01:00
Beniamino Galvani
7a73431608
core: fix setting IPv6 retrans timer
Fixes: 5c48c5d5d6 ('l3cfg: set IPv6 sysctls during NML3Cfg commit')
(cherry picked from commit 50b6f3d6d3)
2022-11-03 20:54:12 +01:00
Michael Catanzaro
1ebef6cabf
core: don't restrict DNS interface when performing connectivity check
Currently, when performing DNS resolution with systemd-resolved,
NetworkManager tells systemd-resolved to consider only DNS configuration
for the network interface that the connectivity check request will be
routed through. But this is not correct because DNS and routing are
configured entirely separately. For example, say we have a VPN that
receives all DNS but only a subset of routing. NetworkManager will
configure systemd-resolved with no DNS servers on any interface except
for the VPN interface, but will still route traffic through other
interfaces. This is entirely legitimate and works fine in practice,
except for the connectivity check.

To fix this, we just drop the restriction and allow systemd-resolved to
consider its full configuration, which is what gets used normally
anyway. This allows our connectivity check to match the real
configuration instead of failing spuriously.

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1415
(cherry picked from commit e6dac4f0b6)
2022-10-19 21:03:58 +02:00
Beniamino Galvani
30b6c75e74 nmcli: fix crash in "nmcli device monitor"
Fix the following crash:

  $ nmcli device monitor a
  Error: Device 'a' not found.
  Segmentation fault (core dumped)

Found by coverity:

  1. NetworkManager-1.41.3/src/nmcli/devices.c:0: scope_hint: In function 'do_devices_monitor'
  2. NetworkManager-1.41.3/src/nmcli/devices.c:2932:28: warning[-Wanalyzer-null-dereference]: dereference of NULL 'devices'
     2930|       }
     2931|
     2932|->     for (i = 0; i < devices->len; i++)
     2933|           device_watch(nmc, g_ptr_array_index(devices, i));
     2934|

Fixes: 2074b28976 ('nmcli/devices: return GPtrArray instead of GSList from get_device_list()')
(cherry picked from commit 40897db056)
2022-10-19 16:13:41 +02:00
Beniamino Galvani
f9db4f4604 Revert "device: restart DHCP when the MAC changes"
The commit causes problems with bridges. When a new port is attached
the MAC of the bridge possibly changes and if we restart DHCP the
bridge will get a different IP address.

Revert the change until a better solution to the original problem is
found.

This reverts commit 905adabdba.

https://bugzilla.redhat.com/show_bug.cgi?id=2124443
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1401
(cherry picked from commit 9819738607)
2022-10-19 14:01:00 +02:00
Beniamino Galvani
4a85225c2c release: bump version to 1.40.3 (development) 2022-10-18 10:10:22 +02:00
Beniamino Galvani
4704b924ad release: bump version to 1.40.2 2022-10-18 10:10:22 +02:00
Beniamino Galvani
e93684e929 NEWS: update 2022-10-18 09:37:06 +02:00
Fernando Fernandez Mancera
310e0d259f policy: track the autoconnect retries in devices for multi-connect
For connections with multi-connect property set to "multiple", the
autoconnect-retries should be tracked per device and not per connection.
That means, if autoconnect-retries is set to 2, each device using that
connection should retry to autoconnect 2 times.

The device autoconnect retries is -2 by default. This is a special
value, in NMPolicy context, if the connection used is multi-connect the
device value will be set to match the connection retries. Each time the
device picks a different connection, it will reset the device
autoconnect retries to -2 and if needed, sync. with the connection
retries.

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

https://bugzilla.redhat.com/show_bug.cgi?id=2039734
(cherry picked from commit 1656d82045)
2022-10-17 16:28:19 +02:00
Thomas Haller
64f6c0ae31 initrd: generate initrd generator profiles with autoconnect-priority -100
... and profiles from firmware with autoconnect-priority -200.

In general, after switch root we remember the still activated profile in
/run, and NetworkManager would take over the device with the same
profile as before. In that case, autoconnect and autoconnect-priority
doesn't matter.

Autoconnect only matters when having a device in disconnected state and
not being blocked from autoconnect. For example, if you unplug and
replug the cable. In that case, it does make sense to me that
user-provided profiles from real-root are preferred.

To me the reasons for this change is not very strong (but neither are
the reasons against it). Read the discussion on rhbz #2089707.

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

Co-authored-by: Lubomir Rintel <lkundrak@v3.sk>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1376
(cherry picked from commit 98575bd513)
2022-10-17 16:26:01 +02:00
Beniamino Galvani
439f0675f2 platform: merge branch 'bg/sriov-bufsize'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1413

(cherry picked from commit 227ae41216)
2022-10-17 10:32:53 +02:00
Beniamino Galvani
a0cd931bef platform: set custom netlink buffer size when adding SR-IOV VFs
When there are many VFs the default buffer size of 1 memory page is
not enough. Each VF can take up to ~120 bytes and so when the page
size is 4KiB at most ~34 VFs can be added.

Specify the buffer size when allocating the message.

(cherry picked from commit f7ac887502)
2022-10-17 10:32:52 +02:00
Beniamino Galvani
88d9836a67 platform: add length argument to _nl_msg_new_link_full()
Add a new argument to specify the netlink buffer length.

(cherry picked from commit a4767ad771)
2022-10-17 10:32:52 +02:00