Commit graph

23935 commits

Author SHA1 Message Date
Thomas Haller
b82a8e4e01 keyfile: avoid assertion failure in nm_keyfile_plugin_kf_get_{string,integer}_list()
g_key_file_get_integer_list() can return %NULL without setting an error.
That is the case if the key is set to an empty value.

For X sake, this API. Read the documentation and figure out whether
the function can return %NULL without reporting an error.

Anyway, avoid the assertion failure.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/412
(cherry picked from commit 8f46425b11)
(cherry picked from commit 97139f5e3d)
(cherry picked from commit 59d488cb46)
2020-04-16 09:48:21 +02:00
Thomas Haller
0a10468d79 initrd: fix setting VLan ID in reader_parse_vlan()
g_ascii_strtoull() returns a guint64, which is very wrong to directly pass
to the variadic argument list of g_object_set(). We expect a guint there
and need to cast.

While at it, use _nm_utils_ascii_str_to_int64() to parse and validate the input.

(cherry picked from commit d506823d4f)
(cherry picked from commit 24177569c1)
2020-04-02 09:52:27 +02:00
Thomas Haller
477c6c3e70 contrib/rpm: avoid bare words in spec file
error: bare words are no longer supported, please use "...":  "x" != x
   error:                                                               ^
   error: /root/nm-build/NetworkManager/contrib/fedora/rpm/NetworkManager.20200402-030113.Hk7EGs/SPECS/NetworkManager.spec:32: bad %if condition:  "x" != x
   ERROR: rpmbuild FAILED

