<html><body><div dir="auto">Hello,<br><br>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.<br><br>Cause: dhcp_packet() in src/dhcp.c (2.93, around line 513) calls<br><br>    setsockopt(fd, IPPROTO_IP, IP_BOUND_IF, &iface_index, sizeof(iface_index));<br><br>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.<br><br>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.<br><br>Evidence:<br>- DTrace on fbt::conn_wantpacket shows the port 67 conn with conn_incoming_ifindex=3 (net1) rejecting a broadcast received on ifindex 4 (net2).<br>- The ipf "pass in" counter for bootpc->bootps on net2 and udpNoPorts increase in lockstep, with no DHCPDISCOVER(net2) in the log.<br>- Restarting dnsmasq "fixes" it until the first reply goes out on some interface.<br>- 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.<br><br>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):<br><br>--- a/src/dhcp.c<br>+++ b/src/dhcp.c<br>@@ -527,6 +527,17 @@<br>       my_syslog(MS_DHCP | LOG_WARNING, _("Error sending DHCP packet to %s: %s"),<br>            daemon->addrbuff, strerror(errno));<br>     }<br>+<br>+#ifdef HAVE_SOLARIS_NETWORK<br>+  /* The DHCP socket is shared by all interfaces. Leaving IP_BOUND_IF set<br>+     makes the kernel deliver only broadcasts arriving on this interface<br>+     to the socket, so DHCPDISCOVERs on every other interface are dropped<br>+     (counted as udpNoPorts) until the next reply happens to go out there. */<br>+  {<br>+    int zero = 0;<br>+    setsockopt(fd, IPPROTO_IP, IP_BOUND_IF, &zero, sizeof(zero));<br>+  }<br>+#endif<br> }<br> <br> /* check against secondary interface addresses */<br><br>Signed-off-by: Ufuk Özkan <<a href="mailto:uozkan64@gmail.com">uozkan64@gmail.com</a>><br><br>Thanks for dnsmasq.<br><br>Ufuk Özkan</div></body></html>