Commit graph

12593 commits

Author SHA1 Message Date
Beniamino Galvani
f59af10216
ifcfg-rh: fix memory leak reading tc filters
Fixes: 902bbfdb18 ('ifcfg-rh: add tc support')
(cherry picked from commit 88e8f2829e)
(cherry picked from commit b1e00a5805)
(cherry picked from commit 7a3f78d7eb)
2020-08-28 12:07:42 +02:00
Beniamino Galvani
cde95a3c75
ifcfg-rh: check return value of fdopen()
Reported by coverity:

>>> CID 210222: Null pointer dereferences (NULL_RETURNS)
>>> Dereferencing a pointer that might be "NULL" "f" when calling
    "fseek".

Fixes: ac5206aa9c ('2007-11-21')
(cherry picked from commit 581aa981c2)
(cherry picked from commit bb40de0ca0)
2020-08-28 12:06:56 +02:00
Thomas Haller
a1a3cce6ef
rdisc: avoid static variable in receive_ra()
It's unnecessary and makes the function unnecessarily not thread safe.
Of course, also ndp_msg_opt_route_prefix() uses static variables, so
it's still not thread safe.

Fixes: c3a4656a68 ('rdisc: libndp implementation')
(cherry picked from commit fbb65de32e)
2020-08-28 11:38:12 +02:00
Thomas Haller
b28eee1c4b
rdisc: fix parsing ndp_msg_opt_dnssl_lifetime() from IPv6 RA
Fixes: c3a4656a68 ('rdisc: libndp implementation')
(cherry picked from commit d1181533b8)
2020-08-28 11:38:01 +02:00
Beniamino Galvani
5f22c06c53 device: don't reset the MAC without ifindex
nm_device_cleanup() can be called when the device no longer has an
ifindex. In such case, don't try to reset the MAC address as that
would lead to an assertion failure.

(cherry picked from commit 77b6ce7d04)
(cherry picked from commit 791a888cad)
(cherry picked from commit e1f76e7044)
2020-07-21 10:19:11 +02:00
Beniamino Galvani
69c5c5e767 ovs: also set cloned MAC address via netlink
We already set the MAC of OVS interfaces in the ovsdb. Unfortunately,
vswitchd doesn't create the interface with the given MAC from the
beginning, but first creates it with a random MAC and then changes it.

This causes a race condition: as soon as NM sees the new link, it
starts IP configuration on it and (possibly later) vswitchd will
change the MAC.

To avoid this, also set the desired MAC via netlink before starting IP
configuration.

https://bugzilla.redhat.com/show_bug.cgi?id=1852106
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/483
(cherry picked from commit 47ec3d14d4)
(cherry picked from commit 60d10b146d)
(cherry picked from commit 0139995590)
2020-07-21 10:19:11 +02:00
Beniamino Galvani
f54c5400c8 ovs: set MAC address on the bridge for local interfaces
When a user creates a ovs-interface with the same name of the parent
ovs-bridge, openvswitch considers the interface as the "local
interface" [1] and assigns the MAC address of the bridge to the
interface [2].

This is confusing for users, as the cloned MAC property is ignored in
some cases, depending on the ovs-interface name.

Instead, detect when the interface is local and set the MAC from the
ovs-interface connection in the bridge table.

[1] https://github.com/openvswitch/ovs/blob/v2.13.0/vswitchd/vswitch.xml#L2546
[2] https://github.com/openvswitch/ovs/blob/v2.13.0/vswitchd/bridge.c#L4744

(cherry picked from commit 5d4c8521a3)
(cherry picked from commit 7548c29a89)
(cherry picked from commit 127294babc)
2020-07-21 10:19:11 +02:00
Beniamino Galvani
bb4781cc58 policy: block connection from autoconnect in case of failed dependency
A connection that fails due to dependency-failed is not able to
reconnect until the master connection activates again; when this
happens, the master clears the blocked reason for all its slaves in
activate_slave_connections() and tries to reconnect them. For this to
work, the slave should be marked as blocked when it fails with
dependency-failed.

