]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use server socket to log TCP accept failures
authorOndřej Surý <ondrej@isc.org>
Tue, 18 Apr 2023 12:35:34 +0000 (14:35 +0200)
committerOndřej Surý <ondrej@isc.org>
Thu, 27 Apr 2023 09:07:57 +0000 (11:07 +0200)
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.

lib/isc/netmgr/tcp.c

index 11b05b639e58f59ac1ee7f95518e0affaf649628..10a71a6d2ea3e8966edcba466d3300eaa5717761 100644 (file)
@@ -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 });