Commit graph

30995 commits

Author SHA1 Message Date
Thomas Haller
e4cc504af5
dhcp: fix crash in "nm-dhcp-helper" passing NULL to g_dbus_connection_flush_sync()
"connection" variable might be NULL, which fails an assertion in
g_dbus_connection_flush_sync(). Consequently, "error_flush" is also
NULL which leads to a crash of "nm-dhcp-helper".

Reported-by: Jules Maselbas <jmaselbas@zdiv.net>

Fixes: 240ec7f891 ('dhcp: implement ACD (address collision detection) for DHCPv4')
(cherry picked from commit 37e130232d)
2022-12-09 12:45:51 +01:00
Beniamino Galvani
e4f5d96d6a macsec: merge branch 'bg/macsec-ckn-len'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1460

(cherry picked from commit 8d6cba6555)
2022-12-05 17:15:06 +01:00
Beniamino Galvani
2dd070e646 macsec: document the format of CAK and CKN properties
(cherry picked from commit dfe63d9eb3)
2022-12-05 17:15:06 +01:00
Beniamino Galvani
faf8f0ff24 macsec: allow CKN shorter than 64 characters
See wpa_supplicant commit [1]:

    macsec: Make pre-shared CKN variable length

    IEEE Std 802.1X-2010, 9.3.1 defines following restrictions for
    CKN:

    "MKA places no restriction on the format of the CKN, save that it
    comprise an integral number of octets, between 1 and 32
    (inclusive), and that all potential members of the CA use the same
    CKN. No further constraints are placed on the CKNs used with PSKs,
    ..."

    Hence do not require a 32 octet long CKN but instead allow a
    shorter CKN to be configured.

    This fixes interoperability with some Aruba switches, that do not
    accept a 32 octet long CKN (only support shorter ones).

[1] https://w1.fi/cgit/hostap/commit/?id=b678ed1efc50e8da4638d962f8eac13312a4048f

(cherry picked from commit df999d1fca)
2022-12-05 17:15:06 +01:00
Beniamino Galvani
7158f58bfc device: merge branch 'bg/rh2122564'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1459
https://bugzilla.redhat.com/show_bug.cgi?id=2122564

(cherry picked from commit fb3be35b8b)
2022-12-05 17:14:49 +01:00
Beniamino Galvani
51062305dd device: fix missing transition from UNAVAILABLE to DISCONNECTED
When called with update_carrier=TRUE, nm_device_bring_up_full() checks
for carrier changes and it may queue a transition to DISCONNECTED
through the following call chain:

 -> nm_device_bring_up_full()
   -> nm_device_set_carrier_from_platform()
     -> nm_device_set_carrier()
       -> carrier_changed()
         -> nm_device_queue_state()

In _set_state_full(state=UNAVAILABLE) after bringing the interface up
we also call nm_device_cleanup() which clears the enqueued state
change to DISCONNECTED. When this happens, the device remains in
UNAVAILABLE and never gets activated even if it was ready.

This was observed with macsec interfaces, but in theory can happen
with all those interfaces that get carrier immediately after being
brought up.

Avoid this issue by not checking the carrier synchronously from
_set_state_full(). The carrier change event will be processed in the
next asynchronous invocation of device_link_changed().

https://bugzilla.redhat.com/show_bug.cgi?id=2122564
(cherry picked from commit 07bc5121a7)
2022-12-05 17:14:49 +01:00
Beniamino Galvani
54170fdfb0 device: add "update_carrier" argument to nm_device_bring_up_full()
In some situations we need to avoid updating the carrier status
synchronously from nm_device_bring_up_full(). Add a flag for that.

(cherry picked from commit 9fd9eaf276)
2022-12-05 17:14:49 +01:00
Beniamino Galvani
738e41cd3e device: add nm_device_bring_up_full()
In the next commit nm_device_bring_up() will be extended with a new
argument. Most callers just want to bring up the device synchronously
and don't care about the "no_firmware" argument. Introduce a
nm_device_bring_up_full() for callers that need special behavior.

(cherry picked from commit 861934a510)
2022-12-05 17:14:49 +01:00
Thomas Haller
fb6e1ec549
release: bump version to 1.40.7 (development) 2022-11-30 16:27:13 +01:00
Thomas Haller
ba35cff250
release: bump version to 1.40.6 2022-11-30 16:27:13 +01:00
Thomas Haller
2e5598b258
NEWS: update 2022-11-30 15:36:30 +01:00
Thomas Haller
b73230ee20
libnm: workaround compiler warning in nm_sock_addr_endpoint_new()
gcc-12.2.1_git20220924-r4 (on Alpine Linux) warns:

  ../src/libnm-core-impl/nm-utils.c: In function 'nm_sock_addr_endpoint_new':
  ../src/libnm-core-impl/nm-utils.c:168:18: error: 'port' may be used uninitialized [-Werror=maybe-uninitialized]
    168 |         ep->port = port;
        |         ~~~~~~~~~^~~~~~
  ../src/libnm-core-impl/nm-utils.c:150:25: note: 'port' was declared here
    150 |     guint16             port;
        |                         ^~~~

Workaround.

Fixes: 713e879d76 ('libnm: add NMSockAddrEndpoint API')
(cherry picked from commit 3515324e90)
2022-11-30 15:25:18 +01:00
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