(cherry picked from commit 725fed01cf)
(cherry picked from commit e1755048e3)
(cherry picked from commit ecb134ac34)
2020-07-21 10:17:20 +02:00
Beniamino Galvani
6d0e8a2acf manager: fix race condition when resuming from sleep
If the device state change (to disconnected or unmanaged) triggered by
a sleep event happens after the wake, the devices becomes wrongly
unmanaged and it's necessary to manually manage it again, or restart
NM.

During the wake event we should disconnect the device_sleep_cb()
callback for all devices because we don't want to react to state
changes anymore; in particular we don't need to detect when the device
becomes disconnected to unmanage it.

(cherry picked from commit fe2d93980b)
(cherry picked from commit 971897195a)
(cherry picked from commit 7913275b02)
2020-07-21 10:17:20 +02:00
Beniamino Galvani
da54b35af3 device: restart DHCP only for devices that are active or activating
do_sleep_wake() tries to restart DHCP for all devices, even ones that
are disconnecting. When a device is disconnecting, it still has a DHCP
client instance but we shouldn't restart it because it makes no sense;
and especially, the device could be already removed.

https://bugzilla.redhat.com/show_bug.cgi?id=1852612
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/561
(cherry picked from commit 2c50438987)
(cherry picked from commit 5321490180)
(cherry picked from commit ef755588ad)
2020-07-21 10:16:55 +02:00
Beniamino Galvani
5bfaee825c ppp: fix taking control of link generated by kernel
NetworkManager can't control the name of the PPP interface name
created by pppd; so it has to wait for the interface to appear and
then rename it. This happens in nm_device_take_over_link() called by
nm-device-ppp.c:ppp_ifindex_set() when pppd tells NM the ifindex of
the interface that was created.

However, sometimes the initial interface name is already correct, for
example when the connection.interface-name is ppp0 and this is the
first PPP interface created.

When this happens, nm_device_update_from_platform_link() is called on
the NMDevicePPP and it sets the device ifindex. Later, when pppd
notifies NM, nm_device_take_over_link() fails because the ifindex is
already set:

 nm_device_take_over_link: assertion 'priv->ifindex <= 0' failed

Make nm_device_take_over_link() more robust to cope with this
situation.

https://bugzilla.redhat.com/show_bug.cgi?id=1849386
(cherry picked from commit 75bc21c4cf)
(cherry picked from commit 72d66fffac)
(cherry picked from commit 684a1a06cc)
2020-07-08 15:14:22 +02:00
Beniamino Galvani
84ad85eb31 device: clean up exported IP6 config when flushing addresses
After flushing addresses and routes, it's also necessary to update the
exported IP6 configuration.

https://bugzilla.redhat.com/show_bug.cgi?id=1848888
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/551

Fixes: e302f5ff77 ('device: flush IP configuration of slaves during activation')
(cherry picked from commit 071104124b)
(cherry picked from commit 2b5ba370a6)
(cherry picked from commit 96f230bcee)
2020-06-30 13:46:04 +02:00
Beniamino Galvani
c92a857538 settings: fix assertion when updating default wired connection
The connection is expected to have the NM_GENERATED flag, since it has
a default wired device.

Fixes: d35d3c468a ('settings: rework tracking settings connections and settings plugins')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/471
(cherry picked from commit 4aefad5673)
(cherry picked from commit 3951396de7)
(cherry picked from commit ac89b8f6b7)
2020-06-22 09:59:14 +02:00
Beniamino Galvani
359f2ef1f2 Revert "manager: change autoconnect-slaves logic for already active slaves"
The commit breaks many nmstate CI tests. It also breaks the
autoconnect-slaves functionality: if the master gets reactivated and
the slave was active, the slave is not reconnected.

A different solution is needed for the original issue.

This reverts commit 024e983c8e.

(cherry picked from commit 6e02622f57)
(cherry picked from commit 877599c390)
2020-06-15 10:15:35 +02:00
Beniamino Galvani
399aad15bf ovs: ignore failures of patch interfaces
When there are two patch ports connected, each of them must reference
the other; however they can't be created in a single transaction
because they are part of different bridges (so, different
connections). Therefore, the first patch that gets activated will
always fail with "No usable peer $x exists in 'system' datapath" until
the second patch exists.

In theory we could also match the error message, however this doesn't
seem very robust as the message may slightly change in the future.

