From patchwork Thu May 9 22:30:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Donald X-Patchwork-Id: 1933678 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=rIHNSX0w; 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=XqOo5aVD; 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=XT0n9CDM; 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 4Vb6Kh63sQz20fh for ; Fri, 10 May 2024 08:35:36 +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=19MPPDfd/2MjQRMkU7oTKw06GRlCjMzkoqK6Ut0x14M=; b=rIHNSX0w1uo4PM o2EJa/PCOluAxbdbren+9/GV2Kbva5EHW6E8O/EeYwXhHtzugjPDA52ZqMxRJnUMtqZKBheAJ3r+C zPaUR4upqP4klpY/H0FIOHpLbZ8P+q+oPhB8qhWVNKQyBs9bcRuLZvkD2dEJuc3KwE9yKyPyEa11N JRXeNWAxtptIP8jo/kW8ObnrAy/FlZw05xdzIM509TygFyN7pPTO3L9s+Lf2eaU3KdcMEn3gPvBUF wEi1Dq3c7o/lC24/92Q+zdNeJ8FgoA9Gg7qkq3j8opev1c1VqLPahZoeUVDjkWFBxY/hfFLyZQ/E6 1Qk5Vxi5iXvclzLr70Eg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s5CKa-000000037a0-2nEK; Thu, 09 May 2024 22:33:40 +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 1s5CJY-000000036vn-3ROv for openwrt-devel@bombadil.infradead.org; Thu, 09 May 2024 22:32:37 +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=Czg5q6Uxi8LowDW616RLS/5yCHTaygMry1DedfJP59Q=; b=XqOo5aVDfJLc1DwcCIKTVm221D g0o0Bp/xZlsf4mixp/dEqjghVdNKUqtt7GrSIjC5Xj/RKOwF+w0y2Rx1SByD+kVeJwmI8pmFHUGLn fPexlFUAjTvm6bzt03dN5WYxO5zahTzbQQnCtpLcXeKhtQXilTlLuCHYo0Z7Z9Fi6aOB726IvQYD4 2BpXXIDGLeG+zgoxrFk/UwDUW80iI4fNjwPbDLiEVqByPV2bZeVC2Zr4/kyBUxwwQKjVVgJHl4xv5 cugaj6AqqQ1QhxJzjg7BvdcGksSfuZH7/SGQ1lgoBc6YD3PP9tFvRBA/uEFJtUuZpXkmDAI+4qR8B OZ0x66yQ==; Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s5CJR-00000001aJi-0LGL for openwrt-devel@lists.openwrt.org; Thu, 09 May 2024 22:32:35 +0000 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2e2b468ea12so12302941fa.1 for ; Thu, 09 May 2024 15:32:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715293938; x=1715898738; 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=Czg5q6Uxi8LowDW616RLS/5yCHTaygMry1DedfJP59Q=; b=XT0n9CDMr5tZunlly2OkqyjivOKEHN9LSiwK11hwUOxgHwrPIu97Wrj3jv+Onkz17y Nnqe5HFxIdT65tU48brCJ8/B4hOM2Bm68KzH+MN+qTxMHkIhEQAovrobWyePyN/3Ioo4 1ZFoQFw3uPzHqJYzdz/476QM6qe45v9XnTawq8y3d+Or9XoltmLpMHwzv/eOA/Tu9ueB AStlcJv/YO2MkqAXZQ0vnvNVmBvjrYPRHbTuf1BY9q1vwQ+x9Dg+Pbr56Ci2/6N+Ys4Q spmbHA/06Hh20ky+OQogO0fI13XpHMOJbSMsxPVhdAujl/sOdZW8n50iqNOStDpwyrN0 NjMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715293938; x=1715898738; 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=Czg5q6Uxi8LowDW616RLS/5yCHTaygMry1DedfJP59Q=; b=kOVRXqeJlu+Rrg0RVO9GMATt1nDkCSTXLn+ZYREyAhWwJcJXobx5yPDcmmNqmeBYxh TGLvCweMMNyuuCxD30E+Wq04L7md7O3XG8FvEDMnnK3RaRLdL46VGcd3vgxnPDHW2IGY cY3/nMHlcz6Ad+crgGY9IVvY5DJPD9JR1Nmp8uvCuCJARstAVVjvdcuNEQmFK6DhRF/g eMv3ywf9dfhhKRSu0AjBMYPE8HI1qsTZCTo+Wpp0fr1xT2ciZSfVDpcVY30vuPWPckqS x7bOVaBhrI57UJtIVCu7Y+/QUodMVRTU1YVRrW1N2wfv0hIWilQp3DdCFs4HL+IDYJix f9IQ== X-Gm-Message-State: AOJu0YxTY4NI4pqv2WPWosZi0GPdia4ylCzv1p2qYLj1pjYlE3akYukq eTgLLAhPNntXAYtFAY4ZJ4geO3ED6tY4w2dfBLmTj1DnCdCBBqkZPQgo1w== X-Google-Smtp-Source: AGHT+IGjXBsLuaHfQqC82fyF2iHoicZy8sTU7841rSyAorhK+33/yQyNmeC7YDsQNWSbGfjbhAzZtg== X-Received: by 2002:a2e:8608:0:b0:2e2:a99a:559 with SMTP id 38308e7fff4ca-2e51b4784d9mr2559691fa.25.1715293938051; Thu, 09 May 2024 15:32:18 -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.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 15:32:17 -0700 (PDT) From: Paul Donald To: OpenWrt Development List Subject: [RFC PATCH 06/14] config: implement RFC4861 AdvValidLifetime (make configurable) Date: Fri, 10 May 2024 00:30:38 +0200 Message-ID: <20240509223213.97389-7-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_271157_9FDACFEF X-CRM114-Status: GOOD ( 14.65 ) 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 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:22f listed in] [list.dnswl.org] -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 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 In accordance with RFC4861. Enables control of ULA. The new config variable is valid_lifetime. e.g.: config dhcp 'lan' ... option valid_lifetime '6h' Signed-off-by: Paul Donald --- README | 2 ++ src/config.c | 14 ++++++++++++++ src/odhcpd.h | 1 + 3 files changed, 17 insertions(+) diff --git a/README b/README index c8f2eb4..4d1956c 100644 --- a/README +++ b/README @@ -155,6 +155,8 @@ prefix_filter string ::/0 Only advertise on-link prefixes within filtered out. ntp list NTP servers to announce accepts IPv4 and IPv6 +valid_lifetime string 30d Value for the valid lifetime + for a prefix Sections of type host (static leases) diff --git a/src/config.c b/src/config.c index a3bf1ba..285e3a1 100644 --- a/src/config.c +++ b/src/config.c @@ -93,6 +93,7 @@ enum { IFACE_ATTR_NDPROXY_SLAVE, IFACE_ATTR_PREFIX_FILTER, IFACE_ATTR_PREFERRED_LIFETIME, + IFACE_ATTR_VALID_LIFETIME, IFACE_ATTR_NTP, IFACE_ATTR_MAX }; @@ -146,6 +147,7 @@ static const struct blobmsg_policy iface_attrs[IFACE_ATTR_MAX] = { [IFACE_ATTR_NDPROXY_SLAVE] = { .name = "ndproxy_slave", .type = BLOBMSG_TYPE_BOOL }, [IFACE_ATTR_PREFIX_FILTER] = { .name = "prefix_filter", .type = BLOBMSG_TYPE_STRING }, [IFACE_ATTR_PREFERRED_LIFETIME] = { .name = "preferred_lifetime", .type = BLOBMSG_TYPE_STRING }, + [IFACE_ATTR_VALID_LIFETIME] = { .name = "valid_lifetime", .type = BLOBMSG_TYPE_STRING }, [IFACE_ATTR_NTP] = { .name = "ntp", .type = BLOBMSG_TYPE_ARRAY }, }; @@ -217,6 +219,7 @@ static void set_interface_defaults(struct interface *iface) iface->learn_routes = 1; iface->dhcp_leasetime = 43200; iface->preferred_lifetime = 604800; /* rfc4861#section-6.2.1: AdvPreferredLifetime 7 days */ + iface->valid_lifetime = 2592000; /* rfc4861#section-6.2.1: AdvValidLifetime 30 days */ iface->dhcpv4_start.s_addr = htonl(START_DEFAULT); iface->dhcpv4_end.s_addr = htonl(START_DEFAULT + LIMIT_DEFAULT - 1); iface->dhcpv6_assignall = true; @@ -659,6 +662,17 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr } + if ((c = tb[IFACE_ATTR_VALID_LIFETIME])) { + uint32_t time = (uint32_t)parse_leasetime(c); + + if (time >= 0) + iface->valid_lifetime = time; + else + syslog(LOG_ERR, "Invalid %s value configured for interface '%s'", + iface_attrs[IFACE_ATTR_VALID_LIFETIME].name, iface->name); + + } + if ((c = tb[IFACE_ATTR_START])) { iface->dhcpv4_start.s_addr = htonl(blobmsg_get_u32(c)); iface->dhcpv4_end.s_addr = htonl(ntohl(iface->dhcpv4_start.s_addr) + diff --git a/src/odhcpd.h b/src/odhcpd.h index fecd77e..ddbc6b3 100644 --- a/src/odhcpd.h +++ b/src/odhcpd.h @@ -320,6 +320,7 @@ struct interface { uint32_t ra_hoplimit; int ra_mtu; uint32_t preferred_lifetime; + uint32_t valid_lifetime; // DHCP uint32_t dhcp_leasetime;