(cherry picked from commit 68b38a09d1)
(cherry picked from commit 045194760e)
2020-04-02 09:37:35 +02:00
Thomas Haller
56c653eca5 core: avoid assertion failure in _settings_connection_flags_changed() without device
It seems not unexpected, that we get a flags-changed notification while
having no device. Handle it gracefully and avoid the assertion failure.

   #0  _g_log_abort (breakpoint=breakpoint@entry=1) at gmessages.c:583
   #1  g_logv (log_domain=0x55f3c86f0262 "NetworkManager", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7ffcbf88f1c0) at gmessages.c:1391
   #2  g_log (log_domain=log_domain@entry=0x55f3c86f0262 "NetworkManager", log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0x7f21e99adb27 "%s: assertion '%s' failed") at gmessages.c:1432
   #3  g_return_if_fail_warning (log_domain=log_domain@entry=0x55f3c86f0262 "NetworkManager", pretty_function=pretty_function@entry=0x55f3c875f290 <__func__.53083> "nm_device_reapply", expression=expression@entry=0x55f3c8752507 "NM_IS_DEVICE (self)") at gmessages.c:2809
   #4  nm_device_reapply (self=0x0, connection=connection@entry=0x55f3caab4e60, error=error@entry=0x7ffcbf88f308) at src/devices/nm-device.c:12107
   #5  _settings_connection_flags_changed (settings_connection=<optimized out>, self=0x55f3caabca70 [NMActRequest]) at src/nm-active-connection.c:960
   #9  <emit signal ??? on instance 0x55f3caaaf530 [NMSettingsConnection]> (instance=instance@entry=0x55f3caaaf530, signal_id=<optimized out>, detail=detail@entry=0) at gsignal.c:3447
   #6  g_closure_invoke (closure=0x55f3caa4c160, return_value=return_value@entry=0x0, n_param_values=1, param_values=param_values@entry=0x7ffcbf88f520, invocation_hint=invocation_hint@entry=0x7ffcbf88f4c0) at gclosure.c:804
   #7  signal_emit_unlocked_R (node=node@entry=0x55f3ca9dcf90, detail=detail@entry=0, instance=instance@entry=0x55f3caaaf530, emission_return=emission_return@entry=0x0, instance_and_params=instance_and_params@entry=0x7ffcbf88f520) at gsignal.c:3635
   #8  g_signal_emit_valist (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>, var_args=var_args@entry=0x7ffcbf88f6a0) at gsignal.c:3391
   #10 nm_settings_connection_set_flags_full (self=self@entry=0x55f3caaaf530 [NMSettingsConnection], mask=<optimized out>, value=<optimized out>) at src/settings/nm-settings-connection.c:2025
   #11 _connection_changed_process_all_dirty (update_reason=(NM_SETTINGS_CONNECTION_UPDATE_REASON_RESET_SYSTEM_SECRETS | NM_SETTINGS_CONNECTION_UPDATE_REASON_RESET_AGENT_SECRETS), sett_mask=<optimized out>, sett_flags=<optimized out>, connection=0x55f3caab4f80, sett_conn_entry=<optimized out>, self=0x55f3ca99c000 [NMSettings]) at src/settings/nm-settings.c:1099
   #12 _connection_changed_process_all_dirty (update_reason=(NM_SETTINGS_CONNECTION_UPDATE_REASON_RESET_SYSTEM_SECRETS | NM_SETTINGS_CONNECTION_UPDATE_REASON_RESET_AGENT_SECRETS), override_sett_flags=1, sett_mask=_NM_SETTINGS_CONNECTION_INT_FLAGS_PERSISTENT_MASK, sett_flags=<optimized out>, allow_add_to_no_auto_default=0, sett_conn_entry=<optimized out>, self=0x55f3ca99c000 [NMSettings]) at src/settings/nm-settings.c:1284
   #13 _connection_changed_process_all_dirty (self=self@entry=0x55f3ca99c000 [NMSettings], allow_add_to_no_auto_default=allow_add_to_no_auto_default@entry=0, sett_flags=sett_flags@entry=NM_SETTINGS_CONNECTION_INT_FLAGS_NONE, sett_mask=sett_mask@entry=NM_SETTINGS_CONNECTION_INT_FLAGS_NONE, override_sett_flags=override_sett_flags@entry=1, update_reason=update_reason@entry=(NM_SETTINGS_CONNECTION_UPDATE_REASON_RESET_SYSTEM_SECRETS | NM_SETTINGS_CONNECTION_UPDATE_REASON_RESET_AGENT_SECRETS)) at src/settings/nm-settings.c:1304
   #14 _plugin_connections_reload (self=self@entry=0x55f3ca99c000 [NMSettings]) at src/settings/nm-settings.c:1417
   #15 impl_settings_reload_connections (obj=0x55f3ca99c000 [NMSettings], interface_info=<optimized out>, method_info=<optimized out>, connection=<optimized out>, sender=<optimized out>, invocation=0x7f21d000c100 [GDBusMethodInvocation], parameters=0x55f3ca9e1f20) at src/settings/nm-settings.c:2822
   ...

https://bugzilla.redhat.com/show_bug.cgi?id=1816067
(cherry picked from commit 44fed3c340)
(cherry picked from commit cdfb762880)
2020-03-23 13:33:16 +01:00
Thomas Haller
76fedd150b man: improve manual page for nm-online
https://bugzilla.redhat.com/show_bug.cgi?id=1706646

(cherry picked from commit b2a0738765)
(cherry picked from commit 4b07cb9d3c)
2020-03-17 13:40:54 +01:00
Beniamino Galvani
e849f540ec Revert "dispatcher/systemd: order NetworkManager-dispatcher.service Before=NetworkManager.service"
The 'Before' dependency between NM-dispatcher and NM causes a deadlock
when stopping the NM service. When terminating, NM wants to D-Bus
activate NM-dispatcher to synchronously handle pre-down events; but
NM-dispatcher start is ordered after NM shutdown due to the following
behavior described in systemd.unit(5) man page:

  Given two units with any ordering dependency between them, if one
  unit is shut down and the other is started up, the shutdown is
  ordered before the start-up. It doesn't matter if the ordering
  dependency is After= or Before=, in this case. It also doesn't
  matter which of the two is shut down, as long as one is shut down
  and the other is started up; the shutdown is ordered before the
  start-up in all cases.

