Commit graph

29695 commits

Author SHA1 Message Date
Thomas Haller
dab70027e6
platform: extend NMPRouteManager to work for routes
(cherry picked from commit 7c27c63bec)
2022-02-10 08:41:18 +01:00
Thomas Haller
506590ff66
platform: use nm_pdirect_{hash,equal}() in "nmp-route-manager.c"
No need for a dedicated implementation just to compare two
indirect pointers.

(cherry picked from commit 2e04d64232)
2022-02-10 08:41:18 +01:00
Thomas Haller
7a80400d7d
platform: use nm_g_slice_free() in "nmp-route-manager.c"
(cherry picked from commit cfdecf5e96)
2022-02-10 08:41:18 +01:00
Thomas Haller
f4a33bd5c0
platform: use NM_HASH_OBFUSCATE_PTR() in "nmp-route-manager.c"
NM_HASH_OBFUSCATE_PTR() is some snake-oil to not log raw pointer values.
It obviously makes debugging harder.

But we don't need to generate differently obfuscated pointer values.
At least, let most users use the same obfuscation, so that the values
are comparable.

(cherry picked from commit 3e6c8d220a)
2022-02-10 08:41:17 +01:00
Thomas Haller
cc7a13c295
platform: use __NMLOG_DEFAULT() in "nmp-route-manager.c"
(cherry picked from commit 1baa301047)
2022-02-10 08:41:17 +01:00
Thomas Haller
aea447ac71
platform: rename internals in "nmp-route-manager.c"
We will not only track (routing) rules, but also routes. Rename.

(cherry picked from commit 75959e2f1a)
2022-02-10 08:41:17 +01:00
Thomas Haller
ca2de61dcc
platform: drop lazy initialization _rules_init() of NMPRouteManager
Let's just always allocate the hash tables. We will likely need them,
and three hash tables are relatively cheap.

(cherry picked from commit 5b3e96451b)
2022-02-10 08:41:17 +01:00
Thomas Haller
78add254a1
platform: rename "nmp-route-manager.h" to "nmp-rules-manager.h"
(cherry picked from commit 3996933c57)
2022-02-10 08:41:17 +01:00
Thomas Haller
e69e5d5446
platform: rename NMPRulesManager API to NMPRouteManager
Routes of type blackhole, unreachable, prohibit don't have an
ifindex/device. They are thus in many ways similar to routing rules,
as they are global. We need a mediator to keep track which routes
to configure.

This will be very similar to what NMPRulesManager already does for
routing rules. Rename the API, so that it also can be used for routes.

Renaming the file will be done next, so that git's rename detection
doesn't get too confused.

(cherry picked from commit ea4f6d7994)
2022-02-10 08:41:17 +01:00
Thomas Haller
a2030c01ce
platform: add support for blackhole,unreachable,prohibit route type
(cherry picked from commit 92f51c6b43)
2022-02-10 08:41:17 +01:00
Thomas Haller
bd08f8e81c
platform: add nm_platform_route_type_is_nodev() helper
(cherry picked from commit 7ad14b86f8)
2022-02-10 08:41:16 +01:00
Thomas Haller
2394a93944
platform: don't treat ifindex zero special in nmp_lookup_init_object()
So far, certain NMObject types could not have an ifindex of zero. Hence,
nmp_lookup_init_object() took such an ifindex to mean lookup all objects
of that type.

Soon, we will support blackhole/unreachable/prohibit route types, which
have their ifindex set to zero. It is still useful to lookup those routes
types via nmp_lookup_init_object().

Change behaviour how to interpret the ifindex. Note that this also
affects various callers of nmp_lookup_init_object(). If somebody was
relying on the previous behavior, it would need fixing.

(cherry picked from commit d4ad9666bd)
2022-02-10 08:41:16 +01:00
Thomas Haller
5c31184585
platform: don't check for valid ifindex in _vt_cmd_obj_is_alive_ipx_route()
_vt_cmd_obj_is_alive_ipx_route() is called by nmp_object_is_alive().
Non-alive objects are not put into the cache.

