]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Collapse common switch cases when emitting EDNS options
authorMark Andrews <marka@isc.org>
Tue, 29 Oct 2024 23:41:21 +0000 (10:41 +1100)
committerEvan Hunt <each@isc.org>
Wed, 7 May 2025 07:00:10 +0000 (00:00 -0700)
The CHAIN and REPORT-CHANNEL EDNS options are both domain names, so they
can be combined.  THE CLIENT-TAG and SERVER-TAG EDNS options are both 16
bit integers, so they can be combined.

(cherry picked from commit e7ef4e41ebd55ed1cfb2b2652b66a0f026aea1c7)

lib/dns/message.c

index f5aa7bb28ff6010a05cd4c3b93b84421ea48f99d..86d4342af975e8f7bb4c7a57a618aa81205960f6 100644 (file)
@@ -3797,6 +3797,7 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, dns_pseudosection_t section,
                                }
                                break;
                        case DNS_OPT_CHAIN:
+                       case DNS_OPT_REPORT_CHANNEL:
                                if (optlen > 0U) {
                                        isc_buffer_t sb = optbuf;
                                        isc_buffer_setactive(&optbuf, optlen);
@@ -3853,14 +3854,6 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, dns_pseudosection_t section,
                                }
                                break;
                        case DNS_OPT_CLIENT_TAG:
-                               if (optlen == 2U) {
-                                       uint16_t id =
-                                               isc_buffer_getuint16(&optbuf);
-                                       snprintf(buf, sizeof(buf), " %u\n", id);
-                                       ADD_STRING(target, buf);
-                                       continue;
-                               }
-                               break;
                        case DNS_OPT_SERVER_TAG:
                                if (optlen == 2U) {
                                        uint16_t id =
@@ -3870,19 +3863,6 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, dns_pseudosection_t section,
                                        continue;
                                }
                                break;
-                       case DNS_OPT_REPORT_CHANNEL:
-                               if (optlen > 0U) {
-                                       isc_buffer_t sb = optbuf;
-                                       isc_buffer_setactive(&optbuf, optlen);
-                                       result = render_nameopt(&optbuf,
-                                                               target);
-                                       if (result == ISC_R_SUCCESS) {
-                                               ADD_STRING(target, "\n");
-                                               continue;
-                                       }
-                                       optbuf = sb;
-                               }
-                               break;
                        default:
                                break;
                        }
@@ -4212,6 +4192,7 @@ dns_message_pseudosectiontotext(dns_message_t *msg, dns_pseudosection_t section,
                                ADD_STRING(target, "\n");
                                continue;
                        case DNS_OPT_CHAIN:
+                       case DNS_OPT_REPORT_CHANNEL:
                                if (optlen > 0U) {
                                        isc_buffer_t sb = optbuf;
                                        isc_buffer_setactive(&optbuf, optlen);
@@ -4272,14 +4253,6 @@ dns_message_pseudosectiontotext(dns_message_t *msg, dns_pseudosection_t section,
                                }
                                break;
                        case DNS_OPT_CLIENT_TAG:
-                               if (optlen == 2U) {
-                                       uint16_t id =
-                                               isc_buffer_getuint16(&optbuf);
-                                       snprintf(buf, sizeof(buf), " %u\n", id);
-                                       ADD_STRING(target, buf);
-                                       continue;
-                               }
-                               break;
                        case DNS_OPT_SERVER_TAG:
                                if (optlen == 2U) {
                                        uint16_t id =
@@ -4289,19 +4262,6 @@ dns_message_pseudosectiontotext(dns_message_t *msg, dns_pseudosection_t section,
                                        continue;
                                }
                                break;
-                       case DNS_OPT_REPORT_CHANNEL:
-                               if (optlen > 0U) {
-                                       isc_buffer_t sb = optbuf;
-                                       isc_buffer_setactive(&optbuf, optlen);
-                                       result = render_nameopt(&optbuf,
-                                                               target);
-                                       if (result == ISC_R_SUCCESS) {
-                                               ADD_STRING(target, "\n");
-                                               continue;
-                                       }
-                                       optbuf = sb;
-                               }
-                               break;
                        default:
                                break;
                        }