Commit graph

1191 commits

Author SHA1 Message Date
Fernando Fernandez Mancera
151b2bed36 platform: pass extra_hops to ip_route_add function
When adding a new route we need to consider it contains extra nexthops
i.e it is a ECMP route. As we cannot modify the NMPObject once created,
we need to pass the extra nexthops as an argument.

We cannot use the original NMPObject because normalization is happening
during when adding the route.
2022-11-21 11:19:19 +01:00
Fernando Fernandez Mancera
1bbdecf5e1 platform: manage ECMP routes
When reading from netlink an ECMP IPv4 route, we need to parse the
multiple nexthops. In order to do that, we are introducing
NMPlatformIP4RtNextHop struct.

The first nexthop information will be kept at the original
NMPlatformIP4Route and the new property n_nexthops will indicate how
many nexthops we need to consider.
2022-11-21 11:18:03 +01:00
Thomas Haller
7f218e6ac5
core/tests: relax timing in "/general/nm_utils_kill_child" test
This test is inherently fragile, as it depends on starting processes,
wait for something and kill the process. There are timings involved
that are out of control of the test. Try to adjust the timing.

  # NetworkManager-DEBUG: <debug> [1668755976.9741] kill child process test-s-4 (111487): sending SIGKILL...
  # NetworkManager-DEBUG: <debug> [1668755976.9753] kill child process test-s-4 (111487): waiting for process to terminate after sending SIGTERM (15) and SIGKILL...
  # NetworkManager-DEBUG: <debug> [1668755976.9758] kill child process test-s-4 (111487): after sending SIGTERM (15) and SIGKILL, process 111487 exited by signal 9 (5759 usec elapsed)
  Bail out! GLib:ERROR:../src/core/tests/test-core-with-expect.c:154:test_nm_utils_kill_child_sync_do: Did not see expected message NetworkManager-DEBUG: *<debug> [*] kill child process test-s-4 (*): waiting up to 1 milliseconds for process to terminate normally after sending SIGTERM (15)...
  Bail out! nm:ERROR:../src/core/tests/test-core-with-expect.c:457:test_nm_utils_kill_child: assertion failed (exit_status == 0): (6 == 0)
  --- stderr ---
  **
  GLib:ERROR:../src/core/tests/test-core-with-expect.c:154:test_nm_utils_kill_child_sync_do: Did not see expected message NetworkManager-DEBUG: *<debug> [*] kill child process test-s-4 (*): waiting up to 1 milliseconds for process to terminate normally after sending SIGTERM (15)...
  **
  nm:ERROR:../src/core/tests/test-core-with-expect.c:457:test_nm_utils_kill_child: assertion failed (exit_status == 0): (6 == 0)
  /builds/NetworkManager/NetworkManager/tools/run-nm-test.sh: line 337: 110662 Aborted                 "${NMTST_DBUS_RUN_SESSION[@]}" "${NMTST_LIBTOOL[@]}" "$NMTST_VALGRIND" --quiet --error-exitcode=$VALGRIND_ERROR --leak-check=full --gen-suppressions=all "${NMTST_SUPPRESSIONS[@]}" --num-callers=100 --log-file="$LOGFILE" "$TEST" "${TEST_ARGV[@]}"
2022-11-18 09:41:49 +01:00
Beniamino Galvani
df999d1fca 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
2022-11-16 10:36:39 +01:00
Beniamino Galvani
07bc5121a7 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
2022-11-16 10:22:45 +01:00
Beniamino Galvani
9fd9eaf276 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.
2022-11-16 10:22:45 +01:00
Beniamino Galvani
861934a510 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.
2022-11-16 10:22:44 +01:00
Beniamino Galvani
c4a7d6a06f vpn: honor the ipvX.method connection property
Currently VPNs always apply the configuration sent by the server for
both address families. So, even if users set e.g. ipv6.method=disabled,
they might end up with IPv6 configured.

Change that and apply the automatic configuration only when the method
is "auto".

