diff options
| author | Florian Eckert | 2025-04-29 13:26:36 +0000 |
|---|---|---|
| committer | Hauke Mehrtens | 2025-05-29 21:54:18 +0000 |
| commit | ae198c6ba08542d7eaca41103ee86d6794039ffc (patch) | |
| tree | b68aa1d5712b7ee7572ba34dfc0ab9fef60226c7 | |
| parent | b90feed6ba7d8437d84fd117ce1a58f00d83806f (diff) | |
| download | openwrt-ae198c6ba08542d7eaca41103ee86d6794039ffc.tar.gz | |
dnsmasq: fix start if dhcp-range is not correct
If the uci 'dhcp' configuration for the dhcp leases is incorrect then
the call to 'ipclac' fails. However, the problem is that the dnsmasq
configuration option 'dhcp-range' is still written for this uci section
even though the information generated by ipcalc is incorrect or not set.
Due to the incorrectly generated configuration for dnsmasq, the service
cannot start.
To prevent an incorrect configuration from being written to the configuration,
a check is now made beforehand to ensure that the required variables are
present and valid. If the configuration is incorrect, a message is emitted
to the log that this configuration section is incorrect and this uci
configuration section is omitted.
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
Link: https://github.com/openwrt/openwrt/pull/18641
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
| -rw-r--r-- | package/network/services/dnsmasq/Makefile | 2 | ||||
| -rwxr-xr-x | package/network/services/dnsmasq/files/dnsmasq.init | 18 |
2 files changed, 15 insertions, 5 deletions
diff --git a/package/network/services/dnsmasq/Makefile b/package/network/services/dnsmasq/Makefile index 5290f1e468..6b9853e5ff 100644 --- a/package/network/services/dnsmasq/Makefile +++ b/package/network/services/dnsmasq/Makefile @@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=dnsmasq PKG_UPSTREAM_VERSION:=2.91 PKG_VERSION:=$(subst test,~~test,$(subst rc,~rc,$(PKG_UPSTREAM_VERSION))) -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_UPSTREAM_VERSION).tar.xz PKG_SOURCE_URL:=https://thekelleys.org.uk/dnsmasq/ diff --git a/package/network/services/dnsmasq/files/dnsmasq.init b/package/network/services/dnsmasq/files/dnsmasq.init index 8258bcc3f4..a0a644fcbd 100755 --- a/package/network/services/dnsmasq/files/dnsmasq.init +++ b/package/network/services/dnsmasq/files/dnsmasq.init @@ -597,10 +597,20 @@ dhcp_add() { nettag="${networkid:+set:${networkid},}" # make sure the DHCP range is not empty - 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}" + if [ "$dhcpv4" != "disabled" ]; then + unset START + unset END + unset NETMASK + ipcalc "$ipaddr/$prefix_or_netmask" "$start" "$limit" + + if [ -z "$START" ] || [ -z "$END" ] || [ -z "$NETMASK" ]; then + logger -t dnsmasq \ + "unable to set dhcp-range for dhcp uci config section '$cfg'" \ + "on interface '$ifname', please check your config" + else + [ "$dynamicdhcpv4" = "0" ] && END="static" + xappend "--dhcp-range=$tags$nettag$START,$END,$NETMASK,$leasetime${options:+ $options}" + fi fi if [ "$dynamicdhcpv6" = "0" ] ; then |