From 5c5eb4e6d20fbf9883bc7426842902f175f28cfa Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Thu, 3 Dec 2015 08:19:26 +0000 Subject: when running on a machine without net, rebound will still receive queries from localhost, but then fail to forward them. this causes the resolver to stall waiting for timeouts in situations where it would otherwise fail quickly. we don't know this happens until it's too late, but we can push the resolver forward by sending back empty replies. ok deraadt --- usr.sbin/rebound/rebound.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/usr.sbin/rebound/rebound.c b/usr.sbin/rebound/rebound.c index bc53e08d1a5..f887d3d8975 100644 --- a/usr.sbin/rebound/rebound.c +++ b/usr.sbin/rebound/rebound.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rebound.c,v 1.47 2015/12/01 23:43:55 gsoares Exp $ */ +/* $OpenBSD: rebound.c,v 1.48 2015/12/03 08:19:25 tedu Exp $ */ /* * Copyright (c) 2015 Ted Unangst * @@ -209,6 +209,16 @@ reqcmp(struct request *r1, struct request *r2) } 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 *remoteaddr) 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) { -- cgit v1.2.3