When running rebound without network, the behavior isn't quite the same
because it will receive the query, but then "loses" it trying to forward. This
leads to long timeout delays when a machine might otherwise fail fast.

Proposed solution: send back an empty reply. This counts as a failure and
pushes the libc resolver state forward so it returns quickly. i don't want to
send back nxdomain or some other response that may be interpreted incorrectly.

Index: rebound.c
===================================================================
RCS file: /cvs/src/usr.sbin/rebound/rebound.c,v
retrieving revision 1.46
diff -u -p -r1.46 rebound.c
--- rebound.c   27 Nov 2015 21:12:08 -0000      1.46
+++ rebound.c   2 Dec 2015 10:40:00 -0000
@@ -209,6 +209,16 @@ reqcmp(struct request *r1, struct reques
 }
 RB_GENERATE_STATIC(reqtree, request, reqnode, reqcmp)
 
+static void
+fakereply(int ud, uint16_t id, struct sockaddr *fromaddr, socklen_t fromlen)
+{
+       struct dnspacket pkt;
+
+       memset(&pkt, 0, sizeof(pkt));
+       pkt.id = id;
+       sendto(ud, &pkt, sizeof(pkt), 0, fromaddr, fromlen);
+}
+
 static struct request *
 newrequest(int ud, struct sockaddr *remoteaddr)
 {
@@ -274,6 +284,8 @@ newrequest(int ud, struct sockaddr *remo
 
        if (connect(req->s, remoteaddr, remoteaddr->sa_len) == -1) {
                logmsg(LOG_NOTICE, "failed to connect (%d)", errno);
+               if (errno == EADDRNOTAVAIL)
+                       fakereply(ud, req->clientid, &from, fromlen);
                goto fail;
        }
        if (send(req->s, buf, r, 0) != r) {

Reply via email to