zephyr/tests/net
Peter Bigot acd43cbaac net: timeout: refactor to fix multiple problems
The net_timeout structure is documented to exist because of behavior
that is no longer true, i.e. that `k_delayed_work_submit()` supports
only delays up to INT32_MAX milliseconds.  Nonetheless, use of 32-bit
timestamps within the work handlers mean the restriction is still
present.

This infrastructure is currently used for two timers with long
durations:
* address for IPv6 addresses
* prefix for IPv6 prefixes

The handling of rollover was subtly different between these: address
wraps reset the start time while prefix wraps did not.

The calculation of remaining time in ipv6_nbr was incorrect when the
original requested time in seconds was a multiple of
NET_TIMEOUT_MAX_VALUE: the remainder value would be zero while the
wrap counter was positive, causing the calculation to indicate no time
remained.

The maximum value was set to allow a 100 ms latency between elapse of
the deadline and assessment of a given timer, but detection of
rollover assumed that the captured time in the work handler was
precisely the expected deadline, which is unlikely to be true.  Use of
the shared system work queue also risks observed latency exceeding 100
ms.  These calculations could produce delays to next event that
exceeded the maximum delay, which introduced special cases.

Refactor so all operations that use this structure are encapsulated
into API that is documented and has a full-coverage unit test.  Switch
to the standard mechanism of detecting completed deadlines by
calculating the signed difference between the deadline and the current
time, which eliminates some special cases.

Uniformly rely on the scanning the set of timers to determine the next
deadline, rather than assuming that the most recent update is always
next.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-01-07 11:14:38 +02:00
..
6lo tests: net: Adjust the thread priorities 2020-11-20 12:57:29 +02:00
all tests: net: Adjust the thread priorities 2020-11-20 12:57:29 +02:00
arp tests: net: Adjust the thread priorities 2020-11-20 12:57:29 +02:00
buf tests: net: buf: validate push & remove impl 2021-01-05 14:31:13 +02:00
checksum_offload
context
dhcpv4 tests: net: Adjust the thread priorities 2020-11-20 12:57:29 +02:00
ethernet_mgmt
hostname
icmpv4
icmpv6 tests: net: Adjust the thread priorities 2020-11-20 12:57:29 +02:00
ieee802154
iface
ip-addr
ipv6 net: timeout: refactor to fix multiple problems 2021-01-07 11:14:38 +02:00
ipv6_fragment
lib tests: add filter for some tests using newlib 2020-12-16 08:57:40 -05:00
mgmt tests: net: Adjust the thread priorities 2020-11-20 12:57:29 +02:00
mld tests: net: Adjust the thread priorities 2020-11-20 12:57:29 +02:00
neighbor tests: net: Adjust the thread priorities 2020-11-20 12:57:29 +02:00
net_pkt tests: net: Adjust the thread priorities 2020-11-20 12:57:29 +02:00
pm power: standarize PM Kconfigs and cleanup 2020-12-09 15:18:29 -05:00
ppp/driver
promiscuous
ptp/clock tests: convert DEVICE_AND_API_INIT to DEVICE_DEFINE 2020-12-19 20:05:40 -05:00
route
route_mcast
shell
socket tests: net: Test resolving literal IPv6 addresses 2020-12-22 15:44:00 +02:00
tcp
tcp2 tests: net: tcp2: Add RST packet handling tests 2020-11-24 13:08:39 +02:00
traffic_class
trickle
tx_timestamp
udp tests: net: Adjust the thread priorities 2020-11-20 12:57:29 +02:00
utils
vlan