]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Show the local and remote addresses for the "Refresh SOA" query
authorAram Sargsyan <aram@isc.org>
Fri, 15 Sep 2023 10:47:17 +0000 (10:47 +0000)
committerAram Sargsyan <aram@isc.org>
Fri, 22 Sep 2023 11:26:11 +0000 (11:26 +0000)
Currently in the statsistics channel's incoming zone transfers list
the local and remote addresses are shown only when the zone transfer
is already running. Since we have now introduced the "Refresh SOA"
state, which shows the state of the SOA query before the zone transfer
is started, this commit implements a feature to show the local and
remote addresses for the SOA query, when the state is "Refresh SOA".

bin/named/statschannel.c
lib/dns/include/dns/zone.h
lib/dns/zone.c

index 8b482e3a46f89d1ac6e9e4fe4e0394b8831c9ec3..2ba5614790c9f3e9a80ce34b188d38d7c6759ee6 100644 (file)
@@ -1459,6 +1459,7 @@ xfrin_xmlrender(dns_zone_t *zone, void *arg) {
        dns_rdataclass_t rdclass;
        const char *ztype;
        uint32_t serial;
+       isc_sockaddr_t addr;
        const isc_sockaddr_t *addrp = NULL;
        char addr_buf[ISC_SOCKADDR_FORMATSIZE];
        dns_transport_type_t transport_type;
@@ -1571,6 +1572,10 @@ xfrin_xmlrender(dns_zone_t *zone, void *arg) {
                addrp = dns_xfrin_getsourceaddr(xfr);
                isc_sockaddr_format(addrp, addr_buf, sizeof(addr_buf));
                TRY0(xmlTextWriterWriteString(writer, ISC_XMLCHAR addr_buf));
+       } else if (is_presoa) {
+               addr = dns_zone_getsourceaddr(zone);
+               isc_sockaddr_format(&addr, addr_buf, sizeof(addr_buf));
+               TRY0(xmlTextWriterWriteString(writer, ISC_XMLCHAR addr_buf));
        } else {
                TRY0(xmlTextWriterWriteString(writer, ISC_XMLCHAR "-"));
        }
@@ -1581,6 +1586,10 @@ xfrin_xmlrender(dns_zone_t *zone, void *arg) {
                addrp = dns_xfrin_getprimaryaddr(xfr);
                isc_sockaddr_format(addrp, addr_buf, sizeof(addr_buf));
                TRY0(xmlTextWriterWriteString(writer, ISC_XMLCHAR addr_buf));
+       } else if (is_presoa) {
+               addr = dns_zone_getprimaryaddr(zone);
+               isc_sockaddr_format(&addr, addr_buf, sizeof(addr_buf));
+               TRY0(xmlTextWriterWriteString(writer, ISC_XMLCHAR addr_buf));
        } else {
                TRY0(xmlTextWriterWriteString(writer, ISC_XMLCHAR "-"));
        }
@@ -2506,6 +2515,7 @@ xfrin_jsonrender(dns_zone_t *zone, void *arg) {
        uint32_t serial;
        json_object *xfrinarray = (json_object *)arg;
        json_object *xfrinobj = NULL;
+       isc_sockaddr_t addr;
        const isc_sockaddr_t *addrp = NULL;
        char addr_buf[ISC_SOCKADDR_FORMATSIZE];
        dns_transport_type_t transport_type;
@@ -2602,6 +2612,11 @@ xfrin_jsonrender(dns_zone_t *zone, void *arg) {
                isc_sockaddr_format(addrp, addr_buf, sizeof(addr_buf));
                json_object_object_add(xfrinobj, "localaddr",
                                       json_object_new_string(addr_buf));
+       } else if (is_presoa) {
+               addr = dns_zone_getsourceaddr(zone);
+               isc_sockaddr_format(&addr, addr_buf, sizeof(addr_buf));
+               json_object_object_add(xfrinobj, "localaddr",
+                                      json_object_new_string(addr_buf));
        } else {
                json_object_object_add(xfrinobj, "localaddr",
                                       json_object_new_string("-"));
@@ -2612,6 +2627,11 @@ xfrin_jsonrender(dns_zone_t *zone, void *arg) {
                isc_sockaddr_format(addrp, addr_buf, sizeof(addr_buf));
                json_object_object_add(xfrinobj, "remoteaddr",
                                       json_object_new_string(addr_buf));
+       } else if (is_presoa) {
+               addr = dns_zone_getprimaryaddr(zone);
+               isc_sockaddr_format(&addr, addr_buf, sizeof(addr_buf));
+               json_object_object_add(xfrinobj, "remoteaddr",
+                                      json_object_new_string(addr_buf));
        } else {
                json_object_object_add(xfrinobj, "remoteaddr",
                                       json_object_new_string("-"));
index 7df0f89a284c99b12b22ba0bef514b02e2ed96a4..694104659ef267256d7c3f6f81ed2128135a53b7 100644 (file)
@@ -1479,6 +1479,27 @@ dns_zone_getsigresigninginterval(dns_zone_t *zone);
  * \li 'zone' to be a valid zone.
  */
 
+isc_sockaddr_t
+dns_zone_getsourceaddr(dns_zone_t *zone);
+/*%<
+ * Get the zone's source address from which it has last contacted the current
+ * primary server.
+ *
+ * Requires:
+ * \li 'zone' to be a valid zone.
+ * \li 'zone' has a non-empty primaries list.
+ */
+
+isc_sockaddr_t
+dns_zone_getprimaryaddr(dns_zone_t *zone);
+/*%<
+ * Get the zone's current primary server.
+ *
+ * Requires:
+ * \li 'zone' to be a valid zone.
+ * \li 'zone' has a non-empty primaries list.
+ */
+
 isc_time_t
 dns_zone_getxfrintime(const dns_zone_t *zone);
 /*%<
index 143e98d6b0f99765eab37d6bcc9f573b8035e315..c500cbfde299b63eb189b2a86696d04310343cb2 100644 (file)
@@ -17588,6 +17588,34 @@ dns_zone_getsigresigninginterval(dns_zone_t *zone) {
        return (zone->sigresigninginterval);
 }
 
+isc_sockaddr_t
+dns_zone_getsourceaddr(dns_zone_t *zone) {
+       isc_sockaddr_t sourceaddr;
+
+       REQUIRE(DNS_ZONE_VALID(zone));
+
+       LOCK_ZONE(zone);
+       INSIST(dns_remote_count(&zone->primaries) > 0);
+       sourceaddr = zone->sourceaddr;
+       UNLOCK_ZONE(zone);
+
+       return (sourceaddr);
+}
+
+isc_sockaddr_t
+dns_zone_getprimaryaddr(dns_zone_t *zone) {
+       isc_sockaddr_t curraddr;
+
+       REQUIRE(DNS_ZONE_VALID(zone));
+
+       LOCK_ZONE(zone);
+       INSIST(dns_remote_count(&zone->primaries) > 0);
+       curraddr = dns_remote_curraddr(&zone->primaries);
+       UNLOCK_ZONE(zone);
+
+       return (curraddr);
+}
+
 isc_time_t
 dns_zone_getxfrintime(const dns_zone_t *zone) {
        REQUIRE(DNS_ZONE_VALID(zone));