Skip to content
This repository was archived by the owner on Aug 13, 2025. It is now read-only.

Commit 152d256

Browse files
committed
add "delv +strace"
"delv +strace" is similar to "delv +mtrace", but sets the logging level to DEBUG(11) instead of DEBUG(10), so that packets sent will be logged along with packets received. "delv +ns" turns this option on by default.
1 parent 32189f6 commit 152d256

File tree

2 files changed

+40
-13
lines changed

2 files changed

+40
-13
lines changed

bin/delv/delv.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static bool showcomments = true, showdnssec = true, showtrust = true,
129129
yaml = false, fulltrace = false;
130130

131131
static bool resolve_trace = false, validator_trace = false,
132-
message_trace = false;
132+
message_trace = false, send_trace = false;
133133

134134
static bool use_ipv4 = true, use_ipv6 = true;
135135

@@ -228,6 +228,8 @@ usage(void) {
228228
" +[no]short (Short form answer)\n"
229229
" +[no]split=## (Split hex/base64 fields "
230230
"into chunks)\n"
231+
" +[no]strace (Trace messages "
232+
"sent)\n"
231233
" +[no]tcp (TCP mode)\n"
232234
" +[no]ttl (Control display of ttls "
233235
"in records)\n"
@@ -307,6 +309,7 @@ setup_logging(FILE *errout) {
307309
isc_result_t result;
308310
isc_logdestination_t destination;
309311
isc_logconfig_t *logconfig = NULL;
312+
int packetlevel = 10;
310313

311314
isc_log_create(mctx, &lctx, &logconfig);
312315
isc_log_registercategories(lctx, categories);
@@ -359,9 +362,12 @@ setup_logging(FILE *errout) {
359362
}
360363
}
361364

362-
if (message_trace && loglevel < 10) {
365+
if (send_trace) {
366+
packetlevel = 11;
367+
}
368+
if ((message_trace || send_trace) && loglevel < packetlevel) {
363369
isc_log_createchannel(logconfig, "messages", ISC_LOG_TOFILEDESC,
364-
ISC_LOG_DEBUG(10), &destination,
370+
ISC_LOG_DEBUG(packetlevel), &destination,
365371
ISC_LOG_PRINTPREFIX);
366372

367373
result = isc_log_usechannel(logconfig, "messages",
@@ -1165,6 +1171,7 @@ plus_option(char *option) {
11651171
case 'm':
11661172
switch (cmd[1]) {
11671173
case 't': /* mtrace */
1174+
FULLCHECK("mtrace");
11681175
message_trace = state;
11691176
if (state) {
11701177
resolve_trace = state;
@@ -1185,6 +1192,7 @@ plus_option(char *option) {
11851192
fulltrace = state;
11861193
if (state) {
11871194
message_trace = state;
1195+
send_trace = state;
11881196
resolve_trace = state;
11891197
logfp = stdout;
11901198
}
@@ -1262,6 +1270,13 @@ plus_option(char *option) {
12621270
fatal("Couldn't parse split");
12631271
}
12641272
break;
1273+
case 't': /* strace */
1274+
FULLCHECK("strace");
1275+
send_trace = state;
1276+
if (state) {
1277+
message_trace = state;
1278+
}
1279+
break;
12651280
default:
12661281
goto invalid_option;
12671282
}

bin/delv/delv.rst

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ assign values to options like the timeout interval. They have the form
235235
This option toggles name server mode. When this option is in use,
236236
the ``delv`` process instantiates a full recursive resolver, and uses
237237
that to look up the requested query name and type. Turning on this
238-
option also activates ``+mtrace`` and ``+rtrace``, so that every
239-
iterative query will be logged, including the full response messages
238+
option also activates ``+mtrace``, ``+strace`` and ``+rtrace``, so that
239+
every iterative query will be logged, including the full response messages
240240
from each authoritatve server. These logged messages will be written
241241
to ``stdout`` rather than ``stderr`` as usual, so that the full trace
242242
can be captured more easily.
@@ -253,11 +253,11 @@ assign values to options like the timeout interval. They have the form
253253

254254
.. option:: +rtrace, +nortrace
255255

256-
This option toggles resolver fetch logging. This reports the name and type of each
257-
query sent by :program:`delv` in the process of carrying out the resolution
258-
and validation process, including the original query
259-
and all subsequent queries to follow CNAMEs and to establish a chain
260-
of trust for DNSSEC validation.
256+
This option toggles resolver fetch logging. This reports the name and
257+
type of each query sent by :program:`delv` in the process of carrying
258+
out the resolution and validation process, including the original query
259+
and all subsequent queries to follow CNAMEs and to establish a chain of
260+
trust for DNSSEC validation.
261261

262262
This is equivalent to setting the debug level to 1 in the "resolver"
263263
logging category. Setting the systemwide debug level to 1 using the
@@ -266,15 +266,27 @@ assign values to options like the timeout interval. They have the form
266266

267267
.. option:: +mtrace, +nomtrace
268268

269-
This option toggles message logging. This produces a detailed dump of the
270-
responses received by :program:`delv` in the process of carrying out the
271-
resolution and validation process.
269+
This option toggles logging of messages received. This produces
270+
a detailed dump of the responses received by :program:`delv` in the
271+
process of carrying out the resolution and validation process.
272272

273273
This is equivalent to setting the debug level to 10 for the "packets"
274274
module of the "resolver" logging category. Setting the systemwide
275275
debug level to 10 using the :option:`-d` option produces the same
276276
output, but affects other logging categories as well.
277277

278+
.. option:: +strace, +nostrace
279+
280+
This option toggles logging of messages sent. This produces a detailed
281+
dump of the queries sent by :program:`delv` in the process of carrying
282+
out the resolution and validation process. Turning on this option
283+
also activates ``+mtrace``.
284+
285+
This is equivalent to setting the debug level to 11 for the "packets"
286+
module of the "resolver" logging category. Setting the systemwide
287+
debug level to 11 using the :option:`-d` option produces the same
288+
output, but affects other logging categories as well.
289+
278290
.. option:: +vtrace, +novtrace
279291

280292
This option toggles validation logging. This shows the internal process of the

0 commit comments

Comments
 (0)