The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
Loading...
Searching...
No Matches
proto_load_step.c
Go to the documentation of this file.
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
15 */
16
17/**
18 * $Id: 763d361486fa35dac02fdf0a1ac3f777bede1eee $
19 * @file proto_load_step.c
20 * @brief Generic protocol load generator
21 *
22 * @copyright 2019 The FreeRADIUS server project.
23 * @copyright 2019 Network RADIUS SAS (legal@networkradius.com)
24 */
25#include <netdb.h>
26#include <fcntl.h>
27#include <freeradius-devel/server/protocol.h>
28#include <freeradius-devel/server/main_loop.h>
29#include <freeradius-devel/io/application.h>
30#include <freeradius-devel/io/listen.h>
31#include <freeradius-devel/io/schedule.h>
32#include <freeradius-devel/io/load.h>
33
34#include "proto_load.h"
35
37
39
40/** What to do when the load test is complete
41 *
42 * The test is complete when the PPS ramp has passed max_pps, all
43 * max_requests packets (if set) have been sent, and every reply has
44 * been received.
45 */
46typedef enum {
47 LOAD_STEP_ON_COMPLETE_EXIT = 0, //!< make the server exit
48 LOAD_STEP_ON_COMPLETE_REPEAT, //!< run the test again from start_pps
49 LOAD_STEP_ON_COMPLETE_STOP, //!< stop generating load, leave the server running
50 LOAD_STEP_ON_COMPLETE_CONTINUE //!< never complete, keep sending at max_pps forever
52
54 { L("continue"), LOAD_STEP_ON_COMPLETE_CONTINUE },
55 { L("exit"), LOAD_STEP_ON_COMPLETE_EXIT },
56 { L("repeat"), LOAD_STEP_ON_COMPLETE_REPEAT },
57 { L("stop"), LOAD_STEP_ON_COMPLETE_STOP }
58};
60
61typedef struct {
62 fr_event_list_t *el; //!< event list
63 fr_network_t *nr; //!< network handler
64
65 char const *name; //!< socket name
66 bool done;
68
69 fr_time_t recv_time; //!< recv time of the last packet
70
72 fr_load_t *l; //!< load generation handler
73 fr_load_config_t load; //!< load configuration
74 fr_stats_t stats; //!< statistics for this socket
75
76 int fd; //!< for CSV files
77 fr_timer_t *ev; //!< for writing statistics
78
79 fr_listen_t *parent; //!< master IO handler
81
84
85 CONF_SECTION *cs; //!< our configuration
86
87 char const *filename; //!< where to read input packet from
88 fr_pair_list_t pair_list; //!< for input packet
89
90 int code;
91 uint32_t max_attributes; //!< Limit maximum decodable attributes
92
93 fr_client_t *client; //!< static client
94
95 fr_load_config_t load; //!< load configuration
96 load_step_on_complete_t on_complete; //!< what to do when the load test completes
97 char const *csv; //!< where to write CSV stats
98
99 fr_dict_t const *dict; //!< Our namespace.
100};
101
102
105 { FR_CONF_OFFSET("csv", proto_load_step_t, csv) },
106
107 { FR_CONF_OFFSET("max_attributes", proto_load_step_t, max_attributes), .dflt = STRINGIFY(RADIUS_MAX_ATTRIBUTES) } ,
108
109 { FR_CONF_OFFSET("start_pps", proto_load_step_t, load.start_pps) },
110 { FR_CONF_OFFSET("max_pps", proto_load_step_t, load.max_pps) },
111 { FR_CONF_OFFSET("duration", proto_load_step_t, load.duration) },
112 { FR_CONF_OFFSET("step", proto_load_step_t, load.step) },
113 { FR_CONF_OFFSET("max_backlog", proto_load_step_t, load.milliseconds) },
114 { FR_CONF_OFFSET("parallel", proto_load_step_t, load.parallel) },
115 { FR_CONF_OFFSET("max_requests", proto_load_step_t, load.max_requests) },
116 { FR_CONF_OFFSET("on_complete", proto_load_step_t, on_complete),
119 .dflt = "exit" },
120
122};
123
124
125static ssize_t mod_read(fr_listen_t *li, void **packet_ctx, fr_time_t *recv_time_p, uint8_t *buffer, size_t buffer_len, size_t *leftover)
126{
128 proto_load_step_thread_t *thread = talloc_get_type_abort(li->thread_instance, proto_load_step_thread_t);
129 fr_io_address_t *address, **address_p;
130
131 if (thread->done) return -1;
132
133 /*
134 * Suspend reading on the FD, because we let the timers
135 * take over the load generation.
136 */
137 if (!thread->suspended) {
138 static fr_event_update_t pause[] = {
141 { 0 }
142 };
143
144 if (fr_event_filter_update(thread->el, li->fd, FR_EVENT_FILTER_IO, pause) < 0) {
145 fr_assert(0);
146 }
147
148 thread->suspended = true;
149 }
150
151 *leftover = 0; /* always for load generation */
152
153 /*
154 * Where the addresses should go. This is a special case
155 * for proto_load.
156 */
157 address_p = (fr_io_address_t **) packet_ctx;
158 address = *address_p;
159
160 memset(address, 0, sizeof(*address));
161 address->socket.inet.src_ipaddr.af = AF_INET;
162 address->socket.inet.dst_ipaddr.af = AF_INET;
163 address->radclient = inst->client;
164
165 *recv_time_p = thread->recv_time;
166
167 if (buffer_len < 1) {
168 DEBUG2("proto_load_step read buffer is too small for input packet");
169 return 0;
170 }
171
172 buffer[0] = 0;
173
174 /*
175 * Print out what we received.
176 */
177 DEBUG2("proto_load_step - reading packet for %s",
178 thread->name);
179
180 return 1;
181}
182
183
184/** The load test is complete - apply on_complete
185 *
186 */
188{
189 fr_load_stats_t const *stats = fr_load_generator_stats(thread->l);
190
191 INFO("Load test for %s complete - sent %d packets, received %d replies",
192 thread->name, stats->sent, stats->received);
193
194 switch (thread->inst->on_complete) {
196 INFO("Signalling the server to exit");
197 thread->done = true;
199 break;
200
202 (void) fr_load_generator_stop(thread->l); /* ensure l->ev is gone */
203 (void) fr_load_generator_start(thread->l);
204 break;
205
207 thread->done = true;
208 break;
209
210 /*
211 * The generator never completes when it's told to
212 * continue forever.
213 */
215 fr_assert(0);
216 break;
217 }
218}
219
220/** The generator noticed completion itself, without a final reply.
221 *
222 */
223static void mod_load_done(void *uctx)
224{
225 fr_listen_t *li = uctx;
226 proto_load_step_thread_t *thread = talloc_get_type_abort(li->thread_instance, proto_load_step_thread_t);
227
228 load_complete(thread);
229}
230
231static ssize_t mod_write(fr_listen_t *li, UNUSED void *packet_ctx, fr_time_t request_time,
232 UNUSED uint8_t *buffer, size_t buffer_len, UNUSED size_t written)
233{
234 proto_load_step_thread_t *thread = talloc_get_type_abort(li->thread_instance, proto_load_step_thread_t);
235 fr_load_reply_t state;
236
237 /*
238 * @todo - share a stats interface with the parent? or
239 * put the stats in the listener, so that proto_radius
240 * can update them, too.. <sigh>
241 */
242 thread->stats.total_responses++;
243
244 /*
245 * Tell the load generator subsystem that we have a
246 * reply. If the reply completes the load test, apply
247 * on_complete.
248 */
249 state = fr_load_generator_have_reply(thread->l, request_time);
250 if (state == FR_LOAD_DONE) {
251 load_complete(thread);
252 }
253
254 return buffer_len;
255}
256
257
258/** Open a load listener
259 *
260 */
261static int mod_open(fr_listen_t *li)
262{
264 proto_load_step_thread_t *thread = talloc_get_type_abort(li->thread_instance, proto_load_step_thread_t);
265
266 fr_ipaddr_t ipaddr;
267
268 /*
269 * We never read or write to this file, but we need a
270 * readable FD in order to bootstrap the process.
271 */
272 li->fd = open(inst->filename, O_RDONLY);
273 if (li->fd < 0) {
274 cf_log_err(li->cs, "Failed opening %s - %s", inst->filename, fr_syserror(errno));
275 return -1;
276 }
277
278 memset(&ipaddr, 0, sizeof(ipaddr));
279 ipaddr.af = AF_INET;
280 li->app_io_addr = fr_socket_addr_alloc_inet_src(li, IPPROTO_UDP, 0, &ipaddr, 0);
281
282 fr_assert((cf_parent(inst->cs) != NULL) && (cf_parent(cf_parent(inst->cs)) != NULL)); /* listen { ... } */
283
284 thread->name = talloc_typed_asprintf(thread, "load_step from filename %s", inst->filename);
285 thread->parent = talloc_parent(li);
286
287 return 0;
288}
289
290
291/** Generate traffic.
292 *
293 */
294static int mod_generate(fr_time_t now, void *uctx)
295{
296 fr_listen_t *li = uctx;
297 proto_load_step_thread_t *thread = talloc_get_type_abort(li->thread_instance, proto_load_step_thread_t);
298
299 thread->recv_time = now;
300
301 /*
302 * Tell the network side to call our read routine.
303 */
304 fr_network_listen_read(thread->nr, thread->parent);
305
306 return 0;
307}
308
309
310static void write_stats(fr_timer_list_t *tl, fr_time_t now, void *uctx)
311{
312 proto_load_step_thread_t *thread = uctx;
313 size_t len;
314 char buffer[1024];
315
316 (void) fr_timer_in(thread, tl, &thread->ev, fr_time_delta_from_sec(1), false, write_stats, thread);
317
318 len = fr_load_generator_stats_sprint(thread->l, now, buffer, sizeof(buffer));
319 if (write(thread->fd, buffer, len) < 0) {
320 DEBUG("Failed writing to %s - %s", thread->inst->csv, fr_syserror(errno));
321 }
322}
323
324
325/** Decode the packet
326 *
327 */
328static int mod_decode(void const *instance, request_t *request, UNUSED uint8_t *const data, UNUSED size_t data_len)
329{
331 fr_io_track_t const *track = talloc_get_type_abort_const(request->async->packet_ctx, fr_io_track_t);
332 fr_io_address_t const *address = track->address;
333
334 /*
335 * Hacks for now until we have a lower-level decode routine.
336 */
337 if (inst->code) request->packet->code = inst->code;
338 request->packet->id = fr_rand() & 0xff;
339 request->reply->id = request->packet->id;
340
341 request->packet->data = talloc_zero_array(request->packet, uint8_t, 1);
342 request->packet->data_len = 1;
343
344 (void) fr_pair_list_copy(request->request_ctx, &request->request_pairs, &inst->pair_list);
345
346 /*
347 * Set the rest of the fields.
348 */
349 request->client = UNCONST(fr_client_t *, address->radclient);
350
351 request->packet->socket = address->socket;
352 fr_socket_addr_swap(&request->reply->socket, &address->socket);
353
354 REQUEST_VERIFY(request);
355
356 return 0;
357}
358
359/** Set the event list for a new socket
360 *
361 * @param[in] li the listener
362 * @param[in] el the event list
363 * @param[in] nr context from the network side
364 */
366{
368 proto_load_step_thread_t *thread = talloc_get_type_abort(li->thread_instance, proto_load_step_thread_t);
369 size_t len;
370 char buffer[256];
371
372 thread->el = el;
373 thread->nr = nr;
374 thread->inst = inst;
375 thread->load = inst->load;
376
377 thread->l = fr_load_generator_create(thread, el, &thread->load, mod_generate, mod_load_done, li);
378 if (!thread->l) return;
379
380 (void) fr_load_generator_start(thread->l);
381
382 if (!inst->csv) return;
383
384 thread->fd = open(inst->csv, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0600);
385 if (thread->fd < 0) {
386 ERROR("Failed opening %s - %s", inst->csv, fr_syserror(errno));
387 return;
388 }
389
390 (void) fr_timer_in(thread, thread->el->tl, &thread->ev, fr_time_delta_from_sec(1), false, write_stats, thread);
391
392 len = fr_load_generator_stats_sprint(thread->l, fr_time(), buffer, sizeof(buffer));
393 if (write(thread->fd, buffer, len) < 0) {
394 DEBUG("Failed writing to %s - %s", thread->inst->csv, fr_syserror(errno));
395 }
396}
397
398static char const *mod_name(fr_listen_t *li)
399{
400 proto_load_step_thread_t *thread = talloc_get_type_abort(li->thread_instance, proto_load_step_thread_t);
401
402 return thread->name;
403}
404
405static int mod_instantiate(module_inst_ctx_t const *mctx)
406{
407 proto_load_step_t *inst = talloc_get_type_abort(mctx->mi->data, proto_load_step_t);
408 CONF_SECTION *conf = mctx->mi->conf;
409 fr_client_t *client;
410 fr_pair_t *vp;
411 module_instance_t const *mi = mctx->mi;
412
414 if (!inst->dict) {
415 cf_log_err(conf, "Please define 'namespace' in this virtual server");
416 return -1;
417 }
418
419 fr_pair_list_init(&inst->pair_list);
420 MEM(inst->client = client = talloc_zero(inst, fr_client_t));
421
422 client->ipaddr.af = AF_INET;
423 client->src_ipaddr = client->ipaddr;
424
425 client->longname = client->shortname = inst->filename;
426 client->secret = talloc_strdup(client, "testing123");
427 client->nas_type = talloc_strdup(client, "load");
428 client->use_connected = false;
429
430 if (inst->filename) {
431 FILE *fp;
432 bool done = false;
433
434 fp = fopen(inst->filename, "r");
435 if (!fp) {
436 cf_log_err(conf, "Failed opening %s - %s",
437 inst->filename, fr_syserror(errno));
438 return -1;
439 }
440
441 if (fr_pair_list_afrom_file(inst, inst->dict, &inst->pair_list, fp, &done, true) < 0) {
442 cf_log_perr(conf, "Failed reading %s", inst->filename);
443 fclose(fp);
444 return -1;
445 }
446
447 fclose(fp);
448 }
449
450 inst->parent = talloc_get_type_abort(mi->parent->data, proto_load_t);
451 inst->cs = conf;
452
453 vp = fr_pair_find_by_da(&inst->pair_list, NULL, inst->parent->attr_packet_type);
454 if (vp) inst->code = vp->vp_uint32;
455
456 FR_INTEGER_BOUND_CHECK("start_pps", inst->load.start_pps, >=, 10);
457 FR_INTEGER_BOUND_CHECK("start_pps", inst->load.start_pps, <, 400000);
458
459 FR_INTEGER_BOUND_CHECK("step", inst->load.step, >=, 1);
460 FR_INTEGER_BOUND_CHECK("step", inst->load.step, <, 100000);
461
462 if (inst->load.max_pps > 0) FR_INTEGER_BOUND_CHECK("max_pps", inst->load.max_pps, >, inst->load.start_pps);
463 FR_INTEGER_BOUND_CHECK("max_pps", inst->load.max_pps, <, 400000);
464
465 FR_TIME_DELTA_BOUND_CHECK("duration", inst->load.duration, >=, fr_time_delta_from_sec(1));
466 FR_TIME_DELTA_BOUND_CHECK("duration", inst->load.duration, <, fr_time_delta_from_sec(10000));
467
468
469 FR_INTEGER_BOUND_CHECK("parallel", inst->load.parallel, >=, 1);
470 FR_INTEGER_BOUND_CHECK("parallel", inst->load.parallel, <, 1000);
471
472 FR_INTEGER_BOUND_CHECK("max_backlog", inst->load.milliseconds, >=, 1);
473 FR_INTEGER_BOUND_CHECK("max_backlog", inst->load.milliseconds, <, 100000);
474
475 /*
476 * "continue" means the test never completes, which
477 * contradicts a finite request count.
478 */
479 if (inst->load.max_requests && (inst->on_complete == LOAD_STEP_ON_COMPLETE_CONTINUE)) {
480 cf_log_err(conf, "'max_requests' cannot be used with 'on_complete = continue'");
481 return -1;
482 }
483
484 inst->load.unlimited = (inst->on_complete == LOAD_STEP_ON_COMPLETE_CONTINUE);
485
486 return 0;
487}
488
495
497 .common = {
498 .magic = MODULE_MAGIC_INIT,
499 .name = "load_step",
501 .inst_size = sizeof(proto_load_step_t),
502 .thread_inst_size = sizeof(proto_load_step_thread_t),
503 .instantiate = mod_instantiate
504 },
505 .default_message_size = 4096,
506 .track_duplicates = false,
507
508 .open = mod_open,
509 .read = mod_read,
510 .write = mod_write,
511 .event_list_set = mod_event_list_set,
512 .client_find = mod_client_find,
513 .get_name = mod_name,
514
515 .decode = mod_decode,
516};
static int const char char buffer[256]
Definition acutest.h:576
module_t common
Common fields to all loadable modules.
Definition app_io.h:34
Public structure describing an I/O path for a protocol.
Definition app_io.h:33
#define load(_var)
#define UNCONST(_type, _ptr)
Remove const qualification from a pointer.
Definition build.h:186
#define L(_str)
Helper for initialising arrays of string literals.
Definition build.h:228
#define STRINGIFY(x)
Definition build.h:216
#define UNUSED
Definition build.h:336
#define NUM_ELEMENTS(_t)
Definition build.h:358
int cf_table_parse_int(UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Generic function for parsing conf pair values as int.
Definition cf_parse.c:1724
#define CONF_PARSER_TERMINATOR
Definition cf_parse.h:669
cf_parse_t func
Override default parsing behaviour for the specified type with a custom parsing function.
Definition cf_parse.h:623
#define FR_INTEGER_BOUND_CHECK(_name, _var, _op, _bound)
Definition cf_parse.h:529
#define FR_CONF_OFFSET(_name, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition cf_parse.h:280
#define FR_CONF_OFFSET_FLAGS(_name, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition cf_parse.h:268
#define FR_TIME_DELTA_BOUND_CHECK(_name, _var, _op, _bound)
Definition cf_parse.h:540
@ CONF_FLAG_REQUIRED
Error out if no matching CONF_PAIR is found, and no dflt value is set.
Definition cf_parse.h:429
@ CONF_FLAG_NOT_EMPTY
CONF_PAIR is required to have a non zero length value.
Definition cf_parse.h:447
@ CONF_FLAG_FILE_READABLE
File matching value must exist, and must be readable.
Definition cf_parse.h:435
Defines a CONF_PAIR to C data type mapping.
Definition cf_parse.h:606
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:106
CONF_ITEM * cf_section_to_item(CONF_SECTION const *cs)
Cast a CONF_SECTION to a CONF_ITEM.
Definition cf_util.c:746
#define cf_log_err(_cf, _fmt,...)
Definition cf_util.h:345
#define cf_parent(_cf)
Definition cf_util.h:118
#define cf_log_perr(_cf, _fmt,...)
Definition cf_util.h:352
#define MEM(x)
Definition debug.h:36
#define ERROR(fmt,...)
Definition dhcpclient.c:40
#define DEBUG(fmt,...)
Definition dhcpclient.c:38
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition dl_module.h:63
@ FR_EVENT_FILTER_IO
Combined filter for read/write functions/.
Definition event.h:83
#define fr_event_filter_update(...)
Definition event.h:239
#define FR_EVENT_SUSPEND(_s, _f)
Temporarily remove the filter for a func from kevent.
Definition event.h:115
Callbacks for the FR_EVENT_FILTER_IO filter.
Definition event.h:188
Structure describing a modification to a filter's state.
Definition event.h:96
int af
Address family.
Definition inet.h:63
IPv4/6 prefix.
fr_socket_t socket
src/dst ip and port.
Definition base.h:336
fr_client_t const * radclient
old-style client definition
Definition base.h:338
CONF_SECTION * cs
of this listener
Definition listen.h:41
fr_socket_t * app_io_addr
for tracking duplicate sockets
Definition listen.h:36
void const * app_io_instance
I/O path configuration context.
Definition listen.h:33
void * thread_instance
thread / socket context
Definition listen.h:34
int fd
file descriptor for this socket - set by open
Definition listen.h:28
void fr_network_listen_read(fr_network_t *nr, fr_listen_t *li)
Signal the network to read from a listener.
Definition network.c:331
fr_ipaddr_t ipaddr
IPv4/IPv6 address of the host.
Definition client.h:83
char const * secret
Secret PSK.
Definition client.h:90
fr_ipaddr_t src_ipaddr
IPv4/IPv6 address to send responses from (family must match ipaddr).
Definition client.h:84
char const * nas_type
Type of client (arbitrary).
Definition client.h:131
char const * longname
Client identifier.
Definition client.h:87
char const * shortname
Client nickname.
Definition client.h:88
bool use_connected
do we use connected sockets for this client
Definition client.h:121
Describes a host allowed to send packets to the server.
Definition client.h:80
uint64_t total_responses
Definition stats.h:38
#define fr_time()
Definition event.c:60
Stores all information relating to an event list.
Definition event.c:377
fr_load_stats_t const * fr_load_generator_stats(fr_load_t const *l)
Definition load.c:452
int fr_load_generator_start(fr_load_t *l)
Start the load generator.
Definition load.c:277
int fr_load_generator_stop(fr_load_t *l)
Stop the load generation through the simple expedient of deleting the timer associated with it.
Definition load.c:312
fr_load_t * fr_load_generator_create(TALLOC_CTX *ctx, fr_event_list_t *el, fr_load_config_t *config, fr_load_callback_t callback, fr_load_done_callback_t done, void *uctx)
Definition load.c:90
size_t fr_load_generator_stats_sprint(fr_load_t *l, fr_time_t now, char *buffer, size_t buflen)
Print load generator statistics in CVS format.
Definition load.c:406
fr_load_reply_t fr_load_generator_have_reply(fr_load_t *l, fr_time_t request_time)
Tell the load generator that we have a reply to a packet we sent.
Definition load.c:324
int sent
total packets sent
Definition load.h:104
int received
total packets received (should be == sent)
Definition load.h:105
fr_load_reply_t
Whether or not the application should continue.
Definition load.h:118
@ FR_LOAD_DONE
the load generator is done
Definition load.h:120
Load generation configuration.
Definition load.h:85
void main_loop_signal_raise(int flag)
Definition main_loop.c:78
@ RADIUS_SIGNAL_SELF_TERM
Definition main_loop.h:37
fr_io_address_t const * address
of this packet.. shared between multiple packets
Definition master.h:55
unsigned int uint32_t
long int ssize_t
unsigned char uint8_t
module_instance_t * mi
Instance of the module being instantiated.
Definition module_ctx.h:51
Temporary structure to hold arguments for instantiation calls.
Definition module_ctx.h:50
int fr_pair_list_copy(TALLOC_CTX *ctx, fr_pair_list_t *to, fr_pair_list_t const *from)
Duplicate a list of pairs.
Definition pair.c:2326
fr_pair_t * fr_pair_find_by_da(fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
Find the first pair with a matching da.
Definition pair.c:707
void fr_pair_list_init(fr_pair_list_t *list)
Initialise a pair list header.
Definition pair.c:46
int fr_pair_list_afrom_file(TALLOC_CTX *ctx, fr_dict_t const *dict, fr_pair_list_t *out, FILE *fp, bool *pfiledone, bool allow_exec)
Read valuepairs from the fp up to End-Of-File.
Load master protocol handler.
fr_app_io_t proto_load_step
fr_listen_t * parent
master IO handler
fr_timer_t * ev
for writing statistics
fr_client_t * client
static client
fr_pair_list_t pair_list
for input packet
fr_load_config_t load
load configuration
static ssize_t mod_read(fr_listen_t *li, void **packet_ctx, fr_time_t *recv_time_p, uint8_t *buffer, size_t buffer_len, size_t *leftover)
static const conf_parser_t load_listen_config[]
CONF_SECTION * cs
our configuration
proto_load_step_t const * inst
static int mod_decode(void const *instance, request_t *request, UNUSED uint8_t *const data, UNUSED size_t data_len)
Decode the packet.
fr_load_config_t load
load configuration
char const * filename
where to read input packet from
uint32_t max_attributes
Limit maximum decodable attributes.
struct proto_load_step_s proto_load_step_t
static size_t load_on_complete_table_len
static fr_table_num_sorted_t const load_on_complete_table[]
char const * csv
where to write CSV stats
static ssize_t mod_write(fr_listen_t *li, UNUSED void *packet_ctx, fr_time_t request_time, UNUSED uint8_t *buffer, size_t buffer_len, UNUSED size_t written)
fr_stats_t stats
statistics for this socket
static void mod_event_list_set(fr_listen_t *li, fr_event_list_t *el, void *nr)
Set the event list for a new socket.
static int mod_open(fr_listen_t *li)
Open a load listener.
fr_time_t recv_time
recv time of the last packet
fr_load_t * l
load generation handler
load_step_on_complete_t
What to do when the load test is complete.
@ LOAD_STEP_ON_COMPLETE_REPEAT
run the test again from start_pps
@ LOAD_STEP_ON_COMPLETE_STOP
stop generating load, leave the server running
@ LOAD_STEP_ON_COMPLETE_EXIT
make the server exit
@ LOAD_STEP_ON_COMPLETE_CONTINUE
never complete, keep sending at max_pps forever
static void mod_load_done(void *uctx)
The generator noticed completion itself, without a final reply.
static void load_complete(proto_load_step_thread_t *thread)
The load test is complete - apply on_complete.
fr_dict_t const * dict
Our namespace.
fr_network_t * nr
network handler
static int mod_generate(fr_time_t now, void *uctx)
Generate traffic.
load_step_on_complete_t on_complete
what to do when the load test completes
fr_event_list_t * el
event list
static char const * mod_name(fr_listen_t *li)
static int mod_instantiate(module_inst_ctx_t const *mctx)
char const * name
socket name
static void write_stats(fr_timer_list_t *tl, fr_time_t now, void *uctx)
proto_load_t * parent
static fr_client_t * mod_client_find(fr_listen_t *li, UNUSED fr_ipaddr_t const *ipaddr, UNUSED int ipproto)
#define fr_assert(_expr)
Definition rad_assert.h:37
static int ipproto
#define DEBUG2(fmt,...)
static bool done
Definition radclient.c:80
#define INFO(fmt,...)
Definition radict.c:63
#define RADIUS_MAX_ATTRIBUTES
Definition radius.h:39
static rs_t * conf
Definition radsniff.c:52
uint32_t fr_rand(void)
Return a 32-bit random number.
Definition rand.c:104
#define REQUEST_VERIFY(_x)
Definition request.h:311
CONF_SECTION * conf
Module's instance configuration.
Definition module.h:351
void * data
Module's instance data.
Definition module.h:293
module_instance_t const * parent
Parent module's instance (if any).
Definition module.h:359
conf_parser_t const * config
How to convert a CONF_SECTION to a module instance.
Definition module.h:206
Module instance data.
Definition module.h:287
eap_aka_sim_process_conf_t * inst
fr_pair_t * vp
Stores an attribute, a value and various bits of other data.
Definition pair.h:68
char const * fr_syserror(int num)
Guaranteed to be thread-safe version of strerror.
Definition syserror.c:243
An element in a lexicographically sorted array of name to num mappings.
Definition table.h:49
char * talloc_typed_asprintf(TALLOC_CTX *ctx, char const *fmt,...)
Call talloc vasprintf, setting the type on the new chunk correctly.
Definition talloc.c:546
#define talloc_get_type_abort_const
Definition talloc.h:117
#define talloc_strdup(_ctx, _str)
Definition talloc.h:149
static fr_time_delta_t fr_time_delta_from_sec(int64_t sec)
Definition time.h:590
"server local" time.
Definition time.h:69
An event timer list.
Definition timer.c:49
A timer event.
Definition timer.c:83
#define fr_timer_in(...)
Definition timer.h:87
static fr_event_list_t * el
static fr_socket_t * fr_socket_addr_alloc_inet_src(TALLOC_CTX *ctx, int proto, int ifindex, fr_ipaddr_t const *ipaddr, int port)
A variant of fr_socket_addr_init_inet_src will also allocates a fr_socket_t.
Definition socket.h:241
int af
AF_INET, AF_INET6, or AF_UNIX.
Definition socket.h:75
static void fr_socket_addr_swap(fr_socket_t *dst, fr_socket_t const *src)
Swap src/dst information of a fr_socket_t.
Definition socket.h:118
static fr_slen_t data
Definition value.h:1340
fr_dict_t const * virtual_server_dict_by_child_ci(CONF_ITEM const *ci)
Return the namespace for a given virtual server specified by a CONF_ITEM within the virtual server.