diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2015-12-03 08:19:26 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2015-12-03 08:19:26 +0000 |
commit | 5c5eb4e6d20fbf9883bc7426842902f175f28cfa (patch) | |
tree | 33e48300f10e9b3622821389bca36055be26974f | |
parent | 729f83c201837353523ea072e047af3d3d1e6b31 (diff) |
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
-rw-r--r-- | usr.sbin/rebound/rebound.c | 14 |
1 files changed, 13 insertions, 1 deletions
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 <tedu@openbsd.org> * @@ -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) { |