[OpenWrt-Devel] [PATCH] [package] Allow UCI dhcp classifier to accept a MAC list

John A Brown nworbnhoj at gmail.com
Fri Jan 15 16:36:47 EST 2016


From: nworbnhoj <nworbnhoj at gmail.com>

dnsmasq offers to group DHCP options and their values by a network-id
and to send options only to hosts which have been tagged with that
network-id.

uci accepts the mac classifier, but only for a single MAC
config mac 'opnvpn'
        option mac  '00:FF:*:*:*:*'
        option networkid   'opnvpn'
        list   dhcp_option '3'

this patch allows a list of macs to be assigned to a network-id
config mac 'opnvpn'
	list   mac  '00:00:00:00:00:AA'
	list   mac  '00:00:00:00:00:BB'
	list   mac  '00:00:00:00:00:CC'
        option networkid   'opnvpn'
        list   dhcp_option '3'

Signed-off-by: John A Brown <nworbnhoj at gmail.com>
---
 package/network/services/dnsmasq/files/dnsmasq.init | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/package/network/services/dnsmasq/files/dnsmasq.init
b/package/network/services/dnsmasq/files/dnsmasq.init
index efc9627..4470d75 100644
--- a/package/network/services/dnsmasq/files/dnsmasq.init
+++ b/package/network/services/dnsmasq/files/dnsmasq.init
@@ -361,9 +361,9 @@ dhcp_mac_add() {
 	[ -n "$networkid" ] || return 0

 	config_get mac "$cfg" mac
-	[ -n "$mac" ] || return 0
-
-	xappend "--dhcp-mac=$networkid,$mac"
+	for o in $mac; do
+		xappend "--dhcp-mac=$networkid,$mac"
+	done

 	dhcp_option_add "$cfg" "$networkid"
 }
@@ -562,7 +562,7 @@ start_service() {
 	procd_add_jail dnsmasq ubus log
 	procd_add_jail_mount $CONFIGFILE $TRUSTANCHORSFILE $HOSTFILE
/etc/passwd /etc/group /etc/TZ /dev/null /dev/urandom /etc/dnsmasq.conf
/tmp/dnsmasq.d /tmp/resolv.conf.auto /etc/hosts /etc/ethers
 	procd_add_jail_mount_rw /var/run/dnsmasq/ /tmp/dhcp.leases $TIMESTAMPFILE
-	
+
 	procd_close_instance

 	# before we can call xappend
-- 
2.5.0
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list