This is a change in behavior and as such it might be disruptive for
users that had a method different from "auto" and expected to have the
interface configured. However, that scenario seems unlikely and can be
easily fixed by setting the right method.
2022-11-16 10:17:49 +01:00
Beniamino Galvani
b84faaefc9 vpn: remove unused variable 2022-11-16 10:17:49 +01:00
Fernando Fernandez Mancera
82009e21d2 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')
2022-11-14 18:28:25 +01:00
Lubomir Rintel
5d851a3c9d merge: branch 'lr/gtk-doc'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1458
2022-11-14 16:18:33 +01:00
Thomas Haller
6c9018a29e
glib-aux: rename _nm_dbus_signal_connect{,_data}() to _nm_dbus_proxy_*()
These are helpers for GDBusProxy. I think we should avoid GDBusProxy where possible,
and these functions too. Give the function a more specific name to show that this
is only for the proxy.
2022-11-14 08:05:47 +01:00
Thomas Haller
cf6d38177f
glib-aux: drop duplicate _nm_dbus_error_has_name() for nm_dbus_error_is() 2022-11-14 08:04:16 +01:00
Thomas Haller
a7fea45adf
libnm: move "nm-dbus-utils.c" from libnm-core to libnm-glib-aux
These are just general purpose D-Bus utils, based on glib and GDBus.
They fit perfectly to libnm-glib-aux. Move the code.

Also, there is already the file "src/core/nm-dbus-utils.c", having two
files with the same name on our source tree is just confusing.
2022-11-14 08:04:06 +01:00
Lubomir Rintel
d4053a83af libnm: move nm-errors.h include away from nm-connection.h
Most users included this by accident, by including nm-connection.h. That
is not too great, becuase stuff it contains is by no means specific to
NMConnection.

Anyways, it's not like it would matter too that. I mainly care about it
being included in NetworkManager.h, so that there's one less special
case in a test that makes sure useful stuff from NetworkManager.h ends up
in gtk-doc (a separate commit).
2022-11-13 23:36:37 +01:00
Thomas Haller
c593834842
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.
2022-11-10 13:46:35 +01:00
Thomas Haller
4303d33727
ifcfg-rh: fix persisting all-default NMSettingEthtool with autoneg/wol flags
Fixes: 26ed9e6714 ('ifcfg-rh: fix persisting all-default NMSettingEthtool settings')
2022-11-10 13:46:34 +01:00
Thomas Haller
21661c6f71
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')
2022-11-10 13:45:43 +01:00
Thomas Haller
3755e6b175
ifcfg-rh/tests: add test checking persisting ethtool settings to ifcfg-rh
There are still various failures. That will be fixed next.
2022-11-10 13:44:58 +01:00
Ratchanan Srirattanamet
e34e38e744
wwan/ofono: cleanup comments and warnings in existing code 2022-11-10 07:54:24 +01:00
Ratchanan Srirattanamet
61e99ed715
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')
2022-11-10 07:54:10 +01:00
Ratchanan Srirattanamet
f0ef4a440f
wwan/device-modem: re-check device availability after enable
It's possible that the modem is enabled outside of NM. If not
re-check, device could stay disabled throughout until something else
about the modem changes again.
2022-11-10 07:44:59 +01:00
Ratchanan Srirattanamet
2f3a0eaa0b
wwan/modem: return early if set_mm_enable is not implemented
We don't want to e.g. pre-empt the state change signal, because it's not
gonna happen.
2022-11-10 07:44:59 +01:00
Ratchanan Srirattanamet
580453d376
wwan/device-modem: disabled but not enable-able modem is unavailable
If a modem is disabled, and it has no method to enable it, then by no
mean it's "available" to NM.
2022-11-10 07:44:58 +01:00
Ratchanan Srirattanamet
f914df4f79
wwan/ofono: avoid bogus IP failure when not connecting
If modem is not at least "registered", a connection is not happening, which
means IP settings change is probably not interesting. Avoid trying to
parse it, so that we don't trigger connection failure when there isn't
one.
2022-11-10 07:44:58 +01:00
Ratchanan Srirattanamet
e7809a2bd7
wwan/ofono: clear current_octx on disconnect
This way, we won't signal failure when "PropertyChanged" signal for an
empty "Settings" eventually arrive.
2022-11-10 07:44:57 +01:00
Ratchanan Srirattanamet
5abc6f5911
wwan/ofono: also recognize connman's "Powered" property
This property "controls [oFono] whether packet radio use is allowed". It
makes sense to consider the value of FALSE to mean DISABLED.
2022-11-10 07:44:57 +01:00
Ratchanan Srirattanamet
ffbb8d2f51
wwan/ofono: when connect while searching, wait a bit
We don't have to outright refuse to connect if we're not registered.
Instead, wait up to 60 seconds for modem to register.
2022-11-10 07:44:56 +01:00
Bhushan Shah
9fc72bf75d
wwan/ofono: create connections based on available contexts
Downstream patches for this does it through NMSettings plugin, however
settings plugin are hard to maintain and complicated architecture wise
as well.