(cherry picked from commit ffeac35f04)
(cherry picked from commit 75cbf21738)
2020-06-11 13:28:09 +02:00
Thomas Haller
f238f0a714
supplicant: fix verification of key_mgmt config for FT-FILS-SHA{256,384}
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/468

Fixes: d17a0a0905 ('supplicant: allow fast transition for WPA-PSK and WPA-EAP')
(cherry picked from commit e7a74721be)
(cherry picked from commit e5fb776441)
2020-06-11 11:10:29 +02:00
Beniamino Galvani
4df63b205e manager: change autoconnect-slaves logic for already active slaves
Autoconnect-slaves currently forces an activation of all slaves, even
if there is already an active connection for them. This is bad because
at boot slaves first try to autoconnect, then the autoconnect-slaves
of the master kicks in and disconnects/reactivates them.

The only reason why the forceful reactivation was added was to fix
[1]; in that scenario, a slave connection is already active as
non-slave; then it is updated to be a slave; later, the master with
autoconnect-slaves is manually activated. NetworkManager should detect
that the slave connection must now be activated by autoconnect-slaves.

Add a specific check for such situation, instead of always
reactivating all slaves.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1845018

Fixes: 4985ca5ada ('manager: allow autoconnect-slaves to reconnect the same connection')
(cherry picked from commit 024e983c8e)
(cherry picked from commit d07d515dd7)
2020-06-11 10:29:57 +02:00
Thomas Haller
77e1132845
ifcfg-rh: support persisting 802-1x.pin and pin-flags property
(cherry picked from commit 655fd1ebd8)
(cherry picked from commit 799cee5068)
2020-05-29 13:12:13 +02:00
Thomas Haller
7a20dd4dbb
ifcfg-rh: fix handling "802-1x.{phase2-,}ca-path" in ifcfg-rh settings plugin
https://bugzilla.redhat.com/show_bug.cgi?id=1840210
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/448
(cherry picked from commit b6b6639c7c)
(cherry picked from commit 67f1da27fe)
2020-05-27 10:57:29 +02:00
Beniamino Galvani
678c6b6a6a core: signal parent-active only when the parent AC is activated
The parent-active signal is used by the manager to determine when the
parent active-connection is ready and a connection that depend on it
can proceed.

The AC state could transition from ACTIVATING directly to
DEACTIVATING; in such case we should not emit the signal but instead
just stop watching the parent AC.

Fixes: 6e382ea91d ('active-connection: add parent active connection tracking')
https://bugzilla.redhat.com/show_bug.cgi?id=1778073
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/510
(cherry picked from commit 02ea74c920)
(cherry picked from commit 30be025e59)
2020-05-19 21:43:42 +02:00
Beniamino Galvani
1dcdd1e8dd device: use the nm-shared firewalld zone in shared mode
When the interface is in IPv4 or IPv6 shared mode and the user didn't
specify an explicit zone, use the nm-shared one.

Note that masquerade is still done through iptables direct calls
because at the moment it is not possible for a firewalld zone to do
masquerade based on the input interface.

The firewalld zone is needed on systems where firewalld is using the
nftables backend and the 'iptables' binary uses the iptables API
(instead of the nftables one). On such systems, even if the traffic is
allowed in iptables by our direct rules, it can still be dropped in
nftables by firewalld.

(cherry picked from commit 3e2b723532)
(cherry picked from commit 13438e041a)
2020-05-19 08:42:42 +02:00
Beniamino Galvani
d69d92c658 ip-tunnel: set cloned-mac-address only for layer2 tunnel devices
For ip-tunnel modes that encapsulate layer2 packets (gretap and
ip6gretap) we allow the presence of an ethernet setting in the
connection and honor the cloned-mac-address specified in it.

For all other modes, the ethernet setting is removed during
normalization, but a value different from 'preserve' could be set via
global default.

The kernel doesn't allow setting a MAC for layer3 devices, don't do
it.

