isc-dhcp: dhcrelay: Add more UCI options

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 <br1@einfach.org>

git-svn-id: svn://svn.openwrt.org/openwrt/packages@38446 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
jow 2013-10-18 11:39:56 +00:00
parent 8aba712580
commit a8ce2d5f8c
3 changed files with 57 additions and 11 deletions

View File

@ -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)

View File

@ -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
}

View File

@ -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'