Re: [OpenWrt-Devel] [PATCH 2/3] isc-dhcp: dhcrelay: Add more UCI options

2013-10-18 Thread Jo-Philipp Wich
Applied in r38446 - thanks!

~ Jow



signature.asc
Description: OpenPGP digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 2/3] isc-dhcp: dhcrelay: Add more UCI options

2013-10-17 Thread Bruno Randolf
Add more options to dhcrelay UCI and init script:

- enabled
- interfaces: Listen interfaces
- relay_mode: What to do about packets that already have a relay option

Also mark /etc/config/dhcrelay as conffile

Signed-off-by: Bruno Randolf b...@einfach.org
---
 net/isc-dhcp/Makefile  |  8 
 net/isc-dhcp/files/dhcrelay4.init  | 36 --
 net/isc-dhcp/files/etc/config/dhcrelay | 24 ++-
 3 files changed, 57 insertions(+), 11 deletions(-)

diff --git a/net/isc-dhcp/Makefile b/net/isc-dhcp/Makefile
index aa27aca..5e5471f 100644
--- a/net/isc-dhcp/Makefile
+++ b/net/isc-dhcp/Makefile
@@ -55,11 +55,19 @@ $(call Package/isc-dhcp-relay-ipv6/description)
  This package is compiled with IPv4 support only.
 endef
 
+define Package/isc-dhcp-relay-ipv4/conffiles
+/etc/config/dhcrelay
+endef
+
 define Package/isc-dhcp-relay-ipv6/description
 $(call Package/isc-dhcp-relay/description)
  This package is compiled with IPv4 and IPv6 support.
 endef
 
+define Package/isc-dhcp-relay-ipv6/conffiles
+/etc/config/dhcrelay
+endef
+
 define Package/isc-dhcp-client-ipv4
   $(call Package/isc-dhcp/Default)
   TITLE+= client (without IPv6)
diff --git a/net/isc-dhcp/files/dhcrelay4.init 
b/net/isc-dhcp/files/dhcrelay4.init
index 70905cf..e1e6871 100644
--- a/net/isc-dhcp/files/dhcrelay4.init
+++ b/net/isc-dhcp/files/dhcrelay4.init
@@ -8,15 +8,39 @@ SERVICE_PID_FILE=/var/run/dhcrelay4.pid
 SERVICE_USE_PID=1
 
 start() {
-local relay_dhcpserver
+   . /lib/functions/network.sh
+   config_load dhcrelay
+   local args=
 
-config_load dhcrelay
-config_get relay_dhcpserver ipv4 dhcpserver
+   local enabled
+   config_get_bool enabled ipv4 enabled 0
+   [ $enabled -eq 0 ]  return 0
 
-service_start /usr/sbin/dhcrelay -4 -q \
--pf $SERVICE_PID_FILE $relay_dhcpserver
+   # listen interfaces
+   local interfaces
+   local ifname
+   config_get interfaces ipv4 interfaces
+   for net in $interfaces; do
+   if network_get_device ifname $net; then
+   append args -i $ifname
+   fi
+   done
+
+   # relay mode
+   local relay_mode
+   config_get relay_mode ipv4 relay_mode
+   [ -n $relay_mode ]  append args -m $relay_mode
+
+   # dhcp server address
+   local server
+   config_get server ipv4 dhcpserver
+   [ -n $server ] || return 0
+   append args $server
+
+   service_start /usr/sbin/dhcrelay -4 -q \
+   -pf $SERVICE_PID_FILE $args
 }
 
 stop() {
-service_stop /usr/sbin/dhcrelay
+   service_stop /usr/sbin/dhcrelay
 }
diff --git a/net/isc-dhcp/files/etc/config/dhcrelay 
b/net/isc-dhcp/files/etc/config/dhcrelay
index 5fde239..1b89782 100644
--- a/net/isc-dhcp/files/etc/config/dhcrelay
+++ b/net/isc-dhcp/files/etc/config/dhcrelay
@@ -1,10 +1,24 @@
 
 config dhcrelay ipv4
-option dhcpserver '192.0.2.10'
+   option 'enabled' '0'
+
+   # IP address of the server
+   option 'dhcpserver' '192.0.2.10'
+
+   # network interfaces to listen on (e.g. lan or wan)
+   option 'interfaces' ''
+
+   # What to do about packets that already have a relay option:
+   # 'append': Forward and append our own relay option
+   # 'replace': Forward, but replace theirs with ours (default)
+   # 'forward': Forward without changes
+   # 'discard': Don't forward
+   option 'relay_mode' ''
+
 
 config dhcrelay ipv6
-#option dhcpserver '2001:db8:1::1'
-option upper 'eth1'
-list lower 'eth0.2'
-list lower 'eth0.3'
+#  option dhcpserver '2001:db8:1::1'
+   option upper 'eth1'
+   list lower 'eth0.2'
+   list lower 'eth0.3'
 
-- 
1.8.1.2
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel