From patchwork Tue Apr 9 03:04:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Donald X-Patchwork-Id: 1921181 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=g5fIY//D; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=GEtDs9a+; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VD9rm1289z1yY8 for ; Tue, 9 Apr 2024 13:08:24 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QZpxe17Gdr+2aQh/MXAlBxGFo6k//rOLN/cTyu6ldeI=; b=g5fIY//DpYy/fF Ie+jyD19p9hmNXiF08bexEJyxbX/TVpP9a3adHhbalKKroOR2SOCf8BjuZvNJpySNnAtzG+mSF5lp CDrhQLAfJjfJIlXB16dvmfBVVeZhc4r31epBL/WXTZy5LLVe/bsYUNpUOoUvuLbFhpjbZvK0faSWf 8vC6uqbhTCuoiYkbQXQY1xWkLKQ0w0NVK4hA0fFuWb6jXM8qJldxS2yhmRMfelCHdjFoJmqylgtj+ ZfJe7gnDxU2jKAhsH95GA4F0puv2BXESs7hWAzkDCkkjShPe5gn1Ycvidf816+bDCWVETZ8CGoNVA B9kxP/2ejhBsaJhouuaw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ru1pD-000000003Jj-1U8B; Tue, 09 Apr 2024 03:07:07 +0000 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ru1ny-000000002ai-0Tvz for openwrt-devel@lists.openwrt.org; Tue, 09 Apr 2024 03:05:55 +0000 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-516d1ecaf25so5268385e87.2 for ; Mon, 08 Apr 2024 20:05:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712631945; x=1713236745; darn=lists.openwrt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=Atm6G4zFQoKsSlpH3YVkiVhq1O3lGShb6PWzhIWMwf0=; b=GEtDs9a+IA9QbjAIzSs2tO7mYdmX7qEjBzn0q7l/pKdiGCjN/Ec4hfegItjyGgL3lX OGPR02+f/jzGw9xDBxjBBuJ04+d5wWH+Yj9EGY0G2D44ajXkT1+oCJL8Ee6E4iZFypwW JDQIlL5ehRt1KC/omeUmBIYNPhQGM0O/8no/lcmAbU3TqwZeoFWMUt8O8pfhXylUx3rT sixJ7TKIqaWUncOTuBvVX4vKFpuTjB2SsQvGIITtulY7NrxqaZ6xGnfpqQRIE/2xQreW zy8lodYYFCQXtxzMr1Wfol7QCfWj0yuVJqnHx+7EG2nM8fex/i2rZg1IqVcMg6aBvIdc hpXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712631945; x=1713236745; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:sender:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Atm6G4zFQoKsSlpH3YVkiVhq1O3lGShb6PWzhIWMwf0=; b=mUaLvdRQGp122YKzGa+80ChfVRAlXjnLZTgp8JGgOmKIqJ8B0eiLpiePHqAH0YqC9Q X2Ur4wBaj1Di/5xL9eDsz823VFNZ/DIWVypXuGcaSovqi092sUTXpZ4Jx8AK8rTxQbbS jz3+DvoaKkPYtuRyL51ENOEX7JH+7ICQUPI0RBmJlm9oSmKlIDd7Hx2BJnoCSXHXsTh/ ifv3102EUzjdL5Qdhrx7MjUns2zyISLBRzLxNU7Xe0Q+pQtPBUKuC8cJX0TuDSHwokpC pEP5dXox4EQhJ0jPM7m3F0Kq4QtpbOiWlFG2iNeLXPAqMTt0B4WOefn8KlVhUxcDVjI3 beKQ== X-Gm-Message-State: AOJu0YyLOvyquOrNh47+DT2EPOvwmi7gSvpwk2te20DTxuPlRqbNWTJ8 VmXgXI9cnbnJ1FYl2ZA6ds3LzLK/HsdlwNlRqwnsxPIv8Lus5EQGuJVdSv5V X-Google-Smtp-Source: AGHT+IE134Xt5oVdhsAihBZq98VWyD8rP9KW73fd8bo4/D5NbxpWSrPZi+WI3odMeh7/EITf/5F3gw== X-Received: by 2002:ac2:4304:0:b0:515:d30f:7670 with SMTP id l4-20020ac24304000000b00515d30f7670mr6653091lfh.13.1712631945030; Mon, 08 Apr 2024 20:05:45 -0700 (PDT) Received: from blackhol3 ([2001:9b0:40::cae3:cb03]) by smtp.gmail.com with ESMTPSA id d9-20020ac25ec9000000b00516b0051e6esm1399491lfq.231.2024.04.08.20.05.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 20:05:44 -0700 (PDT) From: Paul Donald To: OpenWrt Development List Subject: [PATCH v3 7/9] router: rename minvalid -> lowest_found_lifetime Date: Tue, 9 Apr 2024 05:04:08 +0200 Message-ID: <20240409030540.77576-8-newtwen+github@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409030540.77576-1-newtwen+github@gmail.com> References: <20240405005510.19778-1-newtwen+github@gmail.com> <20240409030540.77576-1-newtwen+github@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240408_200550_448483_47EE6E9A X-CRM114-Status: GOOD ( 12.58 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Paul Donald The variable is used across all prefix lifetimes, serving as a low-tide mark. It stores the lowest lifetime among all prefixes. Signed-off-by: Paul Donald --- src/router.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:12e listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [newtwen+github(at)gmail.com] X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Paul Donald The variable is used across all prefix lifetimes, serving as a low-tide mark. It stores the lowest lifetime among all prefixes. Signed-off-by: Paul Donald --- src/router.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/router.c b/src/router.c index c02b408..2a59530 100644 --- a/src/router.c +++ b/src/router.c @@ -334,7 +334,7 @@ static bool parse_routes(struct odhcpd_ipaddr *n, ssize_t len) return found_default; } -static int calc_adv_interval(struct interface *iface, uint32_t minvalid, +static int calc_adv_interval(struct interface *iface, uint32_t lowest_found_lifetime, uint32_t *maxival) { uint32_t minival = iface->ra_mininterval; @@ -342,8 +342,11 @@ static int calc_adv_interval(struct interface *iface, uint32_t minvalid, *maxival = iface->ra_maxinterval; - if (*maxival > minvalid/3) - *maxival = minvalid/3; + /* rfc4861#section-6.2.1 : AdvDefaultLifetime Default: 3 * MaxRtrAdvInterval + therefore max interval shall be no greater than 1/3 of the lowest valid lease + time of all known prefixes */ + if (*maxival > lowest_found_lifetime/3) + *maxival = lowest_found_lifetime/3; if (*maxival > MaxRtrAdvInterval) *maxival = MaxRtrAdvInterval; @@ -452,7 +455,9 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr size_t dns_sz = 0, search_sz = 0, pref64_sz = 0; size_t pfxs_cnt = 0, routes_cnt = 0; ssize_t valid_addr_cnt = 0, invalid_addr_cnt = 0; - uint32_t minvalid = UINT32_MAX, maxival, lifetime; + /* lowest_found_lifetime stores the lowest lifetime of all prefixes; + necessary to find shortest adv interval necessary for shortest lived prefix */ + uint32_t lowest_found_lifetime = UINT32_MAX, maxival, lifetime; int msecs, mtu = iface->ra_mtu, hlim = iface->ra_hoplimit; bool default_route = false; bool valid_prefix = false; @@ -610,8 +615,8 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr preferred_lt = valid_lt; } - if (minvalid > valid_lt) - minvalid = valid_lt; + if (lowest_found_lifetime > valid_lt) + lowest_found_lifetime = valid_lt; if ((!IN6_IS_ADDR_ULA(&addr->addr.in6) || iface->default_router) && valid_lt) valid_prefix = true; @@ -636,7 +641,7 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr iov[IOV_RA_PFXS].iov_len = pfxs_cnt * sizeof(*pfxs); /* Calculate periodic transmit */ - msecs = calc_adv_interval(iface, minvalid, &maxival); + msecs = calc_adv_interval(iface, lowest_found_lifetime, &maxival); lifetime = calc_ra_lifetime(iface, maxival); if (!iface->have_link_local) {