Commit graph

32402 commits

Author SHA1 Message Date
Thomas Haller dbb45f14d3
device: add nm_device_get_s390_subchannels() accessor 2023-06-14 11:07:34 +02:00
Thomas Haller c47d6b17d5
core: replace multiple arguments of nm_match_spec_device() with struct
Struct allow named arguments, which seems easier to maintain instead of
a function with many arguments. Also, adding a new parameter does not
require changes to most of the callers.

The real advantage of this is that we encode all the search parameters
in one argument. And we can add that argument to
_match_section_infos_lookup(), alongside lookup by NMDevice or
NMPlatformLink.
2023-06-14 11:07:34 +02:00
Thomas Haller cba8eb9784
core: add nm_match_spec_match_type_to_bool() helper to convert enum to boolean
All callers eventually want a boolean instead of a NMMatchSpecMatchType.

I think the NMMatchSpecMatchType enum still has value at the lower
layers, where the enum values are clearer (when reading the code). So
don't drop NMMatchSpecMatchType entirely.

However, let's add nm_match_spec_match_type_to_bool() to convert the
match-type to a boolean to avoid duplicating the code.
2023-06-14 10:49:14 +02:00
Thomas Haller 5b8e6c01a9
device: define auto variables on separate lines in connection_requires_carrier() 2023-06-14 10:49:14 +02:00
Thomas Haller 42f20a4edf
device: reorder checks in check_connection_available()
No change in behavior. Just reorder, so that the checks that can be
reviewed in place are handled first.
2023-06-14 10:49:13 +02:00
Javier Sánchez Parra b3b8323499 tui: Enable/disable Wi-Fi and WWAN radios
This commit adds functionality to nmtui to enable or disable the Wi-Fi
and WWAN radios. Additionally, it provides a display of the hardware
status.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1655
2023-06-14 09:58:11 +02:00
Thomas Haller dd561875dc
contrib/rpm: update RPM description for NetworkManager-cloud-setup package
https://bugzilla.redhat.com/show_bug.cgi?id=2214491
2023-06-13 09:34:36 +02:00
Beniamino Galvani b8bbcea744 n-dhcp4: re-import git-subtree for 'src/n-dhcp4'
git subtree pull --prefix src/n-dhcp4 git@github.com:nettools/n-dhcp4.git master --squash
2023-06-12 14:10:08 +02:00
Beniamino Galvani 90b0404e8d Squashed 'src/n-dhcp4/' changes from b2a382ac4500..2707213e3ee0
2707213e3ee0 n-dhcp4: close packet socket after timeout

git-subtree-dir: src/n-dhcp4
git-subtree-split: 2707213e3ee04d9a76ad7df027def93e4dea739f
2023-06-12 14:10:08 +02:00
Thomas Haller 8dfca3d552
platform/tests: skip test_netns_bind_to_path() test on failure
Our copr builds start to fail, since the copr builds updated to Fedora
38 ([1]).

  ERROR: src/core/platform/tests/test-link-linux - Bail out! nm:ERROR:src/core/platform/tests/test-link.c:3486:test_netns_bind_to_path: assertion failed (nmtstp_run_command("ip netns exec " P_NETNS_BINDNAME " true") == 0): (65280 == 0)

The cause is not understood, but it seems not worth investigating.
Just skip the test.

[1] https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/KOR3HE2VHHIPDBLDLXTYRMON6JQXCHMW/#J4K5VB5SA6I5P2ZLI65OHNQ6X7SINSHA
2023-06-12 12:13:08 +02:00
Beniamino Galvani 647fa98810 merge: branch 'bg/log-device-type'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1638
2023-06-12 11:18:39 +02:00
Beniamino Galvani 680c95ddd2 core: log the device type when it can be ambiguous
Use the nm_device_get_type_desc_for_log() helper function defined
earlier to show the device type when it can be ambiguous.