(cherry picked from commit 0494a84878)
(cherry picked from commit 78ed14166c)
2020-05-15 10:04:04 +02:00
Thomas Haller
c0997fa4f3
acd: fix char buffer argument to _acd_event_to_string_buf()
(cherry picked from commit 6e9967939b)
(cherry picked from commit 1e1ae9ba07)
2020-05-08 07:58:36 +02:00
Thomas Haller
198e233b91
acd: avoid alloca() inside an unbounded loop
(cherry picked from commit b447c80ad8)
(cherry picked from commit ecb9e0e3df)
2020-05-07 14:06:09 +02:00
Beniamino Galvani
cd056b664b platform: fix test failure when /proc is mounted read-only
Expect a failure when writing to /proc if the file system is mounted
read-only.

(cherry picked from commit 211eb3ff8a)
2020-05-04 14:00:27 +02:00
Beniamino Galvani
93df9d6c49 device: flush IP configuration of slaves during activation
If a device only has an IPv6 link-local address, we don't generate an
assumed connection. Therefore, when a new slave connection (without IP
configuration) is activated on the device, we don't deactivate any
existing connection and the link-local address remains configured.

The IP configuration of an activated slave should be predictable and
not depend on the previous state; let's flush addresses and routes on
activation.

https://bugzilla.redhat.com/show_bug.cgi?id=1816517
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/480
(cherry picked from commit e302f5ff77)
(cherry picked from commit 0344a97105)
2020-04-28 10:02:58 +02:00
Thomas Haller
55c361453b vpn: clear host part of IPv6 routes received from VPN plugin
Kernel would reject adding a route with a destination host part not
all zero. NetworkManager generally coerces such routes and there
are assertions in place to ensure that.

We forgot to ensure that for certain IPv6 routes from VPN plugins.
This can cause an assertion failure and wrong behavior.

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/482
(cherry picked from commit b437bb4a6e)
(cherry picked from commit c7586e6388)
2020-04-28 09:43:04 +02:00
Beniamino Galvani
6abf71f056 bluetooth: disconnect signal on dispose
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/417

Fixes: 4154d9618c ('bluetooth: refactor BlueZ handling and let NMBluezManager cache ObjectManager data')
(cherry picked from commit 5c547fdab3)
(cherry picked from commit 93b130c05a)
2020-04-22 09:24:29 +02:00
Beniamino Galvani
2b7908a1c6 dhcp-helper: retry in case of failure connecting to D-Bus unix socket
Connecting to the unix socket can fail with EAGAIN if there are too
many pending connections and the server can't accept them in time
before reaching backlog capacity. Ideally the server should increase
the backlog length, but GLib doesn't provide a way to change it for a
GDBus server. Retry for up to 5 seconds in case of failure.

https://bugzilla.redhat.com/show_bug.cgi?id=1821594
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/471
(cherry picked from commit eefe5dacaa)
(cherry picked from commit 4cf63dfa15)
2020-04-21 08:58:29 +02:00
Beniamino Galvani
54254bf6fe ovsdb: retry calls in case of communication error with server
When the server is restarted the write to unix socket fails with
EPIPE. In such case, don't fail all the calls in queue; instead, after
a sync of the ovsdb state (through a monitor call), start processing
the queue again, including the call that previously failed.

Add a retry counter to avoid that calls are stuck in the queue forever
in a hypothetical scenario in which the write always fails.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/459
(cherry picked from commit db37e530e8)
2020-04-09 17:29:17 +02:00
Thomas Haller
eec2740d71 all: use wrappers for g_ascii_strtoll(), g_ascii_strtoull(), g_ascii_strtod()
Sometimes these function may set errno to unexpected values like EAGAIN.
This causes confusion. Avoid that by using our own wrappers that retry
in that case. For example, in rhbz#1797915 we have failures like:

    errno = 0;
    v = g_ascii_strtoll ("10", 0, &end);
    if (errno != 0)
        g_assert_not_reached ();

as g_ascii_strtoll() would return 10, but also set errno to EAGAIN.

Work around that by using wrapper functions that retry. This certainly
should be fixed in glib (or glibc), but the issues are severe enough to
warrant a workaround.

Note that our workarounds are very defensive. We only retry 2 times, if
we get an unexpected errno value. This is in the hope to recover from
a spurious EAGAIN. It won't recover from other errors.

