From: Alan T. DeKok Date: Wed, 22 Nov 2017 20:36:06 +0000 (-0500) Subject: start of fixes to mod_write() for dynamic clients X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2bf5ee0ffedb27c8e127e25ee91f68a1ee04b701;p=thirdparty%2Ffreeradius-server.git start of fixes to mod_write() for dynamic clients --- diff --git a/src/modules/proto_radius/proto_radius_udp.c b/src/modules/proto_radius/proto_radius_udp.c index 30bd988d27a..60c83118b3c 100644 --- a/src/modules/proto_radius/proto_radius_udp.c +++ b/src/modules/proto_radius/proto_radius_udp.c @@ -694,6 +694,51 @@ static ssize_t mod_write(void *instance, void *packet_ctx, fr_time_t reply_time; struct timeval tv; + /* + * Check for the first packet back from a dynamic client + * definition. If we find it, add the client (or not), + * as required. + */ + if (inst->dynamic_clients_is_set && address->client->dynamic && !address->client->active) { + RADCLIENT *client = address->client; + fr_dlist_t *entry; + + if (buffer_len == 1) { + while ((entry = FR_DLIST_FIRST(client->packets)) != NULL) { + dynamic_packet_t *saved; + + saved = fr_ptr_to_type(dynamic_packet_t, entry, entry); + (void) fr_radius_tracking_entry_delete(inst->ft, saved->track); + fr_dlist_remove(&saved->entry); + talloc_free(saved); + inst->dynamic_clients.num_pending_packets--; + } + + client_delete(inst->dynamic_clients.clients, client); + client_free(client); /* @todo - fix this to NOT have a FIFO */ + + return buffer_len; + } + + inst->dynamic_clients.num_pending_clients--; + + // @todo - update the client definition, etc... + // @todo - call fr_network_read() + // @todo - cache 'nr' in inst, too.. like proto_detail_file / proto_detail_work + + /* + * Move the packets over to the pending list. + */ + while ((entry = FR_DLIST_FIRST(client->packets)) != NULL) { + fr_dlist_remove(entry); + fr_dlist_insert_tail(&inst->dynamic_clients.pending, entry); + inst->dynamic_clients.num_pending_packets--; + } + + rad_assert(0 == 1); + return buffer_len; + } + /* * The original packet has changed. Suppress the write, * as the client will never accept the response.