Skip to content

Enable extraction of exact local socket addresses

Extracting the exact address that each wildcard/TCP socket is bound to locally requires issuing the getsockname() system call, which libuv exposes via its uv_*_getsockname() functions. This is only required for detailed logging and comes at a noticeable performance cost, so it should not happen by default. However, it is useful for debugging certain problems (e.g. cryptic system test failures), so a convenient way of enabling that behavior should exist.

Update isc_nmhandle_localaddr() so that it calls uv_*_getsockname() when the ISC_SOCKET_DETAILS preprocessor macro is set at compile time. Ensure proper handling of Stream DNS sockets, which wrap the actual underlying TCP/TLS socket.

Set the new ISC_SOCKET_DETAILS macro by default when --enable-developer is passed to ./configure. This enables detailed logging in the system tests run in GitLab CI without affecting performance in non-development BIND 9 builds.

Note that setting the ISC_SOCKET_DETAILS preprocessor macro at compile time enables all callers of isc_nmhandle_localaddr() to extract the exact address of a given local socket, which results e.g. in dnstap captures containing more accurate information.

Mention the new preprocessor macro in the section of the ARM that discusses why exact socket addresses may not be logged by default.

Closes #4344

Edited by Michał Kępień

Merge request reports