From 899034ba8167bd16e802cfbea29a9ee85dee5be5 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 2 Jul 2021 22:26:04 +0900 Subject: [PATCH] network: fix overflow issue in address lifetime calculation Fixes another issue reported in #20050. See https://github.com/systemd/systemd/issues/20050#issuecomment-872967337. --- src/network/networkd-ndisc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c index eebcea1a690..efc47078550 100644 --- a/src/network/networkd-ndisc.c +++ b/src/network/networkd-ndisc.c @@ -819,8 +819,10 @@ static int ndisc_router_process_autonomous_prefix(Link *link, sd_ndisc_router *r r = address_get(link, address, &e); if (r > 0) { /* If the address is already assigned, but not valid anymore, then refuse to - * update the address. */ - if (e->cinfo.tstamp / 100 + e->cinfo.ifa_valid < time_now / USEC_PER_SEC) + * update the address, and it will be removed. */ + if (e->cinfo.ifa_valid != CACHE_INFO_INFINITY_LIFE_TIME && + usec_add(e->cinfo.tstamp / 100 * USEC_PER_SEC, + e->cinfo.ifa_valid * USEC_PER_SEC) < time_now) continue; } -- 2.47.3