So, NM is waiting NM-dispatcher to start and NM-dispatcher is queued
by systemd, waiting that NM is stopped. The result is a 90 seconds
delay, after which systemd kills NM and continues.

The dependency was added so that during shutdown NM-dispatcher would
be stopped after NM. I don't think it worked as expected because
NM-dispatcher is not supposed to be active most of the times, and so
it doesn't need a dependency that delays its stop after NM.

This reverts commit acc335aad4.

(cherry picked from commit 105abf27c1)
(cherry picked from commit 08e8afcf17)
2020-03-02 17:51:16 +01:00
Beniamino Galvani
eee2224779 Revert "core: create virtual device on settings changes in idle handler"
When AddConnection() or Update() terminate, the (unrealized) virtual
device should be already be available, otherwise an activation attempt
of that connection can fail.

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

This reverts commit c163207b07.

(cherry picked from commit efc04b1285)
(cherry picked from commit 987c1d282a)
2020-02-26 15:00:15 +01:00
Beniamino Galvani
ee8ae9ae43 dhcp: merge branch 'bg/dhcp-invalid-hostname'
https://bugzilla.redhat.com/show_bug.cgi?id=1744427
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/310
(cherry picked from commit a5f22dbc5d)
2020-02-10 09:44:20 +01:00
Beniamino Galvani
9c7859d05b dhcp: ignore hostname when invalid
The hostname used for DHCP can be the one obtained from the hostnamed
service and is not guaranteed to be valid, at least with systemd
239. Instead of sending an invalid DHCP option to the server or
failing due to later checks in clients, ignore the hostname and log a
warning when it is invalid.

https://bugzilla.redhat.com/show_bug.cgi?id=1744427
(cherry picked from commit 2da4d54ac3)
2020-02-10 09:44:03 +01:00
Beniamino Galvani
7a08b29a3d shared: export systemd dns and hostname validation functions
(cherry picked from commit 38f942e038)
2020-02-10 09:44:01 +01:00
Beniamino Galvani
fddc57d60a shared: fix function return value
(cherry picked from commit 319a39cac6)
2020-02-10 09:44:00 +01:00
Thomas Haller
dc9322c0a9 supplicant: fix memory corruption with wrong argument to NM_SUPPLICANT_INTERFACE_GROUP_FORMATION_FAILURE signal
The signal is unused (and should be removed).

Still, the parameter passed to g_signal_emit() is a C string, not a
GVariant. I think as there are no subscribers, glib wouldn't actually
do anything with the arguments. Though, I am not sure whether glib still
tries to initialize a GValue with a GVariant type, leading to a crash.

Fixes: f05b7a78c9 ('supplicant: Track P2P Group information, creation and destruction')
(cherry picked from commit c106008091)
(cherry picked from commit 26d6ac5385)
2020-01-30 11:45:49 +01:00
Will Dietz
74eeb1d2cd build/meson: fix missing slash when detecting resolvconf/netconfig binaries
Fix detection for /usr/local/sbin/{resolvconf,netconfig}.
(and no longer automatically use "/usr/local/sbinnetconfig" if present)

Fixes: 5a0cef2f36 ('build: meson: uniform handling of rc managers')

[thaller@redhat.com: commit message adjusted]

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/349
(cherry picked from commit 2b17f246f0)
(cherry picked from commit 00feb26d70)
2020-01-28 16:12:59 +01:00
Antonio Cardace
ee7bbddb6f release: bump version to 1.20.11 (development) 2020-01-09 18:18:40 +01:00
Antonio Cardace
d4030b240e release: bump version to 1.20.10 2020-01-09 18:17:51 +01:00
Antonio Cardace
023fd136d1 release: update NEWS 2020-01-09 18:16:10 +01:00
Thomas Haller
fff235e3a5 device/wifi: fix memleak parsing SSID arguments for "RequestScan"
Oddly enough, valgrind was not complaining about this leak...

