Commit 7569b4b6 authored by Marek Vavrusa's avatar Marek Vavrusa

Use QNAME for transfer logging & minor updates.

QD=1 is now checked for each query instead of allowing empty questions.
parent b64fd3ad
......@@ -898,15 +898,15 @@ int zones_update_db_from_config(const conf_t *conf, knot_nameserver_t *ns,
dbg_zones_detail("zones: old db in nameserver: %p, old db stored: %p, "
"new db: %p\n", ns->zone_db, *db_old, db_new);
/* Rebuild zone database search stack. */
knot_zonedb_build_index(db_new);
/* Switch the databases. */
UNUSED(rcu_xchg_pointer(&ns->zone_db, db_new));
dbg_zones_detail("db in nameserver: %p, old db stored: %p, new db: %p\n",
ns->zone_db, *db_old, db_new);
/* Rebuild zone database search stack. */
knot_zonedb_build_index(db_new);
/*
* Remove all zones present in the new DB from the old DB.
* No new thread can access these zones in the old DB, as the
......
......@@ -189,11 +189,16 @@ static void ixfr_answer_cleanup(struct query_data *qdata)
static int ixfr_answer_init(struct query_data *qdata)
{
/* Check query. */
/* Check IXFR query validity. */
int state = ixfr_query_check(qdata);
if (state == NS_PROC_FAIL) {
return KNOT_EMALF; /* Malformed query. */
if (qdata->rcode == KNOT_RCODE_FORMERR) {
return KNOT_EMALF;
} else {
return KNOT_EDENIED;
}
}
/* Compare serials. */
const knot_rrset_t *their_soa = knot_pkt_section(qdata->query, KNOT_AUTHORITY)->rr[0];
knot_changesets_t *chgsets = NULL;
......
......@@ -103,8 +103,8 @@ int ns_proc_query_in(knot_pkt_t *pkt, ns_proc_context_t *ctx)
return NS_PROC_NOOP; /* Ignore. */
}
/* Accept only queries. */
if (knot_wire_get_qr(pkt->wire)) {
/* Accept only queries with QD=1. */
if (knot_wire_get_qr(pkt->wire) || knot_wire_get_qdcount(pkt->wire) != 1) {
knot_pkt_free(&pkt);
return NS_PROC_NOOP; /* Ignore. */
}
......
......@@ -38,12 +38,13 @@ extern const ns_proc_module_t _ns_proc_query;
/*! \brief Query processing logging common base. */
#define NS_PROC_LOG(severity, qdata, what, msg, ...) do { \
sockaddr_t *addr = &(qdata)->param->query_source; \
char addr_str[SOCKADDR_STRLEN]; \
char addr_str[SOCKADDR_STRLEN] = {0}; \
sockaddr_tostr(addr, addr_str, sizeof(addr_str)); \
zonedata_t *zone_data = (zonedata_t *)knot_zone_data((qdata)->zone); \
char *zone_str = knot_dname_to_str(knot_pkt_qname((qdata)->query)); \
log_msg(LOG_SERVER, severity, what msg "\n", \
zone_data->conf ? zone_data->conf->name : NULL, \
zone_str, \
addr_str, sockaddr_portnum(addr), ##__VA_ARGS__); \
free(zone_str); \
} while (0)
/*! \brief Query logging common base. */
......
......@@ -331,7 +331,7 @@ uint16_t knot_pkt_question_size(const knot_pkt_t *pkt)
const knot_dname_t *knot_pkt_qname(const knot_pkt_t *pkt)
{
dbg_packet("%s(%p)\n", __func__, pkt);
if (pkt == NULL) {
if (pkt == NULL || pkt->qname_size == 0) {
return NULL;
}
......
......@@ -274,7 +274,7 @@ void knot_zone_set_flag(knot_zone_t *zone, knot_zone_flag_t flag, unsigned on)
int knot_zone_state(const knot_zone_t *zone)
{
if (zone == NULL) {
if (zone == NULL || zone->data == NULL) {
dbg_ns("%s: zone not found\n", __func__);
return KNOT_ENOENT;
} else if (zone->contents == NULL) {
......
......@@ -49,10 +49,8 @@ static void delete_zone_from_db(knot_zone_t *zone)
knot_zonedb_t *knot_zonedb_new(uint32_t size)
{
/* Create memory pool context. */
mm_ctx_t mm;
mm.ctx = mp_new(4096);
mm.alloc = (mm_alloc_t)mp_alloc;
mm.free = mm_nofree;
mm_ctx_t mm = {0};
mm_ctx_mempool(&mm, 4096);
knot_zonedb_t *db = mm.alloc(mm.ctx, sizeof(knot_zonedb_t));
if (db == NULL) {
return NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment