dnsmasq: add dhcp-range tags configuration
authorGrégoire Delattre <gregoire.delattre@gmail.com>
Tue, 20 Jun 2017 09:45:49 +0000 (11:45 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Tue, 20 Jun 2017 20:33:41 +0000 (22:33 +0200)
dnsmasq can match tags in its dhcp-range configuration, this commit adds
the option to configure it in the dhcp section

uci configuration:
config dhcp 'lan'
        option interface 'lan'
        list tag 'blue'
        list tag '!red'
        option start '10'
        option limit '150'
        option leasetime '12h'

generated dnsmasq configuration:
dhcp-range=tag:blue,tag:!red,set:lan,192.168.1.10,192.168.1.159,255.255.255.0,12h

Signed-off-by: Grégoire Delattre <gregoire.delattre@gmail.com>
package/network/services/dnsmasq/Makefile
package/network/services/dnsmasq/files/dnsmasq.init

index f9ab13aef096d1ad3d3abbaf5b45e7abecc7fda4..35ac6b2891a976530632d541e90b0d19005a4384 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=dnsmasq
 PKG_VERSION:=2.77
-PKG_RELEASE:=3
+PKG_RELEASE:=4
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
 PKG_SOURCE_URL:=http://thekelleys.org.uk/dnsmasq/
index d5177ecb0ca652f2f8100bf610885f2fcb386f1b..065d1fd8c2be8bb397cab4a4d02c19eb983e0c85 100644 (file)
@@ -440,6 +440,7 @@ dhcp_add() {
        local cfg="$1"
        local dhcp6range="::"
        local nettag
+       local tags
 
        config_get net "$cfg" interface
        [ -n "$net" ] || return 0
@@ -491,6 +492,12 @@ dhcp_add() {
        dhcp_this_host_add "$net" "$ifname" "$ADD_LOCAL_FQDN"
 
        start="$( dhcp_calc "$start" )"
+
+       add_tag() {
+               tags="${tags}tag:$1,"
+       }
+       config_list_foreach "$cfg" tag add_tag
+
        nettag="${networkid:+set:${networkid},}"
 
        if [ "$limit" -gt 0 ] ; then
@@ -508,7 +515,7 @@ dhcp_add() {
 
 
        if [ "$dhcpv4" != "disabled" ] ; then
-               xappend "--dhcp-range=$nettag$START,$END,$NETMASK,$leasetime${options:+ $options}"
+               xappend "--dhcp-range=$tags$nettag$START,$END,$NETMASK,$leasetime${options:+ $options}"
        fi