Fixes: 87b2d783b6 ('core: accept 'ssids':aay option in RequestScan() dictionary parameter')
(cherry picked from commit 5ed1edc02a)
(cherry picked from commit 568c19f07d)
2020-01-08 13:22:27 +01:00
Andika Triwidada
66108969e2 po: update Indonesian (id) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/380
2020-01-02 09:52:42 +01:00
Beniamino Galvani
cbb1ad1ba7 manager: create a virtual device only if the connection can autoconnect
The autoconnection for virtual devices currently works in two
phases. First we detect that there is suitable profile that can
autoconnect and we realize the device. Then, when the device becomes
'disconnected', autoconnect kicks in and starts the activation.

However, if autoconnect is blocked for a device, currently we do step
1 without step 2, leaving a stale interface around. Fix this by also
checking that autoconnect is not blocked during step 1.

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/360
(cherry picked from commit 6c716912eb)
(cherry picked from commit 944ff9f9dc)
2019-12-24 09:21:46 +01:00
Piotr Drąg
e6a06fd68e po: update Polish (pl) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/371
2019-12-22 08:12:03 +01:00
Thomas Haller
2f62e30b7c libnm: fix type annotation for nm_sriov_vf_get_vlan_ids()
Otherwise, this function cannot really be used via generated bindings.
Also, it's the only way to actually retrieve the set vlan-ids, without
it, you wouldn't know which ones are set.

Fixes: a9b4532fa7 ('libnm-core: add SR-IOV setting')
(cherry picked from commit c4a728217d)
(cherry picked from commit 49376697c6)
2019-12-20 14:53:24 +01:00
Beniamino Galvani
bfece9d4fc dhcp: nettools: fix parsing of search domains option
'first' was never modified and so the dot was never added.

Fixes: 6adade6f21 ('dhcp: add nettools dhcp4 client')

https://bugzilla.redhat.com/show_bug.cgi?id=1783981
(cherry picked from commit 9aa00a8a14)
(cherry picked from commit ea22135384)
2019-12-17 14:36:23 +01:00
Thomas Haller
f200573a95 all: fix wrong "gs_free GError *" declarations
This is a bug and leads either to a leak or a crash.

(cherry picked from commit 4a3ca7115a)
(cherry picked from commit 809d70ee64)
2019-12-16 17:46:59 +01:00
Thomas Haller
00cf235a7a checkpatch: catch "gs_free GError *" declations
(cherry picked from commit ec0adbfaf0)
(cherry picked from commit 2fa4827eb9)
2019-12-16 17:46:10 +01:00
Beniamino Galvani
a3ed90bdbc device: don't reapply IP configuration if the ifindex is missing
Assertions will fail in ip_config_merge_and_apply() if the device
doesn't have an ifindex. Reproducible with:

 $ nmcli connection add type ovs-bridge ifname ovs0 ipv4.method disabled ipv6.method disabled
 Connection 'ovs-bridge-ovs0' (1d5e794b-10ad-4b2b-aa7c-5ca7e34b0a55) successfully added

 $ nmcli device reapply ovs0
 Error: Reapplying connection to device '(null)' (/org/freedesktop/NetworkManager/Devices/16) failed: Remote peer disconnected

 $ journalctl -u NetworkManager -e
 ...
 NetworkManager[73824]: nm_ip4_config_add_dependent_routes: assertion 'ifindex > 0' failed
 systemd[1]: NetworkManager.service: Main process exited, code=dumped, status=5/TRAP
 ...

(cherry picked from commit 6d6e1402dc)
(cherry picked from commit f1d4853927)
2019-12-14 21:08:27 +01:00
Beniamino Galvani
65d37a3bfa ovs: check state before starting ip configuration after link change
When the link becomes available, check that the device is in the
ip-config state before starting ip configuration. Also, reset the
'waiting_for_interface' flag when the device deactivates.

https://bugzilla.redhat.com/show_bug.cgi?id=1781165
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/358
(cherry picked from commit 0738c10445)
(cherry picked from commit 3381299562)
2019-12-14 21:08:26 +01:00
Beniamino Galvani
74649429df manager: forbid autoactivation of parent when it is blocked by user request
If a device is being autoactivated and requires a parent that is
blocked due to user request, the autoactivation attempt should fail
because NM shouldn't overrule the user decision.