So directly create a connection profiles in-memory from the
nm-modem-ofono side. Those profiles are created in /run, and are not
added as a persistent connection, because connection state quite depends
on the state of ofono

This also allows us to drop the hack where we are keeping track of
active context/APN through the connection name, i.e if connection name
was in /imsi/context1 format, it was used. Instead now, Connection name
is actual context name which is user friendly ("Vodafone Connect" e.g.
in my case), and details like IMSI and context are stored internally.

[ratchanan@ubports.com:
- forward-ported to main branch.
- fold "wwan/ofono: handle context removal" into this commit.
- track the "preferred"-ness of the context and react accordingly.
  Creates proxies for all retrived contexts to listen to changes.
  While at it, also track name and type.
- use, instead of ignore, internet APN. Also support internet+mms APN.
- correct priv->contexts' value destroy function.
- factor out UUID generation as a helper function.
- handle the case where context dictionary is missing required keys.
- simplify nm_ofono_connection_new's arguments and rename to
  add_or_update_connection. Makes it handle the case where the
  connection already exists.
- also simplify other functions' arguments.
- clean up code and comments. Fix memory problems. Get rid of warnings.
]

Co-authored-by: Ratchanan Srirattanamet <ratchanan@ubports.com>
2022-11-10 07:44:56 +01:00
Yufan You
a275285537
supplicant: add NMSetting8021xAuthFlags for TLS v1.3 / enable a version
In the commit 2a11c57c4e ('libnm/wifi: rework NMSetting8021xAuthFlags
to explicitly disable TLS version'), it said:

> In the future, supplicant may disable options by default, and
> the inverse option can become interesting to configure
> "tls_disable_tlsv1_0=0". When that happens, we can solve it by
> adding another flag NM_SETTING_802_1X_AUTH_FLAGS_TLS_1_0_ENABLE.

This commit adds the `NM_SETTING_802_1X_AUTH_FLAGS_TLS_1_0_ENABLE`
flag as well as similar flags for other TLS versions.

This commit also adds flags for TLS v1.3, as the corresponding flags
are now provided in wpa_supplicant.

The NMSetting8021xAuthFlags setting is rejected when both enable and
disable are set for the same TLS version. if-else-if is used in
nm_supplicant_config_add_setting_8021x to guarantee this behavior.
It prefers ENABLE over DISABLE to match the behavior of wpa_supplicant.

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1450
2022-11-08 07:15:14 +01:00
Thomas Haller
dc26e65928
tests: add tests for generating stable UUIDs for keyfile/initrd
Fixes: 7ee0da3eaf ('build: don't "update-po" during make dist')
2022-11-03 09:23:57 +01:00
Thomas Haller
4fa20ce710
platform/tests: don't use translations in test tool
Otherwise, this file would need to be included in POTFILES.in.
This is unnecessary.

Fixes: 06cf1f5e2d ('platform/tests: extend monitor tool to dump the state of NMPlatform')
2022-10-27 15:18:54 +02:00
Thomas Haller
3a8decd9cf
hostname: rename nm_hostname_manager_write_hostname() to set_static_hostname() 2022-10-27 15:18:54 +02:00
Thomas Haller
d5be1c706e
dns/resolved: set DoT server name (SNI) in systemd-resolved
Unfortunately, for this we require SetLinkDNSEx() API from v246.
That adds extra complexity.

If the configuration contains no server name, we continue using
SetLinkDNS(). Otherwise, at first we try using SetLinkDNSEx().
We will notice if that method is unsupported, reconfigure with
SetLinkDNS(), and set a flag to not try that again.
2022-10-27 09:11:38 +02:00
Thomas Haller
ba33942734
dns/resolved: cleanup detection of supported API in "nm-dns-systemd-resolved.c"
- rename the "has_" variables to have the same name as the API that they
  check.
- do an if-else-if for checking the operation when detecting support.

This just feels nicer. No strong reasons.
2022-10-27 09:11:35 +02:00
Thomas Haller
c68e148b02
core: extend NML3ConfigData:nameserver to track DNS as string
The DNS name can now also contain the DoT server name. It's not longer a
binary IP address only.

Extend NML3ConfigData to account for that. To track the additional
data, use the string representation. The alternative to have a separate
type that contains the parsed information would be cumbersome too.
2022-10-27 09:11:33 +02:00
Thomas Haller
6f9090538f
dns: accept DoT SNI server name in "ipv[46].dns" settings 2022-10-27 09:11:31 +02:00
Thomas Haller
d8ea008372
wifi/iwd: merge ip[46]_config_to_iwd_config()
It is almost always wrong, to split IPv4 and IPv6 behaviors at a high level.
Most of the code does something very similar. Combine the two functions.
and let them handle the difference closer to where it is.
2022-10-27 09:11:27 +02:00
Thomas Haller
8e3202e499
policy: refactor all_devices_not_active() to any_devices_active()
The double negation is hard to understand.
2022-10-26 13:50:50 +02:00
Beniamino Galvani
8e85c86add dhcp: improve detection of DADFAILED addresses
Instead of assuming any address that disappeared was because of a DAD
failure, check explicitly that either:

 - the address is still present with DADFAILED flag (in case it was a
   permanent address), or

 - the address was removed and platform recorded that it had the
   DADFAILED flag.
2022-10-26 10:08:53 +02:00
Beniamino Galvani
922ef4344e ndisc: log DAD failures at info level
A DAD failure is in most cases a symptom of a network
misconfiguration; as such it must be logged in the default
configuration (info level).

While at it, fix other log messages.
2022-10-26 10:08:53 +02:00
Beniamino Galvani
addb4e3a0c device: generate a new AC6 address when DAD fails
For addresses that fail DAD we need to call nm_ndisc_dad_failed() to
generate a new address if addrgenmode is stable-privacy.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1046
2022-10-26 10:08:53 +02:00
Beniamino Galvani
15d55e5a68 device: use nm_l3cfg_check_ready() in _dev_ipac6_ndisc_config_changed()
Instead of open coding the check for ready addresses, use
nm_l3cfg_check_ready().
2022-10-26 10:05:16 +02:00
Beniamino Galvani
5da8e0666b ndisc: accept multiple addresses in nm_ndisc_dad_failed()
Since we evaluate platform changes in a idle handler, there can be
multiple DAD failure at the same time that must generate a single
ndisc.configuration-change signal.

The function is unused at the moment.
2022-10-26 08:54:29 +02:00
Beniamino Galvani
afa208c862 core: return conflicting addresses from nm_l3cfg_check_ready()
It can be useful to know which addresses are conflicting, return them
from nm_l3cfg_check_ready().
2022-10-26 08:54:29 +02:00
Beniamino Galvani
19c0018f58 l3cfg: don't accept AF_UNSPEC in nm_l3cfg_check_ready()
All the callers pass either AF_INET or AF_INET6, drop support for
AF_UNSPEC; this simplifies the function for the next commit that adds
a @conflicts argument.
2022-10-26 08:54:29 +02:00
Thomas Haller
ff9f413fcc
platform/tests: use nmtst_inet6_from_string() instead of *nmtst_inet6_from_string_p() 2022-10-26 08:24:29 +02:00
Thomas Haller
2786a30a7c
platform/tests: rename nmtst_inet6_from_string() to nmtst_inet6_from_string_p()
This helper returns a pointer (to a thread local variable).
2022-10-26 08:24:28 +02:00
Thomas Haller
06cf1f5e2d
platform/tests: extend monitor tool to dump the state of NMPlatform
This is useful for manual testing ("manual", in the sense that you can
write a script that tests the behavior of the platform cache, without
humanly reading the logfile).

Usage:

To write the content of the platform cache once:

  ./src/core/platform/tests/monitor -P -S './statefile'

To keep monitor running, and update the state file:

  ./src/core/platform/tests/monitor -S './statefile'
2022-10-26 08:24:28 +02:00
Thomas Haller
3654fc8145
platform/tests: make "external_command" int type
The variable is passed to nmtstp_run_command_check_external(), which accepts
-1 to mean choose randomly. Change the function signature to reflect that.
2022-10-26 08:24:28 +02:00