From: Ondřej Surý Date: Tue, 18 Apr 2023 12:35:34 +0000 (+0200) Subject: Use server socket to log TCP accept failures X-Git-Tag: v9.19.13~15^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=58663574b9ee160ca7880f004ed10ed5947b9be8;p=thirdparty%2Fbind9.git Use server socket to log TCP accept failures The accept_connection() could detach from the child socket on a failure, so we need to keep and use the server socket for logging the accept failures. --- diff --git a/lib/isc/netmgr/tcp.c b/lib/isc/netmgr/tcp.c index 11b05b639e5..10a71a6d2ea 100644 --- a/lib/isc/netmgr/tcp.c +++ b/lib/isc/netmgr/tcp.c @@ -795,19 +795,21 @@ free: */ static void tcpaccept_cb(void *arg) { - isc_nmsocket_t *sock = arg; + isc_nmsocket_t *csock = arg; + isc_nmsocket_t *ssock = csock->server; - REQUIRE(VALID_NMSOCK(sock)); - REQUIRE(sock->tid == isc_tid()); + REQUIRE(VALID_NMSOCK(csock)); + REQUIRE(csock->tid == isc_tid()); - isc_result_t result = accept_connection(sock); - isc__nm_accept_connection_log(sock, result, can_log_tcp_quota()); - isc__nmsocket_detach(&sock); + isc_result_t result = accept_connection(csock); + isc__nm_accept_connection_log(ssock, result, can_log_tcp_quota()); + isc__nmsocket_detach(&csock); } static void quota_accept_cb(void *arg) { isc_nmsocket_t *csock = arg; + isc_nmsocket_t *ssock = csock->server; REQUIRE(VALID_NMSOCK(csock)); @@ -817,7 +819,7 @@ quota_accept_cb(void *arg) { */ if (csock->tid == isc_tid()) { isc_result_t result = accept_connection(csock); - isc__nm_accept_connection_log(csock, result, + isc__nm_accept_connection_log(ssock, result, can_log_tcp_quota()); } else { isc__nmsocket_attach(csock, &(isc_nmsocket_t *){ NULL });