That certainly makes sense for RTM_F_CLONED routes, because they are
generated ad-hoc during the `ip route get` request.

Checking for the ifindex is not necessary. For one, some route types
(blackhole, unreachable, prohibit) don't have an ifindex. Also, the
purpose of _vt_cmd_obj_is_alive_ipx_route() is not to validate the
object. Just don't create objects without an ifindex, if you think the
route needs an ifindex. Checking here is not useful.

We also don't check that other fields like rt_source are valid, so there
is no need to do it for the ifindex either.

(cherry picked from commit 1123d3a5fb)
2022-02-10 08:41:16 +01:00
Thomas Haller
1853d53425
platform: don't print NUL gateway in nm_platform_ip[46]_route_to_string()
Currently, for NMPlatformIP[46]Route always has a gateway, even if it's
possibly set to 0.0.0.0/::. Not sure whether kernel has a further
distinction between no-gateway and all-zero gateway.

Anyway. For us, a gateway of 0.0.0.0/:: means the same as having no
gateway. We cannot differentiate the two (nor do we need to).

Don't print that in nm_platform_ip[46]_route_to_string().

Also, because we are going to add blackhole route types, which cannot
have a next-hop. But we do this change for all routes types, because
it makes sense in general (and also what `ip route show` prints).

(cherry picked from commit b58711f20d)
2022-02-10 08:41:16 +01:00
Thomas Haller
2eaf8d7048
core: use IS_IPv4 variable in nm_utils_ip_route_attribute_to_platform()
It's what we do at many other places. Consistency.

(cherry picked from commit 596d1645e8)
2022-02-10 08:41:16 +01:00
Thomas Haller
eec32669a9
platform: rename variable "IS_IPv4" in platform code
The variable with this purpose is usually called "IS_IPv4".

It's upper case, because usually this is a const variable, and because
it reminds of the NM_IS_IPv4(addr_family) macro. That letter case
is unusual, but it makes sense to me for the special purpose that this
variable has.

Anyway. The naming of this variable is a different point. Let's
use the variable name that is consistent and widely used.

(cherry picked from commit 8085c0121f)
2022-02-10 08:41:16 +01:00
Thomas Haller
9259ac065f
libnm: rework validating route attributes to avoid duplicate check
_nm_ip_route_attribute_validate_all() validates all attributes together.
As such, it calls to nm_ip_route_attribute_validate(), which in turn
validates one attribute at a time.

Such full validation needs to check that (potentially conflicting)
attributes are valid together. Hence, _nm_ip_route_attribute_validate_all()
needs again peek into the attributes.

Refactor the code, so that we can extract the pieces that we need and
not need to parse them twice.

(cherry picked from commit 0413b1bf8a)
2022-02-10 08:41:16 +01:00
Thomas Haller
70c2478f89
libnm: change NMVariantAttributeSpec.str_type to work for attributes of any type
First of all, all of NMVariantAttributeSpec is internal API. We only
expose the typedef itself as public API, but not its fields nor
their meaning. So we can change things.

Change "str_type" to "type_detail", so that it can work for any kind of
attribute, not only for strings. Usually, we want to avoid special
cases and treat all attributes the same, based on their GVariant type.
But sometimes, it is necessary to do something special with an
attribute. This is what the "type_detail" encodes, but it's not only
relevant for strings.

(cherry picked from commit 6f277d8fa6)
2022-02-10 08:41:16 +01:00
Thomas Haller
11d4d244dd
libnm: avoid parsing IP addresses twice in NMIPAddress/NMIPRoute API
Usually the normalization (canonicalize) and validation of the IP
address string both requires to parse the string. As we always do
validation first, we can use the parsed address and don't need to parse
it a second time.

