From: Alan T. DeKok Date: Thu, 23 Nov 2017 19:37:05 +0000 (-0500) Subject: more cleanups for dynamic clients X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c3cceb15aaa2b22343b6dce342fd92d9160b14b2;p=thirdparty%2Ffreeradius-server.git more cleanups for dynamic clients --- diff --git a/src/include/clients.h b/src/include/clients.h index 5d79e089cb9..1c6c2a634e6 100644 --- a/src/include/clients.h +++ b/src/include/clients.h @@ -86,6 +86,7 @@ typedef struct radclient { uint32_t lifetime; //!< How long before the client is removed. uint32_t outstanding; //!< number of requests outstanding time_t created; //!< When the client was created. + fr_ipaddr_t network; //!< encapsulating network #endif } RADCLIENT; @@ -151,10 +152,6 @@ RADCLIENT *client_find(RADCLIENT_LIST const *clients, fr_ipaddr_t const *ipaddr, RADCLIENT *client_findbynumber(RADCLIENT_LIST const *clients, int number); -RADCLIENT *client_find_old(fr_ipaddr_t const *ipaddr); - -bool client_add_dynamic(RADCLIENT_LIST *clients, RADCLIENT *master, RADCLIENT *c); - RADCLIENT *client_read(char const *filename, CONF_SECTION *server_cs, bool check_dns); #ifdef __cplusplus } diff --git a/src/main/client.c b/src/main/client.c index f3943db6375..ac3013b991c 100644 --- a/src/main/client.c +++ b/src/main/client.c @@ -371,14 +371,6 @@ RADCLIENT *client_find(RADCLIENT_LIST const *clients, fr_ipaddr_t const *ipaddr, return NULL; } -/* - * Old wrapper for client_find - */ -RADCLIENT *client_find_old(fr_ipaddr_t const *ipaddr) -{ - return client_find(root_clients, ipaddr, IPPROTO_UDP); -} - static fr_ipaddr_t cl_ipaddr; static char const *cl_srcipaddr = NULL; #ifdef WITH_TCP @@ -533,7 +525,7 @@ static const CONF_PARSER dynamic_config[] = { /** Add a dynamic client * */ -bool client_add_dynamic(RADCLIENT_LIST *clients, RADCLIENT *master, RADCLIENT *c) +static bool client_add_dynamic(RADCLIENT_LIST *clients, RADCLIENT *master, RADCLIENT *c) { char buffer[128]; diff --git a/src/modules/proto_radius/proto_radius_udp.c b/src/modules/proto_radius/proto_radius_udp.c index 684cb5f860b..1133d40f982 100644 --- a/src/modules/proto_radius/proto_radius_udp.c +++ b/src/modules/proto_radius/proto_radius_udp.c @@ -402,7 +402,7 @@ static int dynamic_client_packet_save(proto_radius_udp_t *inst, uint8_t *packet, static ssize_t dynamic_client_alloc(proto_radius_udp_t *inst, uint8_t *packet, size_t packet_len, - proto_radius_udp_address_t *address, fr_tracking_entry_t **track, UNUSED fr_ipaddr_t *network) + proto_radius_udp_address_t *address, fr_tracking_entry_t **track, fr_ipaddr_t *network) { RADCLIENT *client; @@ -437,6 +437,7 @@ static ssize_t dynamic_client_alloc(proto_radius_udp_t *inst, uint8_t *packet, s client->ipaddr = address->src_ipaddr; client->src_ipaddr = address->dst_ipaddr; + client->network = *network; address->client = client; @@ -759,14 +760,14 @@ static ssize_t mod_write(void *instance, void *packet_ctx, } client_delete(inst->dynamic_clients.clients, client); - client_free(client); /* @todo - fix this to NOT have a FIFO */ + client_free(client); return buffer_len; } inst->dynamic_clients.num_pending_clients--; - // @todo - update the client definition, etc... + // @todo - create / pack the client definition... /* * This particular packet had a later one @@ -1113,8 +1114,6 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs) } } - // @todo - sanity check parameters - parent_inst = cf_data_value(cf_data_find(cf_parent(cs), dl_instance_t, "proto_radius")); rad_assert(parent_inst != NULL); @@ -1131,6 +1130,15 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs) * Allow static clients for this virtual server. */ inst->dynamic_clients.clients = client_list_init(NULL); // client_list_parse_section(inst->parent->server_cs, false); + + FR_INTEGER_BOUND_CHECK("max_clients", inst->dynamic_clients.max_clients, >=, 1); + FR_INTEGER_BOUND_CHECK("max_clients", inst->dynamic_clients.max_clients, <=, (1 << 20)); + + FR_INTEGER_BOUND_CHECK("max_pending_clients", inst->dynamic_clients.max_pending_clients, >=, 4); + FR_INTEGER_BOUND_CHECK("max_pending_clients", inst->dynamic_clients.max_pending_clients, <=, 2048); + + FR_INTEGER_BOUND_CHECK("max_pending_packets", inst->dynamic_clients.max_pending_clients, >=, 256); + FR_INTEGER_BOUND_CHECK("max_pending_packets", inst->dynamic_clients.max_pending_clients, <=, 65536); } return 0;