diff mbox

[OpenWrt-Devel] dnsmasq: add host-specific lease time option for static hosts

Message ID 1451994508-2463-1-git-send-email-hannu.nyman@iki.fi
State Superseded
Headers show

Commit Message

Hannu Nyman Jan. 5, 2016, 11:48 a.m. UTC
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 <hannu.nyman@iki.fi>
---
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(-)

Comments

John Crispin Feb. 26, 2016, 8:33 a.m. UTC | #1
Hi,

this does not apply anymore. mind to rebase and resend it please ?

John

On 05/01/2016 12:48, Hannu Nyman wrote:
> 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 <hannu.nyman@iki.fi>
> ---
> 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() {
>
Hannu Nyman Feb. 26, 2016, 9:11 a.m. UTC | #2
On 26.2.2016 10:33, John Crispin wrote:
> Hi,
>
> this does not apply anymore. mind to rebase and resend it please ?
>
> John
>

Rebased patch v2 re-sent as https://patchwork.ozlabs.org/patch/588694/
diff mbox

Patch

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() {