isc-dhcp: add support for RFC-3442 classless routes to hosts
authorPhilip Prindeville <philipp@redfish-solutions.com>
Thu, 10 Sep 2020 16:16:09 +0000 (10:16 -0600)
committerPhilip Prindeville <philipp@redfish-solutions.com>
Thu, 10 Sep 2020 16:43:29 +0000 (10:43 -0600)
Also avoid forward references to functions.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
net/isc-dhcp/Makefile
net/isc-dhcp/files/dhcpd.init

index 5f0f75652b3460af2dbaa46ffa8970c7d85bc37e..9ec28a4532e38a57d18f6fff25306787844c89f2 100644 (file)
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
 PKG_NAME:=isc-dhcp
 UPSTREAM_NAME:=dhcp
 PKG_VERSION:=4.4.1
-PKG_RELEASE:=8
+PKG_RELEASE:=9
 
 PKG_LICENSE:=BSD-3-Clause
 PKG_LICENSE_FILES:=LICENSE
index 2a1111697a67dcbcd1d8002d66679d6a50beb64d..7dfe127cdd92b224b6317e1ac47701a55b83de6d 100755 (executable)
@@ -57,70 +57,6 @@ hex_to_hostid() {
        return 0
 }
 
-static_host_add() {
-       local cfg="$1"
-       local broadcast hostid macn macs mac name ip leasetime
-
-       config_get macs "$cfg" "mac"
-       [ -n "$macs" ] || return 0
-       config_get name "$cfg" "name"
-       [ -n "$name" ] || return 0
-       config_get ip "$cfg" "ip"
-       [ -n "$ip" ] || return 0
-
-       config_get_bool broadcast "$cfg" "broadcast" 0
-       config_get dns "$cfg" "dns"
-       config_get gateway "$cfg" "gateway"
-       config_get leasetime "$cfg" "leasetime"
-       if [ -n "$leasetime" ] ; then
-               leasetime="$(time2seconds "$leasetime")"
-               [ "$?" -ne 0 ] && return 1
-       fi
-
-       config_get hostid "$cfg" "hostid"
-       if [ -n "$hostid" ] ; then
-               hex_to_hostid hostid "$hostid" || return 1
-       fi
-
-       macn=0
-       for mac in $macs; do
-               macn=$(( macn + 1 ))
-       done
-
-       for mac in $macs; do
-               local secname="$name"
-               if [ $macn -gt 1 ] ; then
-                       secname="${name}-${mac//:}"
-               fi
-               echo "host $secname {"
-               echo " hardware ethernet $mac;"
-               echo " fixed-address $ip;"
-               echo " option host-name \"$name\";"
-               if [ "$broadcast" -eq 1 ] ; then
-                       echo " always-broadcast true;"
-               fi
-               if [ -n "$leasetime" ] ; then
-                       echo " default-lease-time $leasetime;"
-                       echo " max-lease-time $leasetime;"
-               fi
-               if [ -n "$hostid" ] ; then
-                       echo " option dhcp-client-identifier $hostid;"
-               fi
-               if [ -n "$dns" ] ; then
-                       echo " option domain-name-servers $dns;"
-               fi
-               if [ -n "$gateway" ] ; then
-                       echo " option routers $gateway;"
-               fi
-               config_list_foreach "$cfg" "dhcp_option" append_dhcp_options
-               echo "}"
-       done
-}
-
-static_hosts() {
-       config_foreach static_host_add host "$@"
-}
-
 typeof() {
        echo "$1" | awk '
 /^\d+\.\d+\.\d+\.\d+$/         { print "ip\n"; next; }
@@ -186,6 +122,71 @@ append_dhcp_options() {
        echo " option $tag $formatted;"
 }
 
+static_host_add() {
+       local cfg="$1"
+       local broadcast hostid macn macs mac name ip leasetime
+
+       config_get macs "$cfg" "mac"
+       [ -n "$macs" ] || return 0
+       config_get name "$cfg" "name"
+       [ -n "$name" ] || return 0
+       config_get ip "$cfg" "ip"
+       [ -n "$ip" ] || return 0
+
+       config_get_bool broadcast "$cfg" "broadcast" 0
+       config_get dns "$cfg" "dns"
+       config_get gateway "$cfg" "gateway"
+       config_get leasetime "$cfg" "leasetime"
+       if [ -n "$leasetime" ] ; then
+               leasetime="$(time2seconds "$leasetime")"
+               [ "$?" -ne 0 ] && return 1
+       fi
+
+       config_get hostid "$cfg" "hostid"
+       if [ -n "$hostid" ] ; then
+               hex_to_hostid hostid "$hostid" || return 1
+       fi
+
+       macn=0
+       for mac in $macs; do
+               macn=$(( macn + 1 ))
+       done
+
+       for mac in $macs; do
+               local secname="$name"
+               if [ $macn -gt 1 ] ; then
+                       secname="${name}-${mac//:}"
+               fi
+               echo "host $secname {"
+               echo " hardware ethernet $mac;"
+               echo " fixed-address $ip;"
+               echo " option host-name \"$name\";"
+               if [ "$broadcast" -eq 1 ] ; then
+                       echo " always-broadcast true;"
+               fi
+               if [ -n "$leasetime" ] ; then
+                       echo " default-lease-time $leasetime;"
+                       echo " max-lease-time $leasetime;"
+               fi
+               if [ -n "$hostid" ] ; then
+                       echo " option dhcp-client-identifier $hostid;"
+               fi
+               if [ -n "$dns" ] ; then
+                       echo " option domain-name-servers $dns;"
+               fi
+               if [ -n "$gateway" ] ; then
+                       echo " option routers $gateway;"
+               fi
+               config_list_foreach "$cfg" "routes" append_routes
+               config_list_foreach "$cfg" "dhcp_option" append_dhcp_options
+               echo "}"
+       done
+}
+
+static_hosts() {
+       config_foreach static_host_add host "$@"
+}
+
 gen_dhcp_subnet() {
        local cfg="$1"