From db00406100cd6bb0c1d53ade166cf9376030bcaa Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 1 Jan 2020 11:42:47 -0800 Subject: [PATCH] Linux: fix RA time unit confusion MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The RA times are provided in milliseconds, but commit 569051c8aa8fc297eb8edb7bd228e0fd353d30c1 (dhcpcd-8.1.3~18) “Linux: prefer ms RA times” incorrectly scaled them by an extra factor of 1000 before writing them to retrans_time_ms and base_reachable_time_ms. Instead, write the values in milliseconds directly to the *_ms files, and correctly convert to jiffies or seconds for the other files if necessary. Fixes NixOS/nixpkgs#76710. Signed-off-by: Anders Kaseorg --- src/if-linux.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/if-linux.c b/src/if-linux.c index befdf183..fe05901e 100644 --- a/src/if-linux.c +++ b/src/if-linux.c @@ -1948,20 +1948,20 @@ if_applyra(const struct ra *rap) error = -1; snprintf(path, sizeof(path), "%s/%s/retrans_time_ms", p_neigh, ifname); - if (if_writepathuint(ctx, path, rap->retrans * 1000) == -1) { + if (if_writepathuint(ctx, path, rap->retrans) == -1) { snprintf(path, sizeof(path), "%s/%s/retrans_time", p_neigh, ifname); /* Jiffies */ - if (if_writepathuint(ctx, path, rap->retrans * 100) == -1) + if (if_writepathuint(ctx, path, rap->retrans * sysconf(_SC_CLK_TCK) / 1000) == -1) error = -1; } snprintf(path, sizeof(path), "%s/%s/base_reachable_time_ms", p_neigh, ifname); - if (if_writepathuint(ctx, path, rap->reachable * 1000) == -1) { + if (if_writepathuint(ctx, path, rap->reachable) == -1) { snprintf(path, sizeof(path), "%s/%s/base_reachable_time", p_neigh, ifname); - if (if_writepathuint(ctx, path, rap->reachable) == -1) + if (if_writepathuint(ctx, path, rap->reachable / 1000) == -1) error = -1; } return error; -- 2.47.2