With this, the log becomes a bit more explicative when there are OVS
devices involved:

  <info> device (ovs-br)[Open vSwitch Bridge]: state change: ip-config -> ip-check (reason 'none', sys-iface-state: 'managed')
  <info> device (ovs-br)[Open vSwitch Port]: state change: ip-check -> secondaries (reason 'none', sys-iface-state: 'managed')
  <info> device (ovs-br)[Open vSwitch Port]: state change: secondaries -> activated (reason 'none', sys-iface-state: 'managed')
  <info> device (ovs-br)[Open vSwitch Port]: Activation: successful, device activated.
  <info> device (ovs-br)[Open vSwitch Bridge]: state change: ip-check -> secondaries (reason 'none', sys-iface-state: 'managed')
  <info> device (ovs-br)[Open vSwitch Bridge]: state change: secondaries -> activated (reason 'none', sys-iface-state: 'managed')
  <info> device (ovs-br)[Open vSwitch Bridge]: Activation: successful, device activated.
  <info> device (ovs-br)[Open vSwitch Interface]: state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
  <info> device (ovs-br)[Open vSwitch Interface]: state change: unavailable -> disconnected (reason 'none', sys-iface-state: 'managed')
  <info> device (ovs-br)[Open vSwitch Interface]: Activation: starting connection 'ovs-interface+' (d3d429b1-3193-4462-a17a-034255c43776)

instead of:

  <info> device (ovs-br): state change: ip-config -> ip-check (reason 'none', sys-iface-state: 'managed')
  <info> device (ovs-br): state change: ip-check -> secondaries (reason 'none', sys-iface-state: 'managed')
  <info> device (ovs-br): state change: secondaries -> activated (reason 'none', sys-iface-state: 'managed')
  <info> device (ovs-br): Activation: successful, device activated.
  <info> device (ovs-br): state change: ip-check -> secondaries (reason 'none', sys-iface-state: 'managed')
  <info> device (ovs-br): state change: secondaries -> activated (reason 'none', sys-iface-state: 'managed')
  <info> device (ovs-br): Activation: successful, device activated.
  <info> device (ovs-br): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
  <info> device (ovs-br): state change: unavailable -> disconnected (reason 'none', sys-iface-state: 'managed')
  <info> device (ovs-br): Activation: starting connection 'ovs-interface+' (d3d429b1-3193-4462-a17a-034255c43776)
2023-06-12 11:17:09 +02:00
Beniamino Galvani cb423ae7ac dhcp: store the device type for logging
Arguably, a kernel link is needed for DHCP and so the interface name
univocally identifies a device (for example, the OVS interface). But
for consistency and clarity, store the device type to be used for
logging.
2023-06-12 11:17:09 +02:00
Beniamino Galvani 749ebef0d9 device: add nm_device_get_type_desc_for_log()
When logging, messages include the interface name to specify what
device they refer to. In most case the interface name is unique.

There are some devices that don't have a kernel link associated, and
their interface name is not guaranteed to be unique. This is currently
the case for OVS bridges and OVS ports. When reading a log with
duplicate interface names, it is difficult to understand what is
happening. And this is made worse by the fact that it is common
practice to assign the same name to all devices in a OVS hierarchy
(bridge, port, interface).

To make logs unambiguous, we want to print the device type together
with the name; however we don't want to *always* print the type
because in most cases it's not useful and it would consume valuable
real estate on the screen. Adopt a simple heuristic of showing the
type only for OVS devices.

This commit adds a helper function to return the device type to show
in logs, when it is needed.
2023-06-12 11:17:09 +02:00
Beniamino Galvani adef815219 device: add comment about return value in nm_device_get_type_description() 2023-06-12 11:17:09 +02:00
Beniamino Galvani 3ea19523ee device: generic: make type-description const
The type is initialized from nm_platform_link_get_type_name(), which
returns a static string; there is no need to duplicate the string.
2023-06-12 11:17:09 +02:00
Beniamino Galvani fd6f48ec35 device: generic: make type-description property read-only
The property is not written anywhere, make it read-only.
2023-06-12 11:17:09 +02:00
Thomas Haller 7e6a6dd275
cloud-setup: merge branch 'th/cloud-setup-fix-cancellation'
https://bugzilla.redhat.com/show_bug.cgi?id=2207812

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1654
2023-06-12 10:39:15 +02:00
Thomas Haller c70a5470be
cloud-setup: clear error variable in nmcs_device_reapply()
This is rather bad, because if we reach the "goto again" case,
the error variable is not cleared. Subsequently passing the
error location to nm_device_reapply_finish() will trigger a glib
warning.

Fixes: 29b0420be7 ('nm-cloud-setup: set preserve-external-ip flag during reapply')
2023-06-12 10:38:00 +02:00
Thomas Haller dab114f038
cloud-setup: fix terminating in the middle of reconfiguring the system
Once we start reconfiguring the system, we need to finish on all
interfaces. Otherwise, we might reconfigure some interfaces, abort
and leave the network broken. When that happens, a subsequent run
might also be unable to recover, because we are unable to reach the
HTTP meta data service.

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

