mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-20 23:00:56 -05:00
Answers use same case as query does.
git-svn-id: file:///svn/unbound/trunk@993 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
c00d1e02cd
commit
39b2a21a81
5 changed files with 24 additions and 18 deletions
|
|
@ -505,11 +505,10 @@ all_rrsets_secure(struct reply_info* rep) {
|
||||||
|
|
||||||
/** answer query from the cache */
|
/** answer query from the cache */
|
||||||
static int
|
static int
|
||||||
answer_from_cache(struct worker* worker, struct lruhash_entry* e, uint16_t id,
|
answer_from_cache(struct worker* worker, struct query_info* qinfo,
|
||||||
uint16_t flags, struct comm_reply* repinfo, struct edns_data* edns)
|
struct reply_info* rep, uint16_t id, uint16_t flags,
|
||||||
|
struct comm_reply* repinfo, struct edns_data* edns)
|
||||||
{
|
{
|
||||||
struct msgreply_entry* mrentry = (struct msgreply_entry*)e->key;
|
|
||||||
struct reply_info* rep = (struct reply_info*)e->data;
|
|
||||||
uint32_t timenow = *worker->env.now;
|
uint32_t timenow = *worker->env.now;
|
||||||
uint16_t udpsize = edns->udp_size;
|
uint16_t udpsize = edns->udp_size;
|
||||||
int secure;
|
int secure;
|
||||||
|
|
@ -547,7 +546,7 @@ answer_from_cache(struct worker* worker, struct lruhash_entry* e, uint16_t id,
|
||||||
edns->ext_rcode = 0;
|
edns->ext_rcode = 0;
|
||||||
edns->bits &= EDNS_DO;
|
edns->bits &= EDNS_DO;
|
||||||
error_encode(repinfo->c->buffer, LDNS_RCODE_SERVFAIL,
|
error_encode(repinfo->c->buffer, LDNS_RCODE_SERVFAIL,
|
||||||
&mrentry->key, id, flags, edns);
|
qinfo, id, flags, edns);
|
||||||
rrset_array_unlock_touch(worker->env.rrset_cache,
|
rrset_array_unlock_touch(worker->env.rrset_cache,
|
||||||
worker->scratchpad, rep->ref, rep->rrset_count);
|
worker->scratchpad, rep->ref, rep->rrset_count);
|
||||||
regional_free_all(worker->scratchpad);
|
regional_free_all(worker->scratchpad);
|
||||||
|
|
@ -573,11 +572,11 @@ answer_from_cache(struct worker* worker, struct lruhash_entry* e, uint16_t id,
|
||||||
edns->udp_size = EDNS_ADVERTISED_SIZE;
|
edns->udp_size = EDNS_ADVERTISED_SIZE;
|
||||||
edns->ext_rcode = 0;
|
edns->ext_rcode = 0;
|
||||||
edns->bits &= EDNS_DO;
|
edns->bits &= EDNS_DO;
|
||||||
if(!reply_info_answer_encode(&mrentry->key, rep, id, flags,
|
if(!reply_info_answer_encode(qinfo, rep, id, flags,
|
||||||
repinfo->c->buffer, timenow, 1, worker->scratchpad,
|
repinfo->c->buffer, timenow, 1, worker->scratchpad,
|
||||||
udpsize, edns, (int)(edns->bits & EDNS_DO), secure)) {
|
udpsize, edns, (int)(edns->bits & EDNS_DO), secure)) {
|
||||||
error_encode(repinfo->c->buffer, LDNS_RCODE_SERVFAIL,
|
error_encode(repinfo->c->buffer, LDNS_RCODE_SERVFAIL,
|
||||||
&mrentry->key, id, flags, edns);
|
qinfo, id, flags, edns);
|
||||||
}
|
}
|
||||||
/* cannot send the reply right now, because blocking network syscall
|
/* cannot send the reply right now, because blocking network syscall
|
||||||
* is bad while holding locks. */
|
* is bad while holding locks. */
|
||||||
|
|
@ -787,7 +786,8 @@ worker_handle_request(struct comm_point* c, void* arg, int error,
|
||||||
h = query_info_hash(&qinfo);
|
h = query_info_hash(&qinfo);
|
||||||
if((e=slabhash_lookup(worker->env.msg_cache, h, &qinfo, 0))) {
|
if((e=slabhash_lookup(worker->env.msg_cache, h, &qinfo, 0))) {
|
||||||
/* answer from cache - we have acquired a readlock on it */
|
/* answer from cache - we have acquired a readlock on it */
|
||||||
if(answer_from_cache(worker, e,
|
if(answer_from_cache(worker, &qinfo,
|
||||||
|
(struct reply_info*)e->data,
|
||||||
*(uint16_t*)ldns_buffer_begin(c->buffer),
|
*(uint16_t*)ldns_buffer_begin(c->buffer),
|
||||||
ldns_buffer_read_u16_at(c->buffer, 2), repinfo,
|
ldns_buffer_read_u16_at(c->buffer, 2), repinfo,
|
||||||
&edns)) {
|
&edns)) {
|
||||||
|
|
@ -817,8 +817,7 @@ worker_handle_request(struct comm_point* c, void* arg, int error,
|
||||||
worker->stats.num_query_list_exceeded++;
|
worker->stats.num_query_list_exceeded++;
|
||||||
comm_point_drop_reply(repinfo);
|
comm_point_drop_reply(repinfo);
|
||||||
return 0;
|
return 0;
|
||||||
} else if(worker->env.mesh->num_reply_addrs >
|
} else if(worker->env.mesh->num_reply_addrs>worker->request_size*16) {
|
||||||
worker->request_size*256) {
|
|
||||||
verbose(VERB_ALGO, "Too many requests queued. "
|
verbose(VERB_ALGO, "Too many requests queued. "
|
||||||
"dropping incoming query.");
|
"dropping incoming query.");
|
||||||
worker->stats.num_query_list_exceeded++;
|
worker->stats.num_query_list_exceeded++;
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
- delay utility delays TCP as well. If the server that is forwarded
|
- delay utility delays TCP as well. If the server that is forwarded
|
||||||
to has a TCP error, the delay utility closes the connection.
|
to has a TCP error, the delay utility closes the connection.
|
||||||
- delay does REUSE_ADDR, and can handle a server that closes its end.
|
- delay does REUSE_ADDR, and can handle a server that closes its end.
|
||||||
|
- answers use casing from query.
|
||||||
|
|
||||||
25 February 2008: Wouter
|
25 February 2008: Wouter
|
||||||
- delay utility works. Gets decent thoughput too (>20000).
|
- delay utility works. Gets decent thoughput too (>20000).
|
||||||
|
|
|
||||||
|
|
@ -1566,11 +1566,6 @@ processFinished(struct module_qstate* qstate, struct iter_qstate* iq,
|
||||||
LDNS_RCODE_SERVFAIL);
|
LDNS_RCODE_SERVFAIL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(query_dname_compare(qstate->qinfo.qname,
|
|
||||||
iq->response->qinfo.qname) == 0) {
|
|
||||||
/* use server supplied upper/lower case */
|
|
||||||
qstate->qinfo.qname = iq->response->qinfo.qname;
|
|
||||||
}
|
|
||||||
qstate->return_rcode = LDNS_RCODE_NOERROR;
|
qstate->return_rcode = LDNS_RCODE_NOERROR;
|
||||||
qstate->return_msg = iq->response;
|
qstate->return_msg = iq->response;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,7 @@ void mesh_new_client(struct mesh_area* mesh, struct query_info* qinfo,
|
||||||
if(!s->reply_list && !s->cb_list)
|
if(!s->reply_list && !s->cb_list)
|
||||||
was_noreply = 1;
|
was_noreply = 1;
|
||||||
/* add reply to s */
|
/* add reply to s */
|
||||||
if(!mesh_state_add_reply(s, edns, rep, qid, qflags)) {
|
if(!mesh_state_add_reply(s, edns, rep, qid, qflags, qinfo->qname)) {
|
||||||
log_err("mesh_new_client: out of memory; SERVFAIL");
|
log_err("mesh_new_client: out of memory; SERVFAIL");
|
||||||
error_encode(rep->c->buffer, LDNS_RCODE_SERVFAIL,
|
error_encode(rep->c->buffer, LDNS_RCODE_SERVFAIL,
|
||||||
qinfo, qid, qflags, edns);
|
qinfo, qid, qflags, edns);
|
||||||
|
|
@ -540,8 +540,11 @@ mesh_send_reply(struct mesh_state* m, int rcode, struct reply_info* rep,
|
||||||
prev->query_reply.c->buffer);
|
prev->query_reply.c->buffer);
|
||||||
ldns_buffer_write_at(r->query_reply.c->buffer, 0,
|
ldns_buffer_write_at(r->query_reply.c->buffer, 0,
|
||||||
&r->qid, sizeof(uint16_t));
|
&r->qid, sizeof(uint16_t));
|
||||||
|
ldns_buffer_write_at(r->query_reply.c->buffer, 12,
|
||||||
|
r->qname, m->s.qinfo.qname_len);
|
||||||
comm_point_send_reply(&r->query_reply);
|
comm_point_send_reply(&r->query_reply);
|
||||||
} else if(rcode) {
|
} else if(rcode) {
|
||||||
|
m->s.qinfo.qname = r->qname;
|
||||||
error_encode(r->query_reply.c->buffer, rcode, &m->s.qinfo,
|
error_encode(r->query_reply.c->buffer, rcode, &m->s.qinfo,
|
||||||
r->qid, r->qflags, &r->edns);
|
r->qid, r->qflags, &r->edns);
|
||||||
comm_point_send_reply(&r->query_reply);
|
comm_point_send_reply(&r->query_reply);
|
||||||
|
|
@ -551,6 +554,7 @@ mesh_send_reply(struct mesh_state* m, int rcode, struct reply_info* rep,
|
||||||
r->edns.udp_size = EDNS_ADVERTISED_SIZE;
|
r->edns.udp_size = EDNS_ADVERTISED_SIZE;
|
||||||
r->edns.ext_rcode = 0;
|
r->edns.ext_rcode = 0;
|
||||||
r->edns.bits &= EDNS_DO;
|
r->edns.bits &= EDNS_DO;
|
||||||
|
m->s.qinfo.qname = r->qname;
|
||||||
if(!reply_info_answer_encode(&m->s.qinfo, rep, r->qid,
|
if(!reply_info_answer_encode(&m->s.qinfo, rep, r->qid,
|
||||||
r->qflags, r->query_reply.c->buffer, 0, 1,
|
r->qflags, r->query_reply.c->buffer, 0, 1,
|
||||||
m->s.env->scratch, udp_size, &r->edns,
|
m->s.env->scratch, udp_size, &r->edns,
|
||||||
|
|
@ -640,7 +644,7 @@ int mesh_state_add_cb(struct mesh_state* s, struct edns_data* edns,
|
||||||
}
|
}
|
||||||
|
|
||||||
int mesh_state_add_reply(struct mesh_state* s, struct edns_data* edns,
|
int mesh_state_add_reply(struct mesh_state* s, struct edns_data* edns,
|
||||||
struct comm_reply* rep, uint16_t qid, uint16_t qflags)
|
struct comm_reply* rep, uint16_t qid, uint16_t qflags, uint8_t* qname)
|
||||||
{
|
{
|
||||||
struct mesh_reply* r = regional_alloc(s->s.region,
|
struct mesh_reply* r = regional_alloc(s->s.region,
|
||||||
sizeof(struct mesh_reply));
|
sizeof(struct mesh_reply));
|
||||||
|
|
@ -652,6 +656,10 @@ int mesh_state_add_reply(struct mesh_state* s, struct edns_data* edns,
|
||||||
r->qflags = qflags;
|
r->qflags = qflags;
|
||||||
r->start_time = *s->s.env->now_tv;
|
r->start_time = *s->s.env->now_tv;
|
||||||
r->next = s->reply_list;
|
r->next = s->reply_list;
|
||||||
|
r->qname = regional_alloc_init(s->s.region, qname,
|
||||||
|
s->s.qinfo.qname_len);
|
||||||
|
if(!r->qname)
|
||||||
|
return 0;
|
||||||
s->reply_list = r;
|
s->reply_list = r;
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,8 @@ struct mesh_reply {
|
||||||
uint16_t qid;
|
uint16_t qid;
|
||||||
/** flags of query, for reply flags */
|
/** flags of query, for reply flags */
|
||||||
uint16_t qflags;
|
uint16_t qflags;
|
||||||
|
/** qname from this query. len same as mesh qinfo. */
|
||||||
|
uint8_t* qname;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -375,10 +377,11 @@ int mesh_state_attachment(struct mesh_state* super, struct mesh_state* sub);
|
||||||
* @param rep: comm point reply info.
|
* @param rep: comm point reply info.
|
||||||
* @param qid: ID of reply.
|
* @param qid: ID of reply.
|
||||||
* @param qflags: original query flags.
|
* @param qflags: original query flags.
|
||||||
|
* @param qname: original query name.
|
||||||
* @return: 0 on alloc error.
|
* @return: 0 on alloc error.
|
||||||
*/
|
*/
|
||||||
int mesh_state_add_reply(struct mesh_state* s, struct edns_data* edns,
|
int mesh_state_add_reply(struct mesh_state* s, struct edns_data* edns,
|
||||||
struct comm_reply* rep, uint16_t qid, uint16_t qflags);
|
struct comm_reply* rep, uint16_t qid, uint16_t qflags, uint8_t* qname);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new callback structure and attach it to a mesh state.
|
* Create new callback structure and attach it to a mesh state.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue