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:
Wouter Wijngaards 2009-06-12 07:53:36 +00:00
parent 16e920f416
commit 5ca6d8c50b
10 changed files with 67 additions and 8 deletions

View file

@ -1285,6 +1285,18 @@ void libworker_handle_control_cmd(struct tube* ATTR_UNUSED(tube),
log_assert(0); 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)) int context_query_cmp(const void* ATTR_UNUSED(a), const void* ATTR_UNUSED(b))
{ {
log_assert(0); log_assert(0);

View file

@ -1,5 +1,7 @@
12 June 2009: Wouter 12 June 2009: Wouter
- Fixup potential wrong NSEC picked out of the cache. - 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 11 June 2009: Wouter
- Fix queries for type DS when forward or stub zones are there. - Fix queries for type DS when forward or stub zones are there.

View file

@ -100,7 +100,6 @@ o infra and lame cache: easier size config (in Mb), show usage in graphs.
- winevent - poll if too many fds - winevent - poll if too many fds
- fwd above stub, make hole in fwds. config non-forwarded-domain names. - fwd above stub, make hole in fwds. config non-forwarded-domain names.
- fix indent # ifs - fix indent # ifs
- do not flush/delete callback queries or call error on callback at least.
later later
- selective verbosity; ubcontrol trace example.com - selective verbosity; ubcontrol trace example.com

View file

@ -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); libworker_enter_result(q->res, buf, q->w->env->scratch, s);
} }
/** callback with fg results */ void
static void
libworker_fg_done_cb(void* arg, int rcode, ldns_buffer* buf, enum sec_status s) libworker_fg_done_cb(void* arg, int rcode, ldns_buffer* buf, enum sec_status s)
{ {
struct ctx_query* q = (struct ctx_query*)arg; 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 */ void
static void
libworker_bg_done_cb(void* arg, int rcode, ldns_buffer* buf, enum sec_status s) libworker_bg_done_cb(void* arg, int rcode, ldns_buffer* buf, enum sec_status s)
{ {
struct ctx_query* q = (struct ctx_query*)arg; struct ctx_query* q = (struct ctx_query*)arg;

View file

@ -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, void libworker_handle_result_write(struct tube* tube, uint8_t* msg, size_t len,
int err, void* arg); 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 * fill result from parsed message, on error fills servfail
* @param res: is clear at start, filled in at end. * @param res: is clear at start, filled in at end.

View file

@ -465,9 +465,15 @@ mesh_state_cleanup(struct mesh_state* mstate)
/* drop unsent replies */ /* drop unsent replies */
if(!mstate->replies_sent) { if(!mstate->replies_sent) {
struct mesh_reply* rep; struct mesh_reply* rep;
struct mesh_cb* cb;
for(rep=mstate->reply_list; rep; rep=rep->next) { for(rep=mstate->reply_list; rep; rep=rep->next) {
comm_point_drop_reply(&rep->query_reply); 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 */ /* de-init modules */
@ -618,6 +624,7 @@ mesh_do_callback(struct mesh_state* m, int rcode, struct reply_info* rep,
rcode = LDNS_RCODE_SERVFAIL; rcode = LDNS_RCODE_SERVFAIL;
/* send the reply */ /* send the reply */
if(rcode) { if(rcode) {
fptr_ok(fptr_whitelist_mesh_cb(r->cb));
(*r->cb)(r->cb_arg, rcode, r->buf, sec_status_unchecked); (*r->cb)(r->cb_arg, rcode, r->buf, sec_status_unchecked);
} else { } else {
size_t udp_size = r->edns.udp_size; size_t udp_size = r->edns.udp_size;
@ -631,12 +638,15 @@ mesh_do_callback(struct mesh_state* m, int rcode, struct reply_info* rep,
m->s.env->scratch, udp_size, &r->edns, m->s.env->scratch, udp_size, &r->edns,
(int)(r->edns.bits & EDNS_DO), secure)) (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, (*r->cb)(r->cb_arg, LDNS_RCODE_SERVFAIL, r->buf,
sec_status_unchecked); sec_status_unchecked);
} } else {
else (*r->cb)(r->cb_arg, LDNS_RCODE_NOERROR, r->buf, fptr_ok(fptr_whitelist_mesh_cb(r->cb));
(*r->cb)(r->cb_arg, LDNS_RCODE_NOERROR, r->buf,
rep->security); rep->security);
} }
}
m->s.env->mesh->num_reply_addrs--; 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) if(!r)
return 0; return 0;
r->buf = buf; r->buf = buf;
log_assert(fptr_whitelist_mesh_cb(r->cb)); /* early failure ifmissing*/
r->cb = cb; r->cb = cb;
r->cb_arg = cb_arg; r->cb_arg = cb_arg;
r->edns = *edns; r->edns = *edns;

View file

@ -226,7 +226,7 @@ struct mesh_cb {
ldns_buffer* buf; ldns_buffer* buf;
/** callback routine for results. if rcode != 0 buf has message. /** 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; mesh_cb_func_t cb;
/** user arg for callback */ /** user arg for callback */

View file

@ -42,6 +42,7 @@
*/ */
#include "config.h" #include "config.h"
#include "util/log.h" #include "util/log.h"
#include "services/mesh.h"
struct comm_reply; struct comm_reply;
struct comm_point; struct comm_point;
struct module_qstate; struct module_qstate;
@ -180,6 +181,18 @@ void libworker_handle_control_cmd(struct tube* ATTR_UNUSED(tube),
log_assert(0); 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)) int context_query_cmp(const void* ATTR_UNUSED(a), const void* ATTR_UNUSED(b))
{ {
log_assert(0); log_assert(0);

View file

@ -376,3 +376,10 @@ int fptr_whitelist_tube_listen(tube_callback_t* fptr)
else if(fptr == &libworker_handle_control_cmd) return 1; else if(fptr == &libworker_handle_control_cmd) return 1;
return 0; 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;
}

View file

@ -58,6 +58,7 @@
#include "util/storage/lruhash.h" #include "util/storage/lruhash.h"
#include "util/module.h" #include "util/module.h"
#include "util/tube.h" #include "util/tube.h"
#include "services/mesh.h"
/** /**
* Macro to perform an assertion check for fptr wlist checks. * 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); 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 /** Due to module breakage by fptr wlist, these test app declarations
* are presented here */ * are presented here */
/** /**