https://bugzilla.redhat.com/show_bug.cgi?id=1765566
(cherry picked from commit f2dbf8fbc0)
(cherry picked from commit 61d431a9e8)
2019-12-11 13:55:32 +01:00
Beniamino Galvani
269deeebf8 merge: branch 'bg/mtu-reapply-rh1779162'
https://bugzilla.redhat.com/show_bug.cgi?id=1779162
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/356
(cherry picked from commit ce2cceef83)
(cherry picked from commit 73a2557a6f)
2019-12-11 13:54:49 +01:00
Beniamino Galvani
0064401e35 device: always allow reapply of MTU from wired setting
Many device types take the MTU value from the wired setting; usually
they don't implement the can_reapply_change() method and so the MTU
can't be changed with the Reapply() API.

Instead of implementing the method for all such devices to support the
same property (adding a lot of duplicated code), add a check in
NMDevice to allow the reapply of MTU when we recognize that the device
uses the MTU from the wired setting.

Device types can still decide to implement can_reapply_change() and
support whatever properties they want, even from the wired setting.

(cherry picked from commit 9339d3310e)
(cherry picked from commit 1191eba15a)
2019-12-11 13:54:35 +01:00
Beniamino Galvani
4134023a29 infiniband: allow reapply of MTU
(cherry picked from commit ceeefa82c5)
(cherry picked from commit 1aedf60244)
2019-12-11 13:54:32 +01:00
Thomas Haller
ee032f79df settings: assert that we don't leak error variable in impl_settings_load_connections()
(cherry picked from commit e0569ee575)
(cherry picked from commit 7e8a5d98e3)
2019-12-09 09:55:51 +01:00
Thomas Haller
aa545d5b58 settings: fix use after free in keyfile's load_connections()
Fixes: d35d3c468a ('settings: rework tracking settings connections and settings plugins')
(cherry picked from commit eb642fecdf)
(cherry picked from commit 6d37f690ad)
2019-12-09 09:55:49 +01:00
Beniamino Galvani
8274cc1353 device: don't transition assumed devices to FAILED before ACTIVATED
If the activation of an assumed device fails, we first set the device
state to FAILED and then to ACTIVATED. In the FAILED state, the active
connection transitions to DEACTIVATED and clears its device pointer;
hence we end up with an inconsistent state which causes assertion
failures in other parts of the code (for example, get_best_ip_config()
assumes that the device of the best active connection is not NULL).

Don't first transition to FAILED and then to ACTIVATED, just set the
latter.

https://bugzilla.redhat.com/show_bug.cgi?id=1737774
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/351
(cherry picked from commit 93e9010b75)
(cherry picked from commit 366b90db87)
2019-12-05 17:14:31 +01:00
Beniamino Galvani
80bb91d8e6 manager: don't activate device if the parent is missing
In multiple places we currently proceed to creating a virtual device
even if the connection specifies a parent device which is
missing. This can be easily reproduced with:

  nmcli con add type vxlan ifname vxlan1 \
                vxlan.parent not-exists \
                id 43 remote 172.25.1.1

which creates a vxlan1 interface without activating any
connection. Add a check to prevent this.

https://bugzilla.redhat.com/show_bug.cgi?id=1774074
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/344
(cherry picked from commit a73efb059f)
2019-11-29 11:13:27 +01:00
Beniamino Galvani
6c8f42fdd1 systemd: use busctl instead of dbus-send
While dbus-send may not be installed, busctl is shipped with systemd
and so it should be always available.

(cherry picked from commit a2e6e7f2a9)
2019-11-29 10:49:08 +01:00
Thomas Haller
37c571a72a dispatcher: use free() to free memory allocated with malloc()
In practice, nowadays g_free() is the same as free(), so there is no
difference. However, we still should not mix the two and use free()
for data that was allocated with malloc() -- in this case, the memory
was allocated by libc's realpath().

