mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 14:07:59 +00:00
Log both "from" and "to" socket in debug messages
Move dns_dispentry_getlocaladdress() calls around so that they are not only invoked when dnstap support is compiled in. This function calls isc_nmhandle_localaddr(), which may issue a system call, but only if the ISC_SOCKET_DETAILS preprocessor macro is set at compile time. Pass the value extracted by dns_dispentry_getlocaladdress() to dns_message_logpacketfromto() so that it gets logged, adding useful information to the relevant debug messages.
This commit is contained in:
@@ -2340,8 +2340,8 @@ resquery_send(resquery_t *query) {
|
|||||||
dns_ednsopt_t ednsopts[DNS_EDNSOPTIONS];
|
dns_ednsopt_t ednsopts[DNS_EDNSOPTIONS];
|
||||||
unsigned int ednsopt = 0;
|
unsigned int ednsopt = 0;
|
||||||
uint16_t hint = 0, udpsize = 0; /* No EDNS */
|
uint16_t hint = 0, udpsize = 0; /* No EDNS */
|
||||||
#ifdef HAVE_DNSTAP
|
|
||||||
isc_sockaddr_t localaddr, *la = NULL;
|
isc_sockaddr_t localaddr, *la = NULL;
|
||||||
|
#ifdef HAVE_DNSTAP
|
||||||
unsigned char zone[DNS_NAME_MAXWIRE];
|
unsigned char zone[DNS_NAME_MAXWIRE];
|
||||||
dns_transport_type_t transport_type;
|
dns_transport_type_t transport_type;
|
||||||
dns_dtmsgtype_t dtmsgtype;
|
dns_dtmsgtype_t dtmsgtype;
|
||||||
@@ -2709,8 +2709,13 @@ resquery_send(resquery_t *query) {
|
|||||||
/*
|
/*
|
||||||
* Log the outgoing packet.
|
* Log the outgoing packet.
|
||||||
*/
|
*/
|
||||||
|
result = dns_dispentry_getlocaladdress(query->dispentry, &localaddr);
|
||||||
|
if (result == ISC_R_SUCCESS) {
|
||||||
|
la = &localaddr;
|
||||||
|
}
|
||||||
|
|
||||||
dns_message_logpacketfromto(
|
dns_message_logpacketfromto(
|
||||||
fctx->qmessage, "sending packet to", NULL, &query->addrinfo->sockaddr,
|
fctx->qmessage, "sending packet to", la, &query->addrinfo->sockaddr,
|
||||||
DNS_LOGCATEGORY_RESOLVER, DNS_LOGMODULE_PACKETS,
|
DNS_LOGCATEGORY_RESOLVER, DNS_LOGMODULE_PACKETS,
|
||||||
ISC_LOG_DEBUG(11), fctx->mctx);
|
ISC_LOG_DEBUG(11), fctx->mctx);
|
||||||
|
|
||||||
@@ -2737,11 +2742,6 @@ resquery_send(resquery_t *query) {
|
|||||||
dtmsgtype = DNS_DTTYPE_RQ;
|
dtmsgtype = DNS_DTTYPE_RQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = dns_dispentry_getlocaladdress(query->dispentry, &localaddr);
|
|
||||||
if (result == ISC_R_SUCCESS) {
|
|
||||||
la = &localaddr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (query->addrinfo->transport != NULL) {
|
if (query->addrinfo->transport != NULL) {
|
||||||
transport_type =
|
transport_type =
|
||||||
dns_transport_get_type(query->addrinfo->transport);
|
dns_transport_get_type(query->addrinfo->transport);
|
||||||
@@ -9718,9 +9718,9 @@ detach:
|
|||||||
static void
|
static void
|
||||||
rctx_logpacket(respctx_t *rctx) {
|
rctx_logpacket(respctx_t *rctx) {
|
||||||
fetchctx_t *fctx = rctx->fctx;
|
fetchctx_t *fctx = rctx->fctx;
|
||||||
#ifdef HAVE_DNSTAP
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
isc_sockaddr_t localaddr, *la = NULL;
|
isc_sockaddr_t localaddr, *la = NULL;
|
||||||
|
#ifdef HAVE_DNSTAP
|
||||||
unsigned char zone[DNS_NAME_MAXWIRE];
|
unsigned char zone[DNS_NAME_MAXWIRE];
|
||||||
dns_transport_type_t transport_type;
|
dns_transport_type_t transport_type;
|
||||||
dns_dtmsgtype_t dtmsgtype;
|
dns_dtmsgtype_t dtmsgtype;
|
||||||
@@ -9729,9 +9729,15 @@ rctx_logpacket(respctx_t *rctx) {
|
|||||||
isc_buffer_t zb;
|
isc_buffer_t zb;
|
||||||
#endif /* HAVE_DNSTAP */
|
#endif /* HAVE_DNSTAP */
|
||||||
|
|
||||||
|
result = dns_dispentry_getlocaladdress(rctx->query->dispentry,
|
||||||
|
&localaddr);
|
||||||
|
if (result == ISC_R_SUCCESS) {
|
||||||
|
la = &localaddr;
|
||||||
|
}
|
||||||
|
|
||||||
dns_message_logpacketfromto(
|
dns_message_logpacketfromto(
|
||||||
rctx->query->rmessage, "received packet from",
|
rctx->query->rmessage, "received packet from",
|
||||||
&rctx->query->addrinfo->sockaddr, NULL, DNS_LOGCATEGORY_RESOLVER,
|
&rctx->query->addrinfo->sockaddr, la, DNS_LOGCATEGORY_RESOLVER,
|
||||||
DNS_LOGMODULE_PACKETS, ISC_LOG_DEBUG(10), fctx->mctx);
|
DNS_LOGMODULE_PACKETS, ISC_LOG_DEBUG(10), fctx->mctx);
|
||||||
|
|
||||||
#ifdef HAVE_DNSTAP
|
#ifdef HAVE_DNSTAP
|
||||||
@@ -9754,12 +9760,6 @@ rctx_logpacket(respctx_t *rctx) {
|
|||||||
dtmsgtype = DNS_DTTYPE_RR;
|
dtmsgtype = DNS_DTTYPE_RR;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = dns_dispentry_getlocaladdress(rctx->query->dispentry,
|
|
||||||
&localaddr);
|
|
||||||
if (result == ISC_R_SUCCESS) {
|
|
||||||
la = &localaddr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rctx->query->addrinfo->transport != NULL) {
|
if (rctx->query->addrinfo->transport != NULL) {
|
||||||
transport_type = dns_transport_get_type(
|
transport_type = dns_transport_get_type(
|
||||||
rctx->query->addrinfo->transport);
|
rctx->query->addrinfo->transport);
|
||||||
|
Reference in New Issue
Block a user