mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 13:38:26 +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:
parent
4ab35f6839
commit
c5555a5ca2
@ -2340,8 +2340,8 @@ resquery_send(resquery_t *query) {
|
||||
dns_ednsopt_t ednsopts[DNS_EDNSOPTIONS];
|
||||
unsigned int ednsopt = 0;
|
||||
uint16_t hint = 0, udpsize = 0; /* No EDNS */
|
||||
#ifdef HAVE_DNSTAP
|
||||
isc_sockaddr_t localaddr, *la = NULL;
|
||||
#ifdef HAVE_DNSTAP
|
||||
unsigned char zone[DNS_NAME_MAXWIRE];
|
||||
dns_transport_type_t transport_type;
|
||||
dns_dtmsgtype_t dtmsgtype;
|
||||
@ -2709,8 +2709,13 @@ resquery_send(resquery_t *query) {
|
||||
/*
|
||||
* Log the outgoing packet.
|
||||
*/
|
||||
result = dns_dispentry_getlocaladdress(query->dispentry, &localaddr);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
la = &localaddr;
|
||||
}
|
||||
|
||||
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,
|
||||
ISC_LOG_DEBUG(11), fctx->mctx);
|
||||
|
||||
@ -2737,11 +2742,6 @@ resquery_send(resquery_t *query) {
|
||||
dtmsgtype = DNS_DTTYPE_RQ;
|
||||
}
|
||||
|
||||
result = dns_dispentry_getlocaladdress(query->dispentry, &localaddr);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
la = &localaddr;
|
||||
}
|
||||
|
||||
if (query->addrinfo->transport != NULL) {
|
||||
transport_type =
|
||||
dns_transport_get_type(query->addrinfo->transport);
|
||||
@ -9718,9 +9718,9 @@ detach:
|
||||
static void
|
||||
rctx_logpacket(respctx_t *rctx) {
|
||||
fetchctx_t *fctx = rctx->fctx;
|
||||
#ifdef HAVE_DNSTAP
|
||||
isc_result_t result;
|
||||
isc_sockaddr_t localaddr, *la = NULL;
|
||||
#ifdef HAVE_DNSTAP
|
||||
unsigned char zone[DNS_NAME_MAXWIRE];
|
||||
dns_transport_type_t transport_type;
|
||||
dns_dtmsgtype_t dtmsgtype;
|
||||
@ -9729,9 +9729,15 @@ rctx_logpacket(respctx_t *rctx) {
|
||||
isc_buffer_t zb;
|
||||
#endif /* HAVE_DNSTAP */
|
||||
|
||||
result = dns_dispentry_getlocaladdress(rctx->query->dispentry,
|
||||
&localaddr);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
la = &localaddr;
|
||||
}
|
||||
|
||||
dns_message_logpacketfromto(
|
||||
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);
|
||||
|
||||
#ifdef HAVE_DNSTAP
|
||||
@ -9754,12 +9760,6 @@ rctx_logpacket(respctx_t *rctx) {
|
||||
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) {
|
||||
transport_type = dns_transport_get_type(
|
||||
rctx->query->addrinfo->transport);
|
||||
|
Loading…
x
Reference in New Issue
Block a user