diff mbox

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

Message ID 1453061119-2438-1-git-send-email-nworbnhoj@gmail.com
State Changes Requested
Delegated to: Jo-Philipp Wich
Headers show

Commit Message

John A Brown Jan. 17, 2016, 8:05 p.m. UTC
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 acceps 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@gmail.com>
---
 package/network/services/dnsmasq/files/dnsmasq.init | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

--
2.5.0

Comments

Jo-Philipp Wich Jan. 18, 2016, 9:28 a.m. UTC | #1
Hi.

The change is fine with me but shouldn't we keep checking whether
there's at least one mac given?

~ Jow
diff mbox

Patch

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