https://bugzilla.redhat.com/show_bug.cgi?id=1797915
(cherry picked from commit 7e49f4a199)
2020-04-02 07:45:39 +02:00
Thomas Haller
62469c1401 device/bluetooth: avoid g_ascii_strtoull() to parse capabilities
Avoid g_ascii_strtoull() calling directly. It has subtle issues, which is why
we have a wrapper for it.

(cherry picked from commit 659ac9cc12)
2020-04-02 07:44:25 +02:00
Thomas Haller
1a80179c60 ifupdown: use _nm_utils_ascii_str_to_int64() for converting netmask to string
(cherry picked from commit 3930ef194e)
2020-04-02 07:44:25 +02:00
Thomas Haller
c81d12bc69 ifcfg-rh/tests: add unit test for reading DEVTIMEOUT (connection.wait-device-timeout)
(cherry picked from commit 9cbf4c2825)
2020-04-02 07:44:25 +02:00
Thomas Haller
5a44792e41 ifcfg: strip whitespaces around "DEVTIMEOUT"
Be more graceful and allow whitespaces around the floating point number
for DEVTIMEOUT. Note that _nm_utils_ascii_str_to_int64() is already graceful
against whitespace, so also be it with the g_ascii_strtod() code path.

(cherry picked from commit 2e4771be5e)
2020-04-02 07:44:25 +02:00
Thomas Haller
24177569c1 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)
2020-04-02 07:44:24 +02:00
Beniamino Galvani
e27a59c69e ovs: set the MTU in ovsdb when changing platform MTU of ovs-interface
If we change the the MTU of an ovs interface only through netlink, the
change could be overridden by ovs-vswitchd at any time when other
interfaces change. Set the MTU also in the ovsdb to prevent such
changes.

Note that if the MTU comes from the connection, we already set the
ovsdb MTU at creation time and so this other update becomes
useless. But it is needed when changing the MTU at runtime (reapply)
or when the MTU comes from a different source (e.g. DHCP).

(cherry picked from commit c2a9712945)
2020-03-26 22:30:43 +01:00
Beniamino Galvani
7311d5e294 ovs: set MTU from connection when creating an internal interface
The ovs-vswitchd.conf.db(5) man page says about the the mtu_request
column in the Interface table:

  "Requested MTU (Maximum Transmission Unit) for the interface. A
   client can fill this column to change the MTU of an
   interface [...] If this is not set and if the interface has
   internal type, Open vSwitch will change the MTU to match the
   minimum of the other interfaces in the bridge."

Therefore, if the connection specifies a MTU, set it early when adding
the interface to the ovsdb so that it will not be changed to the
minimum of other interfaces.

(cherry picked from commit ad12f26312)
2020-03-26 22:30:39 +01:00
Beniamino Galvani
c1be15a66e ovs/ovsdb: support changing the MTU of an ovs interface
Introduce a nm_ovsdb_set_interface_mtu() function to update the MTU of
an ovs interface in the ovsdb.

(cherry picked from commit a4c2c1a843)
2020-03-26 22:30:16 +01:00
Beniamino Galvani
a8ce20e96f platform: improve IPv6 address synchronization
When we must synchronize IPv6 addresses, we compare the order of
addresses to set with what is currently set on platform. Starting from
addresses with lower priority, when a mismatch is found we remove it
from platform and also remove all following addresses, so that we can
re-add them in the right order.

Since kernel keeps addresses internally sorted by scope, we should
consider each scope separately in order to avoid unnecessary address
deletions. For example, if we want to configure addresses
fe80::1/64,2000::1/64 and we currently have on platform 2000::1/64,
it's not necessary to remove the existing address; we can just add the
link-local one.

Co-authored-by: Thomas Haller <thaller@redhat.com>

https://bugzilla.redhat.com/show_bug.cgi?id=1814557
(cherry picked from commit 0118ad5125)
2020-03-26 22:23:01 +01:00
Beniamino Galvani
357159394e platform: sort IPv6 addresses from platform during sync
There is no guarantee that addresses returned from the cache are in
scope-priority order. Sort them.

(cherry picked from commit c878c48efb)
2020-03-26 22:22:59 +01:00
Thomas Haller
743377595d tests: replace NMTST_SWAP() by new NM_SWAP() macro
NMTST_SWAP() used memcpy() for copying the value, while NM_SWAP() uses
a temporary variable with typeof(). I think the latter is preferable.

