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: 55fe4c0b453ac9f73bc48378ba4463800c134993 $
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/main_loop.h>
28#include <freeradius-devel/io/application.h>
29#include <freeradius-devel/io/listen.h>
30#include <freeradius-devel/io/schedule.h>
31#include <freeradius-devel/io/load.h>
32
33#include "proto_load.h"
34
36
38
39/** What to do when the load test is complete
40 *
41 * The test is complete when the PPS ramp has passed max_pps, all
42 * max_requests packets (if set) have been sent, and every reply has
43 * been received.
44 */
45typedef enum {
46 LOAD_STEP_ON_COMPLETE_EXIT = 0, //!< make the server exit
47 LOAD_STEP_ON_COMPLETE_REPEAT, //!< run the test again from start_pps
48 LOAD_STEP_ON_COMPLETE_STOP, //!< stop generating load, leave the server running
49 LOAD_STEP_ON_COMPLETE_CONTINUE //!< never complete, keep sending at max_pps forever
51
53 { L("continue"), LOAD_STEP_ON_COMPLETE_CONTINUE },
54 { L("exit"), LOAD_STEP_ON_COMPLETE_EXIT },
55 { L("repeat"), LOAD_STEP_ON_COMPLETE_REPEAT },
56 { L("stop"), LOAD_STEP_ON_COMPLETE_STOP }
57};
59
60typedef struct {
61 fr_event_list_t *el; //!< event list
62 fr_network_t *nr; //!< network handler
63
64 char const *name; //!< socket name
65 bool done;
67
68 fr_time_t recv_time; //!< recv time of the last packet
69
71 fr_load_t *l; //!< load generation handler
72 fr_load_config_t load; //!< load configuration
73 fr_stats_t stats; //!< statistics for this socket
74
75 int fd; //!< for CSV files
76 fr_timer_t *ev; //!< for writing statistics
77
78 fr_listen_t *parent; //!< master IO handler
80
83
84 CONF_SECTION *cs; //!< our configuration
85
86 char const *filename; //!< where to read input packet from
87 fr_pair_list_t pair_list; //!< for input packet
88
89 int code;
90 uint32_t max_attributes; //!< Limit maximum decodable attributes
91
92 fr_client_t *client; //!< static client
93
94 fr_load_config_t load; //!< load configuration
95 load_step_on_complete_t on_complete; //!< what to do when the load test completes
96 char const *csv; //!< where to write CSV stats
97
98 fr_dict_t const *dict; //!< Our namespace.
99};
100
101
104 { FR_CONF_OFFSET("csv", proto_load_step_t, csv) },
105
106 { FR_CONF_OFFSET("max_attributes", proto_load_step_t, max_attributes), .dflt = STRINGIFY(RADIUS_MAX_ATTRIBUTES) } ,
107
108 { FR_CONF_OFFSET("start_pps", proto_load_step_t, load.start_pps) },
109 { FR_CONF_OFFSET("max_pps", proto_load_step_t, load.max_pps) },
110 { FR_CONF_OFFSET("duration", proto_load_step_t, load.duration) },
111 { FR_CONF_OFFSET("step", proto_load_step_t, load.step) },
112 { FR_CONF_OFFSET("max_backlog", proto_load_step_t, load.milliseconds) },
113 { FR_CONF_OFFSET("parallel", proto_load_step_t, load.parallel) },
114 { FR_CONF_OFFSET("max_requests", proto_load_step_t, load.max_requests) },
115 { FR_CONF_OFFSET("on_complete", proto_load_step_t, on_complete),
118 .dflt = "exit" },
119
121};
122
123
124static 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)
125{
127 proto_load_step_thread_t *thread = talloc_get_type_abort(li->thread_instance, proto_load_step_thread_t);
128 fr_io_address_t *address, **address_p;
129
130 if (thread->done) return -1;
131
132 /*
133 * Suspend reading on the FD, because we let the timers
134 * take over the load generation.
135 */
136 if (!thread->suspended) {
137 static fr_event_update_t pause[] = {
140 { 0 }
141 };
142
143 if (fr_event_filter_update(thread->el, li->fd, FR_EVENT_FILTER_IO, pause) < 0) {
144 fr_assert(0);
145 }
146
147 thread->suspended = true;
148 return 0;
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);
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/** Close a virtual listener
360 *
361 * The fd only exists to bootstrap the listener, so closing it mostly means
362 * removing the timer that drives the load generator.
363 *
364 * @param[in] li the listener
365 * @return
366 * - 0 on success.
367 * - -1 if the generator could not be stopped. The fd is closed either way.
368 */
369static int mod_close(fr_listen_t *li)
370{
371 proto_load_step_thread_t *thread = talloc_get_type_abort(li->thread_instance, proto_load_step_thread_t);
372 int ret = 0;
373
374 if (thread->l && (fr_load_generator_stop(thread->l) < 0)) {
375 PERROR("Failed stopping load generator");
376 ret = -1;
377 }
378
379 close(li->fd);
380
381 return ret;
382}
383
384/** Set the event list for a new socket
385 *
386 * @param[in] li the listener
387 * @param[in] el the event list
388 * @param[in] nr context from the network side
389 */
391{
393 proto_load_step_thread_t *thread = talloc_get_type_abort(li->thread_instance, proto_load_step_thread_t);
394 size_t len;
395 char buffer[256];
396
397 thread->el = el;
398 thread->nr = nr;
399 thread->inst = inst;
400 thread->load = inst->load;
401
402 thread->l = fr_load_generator_create(thread, el, &thread->load, mod_generate, mod_load_done, li);
403 if (!thread->l) return;
404
405 (void) fr_load_generator_start(thread->l);
406
407 if (!inst->csv) return;
408
409 thread->fd = open(inst->csv, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0600);
410 if (thread->fd < 0) {
411 ERROR("Failed opening %s - %s", inst->csv, fr_syserror(errno));
412 return;
413 }
414
415 (void) fr_timer_in(thread, thread->el->tl, &thread->ev, fr_time_delta_from_sec(1), false, write_stats, thread);
416
417 len = fr_load_generator_stats_sprint(thread->l, fr_time(), buffer, sizeof(buffer));
418 if (write(thread->fd, buffer, len) < 0) {
419 DEBUG("Failed writing to %s - %s", thread->inst->csv, fr_syserror(errno));
420 }
421}
422
423static char const *mod_name(fr_listen_t *li)
424{
425 proto_load_step_thread_t *thread = talloc_get_type_abort(li->thread_instance, proto_load_step_thread_t);
426
427 return thread->name;
428}
429
430static int mod_instantiate(module_inst_ctx_t const *mctx)
431{
432 proto_load_step_t *inst = talloc_get_type_abort(mctx->mi->data, proto_load_step_t);
433 CONF_SECTION *conf = mctx->mi->conf;
434 fr_client_t *client;
435 fr_pair_t *vp;
436 module_instance_t const *mi = mctx->mi;
437
439 if (!inst->dict) {
440 cf_log_err(conf, "Please define 'namespace' in this virtual server");
441 return -1;
442 }
443
444 fr_pair_list_init(&inst->pair_list);
445 MEM(inst->client = client = talloc_zero(inst, fr_client_t));
446
447 client->ipaddr.af = AF_INET;
448 client->src_ipaddr = client->ipaddr;
449
450 client->longname = client->shortname = inst->filename;
451 client->secret = talloc_strdup(client, "testing123");
452 client->nas_type = talloc_strdup(client, "load");
453 client->use_connected = false;
454
455 if (inst->filename) {
456 FILE *fp;
457 bool done = false;
458
459 fp = fopen(inst->filename, "r");
460 if (!fp) {
461 cf_log_err(conf, "Failed opening %s - %s",
462 inst->filename, fr_syserror(errno));
463 return -1;
464 }
465
466 if (fr_pair_list_afrom_file(inst, inst->dict, &inst->pair_list, fp, &done, true) < 0) {
467 cf_log_perr(conf, "Failed reading %s", inst->filename);
468 fclose(fp);
469 return -1;
470 }
471
472 fclose(fp);
473 }
474
475 inst->parent = talloc_get_type_abort(mi->parent->data, proto_load_t);
476 inst->cs = conf;
477
478 vp = fr_pair_find_by_da(&inst->pair_list, NULL, inst->parent->attr_packet_type);
479 if (vp) inst->code = vp->vp_uint32;
480
481 FR_INTEGER_BOUND_CHECK("start_pps", inst->load.start_pps, >=, 10);
482 FR_INTEGER_BOUND_CHECK("start_pps", inst->load.start_pps, <, 400000);
483
484 FR_INTEGER_BOUND_CHECK("step", inst->load.step, >=, 1);
485 FR_INTEGER_BOUND_CHECK("step", inst->load.step, <, 100000);
486
487 if (inst->load.max_pps > 0) FR_INTEGER_BOUND_CHECK("max_pps", inst->load.max_pps, >, inst->load.start_pps);
488 FR_INTEGER_BOUND_CHECK("max_pps", inst->load.max_pps, <, 400000);
489
490 FR_TIME_DELTA_BOUND_CHECK("duration", inst->load.duration, >=, fr_time_delta_from_sec(1));
491 FR_TIME_DELTA_BOUND_CHECK("duration", inst->load.duration, <, fr_time_delta_from_sec(10000));
492
493
494 FR_INTEGER_BOUND_CHECK("parallel", inst->load.parallel, >=, 1);
495 FR_INTEGER_BOUND_CHECK("parallel", inst->load.parallel, <, 1000);
496
497 FR_INTEGER_BOUND_CHECK("max_backlog", inst->load.milliseconds, >=, 1);
498 FR_INTEGER_BOUND_CHECK("max_backlog", inst->load.milliseconds, <, 100000);
499
500 /*
501 * "continue" means the test never completes, which
502 * contradicts a finite request count.
503 */
504 if (inst->load.max_requests && (inst->on_complete == LOAD_STEP_ON_COMPLETE_CONTINUE)) {
505 cf_log_err(conf, "'max_requests' cannot be used with 'on_complete = continue'");
506 return -1;
507 }
508
509 inst->load.unlimited = (inst->on_complete == LOAD_STEP_ON_COMPLETE_CONTINUE);
510
511 return 0;
512}
513
520
522 .common = {
523 .magic = MODULE_MAGIC_INIT,
524 .name = "load_step",
526 .inst_size = sizeof(proto_load_step_t),
527 .thread_inst_size = sizeof(proto_load_step_thread_t),
528 .instantiate = mod_instantiate
529 },
530 .default_message_size = 4096,
531 .track_duplicates = false,
532
533 .open = mod_open,
534 .close = mod_close,
535 .read = mod_read,
536 .write = mod_write,
537 .event_list_set = mod_event_list_set,
538 .client_find = mod_client_find,
539 .get_name = mod_name,
540
541 .decode = mod_decode,
542};
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:384
#define NUM_ELEMENTS(_t)
Definition build.h:406
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:749
#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:38
#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:64
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
void fr_network_listen_read(fr_network_t *nr, fr_listen_t *li)
Signal the network to read from a listener.
Definition network.c:335
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:125
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:115
Describes a host allowed to send packets to the server.
Definition client.h:80
#define PERROR(_fmt,...)
Definition log.h:233
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
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
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.
#define O_CLOEXEC
Definition posix.c:49
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_close(fr_listen_t *li)
Close a virtual listener.
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:310
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
void * state
Definition testlib.c:46
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:249
int af
AF_INET, AF_INET6, or AF_UNIX.
Definition socket.h:83
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:126
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.