Message ID | 20240509223213.97389-5-newtwen+github@gmail.com |
---|---|
State | New |
Headers | show
Return-Path: <openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org> 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=P03Pbdeb; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=casper.20170209 header.b=WC/rMRuJ; 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=ka8MrV4R; 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 4Vb6Kg28xbz20fh for <incoming@patchwork.ozlabs.org>; Fri, 10 May 2024 08:35:35 +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=CdduIjuWxQd3eP2w/2h9B808rWFB4J2kav5IAmYdDMA=; b=P03PbdebLCXkHH r5v7xSMBfuQMXV7kQ8tckDbLR8VZyFFXdvAxMjqcu291mRSfdGxUA3s+TRhd8ebnw+j2p/QLV29np BMn6SN9zRb97+dPFnHoJZbW7xyIpzikCa2ASVQ/QOKNPWe/KbFZL+tGkWNIwYndj0fZc4U8iO/qDc OAEfLJVfnkrG/I4fVolKcGr+qmwhhp1cYSyzUjX7VyyC+o8Ln/rrAnVTyRfAvh2RwHqqGjeG8GPjb c5rEYWoGjJy9WYXba6mcPnH9t165qkEIYqc5+KqSdxh66g8qn3ndD3X1J7iJwM/7xXLg4yKjsNvDF hwvHSSWrQwKjhnn6T61Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s5CKu-000000037ou-10n8; Thu, 09 May 2024 22:34:00 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s5CJa-000000036wv-06l6 for openwrt-devel@bombadil.infradead.org; Thu, 09 May 2024 22:32:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description; bh=axSAZHgAHpBIwpmETIw5If+E1m7OWMtFCBLKF0tg/Pw=; b=WC/rMRuJ/8k4xhrQ9wxFkFct8T 3QM9p+xF6gp7B58Wb9Fadxtj4/Kalo3GJGQ6OhW152Fo80AzPn40nL+V2ThR4rLcJc1qdptw7gSdv 4Hpk+YlsFAzaX73B31X/WMj4eBYkxx7M/5U+xz6OiYjFksWWNjW+K7z1i2VvS40wwOWMG5J/pXOFm foZkbWs4oFTeyrmZ3/HWJsCP1oX7rJspzcgq33jspnv7LFimvaIeacNii4+PYABUlxXiE9MaJ9uMC UOXEI99tdBbD7ZRZul4kKQ4z71nFBb9OCVYxSQxBgb/kTqR0Ca1G9ebi5isgtXkrj0jLdNwT9qSpy wn4oL9Ag==; Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s5CJR-00000001aJf-0IUu for openwrt-devel@lists.openwrt.org; Thu, 09 May 2024 22:32:36 +0000 Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2e09138a2b1so15195261fa.3 for <openwrt-devel@lists.openwrt.org>; Thu, 09 May 2024 15:32:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715293937; x=1715898737; 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=axSAZHgAHpBIwpmETIw5If+E1m7OWMtFCBLKF0tg/Pw=; b=ka8MrV4RLG6uNSuyETEsQS//POt4fxYW5jbTPDZb2gxIoaj59wCqPRz6+VW8zHZVB0 9Mj1tPfX8UIvzTeCyULfasBp9dkhS0Uqd/sVmUkE3jp9HHMwE31jby/ctBm/L0PsWnl6 mHKEVJmetbF4CFp40cwn8dTazre4JRYjm3hRgpAxAiMb2wzmo63IHaEPoRriq9/qFNXg dA5VNB0VEctOlCtLg4ZTb7kKYJyxGPt7MtkCyR5LtVK17j8psqZubTXp10y5EqaE8/15 /AQb56PS/Oqg2V4REA81Z76SDNxA6YcfLV1YsFOylfHlKN5CJSOevcW9MJ3lI9zSItJU bKOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715293937; x=1715898737; 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=axSAZHgAHpBIwpmETIw5If+E1m7OWMtFCBLKF0tg/Pw=; b=hbUklacVYGTmRXRgA9+J4nXe0/hmo8kqEg2BrFDpdIUWu1LxmMXkoALGHMmpv3Pba2 W9YTtdLw7+fClzFW5iY8pbSsL2APXGiO+wAfh07BxikS5Nk6VclMgiFLCsIBNtLL4KMX jE60Jc81DJM6ydG0c+E0yclTfpLbqJWb4z/gI+wdsmc2K+APTWG9PSK1wqTbjFUSpav7 Wx12mQ6eUn3ZUgmeEwl02EXYFPJNd+oTWixGljX4wWBzRc/aJrC3LOh/CFXfItu3xbp7 /sKGVaJYkmUqqd2RcvttfeH8KOeD1HFv5HwAVw+w5iTUacgdbNCq1qZ0CGId8w5zAeO5 s1ew== X-Gm-Message-State: AOJu0YwIjzAusasNhJ1KuyYKLXbigORvay4UN0srirvD9EnQ++h5v4B8 +w2mhiW7yOXmGsWu1IU8UUxFphOaX3Xotkzr32oJvIellnTecAUhcZ6Pvw== X-Google-Smtp-Source: AGHT+IHRMgFceSOZvmVHNn/frPDZ+ioqsYSnl7a2x1pBA9T0s47tqNIbzaVpWrBevreEbLE+qBfA0Q== X-Received: by 2002:a2e:8255:0:b0:2df:8ce6:96ae with SMTP id 38308e7fff4ca-2e51fe52568mr3872221fa.7.1715293937126; Thu, 09 May 2024 15:32:17 -0700 (PDT) Received: from blackhol3 ([2001:9b0:40::cae3:cb03]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2e4d0bbc3a6sm3156191fa.13.2024.05.09.15.32.16 for <openwrt-devel@lists.openwrt.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 15:32:16 -0700 (PDT) From: Paul Donald <newtwen+github@gmail.com> To: OpenWrt Development List <openwrt-devel@lists.openwrt.org> Subject: [RFC PATCH 04/14] router: refactor calc_ra_lifetime, and define ra_lifetime as uint32_t Date: Fri, 10 May 2024 00:30:36 +0200 Message-ID: <20240509223213.97389-5-newtwen+github@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240509223213.97389-1-newtwen+github@gmail.com> References: <20240509223213.97389-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-20240509_233229_286487_45A1C1DA X-CRM114-Status: GOOD ( 12.68 ) X-Spam-Score: -2.1 (--) X-Spam-Report: SpamAssassin version 4.0.0 on casper.infradead.org summary: Content analysis details: (-2.1 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:22a listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -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 -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 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 <openwrt-devel.lists.openwrt.org> List-Unsubscribe: <https://lists.openwrt.org/mailman/options/openwrt-devel>, <mailto:openwrt-devel-request@lists.openwrt.org?subject=unsubscribe> List-Archive: <http://lists.openwrt.org/pipermail/openwrt-devel/> List-Post: <mailto:openwrt-devel@lists.openwrt.org> List-Help: <mailto:openwrt-devel-request@lists.openwrt.org?subject=help> List-Subscribe: <https://lists.openwrt.org/mailman/listinfo/openwrt-devel>, <mailto:openwrt-devel-request@lists.openwrt.org?subject=subscribe> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "openwrt-devel" <openwrt-devel-bounces@lists.openwrt.org> Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org |
Series |
odhcpd config value clamping
|
expand
|
diff --git a/src/odhcpd.h b/src/odhcpd.h index 7a82e98..09cd4f1 100644 --- a/src/odhcpd.h +++ b/src/odhcpd.h @@ -314,7 +314,7 @@ struct interface { int route_preference; int ra_maxinterval; int ra_mininterval; - int ra_lifetime; + uint32_t ra_lifetime; uint32_t ra_reachabletime; uint32_t ra_retranstime; uint32_t ra_hoplimit; diff --git a/src/router.c b/src/router.c index 96237d6..b859c46 100644 --- a/src/router.c +++ b/src/router.c @@ -366,17 +366,14 @@ static int calc_adv_interval(struct interface *iface, uint32_t lowest_found_life static uint32_t calc_ra_lifetime(struct interface *iface, uint32_t maxival) { - uint32_t lifetime = 3*maxival; - - if (iface->ra_lifetime >= 0) { - lifetime = iface->ra_lifetime; - if (lifetime > 0 && lifetime < maxival) - lifetime = maxival; - /* // RouterLifetime is a 16 bit packet field: skip this check - else if (lifetime > RouterLifetime_MAX) - lifetime = RouterLifetime_MAX; - */ - } + uint32_t lifetime = iface->ra_lifetime; + + if (lifetime > 0 && lifetime < maxival) + lifetime = maxival; + /* // RouterLifetime is a 16 bit packet field: skip this check + else if (lifetime > RouterLifetime_MAX) + lifetime = RouterLifetime_MAX; + */ return lifetime; }