NetworkManager/src/core/ndisc
Sergey Koshelenko d88e21ff91 ndisc: fix IPv6 address lifetimes computation
Background: when router sends router advertisement (RA) message,
NetworkManager processes it and passes data to a lower system layer.
Currently there is a problem that NetworkManager adds one second to both
valid lifetime and preferred lifetime. This happens because of the
algorithm in nm_ndisc_data_to_l3cd() function.

Let's look at an example: let current timestamp be 100450, so now_sec
variable is 100. At this moment RA message was received from the router.
The IPv6 address' valid lifetime is 200 seconds (for example), so
expiration timestamp (ndisc_addr->expiry_msec) is 300450. But after the
_nm_ndisc_lifetime_from_expiry() call, NMPlatformIP6Address lifetime
becomes 201 ((300450-(100*1000)+999)/1000). Which is wrong.

This commit fixes this behaviour by replacing
nm_utils_get_monotonic_timestamp_sec() with
nm_utils_get_monotonic_timestamp_msec() so that timestamps are
calculated more precisely.

Related issue: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1464
Merge request: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1863

(cherry picked from commit 14e7220f5f)
2024-02-21 11:48:04 +01:00
..
tests ndisc/tests: fix reference counting in nm_fake_ndisc_new() 2023-01-05 12:13:39 +01:00
nm-fake-ndisc.c all: use NM_MAX() instead of MAX() 2023-11-15 09:32:21 +01:00
nm-fake-ndisc.h all: use _NM_G_TYPE_CHECK_INSTANCE_CAST() for internal uses 2022-12-16 10:55:03 +01:00
nm-lndp-ndisc.c all: use NM_MAX() instead of MAX() 2023-11-15 09:32:21 +01:00
nm-lndp-ndisc.h all: use _NM_G_TYPE_CHECK_INSTANCE_CAST() for internal uses 2022-12-16 10:55:03 +01:00
nm-ndisc-private.h format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-ndisc.c ndisc: fix IPv6 address lifetimes computation 2024-02-21 11:48:04 +01:00
nm-ndisc.h ndisc: Accept routes from on-link prefixes form ra 2023-01-23 16:50:08 +00:00