]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add CO support to dig
authorMark Andrews <marka@isc.org>
Tue, 27 May 2025 04:41:24 +0000 (14:41 +1000)
committerMark Andrews <marka@isc.org>
Fri, 13 Jun 2025 10:31:31 +0000 (20:31 +1000)
Dig now support setting the EDNS CO as flag using "+coflag" /
"+nocoflag" rather than as part of +ednsflags.

(cherry picked from commit 6c28411c55d595e3c9ce3f8d1754b24875eb5306)

bin/dig/dig.c
bin/dig/dig.rst
bin/dig/dighost.c
bin/dig/dighost.h
lib/dns/include/dns/message.h
lib/dns/message.c

index 921b092bd413ea9adca17529d189a577821e48c1..e7731344c8fd2b75074c4c150706a5c72b353064 100644 (file)
@@ -188,6 +188,9 @@ help(void) {
               "                 +[no]cmd            (Control display of "
               "command line -\n"
               "                                      global option)\n"
+              "                 +[no]coflag         (Set compact denial of "
+              "existence ok flag)\n"
+              "                                      in query)\n"
               "                 +[no]comments       (Control display of "
               "packet "
               "header\n"
@@ -1634,6 +1637,11 @@ plus_option(char *option, bool is_batchfile, bool *need_clone,
                        break;
                case 'o': /* comments */
                        switch (cmd[2]) {
+                       case 'f':
+                       case '\0': /* +co is a synonym for +coflag */
+                               FULLCHECK("coflag");
+                               lookup->coflag = state;
+                               break;
                        case 'm':
                                FULLCHECK("comments");
                                lookup->comments = state;
index ef492a34cf43b7848953dc4a339b963a293ddc7c..19602607d21aaacf33092909766a6a070c3bdc05 100644 (file)
@@ -298,6 +298,13 @@ abbreviation is unambiguous; for example, :option:`+cd` is equivalent to
    always has a global effect; it cannot be set globally and then overridden on a
    per-lookup basis. The default is to print this comment.
 
+.. option:: +coflag, +co, +nocoflag, +noco
+
+   This option sets [or does not set] the CO (Compact denial of
+   existence Ok) EDNS bit in the query.  If set, it tells servers
+   that Compact Denial of Existence responses are acceptable when
+   replying to queries.  The default is ``+nocoflag``.
+
 .. option:: +comments, +nocomments
 
    This option toggles the display of some comment lines in the output, with
@@ -358,7 +365,7 @@ abbreviation is unambiguous; for example, :option:`+cd` is equivalent to
 
    This option sets the must-be-zero EDNS flags bits (Z bits) to the specified value.
    Decimal, hex, and octal encodings are accepted. Setting a named flag
-   (e.g., DO) is silently ignored. By default, no Z bits are set.
+   (e.g. DO, CO) is silently ignored. By default, no Z bits are set.
 
 .. option:: +ednsnegotiation, +noednsnegotiation
 
index b7e3c52b9e3a1747596d9bcadf1eab1d5baa2497..c5bf944e34a9833263a21013ae750fd8dcbafb08 100644 (file)
@@ -773,6 +773,7 @@ clone_lookup(dig_lookup_t *lookold, bool servers) {
        looknew->aaonly = lookold->aaonly;
        looknew->adflag = lookold->adflag;
        looknew->cdflag = lookold->cdflag;
+       looknew->coflag = lookold->coflag;
        looknew->raflag = lookold->raflag;
        looknew->tcflag = lookold->tcflag;
        looknew->print_unknown_format = lookold->print_unknown_format;
@@ -2632,10 +2633,13 @@ setup_lookup(dig_lookup_t *lookup) {
                }
 
                flags = lookup->ednsflags;
-               flags &= ~DNS_MESSAGEEXTFLAG_DO;
+               flags &= ~(DNS_MESSAGEEXTFLAG_DO | DNS_MESSAGEEXTFLAG_CO);
                if (lookup->dnssec) {
                        flags |= DNS_MESSAGEEXTFLAG_DO;
                }
+               if (lookup->coflag) {
+                       flags |= DNS_MESSAGEEXTFLAG_CO;
+               }
                add_opt(lookup->sendmsg, lookup->udpsize, lookup->edns, flags,
                        opts, i);
        }
index 86ccfe03212b0bd58b2c409b315a7ee52c2c78e9..22ab5d7714d24625c3cfc613d57cceca7bcb1d13 100644 (file)
@@ -105,11 +105,10 @@ typedef struct dig_searchlist dig_searchlist_t;
 struct dig_lookup {
        unsigned int magic;
        isc_refcount_t references;
-       bool aaonly, adflag, badcookie, besteffort, cdflag, cleared, comments,
-               dns64prefix, dnssec, doing_xfr, done_as_is, ednsneg, expandaaaa,
-               expire, fuzzing, header_only, identify, /*%< Append an "on
-                                                          server <foo>" message
-                                                        */
+       bool aaonly, adflag, badcookie, besteffort, cdflag, cleared, coflag,
+               comments, dns64prefix, dnssec, doing_xfr, done_as_is, ednsneg,
+               expandaaaa, expire, fuzzing, header_only,
+               identify, /*%< Append an "on server <foo>" message */
                identify_previous_line, /*% Prepend a "Nameserver <foo>:"
                                           message, with newline and tab */
                idnin, idnout, ignore, multiline, need_search, new_search,
index 3097612839ef250b6cb34c4c40ade218d4b1379e..c105d0a8c085b8b3f6af1ad956b8ff61f83e73c6 100644 (file)
 #define DNS_MESSAGEFLAG_CD 0x0010U
 
 /*%< EDNS0 extended message flags */
-#define DNS_MESSAGEEXTFLAG_DO 0x8000U
+#define DNS_MESSAGEEXTFLAG_DO 0x8000U /* DNSSEC OK */
+#define DNS_MESSAGEEXTFLAG_CO 0x4000U /* Compact denial of existence OK */
 
 /*%< EDNS0 extended OPT codes */
 
index 32a5976b775be4caace0122d2424200a27ae646a..6e77144663eef01f5d46f01db6008b6f5bfe5220 100644 (file)
@@ -3732,9 +3732,13 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, dns_pseudosection_t section,
                if ((ps->ttl & DNS_MESSAGEEXTFLAG_DO) != 0) {
                        ADD_STRING(target, " do");
                }
+               if ((ps->ttl & DNS_MESSAGEEXTFLAG_CO) != 0) {
+                       ADD_STRING(target, " co");
+               }
                ADD_STRING(target, "\n");
                mbz = ps->ttl & 0xffff;
-               mbz &= ~DNS_MESSAGEEXTFLAG_DO; /* Known Flags. */
+               /* Exclude Known Flags. */
+               mbz &= ~(DNS_MESSAGEEXTFLAG_DO | DNS_MESSAGEEXTFLAG_CO);
                if (mbz != 0) {
                        INDENT(style);
                        ADD_STRING(target, "MBZ: ");
@@ -4157,8 +4161,12 @@ dns_message_pseudosectiontotext(dns_message_t *msg, dns_pseudosection_t section,
                if ((ps->ttl & DNS_MESSAGEEXTFLAG_DO) != 0) {
                        ADD_STRING(target, " do");
                }
+               if ((ps->ttl & DNS_MESSAGEEXTFLAG_CO) != 0) {
+                       ADD_STRING(target, " co");
+               }
                mbz = ps->ttl & 0xffff;
-               mbz &= ~DNS_MESSAGEEXTFLAG_DO; /* Known Flags. */
+               /* Exclude Known Flags. */
+               mbz &= ~(DNS_MESSAGEEXTFLAG_DO | DNS_MESSAGEEXTFLAG_CO);
                if (mbz != 0) {
                        ADD_STRING(target, "; MBZ: ");
                        snprintf(buf, sizeof(buf), "0x%.4x", mbz);