[Dnsmasq-discuss] [PATCH] Solaris/illumos: IP_BOUND_IF left set on shared DHCP socket breaks multi-interface DHCP

ufuk ozkan uozkan64 at gmail.com
Sun Nov 8 21:43:53 UTC 2026


Hello,

On Solaris/illumos (HAVE_SOLARIS_NETWORK), a single dnsmasq instance
serving DHCP on more than one interface only answers DHCPDISCOVERs arriving
on the interface it last sent a reply on. Clients on every other interface
get no answer at all, and dnsmasq logs nothing for them.

Cause: dhcp_packet() in src/dhcp.c (2.93, around line 513) calls

setsockopt(fd, IPPROTO_IP, IP_BOUND_IF, &iface_index, sizeof(iface_index));

under #ifdef HAVE_SOLARIS_NETWORK on the shared, wildcard-bound DHCP socket
(UDP port 67) before sendmsg(), so that the reply leaves via the right
interface, but never clears it afterwards. On illumos, IP_BOUND_IF also
restricts reception: conn_wantpacket() rejects broadcast/multicast packets
that arrive on any other ifindex. Broadcast DISCOVERs from other interfaces
therefore never reach the socket. They are counted as udpNoPorts, and
recvmsg() is never called. Unicast renewals are not affected, so the
problem only shows up when a new client (or a client in INIT/REBOOT)
appears on a different interface.

Environment: SmartOS (illumos) zone acting as a router, pkgsrc dnsmasq
2.93, three interfaces (net1-3), each with its own dhcp-range,
bind-interfaces, interface=net1/net2/net3.

Evidence:
- DTrace on fbt::conn_wantpacket shows the port 67 conn with
conn_incoming_ifindex=3 (net1) rejecting a broadcast received on ifindex 4
(net2).
- The ipf "pass in" counter for bootpc->bootps on net2 and udpNoPorts
increase in lockstep, with no DHCPDISCOVER(net2) in the log.
- Restarting dnsmasq "fixes" it until the first reply goes out on some
interface.
- Resetting IP_BOUND_IF to 0 after sendmsg() fixes it (tested via an
LD_PRELOAD shim wrapping __xnet_sendmsg). Without restarting dnsmasq,
clients on net1 and then on net2 both get DHCPACK; DTrace shows
setsockopt(IP_BOUND_IF) 5 followed by 0. This has been running on two
routers since then.

Proposed patch against 2.93 is attached
(0001-solaris-reset-IP_BOUND_IF-after-dhcp-send.patch, applies with patch
-p1). Inline copy for review (mail clients may mangle whitespace, please
use the attachment):

--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -527,6 +527,17 @@
my_syslog(MS_DHCP | LOG_WARNING, _("Error sending DHCP packet to %s: %s"),
daemon->addrbuff, strerror(errno));
}
+
+#ifdef HAVE_SOLARIS_NETWORK
+ /* The DHCP socket is shared by all interfaces. Leaving IP_BOUND_IF set
+ makes the kernel deliver only broadcasts arriving on this interface
+ to the socket, so DHCPDISCOVERs on every other interface are dropped
+ (counted as udpNoPorts) until the next reply happens to go out there. */
+ {
+ int zero = 0;
+ setsockopt(fd, IPPROTO_IP, IP_BOUND_IF, &zero, sizeof(zero));
+ }
+#endif
}

/* check against secondary interface addresses */

Signed-off-by: Ufuk Özkan <uozkan64 at gmail.com>

Thanks for dnsmasq.

Ufuk Özkan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20261108/854c1e41/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-solaris-reset-IP_BOUND_IF-after-dhcp-send.patch
Type: text/x-patch
Size: 749 bytes
Desc: not available
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20261108/854c1e41/attachment.bin>


More information about the Dnsmasq-discuss mailing list