From patchwork Tue Jan 5 11:48:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannu Nyman X-Patchwork-Id: 563051 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BB87014031D for ; Tue, 5 Jan 2016 22:48:53 +1100 (AEDT) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id EB6B628109D; Tue, 5 Jan 2016 12:48:10 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00 autolearn=unavailable version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 1BDC2280AE5 for ; Tue, 5 Jan 2016 12:48:04 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 CL_IP_EQ_HELO_IP=-2 (check from: .iki. - helo: .welho-filter1.welho. - helo-domain: .welho.) FROM/MX_MATCHES_NOT_HELO(DOMAIN)=1; rate: -5.5 Received: from welho-filter1.welho.com (welho-filter1.welho.com [83.102.41.23]) by arrakis.dune.hu (Postfix) with ESMTP for ; Tue, 5 Jan 2016 12:48:03 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by welho-filter1.welho.com (Postfix) with ESMTP id D9A02114; Tue, 5 Jan 2016 13:48:31 +0200 (EET) X-Virus-Scanned: Debian amavisd-new at pp.htv.fi Received: from welho-smtp2.welho.com ([IPv6:::ffff:83.102.41.85]) by localhost (welho-filter1.welho.com [::ffff:83.102.41.23]) (amavisd-new, port 10024) with ESMTP id 3LD5w77JnxAP; Tue, 5 Jan 2016 13:48:31 +0200 (EET) Received: from localhost.localdomain (87-100-186-127.bb.dnainternet.fi [87.100.186.127]) by welho-smtp2.welho.com (Postfix) with ESMTP id 290FF231; Tue, 5 Jan 2016 13:48:31 +0200 (EET) From: Hannu Nyman To: openwrt-devel@lists.openwrt.org Date: Tue, 5 Jan 2016 13:48:28 +0200 Message-Id: <1451994508-2463-1-git-send-email-hannu.nyman@iki.fi> X-Mailer: git-send-email 2.5.0 Cc: Hannu Nyman Subject: [OpenWrt-Devel] [PATCH] dnsmasq: add host-specific lease time option for static hosts X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Enable setting a host-specific lease time for static hosts. The new option is called "leasetime" and the format is similar as for the default lease time: e.g. 12h, 3d, infinite Default lease time is used for all hosts for which there is no host-specific definition. The option is added to /etc/config/dhcp for the selected hosts: config host option name 'Nexus' option mac 'd8:50:66:55:59:7c' option ip '192.168.1.245' option leasetime '2h' It gets appended to /var/etc/dnsmasq.conf like this: dhcp-host=d8:50:66:55:59:7c,192.168.1.245,Nexus,2h Signed-off-by: Hannu Nyman --- Reference to discussion at https://patchwork.ozlabs.org/patch/561694/ I have included this option in my own build for the last 4 years. (Ever since I tried to submit it via https://dev.openwrt.org/ticket/11227 ) I have also the Luci part ready. package/network/services/dnsmasq/Makefile | 4 ++-- package/network/services/dnsmasq/files/dnsmasq.init | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/package/network/services/dnsmasq/Makefile b/package/network/services/dnsmasq/Makefile index cddde5c..530d33d 100644 --- a/package/network/services/dnsmasq/Makefile +++ b/package/network/services/dnsmasq/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2006-2015 OpenWrt.org +# Copyright (C) 2006-2016 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=dnsmasq PKG_VERSION:=2.75 -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=http://thekelleys.org.uk/dnsmasq diff --git a/package/network/services/dnsmasq/files/dnsmasq.init b/package/network/services/dnsmasq/files/dnsmasq.init index 3ef2b3d..f89bd8c 100644 --- a/package/network/services/dnsmasq/files/dnsmasq.init +++ b/package/network/services/dnsmasq/files/dnsmasq.init @@ -334,7 +334,9 @@ dhcp_host_add() { config_get_bool broadcast "$cfg" broadcast 0 [ "$broadcast" = "0" ] && broadcast= - xappend "--dhcp-host=$macs${networkid:+,net:$networkid}${broadcast:+,set:needs-broadcast}${tag:+,set:$tag}${ip:+,$ip}${name:+,$name}" + config_get leasetime "$cfg" leasetime + + xappend "--dhcp-host=$macs${networkid:+,net:$networkid}${broadcast:+,set:needs-broadcast}${tag:+,set:$tag}${ip:+,$ip}${name:+,$name}${leasetime:+,$leasetime}" } dhcp_tag_add() {