Skip to content

Commit

Permalink
Merge 3f15edc into a68b083
Browse files Browse the repository at this point in the history
  • Loading branch information
omoerbeek committed Oct 11, 2023
2 parents a68b083 + 3f15edc commit f276c0c
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 10 deletions.
2 changes: 2 additions & 0 deletions pdns/recursordist/rec-main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1687,6 +1687,8 @@ static int initSyncRes(Logr::log_t log)
SyncRes::s_ecscachelimitttl = ::arg().asNum("ecs-cache-limit-ttl");

SyncRes::s_qnameminimization = ::arg().mustDo("qname-minimization");
SyncRes::s_minimize_one_label = ::arg().asNum("qname-minimize-one-label");
SyncRes::s_max_minimize_count = ::arg().asNum("qname-max-minimize-count");

SyncRes::s_hardenNXD = SyncRes::HardenNXD::DNSSEC;
string value = ::arg()["nothing-below-nxdomain"];
Expand Down
27 changes: 26 additions & 1 deletion pdns/recursordist/settings/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1955,10 +1955,35 @@
'help' : 'Use Query Name Minimization',
'doc' : '''
Enable Query Name Minimization. This implements a relaxed form of Query Name Mimimization as
described in :rfc:`7816`.
described in :rfc:`9156`.
''',
'versionadded': '4.3.0'
},
{
'name' : 'qname_max_minimize_count',
'section' : 'recursor',
'type' : LType.Uint64,
'default' : '10',
'help' : 'RFC9156 max minimize count',
'doc' : '''
``Max minimize count`` parameter, described in :rfc:`9156`. This is the maximum number of iterations
of the Query Name Minimization Algorithm.
''',
'versionadded': '5.0.0'
},
{
'name' : 'qname_minimize_one_label',
'section' : 'recursor',
'type' : LType.Uint64,
'default' : '4',
'help' : 'RFC9156 minimize one label parameter',
'doc' : '''
``Minimize one label`` parameter, described in :rfc:`9156`.
The value for the number of iterations of the Query Name Minimization Algorithm that should only have one label appended.
This value has precedence over :ref:`setting-qname-max-minimize-count`.
''',
'versionadded': '5.0.0'
},
{
'name' : 'source_address',
'section' : 'outgoing',
Expand Down
18 changes: 9 additions & 9 deletions pdns/recursordist/syncres.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1596,20 +1596,20 @@ LWResult::Result SyncRes::asyncresolveWrapper(const ComboAddress& address, bool
}

/* The parameters from rfc9156. */
/* maximum number of QNAME minimisation iterations */
static const unsigned int s_max_minimise_count = 10;
/* number of queries that should only have one label appended */
static const unsigned int s_minimise_one_lab = 4;
/* maximum number of QNAME minimization iterations */
unsigned int SyncRes::s_max_minimize_count; // default is 10
/* number of iterations that should only have one label appended */
unsigned int SyncRes::s_minimize_one_label; // default is 4

static unsigned int qmStepLen(unsigned int labels, unsigned int qnamelen, unsigned int i)
{
unsigned int step;

if (i < s_minimise_one_lab) {
if (i < SyncRes::s_minimize_one_label) {
step = 1;
}
else if (i < s_max_minimise_count) {
step = std::max(1U, (qnamelen - labels) / (10 - i));
else if (i < SyncRes::s_max_minimize_count) {
step = std::max(1U, (qnamelen - labels) / (SyncRes::s_max_minimize_count - i));
}
else {
step = qnamelen - labels;
Expand Down Expand Up @@ -1695,7 +1695,7 @@ int SyncRes::doResolve(const DNSName& qname, const QType qtype, vector<DNSRecord
LOG(prefix << qname << ": Step0 qname is in a forwarded domain " << fwdomain << endl);
}

for (unsigned int i = 0; i <= qnamelen;) {
for (unsigned int i = 0; i <= qnamelen; i++) {

// Step 1
vector<DNSRecord> bestns;
Expand All @@ -1714,7 +1714,7 @@ int SyncRes::doResolve(const DNSName& qname, const QType qtype, vector<DNSRecord
}
}

if (bestns.size() == 0) {
if (bestns.empty()) {
if (!forwarded) {
// Something terrible is wrong
LOG(prefix << qname << ": Step1 No ancestor found return ServFail" << endl);
Expand Down
2 changes: 2 additions & 0 deletions pdns/recursordist/syncres.hh
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,8 @@ public:
static bool s_dot_to_port_853;
static unsigned int s_max_busy_dot_probes;
static unsigned int s_max_CNAMES_followed;
static unsigned int s_max_minimize_count;
static unsigned int s_minimize_one_label;

static const int event_trace_to_pb = 1;
static const int event_trace_to_log = 2;
Expand Down
2 changes: 2 additions & 0 deletions pdns/recursordist/test-syncres_cc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ void initSR(bool debug)
SyncRes::s_save_parent_ns_set = true;
SyncRes::s_maxnsperresolve = 13;
SyncRes::s_locked_ttlperc = 0;
SyncRes::s_minimize_one_label = 4;
SyncRes::s_max_minimize_count = 10;

SyncRes::clearNSSpeeds();
BOOST_CHECK_EQUAL(SyncRes::getNSSpeedsSize(), 0U);
Expand Down

0 comments on commit f276c0c

Please sign in to comment.