Skip to content

Commit

Permalink
net: dns: Fix timeout calculation with DNS retransmissions
Browse files Browse the repository at this point in the history
With recently introduced DNS retransmission mechanism, a certain bug
could occur when calculating query timeout.

If the time until the final DNS timeout (as indicated by
CONFIG_NET_SOCKETS_DNS_TIMEOUT) was less than 1 millisecond, the actual
millisecond timeout value was rounded down, resulting in 0 ms timeout.
This in order was interpreted as invalid argument by dns_get_addr_info()
function, so in result, instead of reporting query timeout, the function
reported invalid argument error.

Fix this by rounding the millisecond timeout up, instead of down, so
that in any case, if the final timeout is not due, we always provide
non-zero timeout to dns_get_addr_info().

Signed-off-by: Robert Lubos <[email protected]>
  • Loading branch information
rlubos authored and dleach02 committed Mar 12, 2024
1 parent 07426a8 commit 53561e3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion subsys/net/lib/sockets/getaddrinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static int exec_query(const char *host, int family,
}

again:
timeout_ms = k_ticks_to_ms_floor32(timeout.ticks);
timeout_ms = k_ticks_to_ms_ceil32(timeout.ticks);

NET_DBG("Timeout %d", timeout_ms);

Expand Down

0 comments on commit 53561e3

Please sign in to comment.