isc-dhcp: add support for RFC-3442 classless IPv4 routes 13153/head
authorPhilip Prindeville <philipp@redfish-solutions.com>
Tue, 18 Aug 2020 02:07:41 +0000 (20:07 -0600)
committerPhilip Prindeville <philipp@redfish-solutions.com>
Sat, 29 Aug 2020 01:30:42 +0000 (19:30 -0600)
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
net/isc-dhcp/Makefile
net/isc-dhcp/files/dhcpd.init [changed mode: 0644->0755]

index abed03e2daa55ec3b4879e65e18eb6921d5ef298..5f0f75652b3460af2dbaa46ffa8970c7d85bc37e 100644 (file)
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
 PKG_NAME:=isc-dhcp
 UPSTREAM_NAME:=dhcp
 PKG_VERSION:=4.4.1
-PKG_RELEASE:=7
+PKG_RELEASE:=8
 
 PKG_LICENSE:=BSD-3-Clause
 PKG_LICENSE_FILES:=LICENSE
old mode 100644 (file)
new mode 100755 (executable)
index 33e45ad..2a11116
@@ -131,6 +131,36 @@ typeof() {
 '
 }
 
+explode() {
+       local arg="$1"
+
+       echo "$arg" | sed -e 's/\./, /g'
+}
+
+append_routes() {
+       local tuple tuples="$1"
+       local string=
+
+       local IFS=','
+       for tuple in $tuples; do
+               local network prefix router save octets compacted
+
+               save="${tuple% *}"
+               router="${tuple#${save} }"
+
+               network="${save%/[0-9]*}"
+               prefix="${save##${network}}"
+               prefix="${prefix:1}"
+
+               octets=$((($prefix + 7) / 8))
+               compacted="$(echo "$network" | cut -d. -f1-$octets)"
+
+               string="${string:+, }$(explode "$prefix.$compacted.$router")"
+       done
+
+       echo " option classless-ipv4-route $string;"
+}
+
 append_dhcp_options() {
        local tuple="$1"
 
@@ -178,6 +208,7 @@ gen_dhcp_subnet() {
        fi
        echo " option routers $gateway;"
        echo " option domain-name-servers $DNS;"
+       config_list_foreach "$cfg" "routes" append_routes
        config_list_foreach "$cfg" "dhcp_option" append_dhcp_options
        echo "}"
 }
@@ -264,6 +295,8 @@ general_config() {
 
        [ -n "$domain" ] && echo "option domain-name \"$domain\";"
 
+       echo -e "\n# additional codes\noption classless-ipv4-route code 121 = array of { unsigned integer 8 };\n"
+
        rm -f /tmp/resolv.conf
        echo "# This file is generated by the DHCPD service" > /tmp/resolv.conf
        [ -n "$domain" ] && echo "domain $domain" >> /tmp/resolv.conf