Skip to content

Fix: IPv6 addresses' lifetimes are one second longer than they should be. Fixes #1464

Sergey Koshelenko requested to merge (removed):fix-ipv6-addr-lifetime into main

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 behaviour causes unwanted side effects, see issue #1464 (closed) for details.

This MR 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.

Resolves: #1464 (closed)

Edited by Sergey Koshelenko

Merge request reports