Skip to content

Commit

Permalink
catch more corner cases when using check_client_connections=yes
Browse files Browse the repository at this point in the history
  • Loading branch information
alandekok committed Jan 3, 2025
1 parent 8c2fb84 commit a9355b7
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion src/main/tls_listen.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,8 +750,16 @@ static int tls_socket_recv(rad_listen_t *listener)
return 1;
}

static int dual_tls_recv_internal(rad_listen_t *listener);

int dual_tls_recv(rad_listen_t *listener)
{
if (listener->status != RAD_LISTEN_STATUS_KNOWN) return 0;

return dual_tls_recv_internal(listener);
}

static int dual_tls_recv_internal(rad_listen_t *listener)
{
RADIUS_PACKET *packet;
RAD_REQUEST_FUNP fun = NULL;
Expand Down Expand Up @@ -914,7 +922,33 @@ int dual_tls_send(rad_listen_t *listener, REQUEST *request)
rad_assert(request->listener == listener);
rad_assert(listener->send == dual_tls_send);

if (listener->status != RAD_LISTEN_STATUS_KNOWN) return 0;
/*
* If the socket is vaguely alive, then write to it.
* Otherwise it's dead, and we don't do anything.
*/
switch (listener->status) {
case RAD_LISTEN_STATUS_KNOWN:
case RAD_LISTEN_STATUS_FROZEN:
case RAD_LISTEN_STATUS_PAUSE:
case RAD_LISTEN_STATUS_RESUME:
break;

case RAD_LISTEN_STATUS_INIT:
case RAD_LISTEN_STATUS_EOL:
case RAD_LISTEN_STATUS_REMOVE_NOW:
return 0;
}

/*
* We're trying to send a reply to the "check
* client connection" packet. Instead, just
* finish the session setup.
*/
if (sock->state == LISTEN_TLS_SETUP) {
RDEBUG("(TLS) Finishing session setup");
(void) dual_tls_recv_internal(listener);
return 0;
}

/*
* See if the policies allowed this connection.
Expand Down

0 comments on commit a9355b7

Please sign in to comment.