mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-20 23:00:56 -05:00
mesh callbacks review, call error if deleted unfulfilled, check fptr wlist.
git-svn-id: file:///svn/unbound/trunk@1652 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
16e920f416
commit
5ca6d8c50b
10 changed files with 67 additions and 8 deletions
|
|
@ -1285,6 +1285,18 @@ void libworker_handle_control_cmd(struct tube* ATTR_UNUSED(tube),
|
|||
log_assert(0);
|
||||
}
|
||||
|
||||
void libworker_fg_done_cb(void* ATTR_UNUSED(arg), int ATTR_UNUSED(rcode),
|
||||
ldns_buffer* ATTR_UNUSED(buf), enum sec_status ATTR_UNUSED(s))
|
||||
{
|
||||
log_assert(0);
|
||||
}
|
||||
|
||||
void libworker_bg_done_cb(void* ATTR_UNUSED(arg), int ATTR_UNUSED(rcode),
|
||||
ldns_buffer* ATTR_UNUSED(buf), enum sec_status ATTR_UNUSED(s))
|
||||
{
|
||||
log_assert(0);
|
||||
}
|
||||
|
||||
int context_query_cmp(const void* ATTR_UNUSED(a), const void* ATTR_UNUSED(b))
|
||||
{
|
||||
log_assert(0);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
12 June 2009: Wouter
|
||||
- Fixup potential wrong NSEC picked out of the cache.
|
||||
- If unfulfilled callbacks are deleted they are called with an error.
|
||||
- fptr wlist checks for mesh callbacks.
|
||||
|
||||
11 June 2009: Wouter
|
||||
- Fix queries for type DS when forward or stub zones are there.
|
||||
|
|
|
|||
1
doc/TODO
1
doc/TODO
|
|
@ -100,7 +100,6 @@ o infra and lame cache: easier size config (in Mb), show usage in graphs.
|
|||
- winevent - poll if too many fds
|
||||
- fwd above stub, make hole in fwds. config non-forwarded-domain names.
|
||||
- fix indent # ifs
|
||||
- do not flush/delete callback queries or call error on callback at least.
|
||||
|
||||
later
|
||||
- selective verbosity; ubcontrol trace example.com
|
||||
|
|
|
|||
|
|
@ -458,8 +458,7 @@ libworker_fillup_fg(struct ctx_query* q, int rcode, ldns_buffer* buf,
|
|||
libworker_enter_result(q->res, buf, q->w->env->scratch, s);
|
||||
}
|
||||
|
||||
/** callback with fg results */
|
||||
static void
|
||||
void
|
||||
libworker_fg_done_cb(void* arg, int rcode, ldns_buffer* buf, enum sec_status s)
|
||||
{
|
||||
struct ctx_query* q = (struct ctx_query*)arg;
|
||||
|
|
@ -574,8 +573,7 @@ add_bg_result(struct libworker* w, struct ctx_query* q, ldns_buffer* pkt,
|
|||
}
|
||||
}
|
||||
|
||||
/** callback with bg results */
|
||||
static void
|
||||
void
|
||||
libworker_bg_done_cb(void* arg, int rcode, ldns_buffer* buf, enum sec_status s)
|
||||
{
|
||||
struct ctx_query* q = (struct ctx_query*)arg;
|
||||
|
|
|
|||
|
|
@ -156,6 +156,14 @@ void libworker_handle_control_cmd(struct tube* tube, uint8_t* msg, size_t len,
|
|||
void libworker_handle_result_write(struct tube* tube, uint8_t* msg, size_t len,
|
||||
int err, void* arg);
|
||||
|
||||
/** mesh callback with fg results */
|
||||
void libworker_fg_done_cb(void* arg, int rcode, ldns_buffer* buf,
|
||||
enum sec_status s);
|
||||
|
||||
/** mesh callback with bg results */
|
||||
void libworker_bg_done_cb(void* arg, int rcode, ldns_buffer* buf,
|
||||
enum sec_status s);
|
||||
|
||||
/**
|
||||
* fill result from parsed message, on error fills servfail
|
||||
* @param res: is clear at start, filled in at end.
|
||||
|
|
|
|||
|
|
@ -465,9 +465,15 @@ mesh_state_cleanup(struct mesh_state* mstate)
|
|||
/* drop unsent replies */
|
||||
if(!mstate->replies_sent) {
|
||||
struct mesh_reply* rep;
|
||||
struct mesh_cb* cb;
|
||||
for(rep=mstate->reply_list; rep; rep=rep->next) {
|
||||
comm_point_drop_reply(&rep->query_reply);
|
||||
}
|
||||
for(cb=mstate->cb_list; cb; cb=cb->next) {
|
||||
fptr_ok(fptr_whitelist_mesh_cb(cb->cb));
|
||||
(*cb->cb)(cb->cb_arg, LDNS_RCODE_SERVFAIL, NULL,
|
||||
sec_status_unchecked);
|
||||
}
|
||||
}
|
||||
|
||||
/* de-init modules */
|
||||
|
|
@ -618,6 +624,7 @@ mesh_do_callback(struct mesh_state* m, int rcode, struct reply_info* rep,
|
|||
rcode = LDNS_RCODE_SERVFAIL;
|
||||
/* send the reply */
|
||||
if(rcode) {
|
||||
fptr_ok(fptr_whitelist_mesh_cb(r->cb));
|
||||
(*r->cb)(r->cb_arg, rcode, r->buf, sec_status_unchecked);
|
||||
} else {
|
||||
size_t udp_size = r->edns.udp_size;
|
||||
|
|
@ -631,11 +638,14 @@ mesh_do_callback(struct mesh_state* m, int rcode, struct reply_info* rep,
|
|||
m->s.env->scratch, udp_size, &r->edns,
|
||||
(int)(r->edns.bits & EDNS_DO), secure))
|
||||
{
|
||||
fptr_ok(fptr_whitelist_mesh_cb(r->cb));
|
||||
(*r->cb)(r->cb_arg, LDNS_RCODE_SERVFAIL, r->buf,
|
||||
sec_status_unchecked);
|
||||
}
|
||||
else (*r->cb)(r->cb_arg, LDNS_RCODE_NOERROR, r->buf,
|
||||
} else {
|
||||
fptr_ok(fptr_whitelist_mesh_cb(r->cb));
|
||||
(*r->cb)(r->cb_arg, LDNS_RCODE_NOERROR, r->buf,
|
||||
rep->security);
|
||||
}
|
||||
}
|
||||
m->s.env->mesh->num_reply_addrs--;
|
||||
}
|
||||
|
|
@ -780,6 +790,7 @@ int mesh_state_add_cb(struct mesh_state* s, struct edns_data* edns,
|
|||
if(!r)
|
||||
return 0;
|
||||
r->buf = buf;
|
||||
log_assert(fptr_whitelist_mesh_cb(r->cb)); /* early failure ifmissing*/
|
||||
r->cb = cb;
|
||||
r->cb_arg = cb_arg;
|
||||
r->edns = *edns;
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ struct mesh_cb {
|
|||
ldns_buffer* buf;
|
||||
|
||||
/** callback routine for results. if rcode != 0 buf has message.
|
||||
* called as cb(cb_arg, rcode, buf);
|
||||
* called as cb(cb_arg, rcode, buf, sec_state);
|
||||
*/
|
||||
mesh_cb_func_t cb;
|
||||
/** user arg for callback */
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
*/
|
||||
#include "config.h"
|
||||
#include "util/log.h"
|
||||
#include "services/mesh.h"
|
||||
struct comm_reply;
|
||||
struct comm_point;
|
||||
struct module_qstate;
|
||||
|
|
@ -180,6 +181,18 @@ void libworker_handle_control_cmd(struct tube* ATTR_UNUSED(tube),
|
|||
log_assert(0);
|
||||
}
|
||||
|
||||
void libworker_fg_done_cb(void* ATTR_UNUSED(arg), int ATTR_UNUSED(rcode),
|
||||
ldns_buffer* ATTR_UNUSED(buf), enum sec_status ATTR_UNUSED(s))
|
||||
{
|
||||
log_assert(0);
|
||||
}
|
||||
|
||||
void libworker_bg_done_cb(void* ATTR_UNUSED(arg), int ATTR_UNUSED(rcode),
|
||||
ldns_buffer* ATTR_UNUSED(buf), enum sec_status ATTR_UNUSED(s))
|
||||
{
|
||||
log_assert(0);
|
||||
}
|
||||
|
||||
int context_query_cmp(const void* ATTR_UNUSED(a), const void* ATTR_UNUSED(b))
|
||||
{
|
||||
log_assert(0);
|
||||
|
|
|
|||
|
|
@ -376,3 +376,10 @@ int fptr_whitelist_tube_listen(tube_callback_t* fptr)
|
|||
else if(fptr == &libworker_handle_control_cmd) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fptr_whitelist_mesh_cb(mesh_cb_func_t fptr)
|
||||
{
|
||||
if(fptr == &libworker_fg_done_cb) return 1;
|
||||
else if(fptr == &libworker_bg_done_cb) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@
|
|||
#include "util/storage/lruhash.h"
|
||||
#include "util/module.h"
|
||||
#include "util/tube.h"
|
||||
#include "services/mesh.h"
|
||||
|
||||
/**
|
||||
* Macro to perform an assertion check for fptr wlist checks.
|
||||
|
|
@ -307,6 +308,14 @@ int fptr_whitelist_alloc_cleanup(void (*fptr)(void*));
|
|||
*/
|
||||
int fptr_whitelist_tube_listen(tube_callback_t* fptr);
|
||||
|
||||
/**
|
||||
* Check function pointer whitelist for mesh state callback values.
|
||||
*
|
||||
* @param fptr: function pointer to check.
|
||||
* @return false if not in whitelist.
|
||||
*/
|
||||
int fptr_whitelist_mesh_cb(mesh_cb_func_t fptr);
|
||||
|
||||
/** Due to module breakage by fptr wlist, these test app declarations
|
||||
* are presented here */
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue