Merge pull request #21597 from pprindeville/isc-dhcp-fix-multiple-routes
isc-dhcp: fix handling multiple instances of 'routes' list
This commit is contained in:
commit
d42ad5cd9f
2 changed files with 24 additions and 19 deletions
|
@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
|
||||||
PKG_NAME:=isc-dhcp
|
PKG_NAME:=isc-dhcp
|
||||||
UPSTREAM_NAME:=dhcp
|
UPSTREAM_NAME:=dhcp
|
||||||
PKG_VERSION:=4.4.3-P1
|
PKG_VERSION:=4.4.3-P1
|
||||||
PKG_RELEASE:=4
|
PKG_RELEASE:=5
|
||||||
|
|
||||||
PKG_LICENSE:=BSD-3-Clause
|
PKG_LICENSE:=BSD-3-Clause
|
||||||
PKG_LICENSE_FILES:=LICENSE
|
PKG_LICENSE_FILES:=LICENSE
|
||||||
|
|
|
@ -138,29 +138,20 @@ create_empty_zone() {
|
||||||
}
|
}
|
||||||
|
|
||||||
append_routes() {
|
append_routes() {
|
||||||
local tuple tuples="$1"
|
local tuple tuple="$(trim "$1")"
|
||||||
local string=
|
local network prefix router save octets compacted
|
||||||
|
|
||||||
local IFS=','
|
save="${tuple% *}"
|
||||||
for tuple in $tuples; do
|
router="$(trim "${tuple#${save} }")"
|
||||||
local network prefix router save octets compacted
|
|
||||||
|
|
||||||
tuple="$(trim "$tuple")"
|
network="$(trim "${save%/[0-9]*}")"
|
||||||
|
|
||||||
save="${tuple% *}"
|
prefix="$(trim "${save##${network}/}")"
|
||||||
router="$(trim "${tuple#${save} }")"
|
|
||||||
|
|
||||||
network="$(trim "${save%/[0-9]*}")"
|
octets=$((($prefix + 7) / 8))
|
||||||
|
compacted="$(echo "$network" | cut -d. -f1-$octets)"
|
||||||
|
|
||||||
prefix="$(trim "${save##${network}/}")"
|
routes="$routes${routes:+, }$(explode "$prefix${compacted:+.$compacted}.$router")"
|
||||||
|
|
||||||
octets=$((($prefix + 7) / 8))
|
|
||||||
compacted="$(echo "$network" | cut -d. -f1-$octets)"
|
|
||||||
|
|
||||||
string="${string:+, }$(explode "$prefix${compacted:+.$compacted}.$router")"
|
|
||||||
done
|
|
||||||
|
|
||||||
echo " option classless-ipv4-route $string;"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
append_dhcp_options() {
|
append_dhcp_options() {
|
||||||
|
@ -306,8 +297,14 @@ static_host_add() {
|
||||||
extra_options="$extra_options${extra_options:+ }0c" ;;
|
extra_options="$extra_options${extra_options:+ }0c" ;;
|
||||||
domain-name)
|
domain-name)
|
||||||
extra_options="$extra_options${extra_options:+ }0f" ;;
|
extra_options="$extra_options${extra_options:+ }0f" ;;
|
||||||
|
renewal-time)
|
||||||
|
extra_options="$extra_options${extra_options:+ }3a" ;;
|
||||||
|
rebinding-time)
|
||||||
|
extra_options="$extra_options${extra_options:+ }3b" ;;
|
||||||
fqdn)
|
fqdn)
|
||||||
extra_options="$extra_options${extra_options:+ }51" ;;
|
extra_options="$extra_options${extra_options:+ }51" ;;
|
||||||
|
routes)
|
||||||
|
extra_options="$extra_options${extra_options:+ }79" ;;
|
||||||
*)
|
*)
|
||||||
echo "unknown option: $option" >&2 ;;
|
echo "unknown option: $option" >&2 ;;
|
||||||
esac
|
esac
|
||||||
|
@ -344,7 +341,11 @@ static_host_add() {
|
||||||
if [ -n "$gateway" ] ; then
|
if [ -n "$gateway" ] ; then
|
||||||
echo " option routers $gateway;"
|
echo " option routers $gateway;"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local routes=
|
||||||
config_list_foreach "$cfg" "routes" append_routes
|
config_list_foreach "$cfg" "routes" append_routes
|
||||||
|
[ -n "$routes" ] && echo " option classless-ipv4-route $routes;"
|
||||||
|
|
||||||
config_list_foreach "$cfg" "dhcp_option" append_dhcp_options
|
config_list_foreach "$cfg" "dhcp_option" append_dhcp_options
|
||||||
if [ -n "$extra_options" ]; then
|
if [ -n "$extra_options" ]; then
|
||||||
echo -e " if exists dhcp-parameter-request-list {\n option dhcp-parameter-request-list = concat(option dhcp-parameter-request-list, $extra_options);\n }"
|
echo -e " if exists dhcp-parameter-request-list {\n option dhcp-parameter-request-list = concat(option dhcp-parameter-request-list, $extra_options);\n }"
|
||||||
|
@ -391,7 +392,11 @@ gen_dhcp_subnet() {
|
||||||
echo " option routers $gateway;"
|
echo " option routers $gateway;"
|
||||||
fi
|
fi
|
||||||
echo " option domain-name-servers $DNS;"
|
echo " option domain-name-servers $DNS;"
|
||||||
|
|
||||||
|
local routes=
|
||||||
config_list_foreach "$cfg" "routes" append_routes
|
config_list_foreach "$cfg" "routes" append_routes
|
||||||
|
[ -n "$routes" ] && echo " option classless-ipv4-route $routes;"
|
||||||
|
|
||||||
config_list_foreach "$cfg" "dhcp_option" append_dhcp_options
|
config_list_foreach "$cfg" "dhcp_option" append_dhcp_options
|
||||||
echo "}"
|
echo "}"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue