dnsmasq: Invoke new ipcalc with CIDR notation
[openwrt/openwrt.git] / package / network / services / dnsmasq / files / dnsmasq.init
index d356a21f81f83cd38881057d32e9c66d67cc8bb2..0c769602366c2934a546c6705b7c3b97e511ee78 100755 (executable)
@@ -539,8 +539,13 @@ dhcp_add() {
        # Do not support non-static interfaces for now
        [ static = "$proto" ] || return 0
 
+       ipaddr="${subnet%%/*}"
+       prefix_or_netmask="${subnet##*/}"
+
        # Override interface netmask with dhcp config if applicable
-       config_get netmask "$cfg" netmask "${subnet##*/}"
+       config_get netmask "$cfg" netmask
+
+       [ -n "$netmask" ] && prefix_or_netmask="$netmask"
 
        #check for an already active dhcp server on the interface, unless 'force' is set
        config_get_bool force "$cfg" force 0
@@ -583,7 +588,7 @@ dhcp_add() {
        nettag="${networkid:+set:${networkid},}"
 
        # make sure the DHCP range is not empty
-       if [ "$dhcpv4" != "disabled" ] && ipcalc "${subnet%%/*}" "$netmask" "$start" "$limit" ; then
+       if [ "$dhcpv4" != "disabled" ] && ipcalc "$ipaddr/$prefix_or_netmask" "$start" "$limit" ; then
                [ "$dynamicdhcpv4" = "0" ] && END="static"
 
                xappend "--dhcp-range=$tags$nettag$START,$END,$NETMASK,$leasetime${options:+ $options}"