(cherry picked from commit 3ade6dacfc)
2019-11-27 12:05:24 +01:00
Thomas Haller
467296ed17 dispatcher: fix detection of no-wait dispatcher scripts
While at it, use NM_STR_HAS_SUFFIX() with the string literal.

Fixes: 35a428f168 ('dispatcher: look for the scripts in /usr/lib as well')
(cherry picked from commit 1c2889faee)
2019-11-27 12:05:23 +01:00
Lubomir Rintel
cbecc4318c release: bump version to 1.20.9 (development) 2019-11-25 14:22:57 +01:00
Lubomir Rintel
4ef92efc07 release: bump version to 1.20.8 2019-11-25 13:58:32 +01:00
Lubomir Rintel
d437d58ebc release: update NEWS 2019-11-25 13:58:32 +01:00
Thomas Haller
962297f908 gitlab-ci: run tests on extra distributions only manually
For the moment, we use docker images from dockerhub, which require
a lot of extra overhead to prepare and install the test environment.
This should be improved, by using more suitable container images.

Anyway, for now to alleviate the pressure on the freedesktop gitlab
infrastructure, disable most test to only run manually.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/241#note_282521
(cherry picked from commit b733d477e8)
2019-11-22 14:41:06 +01:00
Thomas Haller
725141c07a gitlab-ci: use Fedora 30 to build documentation and archived tarball
(cherry picked from commit 339df56887)
2019-11-22 14:41:05 +01:00
Thomas Haller
361251989f ifcfg: merge branch 'th/ifcfg-8021x-system-ca-certs'
(cherry picked from commit c1dca47619)
2019-11-22 14:40:32 +01:00
Thomas Haller
b67983c387 ifcfg: various cleanup in ifcfg writer
svUnsetValue (ifcfg, KEY);
    if (condition)
         svSetValue* (ifcfg, KEY, ...);

is not good. It requires first clearing the value, before setting
it again.

Various cleanup to fix such uses.

(cherry picked from commit 5028206ec4)
2019-11-22 14:40:32 +01:00
Thomas Haller
d0572b6602 ifcfg: add support for "802-1x.system-ca-certs" setting
(cherry picked from commit 2a4fb75d3b)
2019-11-22 14:40:32 +01:00
Thomas Haller
f449ace2f1 ifcfg: add svSetValueBoolean_cond_true() helper
(cherry picked from commit 87af96a9d6)
2019-11-22 14:40:32 +01:00
Beniamino Galvani
8e2ad6f0c3 ethernet: wait for carrier before starting supplicant
After we set link parameters (auto-negotiation, speed, duplex) in
stage1, the carrier can go down for several seconds because the
Ethernet PHY needs to renegotiate the link. Wait that carrier goes up
before starting the supplicant or the EAPoL start packet can be lost
causing an authentication failure.

https://bugzilla.redhat.com/show_bug.cgi?id=1759797
(cherry picked from commit 838e5b87c2)
2019-11-21 10:22:47 +01:00
Beniamino Galvani
5a8ea69209 device: check for disconnected state before activating NMActRequest
When a new activation request comes and the device is currently
activated, we move the device state to 'deactivating' and wait that it
reaches 'disconnected' before starting the new activation request.

In the meantime, a carrier change could happen but still we have to
wait that device finishes any pending deactivation.

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/339
(cherry picked from commit 4b4f18e77b)
2019-11-21 10:10:06 +01:00
Beniamino Galvani
b366234a3a ovs: allow changing mac address of bridges and interfaces
Allow changing the cloned MAC address for OVS bridges and
interfaces. The MAC address set on the bridge is propagated by ovs to
the local interface (the one with the same name as the bridge), while
all other internal interfaces use the address defined in the interface
connection.

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/321
(cherry picked from commit 101e65d2bb)
2019-11-20 11:12:12 +01:00
Beniamino Galvani
ad17cfff24 ovs: fix memory leak
(cherry picked from commit 508c7679cf)
2019-11-20 11:10:53 +01:00