Commit 688c1ce0 authored by Marek Vavrusa's avatar Marek Vavrusa

Merge branch 'master' into packet-api-rewrite

Didn't port over the packet fixes that are already reworked in this
branch.

Conflicts:
	configure.ac
	src/knot/server/zones.c
	src/libknot/nameserver/name-server.c
	src/libknot/packet/packet.c
	src/libknot/packet/response.c
parents 5609e6cd ffc02e9d
Knot DNS NEWS
v1.4.0 - Dec 27, 2013
v1.4.1 - Jan 13, 2014
---------------------
Bugfixes:
* Empty APL record support
* 'zonestatus' when using immediate zone syncing
* Immediate zone syncing after reload
* Race condition writing time values to zone file
v1.4.0 - Jan 6, 2014
---------------------
Features:
* Zone SERIAL policies (INCREMENT, UNIXTIME)
......
# -*- Autoconf -*-
AC_PREREQ([2.60])
AC_INIT([knot], [1.4-dev], [knot-dns@labs.nic.cz])
AC_INIT([knot], [1.4.1], [knot-dns@labs.nic.cz])
AM_INIT_AUTOMAKE([gnits subdir-objects dist-xz -Wall -Werror])
AM_SILENT_RULES([yes])
AC_CONFIG_SRCDIR([src/knot/main.c])
......
......@@ -850,7 +850,7 @@ int knot_pkt_add_opt(knot_pkt_t *resp,
* other options are supported.
*/
if (add_nsid) {
if (add_nsid && opt_rr->option_count > 0) {
resp->opt_rr.option_count = opt_rr->option_count;
assert(resp->opt_rr.options == NULL);
resp->opt_rr.options = (knot_opt_option_t *)malloc(
......
......@@ -624,9 +624,10 @@ static void wire_timestamp_to_str(rrset_dump_params_t *p)
time_t timestamp = ntohl(data);
if (p->style->human_tmstamp) {
struct tm result;
// Write timestamp in YYYYMMDDhhmmss format.
ret = strftime(p->out, p->out_max, "%Y%m%d%H%M%S",
gmtime(&timestamp));
gmtime_r(&timestamp, &result));
if (ret == 0) {
return;
}
......
......@@ -42,10 +42,11 @@ int test__date_to_timestamp()
// Testing loop over whole input interval.
for (ref_timestamp = 0;
ref_timestamp < max_timestamp;
ref_timestamp += 30) {
ref_timestamp += 1) {
struct tm result;
// Get reference (correct) timestamp.
strftime((char*)buffer, sizeof(buffer), "%Y%m%d%H%M%S",
gmtime(&ref_timestamp));
gmtime_r(&ref_timestamp, &result));
// Get testing timestamp.
date_to_timestamp(buffer, &test_timestamp);
......
......@@ -19,6 +19,7 @@
#include <stdio.h> // printf
#include <stdlib.h> // atoi
#include <getopt.h> // getopt
#include <pthread.h> // pthread_t
#include "error.h" // knot_strerror
#include "file_loader.h" // file_loader
......@@ -29,7 +30,14 @@
#define DEFAULT_CLASS 1
#define DEFAULT_TTL 0
void help(void)
static void *timestamp_worker(void *data)
{
int *ret = (int *)data;
*ret = test__date_to_timestamp();
return NULL;
}
static void help(void)
{
printf("\nZone scanner testing tool.\n"
"Usage: zscanner-tool [parameters] origin zonefile\n"
......@@ -79,7 +87,20 @@ int main(int argc, char *argv[])
}
if (test == 1) {
test__date_to_timestamp();
pthread_t t1, t2, t3;
int ret1, ret2, ret3;
pthread_create(&t1, NULL, timestamp_worker, &ret1);
pthread_create(&t2, NULL, timestamp_worker, &ret2);
pthread_create(&t3, NULL, timestamp_worker, &ret3);
pthread_join(t1, NULL);
pthread_join(t2, NULL);
pthread_join(t3, NULL);
if (ret1 != 0 || ret2 != 0 || ret3 != 0) {
return EXIT_FAILURE;
}
} else {
// Check if there are 2 remaining non-options.
if (argc - optind != 2) {
......
......@@ -46,6 +46,8 @@ def check_zone(server, expect_dnskey, expect_rrsig):
err("Expectations do not match.")
set_err("DNSKEYs not published and activated as expected.")
detail_log(SEP)
t = Test()
knot = t.server("knot")
......
......@@ -62,11 +62,11 @@ class Response(object):
self._check_question()
# Check rcode.
if type(rcode) is str:
rc = dns.rcode.from_text(rcode)
if type(rcode) is not str:
rc = dns.rcode.to_text(rcode)
else:
rc = rcode
compare(self.resp.rcode(), rc, "RCODE")
compare(dns.rcode.to_text(self.resp.rcode()), rc, "RCODE")
# Check rdata only if NOERROR.
if rc != 0 or rdata == None:
......
......@@ -272,12 +272,15 @@ class Server(object):
split(" ")[0].replace(",", ""))
if lost > 0 or reachable > 0 or errcount > 0:
err("%s memcheck: lost(%i B), reachable(%i B), errcount(%i)" \
% (self.name, lost, reachable, errcount))
set_err("VALGRIND")
detail_log("%s memcheck: lost(%i B), reachable(%i B), " \
"errcount(%i)" \
% (self.name, lost, reachable, errcount))
lock = False
continue
detail_log(SEP)
f.close()
def stop(self):
......@@ -296,8 +299,8 @@ class Server(object):
f.write(self.get_config())
f.close
def dig(self, rname, rtype, rclass="IN", udp=None, serial=None, \
timeout=None, tries=3, recursion=False, bufsize=None, \
def dig(self, rname, rtype, rclass="IN", udp=None, serial=None,
timeout=None, tries=3, recursion=False, bufsize=None,
nsid=False, dnssec=False):
key_params = self.tsig.key_params if self.tsig else dict()
......@@ -307,18 +310,71 @@ class Server(object):
raise Exception("One zone required.")
rname = rname[0].name
if timeout is None:
timeout = self.DIG_TIMEOUT
rtype_str = rtype.upper()
# Set port type.
if rtype.upper() == "AXFR":
# Always use TCP.
udp = False
elif rtype.upper() == "IXFR":
# Use TCP if not specified.
udp = udp if udp != None else False
rtype_str += "=%i" % int(serial)
else:
# Use TCP or UDP at random if not specified.
udp = udp if udp != None else random.choice([True, False])
if udp:
dig_flags = "+notcp"
else:
dig_flags = "+tcp"
dig_flags += " +tries=%i" % tries
# Set timeout.
if timeout is None:
timeout = self.DIG_TIMEOUT
dig_flags += " +time=%i" % timeout
# Prepare query (useless for XFR).
query = dns.message.make_query(rname, rtype, rclass)
# Set recursion.
if recursion:
query.flags |= dns.flags.RD
dig_flags += " +rec"
else:
query.flags &= ~dns.flags.RD
dig_flags += " +norec"
# Set EDNS.
if nsid or bufsize:
class NsidFix(object):
'''Current pythondns doesn't implement NSID option.'''
def __init__(self):
self.otype = dns.edns.NSID
def to_wire(self, file=None):
pass
if bufsize:
payload = int(bufsize)
else:
payload = 1280
dig_flags += " +bufsize=%i" % payload
if nsid:
options = [NsidFix()]
dig_flags += " +nsid"
else:
options = None
query.use_edns(edns=0, payload=payload, options=options)
# Set DO flag.
if dnssec:
query.want_dnssec()
dig_flags += " +dnssec +bufsize=%i" % query.payload
# Store function arguments for possible comparation.
args = dict()
params = inspect.getargvalues(inspect.currentframe())
......@@ -326,49 +382,28 @@ class Server(object):
if param != "self":
args[param] = params.locals[param]
check_log("DIG %s %s %s @%s -p %i %s" % \
(rname, rtype, rclass, self.addr, self.port, \
"+notcp" if udp else "+tcp"))
check_log("DIG %s %s %s @%s -p %i %s" %
(rname, rtype_str, rclass, self.addr, self.port, dig_flags))
if key_params:
detail_log("%s:%s:%s" % (self.tsig.alg, self.tsig.name, self.tsig.key))
for t in range(tries):
try:
if rtype.upper() == "AXFR":
resp = dns.query.xfr(self.addr, rname, rtype, rclass, \
port=self.port, lifetime=timeout, \
resp = dns.query.xfr(self.addr, rname, rtype, rclass,
port=self.port, lifetime=timeout,
use_udp=udp, **key_params)
elif rtype.upper() == "IXFR":
resp = dns.query.xfr(self.addr, rname, rtype, rclass, \
port=self.port, lifetime=timeout, \
use_udp=udp, serial=int(serial), \
resp = dns.query.xfr(self.addr, rname, rtype, rclass,
port=self.port, lifetime=timeout,
use_udp=udp, serial=int(serial),
**key_params)
elif udp:
resp = dns.query.udp(query, self.addr, port=self.port,
timeout=timeout)
else:
query = dns.message.make_query(rname, rtype, rclass)
# Set query.
if not recursion:
# Remove RD bit which is a default.
query.flags &= ~dns.flags.RD
if nsid or bufsize:
class NsidFix(object):
'''Current pythondns doesn't implement this'''
def __init__(self):
self.otype = dns.edns.NSID
def to_wire(self, file=None):
pass
payload = int(bufsize) if bufsize else 1280
options = [NsidFix()] if nsid else None
query.use_edns(edns=0, payload=payload, options=options)
if dnssec:
query.want_dnssec()
# Send query.
if udp:
resp = dns.query.udp(query, self.addr, port=self.port, \
timeout=timeout)
else:
resp = dns.query.tcp(query, self.addr, port=self.port, \
timeout=timeout)
resp = dns.query.tcp(query, self.addr, port=self.port,
timeout=timeout)
detail_log(SEP)
return dnstest.response.Response(self, resp, args)
......
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