--leasequery can now take a subnet argument.
authorSimon Kelley <simon@thekelleys.org.uk>
Wed, 30 Apr 2025 10:44:47 +0000 (11:44 +0100)
committerSimon Kelley <simon@thekelleys.org.uk>
Wed, 14 May 2025 21:36:03 +0000 (22:36 +0100)
man/dnsmasq.8
src/option.c
src/rfc2131.c

index 1043ace..10215f8 100644 (file)
@@ -1438,10 +1438,11 @@ DHCP options. This make extra space available in the DHCP packet for
 options but can, rarely, confuse old or broken clients. This flag
 forces "simple and safe" behaviour to avoid problems in such a case.
 .TP
-.B --leasequery[=<addr>]
+.B --leasequery[=<addr>[/<prefix>]]
 Enable RFC 4388 leasequery. The dnsmasq DHCP server will answer LEASEQUERY messages from DHCP relays
-when this option is given. If an address is given, only queries from a relay at that address are allowed. Repeat
-the --leasequery option to specify multiple addresses. To correctly answer lease queries it is necessary to store extra data in
+when this option is given. If an address or subnet is given, only queries from a relay at that source are allowed. Repeat
+the --leasequery option to specify multiple allowed sources.
+To correctly answer lease queries it is necessary to store extra data in
 the lease database, and this is also enabled by the \fB--leasequery\fP option. The extra fields
 (agent-info and vendorclass) are stored in the leases file in a somewhat backwards compatible manner.
 Enabling and then disabling leasequery will not cause problems; the extra information will be aged
index 5b68632..28c50d2 100644 (file)
@@ -501,7 +501,7 @@ static struct {
   { '4', ARG_DUP, "set:<tag>,<mac address>", gettext_noop("Map MAC address (with wildcards) to option set."), NULL },
   { LOPT_BRIDGE, ARG_DUP, "<iface>,<alias>..", gettext_noop("Treat DHCP requests on aliases as arriving from interface."), NULL },
   { LOPT_SHARED_NET, ARG_DUP, "<iface>|<addr>,<addr>", gettext_noop("Specify extra networks sharing a broadcast domain for DHCP"), NULL},
-  { LOPT_LEASEQUERY, ARG_DUP, "[<addr>]", gettext_noop("Enable RFC 4388 leasequery functions for DHCPv4"), NULL },
+  { LOPT_LEASEQUERY, ARG_DUP, "[<addr>[/prefix>]]", gettext_noop("Enable RFC 4388 leasequery functions for DHCPv4"), NULL },
   { '5', OPT_NO_PING, NULL, gettext_noop("Disable ICMP echo address checking in the DHCP server."), NULL },
   { '6', ARG_ONE, "<path>", gettext_noop("Shell script to run on DHCP lease creation and destruction."), NULL },
   { LOPT_LUASCRIPT, ARG_DUP, "path", gettext_noop("Lua script to run on DHCP lease creation and destruction."), NULL },
index b45ffcf..c736fef 100644 (file)
@@ -1069,7 +1069,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
          struct bogus_addr *baddrp;
 
          for (baddrp = daemon->leasequery_addr; baddrp; baddrp = baddrp->next)
-           if (!baddrp->is6 && baddrp->addr.addr4.s_addr == leasequery_source.s_addr)
+           if (!baddrp->is6 && is_same_net_prefix(leasequery_source, baddrp->addr.addr4, baddrp->prefix))
              break;
          
          if (!baddrp)