From: Alan T. DeKok Date: Thu, 14 Mar 2024 14:29:41 +0000 (-0400) Subject: more attempts to get the retry bio working X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=61d316f0efef6ca0e3b9f32d4f0e3726e702fbbc;p=thirdparty%2Ffreeradius-server.git more attempts to get the retry bio working we still have to make radclient-ng use the event loop, and do a few other cleanups. Hopefully after that happens, we can start testing the bios --- diff --git a/src/protocols/radius/client.c b/src/protocols/radius/client.c index 56192a26629..1d911436d6a 100644 --- a/src/protocols/radius/client.c +++ b/src/protocols/radius/client.c @@ -29,6 +29,11 @@ RCSID("$Id$") #include #include +static void radius_client_retry_sent(fr_bio_t *bio, void *packet_ctx, const void *buffer, UNUSED size_t size, + fr_bio_retry_entry_t *retry_ctx); +static bool radius_client_retry_response(fr_bio_t *bio, fr_bio_retry_entry_t **retry_ctx_p, UNUSED void *packet_ctx, const void *buffer, UNUSED size_t size); +static void radius_client_retry_release(fr_bio_t *bio, fr_bio_retry_entry_t *retry_ctx, UNUSED fr_bio_retry_release_reason_t reason); + fr_bio_packet_t *fr_radius_client_bio_alloc(TALLOC_CTX *ctx, fr_radius_client_config_t *cfg, fr_bio_fd_config_t const *fd_cfg) { fr_assert(fd_cfg->type == FR_BIO_FD_CONNECTED); @@ -87,9 +92,14 @@ fr_radius_client_fd_bio_t *fr_radius_client_fd_bio_alloc(TALLOC_CTX *ctx, size_t my->mem = fr_bio_mem_alloc(my, read_size, 2 * 4096, my->fd); if (!my->mem) goto fail; + my->mem->uctx = &my->cfg.verify; + my->retry = fr_bio_retry_alloc(my, 256, radius_client_retry_sent, radius_client_retry_response, + NULL, radius_client_retry_release, &cfg->retry_cfg, my->mem); + if (!my->retry) goto fail; + my->retry->uctx = my; + my->cfg = *cfg; - my->mem->uctx = &my->cfg.verify; my->common.bio = my->mem; @@ -148,7 +158,6 @@ int fr_radius_client_fd_bio_write(fr_radius_client_fd_bio_t *my, void *request_c return 0; } -#if 1 static const fr_radius_packet_code_t allowed_replies[FR_RADIUS_CODE_MAX] = { [FR_RADIUS_CODE_ACCESS_ACCEPT] = FR_RADIUS_CODE_ACCESS_REQUEST, [FR_RADIUS_CODE_ACCESS_CHALLENGE] = FR_RADIUS_CODE_ACCESS_REQUEST, @@ -241,7 +250,6 @@ static void radius_client_retry_release(fr_bio_t *bio, fr_bio_retry_entry_t *ret fr_radius_code_id_push(my->codes, id_ctx->packet); } -#endif int fr_radius_client_fd_bio_read(fr_bio_packet_t *bio, void **request_ctx_p, fr_packet_t **packet_p, TALLOC_CTX *out_ctx, fr_pair_list_t *out) diff --git a/src/protocols/radius/client.h b/src/protocols/radius/client.h index 7ec66336e7d..df5a9c6c542 100644 --- a/src/protocols/radius/client.h +++ b/src/protocols/radius/client.h @@ -34,6 +34,8 @@ RCSIDH(radius_client_h, "$Id$") typedef struct { fr_radius_bio_verify_t verify; + fr_bio_retry_config_t retry_cfg; + bool allowed[FR_RADIUS_CODE_MAX]; //!< allowed outgoing packet types fr_retry_config_t retry[FR_RADIUS_CODE_MAX]; //!< default retry configuration for each packet type