(cherry picked from commit 00e4f21629)
2022-02-10 08:41:16 +01:00
Thomas Haller
beca3a4d46
libnm: reorder fields in NMIPAddress/NMIPRoute struct
Order the fields by their size, to minimize the alignment gaps.
I guess, that doesn't matter because the alignment of the heap
allocation is larger than what we can safe here. Still, there is
on reason to do it any other way.

Also, it's not possible via API to set family/prefix to values outside
their range, so an 8bit integer is always sufficient. And we don't want
that invariant to change. We don't ever want to allow the caller to set
values that are clearly invalid, and will assert against that early (g_return()).
Point is, we can do this and there is no danger of future problems.
And even if we will support larger values, it's all an implementation
detail anyway.

(cherry picked from commit 6208a1bb84)
2022-02-10 08:41:15 +01:00
Thomas Haller
1701048e02
tests: let "run-nm-test.sh" fail with exit code 1 on failure
`git bisect run` is peculiar about the exit code:

  error: bisect run failed: exit code 134 from '...' is < 0 or >= 128

If we just "exec" the test, it usually will fail on an assert. That results
in SIGABRT or exit code 134. So out of the box that is annoying with
git-bisect.

Work around that and let the test wrapper always coerce any test failure
to exit code 1.

(cherry picked from commit f65747f6e9)
2022-02-10 08:41:15 +01:00
Val Och
00609c900b
libnm: fix nm_client_add_and_activate_connection2_finish annotation
Mark out_result as out argument. Fixes an issue when using libnm bindings.

Fixes: fbb038af5e ('all: return output dictionary from "AddAndActivate2"')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1092
(cherry picked from commit 3b67b7768d)
2022-02-09 18:51:53 +01:00
Beniamino Galvani
f55dc420ba
device: fix required-timeout evaluation
Once the required-timeout expires, we should evaluate whether the
*other* address family is ready.

Fixes: 58287cbcc0 ('core: rework IP configuration in NetworkManager using layer 3 configuration')
Fixes-test: @dracut_NM_NFS_root_nfs_ip_dhcp_dhcp6_slow_ip6

https://bugzilla.redhat.com/show_bug.cgi?id=2051904
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1090
(cherry picked from commit 02106df3be)
2022-02-09 18:51:49 +01:00
Thomas Haller
9e7f7a48be
l3cfg: fix setting default route table during nm_l3_config_data_merge()
We made the choice, that NMPlatformIPRoute does not contain the actual
route table, instead it contains a "remapped" number: table_coerced.
That remapping done, so that the default (which we want semantically to
be 254, RT_TABLE_MAIN) is numerical zero so that struct initialization
doesn't you require to explicitly set the default.

Hence, we must always distinguish whether we have the real table number
or the "table_coerced", and you must convert back and forth between the
two.

Now, the parameter of nm_l3_config_data_merge() are real table numbers
(as also indicated by their name not having the term "coerced"). So
usually they are set to actually 254.

