]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
EOF is not always an error case
authorAlan T. DeKok <aland@freeradius.org>
Thu, 7 Aug 2025 14:43:19 +0000 (10:43 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 7 Aug 2025 15:01:26 +0000 (11:01 -0400)
From the docs:

> If the read direction of the socket has shutdown, then the filter
> also sets EV_EOF in flags, and returns the socket error (if any) in
> fflags. It is possible for EOF to be returned (indicating the
> connection is gone) while there is still data pending in the socket
> buffer.

So we suppress printing an error on normal EOF.  Instead, we just
see if we need to reconnect the socket.

Arguably if the other end closes our read side, we _might_ be able
to write to the socket?  but we could still write to it.

src/lib/server/trunk.h
src/modules/rlm_logtee/rlm_logtee.c
src/modules/rlm_radius/bio.c
src/modules/rlm_tacacs/rlm_tacacs_tcp.c

index ae29dba62c25def2ffff9e3c1d0e6b1934e5443d..2b970de78938d0f97a294bdd47f6d2ecd4a1bfe8 100644 (file)
@@ -964,7 +964,7 @@ static void _conn_readable(UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int
 static void _conn_error(UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, int fd_errno, void *uctx) \
 { \
        trunk_connection_t      *tconn = talloc_get_type_abort(uctx, trunk_connection_t); \
-       ERROR("%s - Connection failed: %s", tconn->conn->name, fr_syserror(fd_errno)); \
+       if (fd_errno) ERROR("%s - Connection failed: %s", tconn->conn->name, fr_syserror(fd_errno)); \
        connection_signal_reconnect(tconn->conn, CONNECTION_FAILED); \
 } \
 CC_NO_UBSAN(function) /* UBSAN: false positive - public vs private connection_t trips --fsanitize=function*/ \
index 6d35e6b9b387b9da4ef6028a4c2353f60d0e53ab..a0ab1cf417e264b72ed31757db309aa74d9bccd0 100644 (file)
@@ -214,7 +214,7 @@ static void _logtee_conn_error(UNUSED fr_event_list_t *el, int sock, UNUSED int
 {
        rlm_logtee_thread_t     *t = talloc_get_type_abort(uctx, rlm_logtee_thread_t);
 
-       ERROR("Connection failed (%i): %s", sock, fr_syserror(fd_errno));
+       if (fd_errno) ERROR("Connection failed (%i): %s", sock, fr_syserror(fd_errno));
 
        /*
         *      Something bad happened... Fix it...
index 19ae7830c8ea17ae74099952c238fe0964d49793..4de7459efeef465e90fa0b3da27d76a61cc3bf24 100644 (file)
@@ -1025,7 +1025,7 @@ static void conn_error(UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int fla
        connection_t            *conn = tconn->conn;
        bio_handle_t            *h = talloc_get_type_abort(conn->h, bio_handle_t);
 
-       ERROR("%s - Connection %s failed: %s", h->ctx.module_name, h->ctx.fd_info->name, fr_syserror(fd_errno));
+       if (fd_errno) ERROR("%s - Connection %s failed: %s", h->ctx.module_name, h->ctx.fd_info->name, fr_syserror(fd_errno));
 
        connection_signal_reconnect(conn, CONNECTION_FAILED);
 }
index f1c9642fa9e60463a5164cf7c56a3cec546861c2..1b39bb140d1f9631f96fad336a320e1ae36b0f95 100644 (file)
@@ -474,7 +474,7 @@ static void conn_error(UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int fla
        connection_t            *conn = tconn->conn;
        tcp_handle_t            *h = talloc_get_type_abort(conn->h, tcp_handle_t);
 
-       ERROR("%s - Connection %s failed: %s", h->module_name, h->name, fr_syserror(fd_errno));
+       if (fd_errno) ERROR("%s - Connection %s failed: %s", h->module_name, h->name, fr_syserror(fd_errno));
 
        connection_signal_reconnect(conn, CONNECTION_FAILED);
 }