Also, the macro is essentially doing the same thing.

(cherry picked from commit 6f9a478b7d)
2020-03-26 22:22:57 +01:00
Thomas Haller
cdfb762880 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)
2020-03-23 13:32:51 +01:00
Beniamino Galvani
9459508012 core: avoid unbound recursion in IPv6 connection sharing
When a device gets a prefix delegation, we call
nm_device_use_ip6_subnet() for all other devices that have IPv6
sharing enabled, which changes the current IPv6 configuration and
notifies NMPolicy. When updating the DNS configuration in NMPolicy, we
should notify all devices except the one that triggered the change.

https://bugzilla.redhat.com/show_bug.cgi?id=1488030
(cherry picked from commit 8fe2046f08)
2020-03-17 21:45:07 +01:00
Thomas Haller
d65b5c2e81 core: periodically cleanup unused device state files from /run
Otherwise, we only prune unused files when the service terminates.
Usually, NetworkManager service doesn't get restarted before shutdown
of the system (nor should it be). That means, if you create (and
destroy) a large number of software devices, the state files pile
up.

From time to time, go through the files on disk and delete those that
are no longer relevant.

In this case, "from time to time" means after we write/update state
files 100 times.

(cherry picked from commit 332df7a58e)
2020-03-04 16:59:22 +01:00
Thomas Haller
fb6e14cf3f core: return ifindex from nm_manager_write_device_state()
nm_manager_write_device_state() writes the device state to a file. The ifindex
is here important, because that is the identifier for the device and is also
used as file name. Return the ifindex that was used, instead of letting the
caller reimplement the knowledge which ifindex was used.

(cherry picked from commit 5477847eed)
2020-03-04 16:59:22 +01:00
Thomas Haller
7fa1e82545 core/trivial: rename nm_config_device_state_prune_unseen() to nm_config_device_state_prune_stale()
It's just a more fitting name after the previous change.

(cherry picked from commit ecb0210e7a)
2020-03-04 16:59:22 +01:00
Thomas Haller
0b4ebda859 core: cleanup nm_config_device_state_prune_unseen() and accept NMPlatform for skipping pruning
(cherry picked from commit ad9e748816)
2020-03-04 16:59:22 +01:00
Thomas Haller
beeb067c71 dhcp/nettools: first clear source before emitting event in dhcp4_event_cb()
A similar patch was done on master, but here the situation is different.

I feel we should not allow for the possibility where we invoke an event
that might mess with the source id. In practice there was no problem.
But it feels cleaner to clear it first.

Fixes: 843d696e46 ('dhcp: clean source on dispatch failure')
(cherry picked from commit 0549351111)
2020-03-04 16:13:05 +01:00
Beniamino Galvani
7a004ef0bb dhcp: clean source on dispatch failure
Fix the following warning:

 NetworkManager[1524461]: Source ID 3844 was not found when attempting to remove it

 g_logv (log_domain=0x7f2816fa676e "GLib", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7ffe697374d0) at gmessages.c:1391
 g_log (log_domain=log_domain@entry=0x7f2816fa676e "GLib", log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0x7f2816fae240 "Source ID %u was not found when attempting to remove it") at gmessages.c:1432
 g_source_remove (tag=519) at gmain.c:2352
 nm_clear_g_source (id=<optimized out>) at ./shared/nm-glib-aux/nm-macros-internal.h:1198
 dispose (object=0x55f7289b1ca0) at src/dhcp/nm-dhcp-nettools.c:1433
 g_object_unref (_object=<optimized out>) at gobject.c:3303
 g_object_unref (_object=0x55f7289b1ca0) at gobject.c:3232
 dhcp4_cleanup (self=self@entry=0x55f728af3b20, cleanup_type=cleanup_type@entry=CLEANUP_TYPE_DECONFIGURE, release=release@entry=0) at src/devices/nm-device.c:7565
 ...

Fixes: 45521b1b38 ('dhcp: nettools: move to failed state if event dispatch fails')
(cherry picked from commit 843d696e46)
2020-03-03 09:40:17 +01:00