When we set the field of NMPlatformIPRoute, we must coerce it. This was
wrong, and we would see wrong table numbers in the log:

  l3cfg[17b98e59a477b0f4,ifindex=2]: obj-state: track: [2a32eca99405767e, ip4-route, type unicast table 0 0.0.0.0/0 via ...

Fixes: b4aa35e72d ('l3cfg: extend nm_l3cfg_add_config() to accept default route table and metric')
(cherry picked from commit e23ebe9183)
2022-02-09 18:51:26 +01:00
Thomas Haller
ad26457d0f
priv-helper: merge branch 'th/nm_priv_helper_dbus_name'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1091

(cherry picked from commit a1abb3ebdf)
2022-02-09 18:49:48 +01:00
Thomas Haller
03e015bacd
priv-helper: remove D-Bus Alias for "nm-priv-helper.service"
In systemd, it's common that a D-Bus activatable service references
`SystemdService=dbus-$BUSNAME.service` instead the real service name.
Together with an `[Install].Alias=dbus-$BUSNAME.service` directive,
this allowed to enable/disable D-Bus activation without uninstalling the
service altogether ([1]).

Currently, when we install the RPM then `nm-priv-helper.service` is not
enabled, consequently the alias is not created, and D-Bus activation
does not work. I guess, we should fix that by enabling the service in
the %post section or via a systemd preset? Dunno.

Anyway. It seems that nm-priv-helper.service is more of an
implementation detail of NetworkManager. It makes not sense for the user
to interact directly, or to enable/disable D-Bus activation (because
that is how it works).

So, drop the alias.

See-also: [1] https://docs.fedoraproject.org/en-US/packaging-guidelines/Systemd/#activation_dbus
(cherry picked from commit d849807521)
2022-02-09 18:49:48 +01:00
Thomas Haller
b21138f4e9
priv-helper: fix D-Bus patch to not contain forbidden character '-'
"-" is not allowed as D-Bus path and interface name, and discouraged as
bus name. This cause nm-priv-helper to crash, because GDBus asserts the
the object path is valid.

Replace the '-' with '_'. This way, it's consistent with
"nm_dispatcher".

Fixes: d68ab6b8f0 ('nm-sudo: rename to nm-priv-helper')
(cherry picked from commit 16a45d07ed)
2022-02-09 18:49:47 +01:00
Lubomir Rintel
7d0faf5077 release: bump version to 1.35.90 (1.36-rc1) 2022-02-04 18:14:15 +01:00
Lubomir Rintel
dc9d932ecc NEWS: update for 1.36-rc1 2022-02-04 18:04:41 +01:00
Thomas Haller
f16d027eb8
systemd: workaround gcc warning about LOG2ULL() by disabling code (2)
gcc-4.8.5-44.el7.x86_64 warns:

    In file included from ./src/libnm-systemd-shared/src/basic/hashmap.h:10:0,
                     from ./src/libnm-systemd-shared/src/shared/dns-domain.h:10,
                     from src/libnm-systemd-shared/nm-sd-utils-shared.c:12:
    ./src/libnm-systemd-shared/src/basic/util.h: In function 'log2u64':
    ./src/libnm-systemd-shared/src/basic/util.h:30:20: error: first argument to '__builtin_choose_expr' not a constant
     #define LOG2ULL(x) __builtin_choose_expr(__builtin_constant_p(x), CONST_LOG2ULL(x), NONCONST_LOG2ULL(x))
                        ^
    ./src/libnm-systemd-shared/src/basic/util.h:34:16: note: in expansion of macro 'LOG2ULL'
             return LOG2ULL(x);
                    ^
    ./src/libnm-systemd-shared/src/basic/util.h: In function 'log2i':
    ./src/libnm-systemd-shared/src/basic/util.h:53:18: error: first argument to '__builtin_choose_expr' not a constant
     #define LOG2U(x) __builtin_choose_expr(__builtin_constant_p(x), CONST_LOG2U(x), NONCONST_LOG2U(x))
                      ^
    ./src/libnm-systemd-shared/src/basic/util.h:56:16: note: in expansion of macro 'LOG2U'
             return LOG2U(x);
                    ^
    ./src/libnm-systemd-shared/src/basic/util.h: In function 'log2u':
    ./src/libnm-systemd-shared/src/basic/util.h:53:18: error: first argument to '__builtin_choose_expr' not a constant
     #define LOG2U(x) __builtin_choose_expr(__builtin_constant_p(x), CONST_LOG2U(x), NONCONST_LOG2U(x))
                      ^
    ./src/libnm-systemd-shared/src/basic/util.h:60:16: note: in expansion of macro 'LOG2U'
             return LOG2U(x);
                    ^
2022-02-04 16:30:02 +01:00
Lubomir Rintel
c8ba636d0e dhcp-options: change "dhcp6_ntp_server" to plural form
The option can be present multiple times.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1085
2022-02-04 15:54:15 +01:00
Lubomir Rintel
f15fb5ecaa contrib/modemu: extend PDP support
Improve it just a bit to make ModemManager 1.18 happy.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1087
2022-02-04 15:54:15 +01:00
Lubomir Rintel
ea37c42b16 contrib/modemu: respond to AT+COPS?
This queries the operator code. If NetworkManager got one, it can
connect the modem device automatically without setting the APN.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1086
2022-02-04 15:54:15 +01:00
Thomas Haller
a16b380d32
systemd: workaround gcc warning about LOG2ULL() by disabling code
gcc-4.8.5-44.el7.x86_64 warns:

    In file included from ./src/libnm-systemd-shared/src/basic/hashmap.h:10:0,
                     from ./src/libnm-systemd-shared/src/shared/dns-domain.h:10,
                     from src/libnm-systemd-shared/nm-sd-utils-shared.c:12:
    ./src/libnm-systemd-shared/src/basic/util.h: In function 'log2u64':
    ./src/libnm-systemd-shared/src/basic/util.h:30:20: error: first argument to '__builtin_choose_expr' not a constant
     #define LOG2ULL(x) __builtin_choose_expr(__builtin_constant_p(x), CONST_LOG2ULL(x), NONCONST_LOG2ULL(x))
                        ^
    ./src/libnm-systemd-shared/src/basic/util.h:34:16: note: in expansion of macro 'LOG2ULL'
             return LOG2ULL(x);
                    ^
    ./src/libnm-systemd-shared/src/basic/util.h: In function 'log2i':
    ./src/libnm-systemd-shared/src/basic/util.h:53:18: error: first argument to '__builtin_choose_expr' not a constant
     #define LOG2U(x) __builtin_choose_expr(__builtin_constant_p(x), CONST_LOG2U(x), NONCONST_LOG2U(x))
                      ^
    ./src/libnm-systemd-shared/src/basic/util.h:56:16: note: in expansion of macro 'LOG2U'
             return LOG2U(x);
                    ^
    ./src/libnm-systemd-shared/src/basic/util.h: In function 'log2u':
    ./src/libnm-systemd-shared/src/basic/util.h:53:18: error: first argument to '__builtin_choose_expr' not a constant
     #define LOG2U(x) __builtin_choose_expr(__builtin_constant_p(x), CONST_LOG2U(x), NONCONST_LOG2U(x))
                      ^
    ./src/libnm-systemd-shared/src/basic/util.h:60:16: note: in expansion of macro 'LOG2U'
             return LOG2U(x);
                    ^
2022-02-04 13:32:43 +01:00
Thomas Haller
18cb8205b3
systemd: merge branch systemd into main
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1068
2022-02-03 18:50:26 +01:00
Thomas Haller
3399e19df8
device: update metered status when getting DHCP lease
The metered status can depend on the DHCP lease, as we accept the
ANDROID_METERED vendor option. That means, on a DHCP update we need
to re-evaluate the metered flag.

This fixes a potential race, where IPv6 might succeed first and
activation completes (with GUESS_NO metered flag). A subsequent
DHCPv4 update requires to re-evaluate that decision.

Fixes-test: @connection_metered_guess_yes

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1080
2022-02-03 18:46:38 +01:00
Lubomir Rintel
ecc73eb239 ovs-port: always remove the OVSDB entry on slave release
When the link is externally removed, the OVSDB entry will be left
behind. That's not cool -- we need to remove it.

https://bugzilla.redhat.com/show_bug.cgi?id=1935026
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1084
2022-02-03 13:38:21 +01:00
Thomas Haller
405afad0a6
platform: merge branch 'th/platform-netlink-alloc'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1069
2022-02-03 13:12:55 +01:00
Thomas Haller
d73594682f
platform: no need to initialize nla sockaddr parameter to nl_recv()
We always call nl_recv() in a loop. If it would be necessary to clear
the variable, then it would need to happen inside the loop. But it's
not necessary.
2022-02-03 13:11:17 +01:00
Thomas Haller
dd3dffb1b0
platform: use pre-allocated receive buffer for rtnetlink socket
Instead of allocating a receive buffer for each nl_recv() call, re-use a
pre-allocated buffer.

The buffer is part of NMPlatform and kept around. As we would not have more
than one NMPlatform instance per netns, we waste a limited amount of
memory.

The buffer gets initialized with 32k, which should be large enough for
any rtnetlink message that we might receive. As before, if the buffer
would be too small, then the first large message would be lost (as we don't
peek). But then we would allocate a larger buffer, resync the platform cache
and recover.
2022-02-03 13:10:29 +01:00
Thomas Haller
e8cfa22929
platform/netlink: accept pre-allocated receive buffer for nl_recv()
Add parameter to accept a pre-allocated buffer for nl_recv(). In
practice, rtnetlink messages are not larger than 32k, so we can always
pre-allocate it and avoid the need to heap allocate it.
2022-02-03 13:08:47 +01:00
Thomas Haller
340f05ba42
platform: use proper g_free() function for netlink receive buffer
In the past, nl_recv() was libnl3 code and thus used malloc()/realloc() to
allocate the buffer. That meant, we should free the buffer with libc's free()
function instead of glib's g_free(). That is what nm_auto_free is for.

Nowadays, nl_recv() is forked and glib-ified, and uses the glib wrappers to
allocate the buffer. Thus the buffer should also be freed with g_free()
(and gs_free).

In practice there is no difference, because glib's allocation directly
uses libc's malloc/free. This is purely a matter of style.
2022-02-03 13:07:35 +01:00
Beniamino Galvani
5153810bd6 merge: branch 'bg/assume-plat-init'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1081
2022-02-03 09:21:16 +01:00
Beniamino Galvani
d72a292005 device: fix assuming connections when platform-init arrives late
When the NM_UNMANAGED_PLATFORM_INIT flag is cleared last in
device_link_changed(), a recheck-assume is scheduled and then the
device goes immediately to UNAVAILABLE. During the state transition,
addresses and routes are removed from the interface. Then,
recheck-assume finds that the device can be assumed but it's too late
since the device was already deconfigured.

This is a problem as the whole point of assuming a device is to
activate a connection while leaving the device untouched.

In the NMCI "dracut_NM_vlan_over_bridge and dracut_NM_vlan_over_bond"
test, NM in real root tries to assume a vlan device that was activated
in initrd. When the interface gets deconfigured in UNAVAILABLE, the
connection to the NFS server breaks and the rootfs becomes
inaccessible.

The fix to this problem is to delay state transitions in
device_link_changed() to a idle handler, so that recheck-assume can
run before.

Fixes-test: @dracut_NM_vlan_over_bridge
Fixes-test: @dracut_NM_vlan_over_bond

https://bugzilla.redhat.com/show_bug.cgi?id=2047302
2022-02-03 09:17:20 +01:00
Beniamino Galvani
b2e1bd4436 device: remove unused if branch in device_link_changed()
nm_device_set_unmanaged_by_user_settings() does nothing when the
device is unmanaged by platform-init. Remove the if branch to make
this more explicit.
2022-02-03 09:16:39 +01:00
Thomas Haller
dc1092e22b
l3cfg: merge branch 'th/l3cfg-acd-crash'
https://bugzilla.redhat.com/show_bug.cgi?id=2047788

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1077
2022-02-02 11:10:36 +01:00
Thomas Haller
db0d84f13a
l3cfg: fix handling "instance-reset" ACD event
The ACD state handling is unfortunately very complicated. That is, because
we obviously need to track state about how ACD is going (the acd_data, and
in particular NML3AcdAddrState). Then there are various things that can
happen, which are the AcdStateChangeMode enums. All these state-changes
come together in one function: _l3_acd_data_state_change(), which is
therefore complicated (I don't think that it would become simpler by
spreading this code out to different functions, on the contrary).
Anyway.

So, what happens when we need to reset the n-acd instance? For example,
because the MAC address of the link changed or some error. I guess, we
need to restart probing.

Previously, I think this was not handled properly. We already tried to
fix this several times, the last was commit b331606386 ('l3cfg: on
n-acd instance-reset clear also ready ACD state'). There is still an
issue ([1]).

The bug [1] is, that we are in state NM_L3_ACD_ADDR_STATE_READY, during
 ACD_STATE_CHANGE_MODE_TIMEOUT event. That leads to an assertion
failure.

  #5  0x00007f23be74698f in g_assertion_message_expr (domain=0x5629aca70359 "nm", file=0x5629aca62aab "src/core/nm-l3cfg.c", line=2395, func=0x5629acb26b30 <__func__.72.lto_priv.4> "_l3_acd_data_state_change", expr=<optimized out>) at ../glib/gtestutils.c:3091
  #6  0x00005629ac937e46 in _l3_acd_data_state_change (self=0x5629add69790, acd_data=0x5629add8d520, state_change_mode=ACD_STATE_CHANGE_MODE_TIMEOUT, sender_addr=0x0, p_now_msec=0x7ffded506460) at src/core/nm-l3cfg.c:2395
  #7  0x00005629ac939f4d in _l3_acd_data_timeout_cb (user_data=user_data@entry=0x5629add8d520) at src/core/nm-l3cfg.c:1933
  #8  0x00007f23be71c5a1 in g_timeout_dispatch (source=0x5629addd7a80, callback=0x5629ac939ee0 <_l3_acd_data_timeout_cb>, user_data=0x5629add8d520) at ../glib/gmain.c:4889
  #9  0x00007f23be71bd4f in g_main_dispatch (context=0x5629adc6da00) at ../glib/gmain.c:3337
  #10 g_main_context_dispatch (context=0x5629adc6da00) at ../glib/gmain.c:4055

That can only happen, (I think) when we scheduled the timeout
during an earlier ACD_STATE_CHANGE_MODE_INSTANCE_RESET event. Meaning,
we need to handle instance-reset better.

Instead, during instance-reset, switch always back to state PROBING, and
let the timeout figure it out.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=2047788
2022-02-02 11:08:31 +01:00
Thomas Haller
d7a951b947
l3cfg: add comment to _acd_data_collect_tracks_data() about linear search 2022-02-02 11:08:30 +01:00
Thomas Haller
f00980e5ca
l3cfg: add assertion for scheduling timeout in _l3_acd_data_timeout_schedule()
The first point is that ACD timeout is strongly tied to the current state. That
is (somewhat) obvious, because _l3_acd_data_state_set_full() will clear any pending
timeout. So you can only schedule a timeout *after* setting the state,
and setting the next state, will clear the timeout.

Likewise, note that l3_acd_data_state_change() for the event
ACD_STATE_CHANGE_MODE_TIMEOUT asserts that it is only called in the few
states where that is expected. See rhbz#2047788 where that assertion
gets hit.

The first point means that we must only schedule a timer when we are
also in a state that supports that. Add an assertion for that at the
point when scheduling the timeout. The assert at this point is useful,
because it catches the moment when we do the wrong thing (instead of
getting the assertion later during the timeout, when we no longer know
where the error happened).

See-also: https://bugzilla.redhat.com/show_bug.cgi?id=2047788
2022-02-02 11:08:30 +01:00
Thomas Haller
6012853010
l3cfg: use nm_g_timeout_add_source() helpers in "nm-l3cfg.c"
It's shorter, and brevity lets us focus on the important things in the
code.
2022-02-02 11:08:30 +01:00