Fixes: 69f048bf0c ('cloud-setup: add tool for automatic IP configuration in cloud')
2023-06-12 10:37:53 +02:00
Thomas Haller cbbf5fed49
libnm/docs: better descripe "ipv[46].dns-options" in man nm-settings-nmcli 2023-06-12 10:01:23 +02:00
Wen Liang f04a9eb098 cloud-setup: add pre-up event to prevent reaching network-online.target
network-online.target should not be reached before nm-cloud-setup
completes configuring the network, which may make user service get
started before the network is fully configured.

Setting nm-cloud-setup.service as "Before=network-online.target" would
maybe have already achieved that. However, also use a pre-up dispatcher
script, so that the device activation in NetworkManager is also waiting
for nm-cloud-setup to complete.

https://bugzilla.redhat.com/show_bug.cgi?id=2151040
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1653
2023-06-09 09:18:20 -04:00
Thomas Haller 6050da93bd
device: only remember "forwarding" sysctl the first time in _dev_ipac6_start()
Fixes: 4c48301594 ('device: don't reset "net.ipv6.conf.$IFACE.forwarding"')
2023-06-08 15:04:50 +02:00
Beniamino Galvani 029e651551 merge: branch 'cathay4t:fix_reapply'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1649
2023-06-08 11:50:59 +02:00
Gris Ge 0486efd358 setting-connection: Unblock autoconnect upon finish of Reapply
The activation of a connection will clear the block of autoconnect,
we should do the same for reapply.

Signed-off-by: Gris Ge <fge@redhat.com>
2023-06-08 14:33:28 +08:00
Petr Menšík 6335e9de6a
dns/dnsmasq: do not use --dnssec-proxy by default
dnsmasq since 2.80 properly forwards all incoming queries with DO bit
set. That ensures even if the dnsmasq does not do validation, it will
always serve all DNSSEC records if the upstream server provides them.
Regardless local validation is enabled or disabled, it will always offer
all data required for validation to its clients.
But does not set AD bit on local responses unless it did the actual
validation itself.

In case users trust their connection to validating DNS server, they
would have to declare it by adding dnssec-proxy option to dnsmasq conf.d
directory. Because there is no negated no-dnssec-proxy, it cannot be
turned off. I think there is no good reason to be on for all cases and
it would be possible to enable it if still wanted. Move the decision to
the user.

That makes it conform with RFC 4035, paragraph 3.2.3.

Signed-off-by: Petr Menšík <pemensik@redhat.com>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1639
2023-06-07 21:46:04 +02:00
Thomas Haller c7ee3a2445
device: merge branch 'th/device-carrier-sources'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1652
2023-06-07 21:33:49 +02:00
Thomas Haller 1ef58332b2
device: use GSource for tracking carrier-wait timeout 2023-06-07 21:32:50 +02:00
Thomas Haller 6a54041ae1
device: clear defer timeout in nm_device_set_carrier()
It's not obvious, why we couldn't have a pending dever action
at that point. Maybe we cannot, but just to be explicit about it,
handle that we potentially might.

For example, we tend to schedule the timeout priv->carrier_defer_source
only from within nm_device_set_carrier() if `priv->carrier` is FALSE.
At the same time, nm_device_set_carrier() does nothing `if
(priv->carrier == carrier)`. So probably there is no problem.

However, we also set priv->carrier directly in
nm_device_set_carrier_from_platform() without clearing the timer. It's
hard to imagine whether there can be a case where we might have two
timeouts pending.
2023-06-07 21:32:49 +02:00
Thomas Haller adc3263920
device: use GSource for tracking carrier-defer timeout
Also no longer log the g_source_get_id(). It's not useful, because
per device there must be only one timeout pending at any time.
2023-06-07 21:32:49 +02:00
Thomas Haller 7009789e85
doc: update Documentation reference in NetworkManager-wait-online.service 2023-06-07 16:48:30 +02:00
Thomas Haller 987488a7ac
CONTRIBUTING: don't use signed-off-by in NetworkManager 2023-06-07 14:25:05 +02:00
Thomas Haller 60f6154134
MAINTAINERS: how to merge merge requests 2023-06-07 14:25:05 +02:00
Thomas Haller 07bc415283
Revert "ppp: fix plugin name for "rp-pppoe.so" with ppp 2.5"
"nm-ppp-manager.c" gets compiled as "libnm-ppp-plugin.so", which does
not link with the ppp code. It thus cannot use
nm_pppd_compat_get_pppoe_plugin_name().

A different solution will be needed. Revert for now.

This reverts commit fe2aade565.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1312
2023-06-07 14:24:17 +02:00
Thomas Haller fe2aade565
ppp: fix plugin name for "rp-pppoe.so" with ppp 2.5
Between ppp 2.4.8 and 2.4.9, "rp-pppoe.so" was renamed to "pppoe.so" (and a
symlink created). Between 2.4.9 and 2.5.0, the symlink was dropped.

See-also: b2c36e6c0e

I guess, NetworkManager always meant to use ppp's "(rp-)pppoe.so"
plugin, and never what rp-pppoe provides.

If a user actually wants to use the plugin from rp-pppoe project, then
this is going to break. But it seams, we usually intend to use the
plugin from the ppp project.

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

Fixes: afe80171b2 ('ppp: move ppp code to "nm-pppd-compat.c"')
2023-06-07 09:26:26 +02:00
Thomas Haller 4d6036ac66
tools/tests: merge branch 'fmartinsons:fm/correct-type-error'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1650
2023-06-07 08:38:38 +02:00
Frederic Martinsons ae408fe4ab tools/tests: correct variant parsing
Seen in NM 1.42.6 where there is now a ipv4.dns-data key which
have as signature:
dbus.Array([dbus.String('a.b.c.d')], signature=dbus.Signature('s'), variant_level=1)

This lead to the following exception:
Cannot convert array element to type 's': Must be string, not Variant

Moreover, the exception TypeError has no message field so it raised
another expcetion which gave me trouble to find what's going on.

Hence the addition of a log file from the previous commit

Signed-off-by: Frederic Martinsons <frederic.martinsons@gmail.com>
2023-06-07 05:48:09 +00:00
Frederic Martinsons 2f7a571759 tools/tests: add ability to log to a file
That has been proven useful for debugging the tool during tests

Signed-off-by: Frederic Martinsons <frederic.martinsons@gmail.com>
2023-06-07 05:48:09 +00:00
Thomas Haller e432b26112
nm-in-container: improve documentation 2023-06-06 15:01:56 +02:00
Thomas Haller 9ede7e04b1
contrib: extend usage for "contrib/scripts/nm-setup-git.sh" script 2023-06-06 15:00:23 +02:00
Thomas Haller e75deb8c94
contrib/copr: update URL in "nm-copr-build.sh" to new nm-git-bundle 2023-06-06 14:53:37 +02:00
Thomas Haller 849817a1eb
docs: extend MAINTAINERS.md 2023-06-06 13:39:52 +02:00
Thomas Haller fbbe81634f
gitlab-ci: add .gitlab-ci/README.md 2023-06-06 12:35:09 +02:00
Thomas Haller a8b2997fa5
contrib/copr: improve readme in copr scripts (2) 2023-06-06 12:21:30 +02:00
Thomas Haller fd6fcf335c
contrib/copr: improve readme in copr scripts 2023-06-06 12:20:29 +02:00
Thomas Haller e267c1d3ff
core: merge branch 'th/rh2156684-ignore-carrier'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1608
2023-06-06 09:15:04 +02:00
Thomas Haller 645a1bb0ef
core: unblock autoconnect when master profile changes
When a port cannot activate because the controller is not ready, it gets
blocked from autoconnect (see commit 725fed01cf ('policy: block
connection from autoconnect in case of failed dependency')).

Later, when the master activates we call activate_slave_connections()
(see commit 32efb87d4d ('core: unblock failed connections when the
master is available')), which unblocks those port profiles so they can
autoconnect.

However, imagine you add a port profile with autoconnect enabled. The
profile tries to autoconnect, finds no master and gets blocked. Then,
add the controller profile with autoconnect disabled. The controller is
not autoactivating, not calling activate_slave_connections() and the
profiles stay down.

Fix that by unblocking autoconnect of the ports when the controller
profile changes.
2023-06-06 09:13:44 +02:00
Thomas Haller 481cf3594b
core: log when we unblock port profiles for controller change 2023-06-06 09:13:44 +02:00
Thomas Haller f373e1f860
core: factor out unblocking autoconnect for port profiles from activate_slave_connections() 2023-06-06 09:13:40 +02:00
Thomas Haller 7f9db1a290
man: minor rewording in "NetworkManager.conf" manual
Just a comma actually.
2023-06-05 20:59:39 +02:00