2015-04-13 17:08:16 -04:00
|
|
|
/*
|
2020-06-11 03:23:02 -04:00
|
|
|
* Datagram processing functions
|
2015-04-13 17:08:16 -04:00
|
|
|
*
|
|
|
|
|
* Copyright 2014 Baptiste Assmann <bedis9@gmail.com>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
|
* 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2020-06-03 13:33:00 -04:00
|
|
|
#include <haproxy/fd.h>
|
2023-10-03 09:33:46 -04:00
|
|
|
#include <haproxy/cfgparse.h>
|
2020-06-11 03:23:02 -04:00
|
|
|
#include <haproxy/dgram.h>
|
2023-10-03 09:33:46 -04:00
|
|
|
#include <haproxy/errors.h>
|
|
|
|
|
#include <haproxy/tools.h>
|
2015-04-13 17:08:16 -04:00
|
|
|
|
|
|
|
|
/* datagram handler callback */
|
2016-04-14 05:13:20 -04:00
|
|
|
void dgram_fd_handler(int fd)
|
2015-04-13 17:08:16 -04:00
|
|
|
{
|
|
|
|
|
struct dgram_conn *dgram = fdtab[fd].owner;
|
|
|
|
|
|
|
|
|
|
if (unlikely(!dgram))
|
2016-04-14 05:13:20 -04:00
|
|
|
return;
|
2015-04-13 17:08:16 -04:00
|
|
|
|
|
|
|
|
if (fd_recv_ready(fd))
|
|
|
|
|
dgram->data->recv(dgram);
|
2019-12-10 12:12:04 -05:00
|
|
|
if (fd_send_ready(fd))
|
2015-04-13 17:08:16 -04:00
|
|
|
dgram->data->send(dgram);
|
|
|
|
|
|
2016-04-14 05:13:20 -04:00
|
|
|
return;
|
2015-04-13 17:08:16 -04:00
|
|
|
}
|
2023-10-03 09:33:46 -04:00
|
|
|
|
|
|
|
|
/* config parser for global "tune.{rcv,snd}buf.{frontend,backend}" */
|
|
|
|
|
static int dgram_parse_tune_bufs(char **args, int section_type, struct proxy *curpx,
|
|
|
|
|
const struct proxy *defpx, const char *file, int line,
|
|
|
|
|
char **err)
|
|
|
|
|
{
|
2024-11-18 12:50:02 -05:00
|
|
|
const char *res;
|
|
|
|
|
uint *valptr;
|
|
|
|
|
uint val;
|
2023-10-03 09:33:46 -04:00
|
|
|
|
|
|
|
|
if (too_many_args(1, args, err, NULL))
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
/* "tune.rcvbuf.frontend", "tune.rcvbuf.backend",
|
|
|
|
|
* "tune.sndbuf.frontend", "tune.sndbuf.backend"
|
|
|
|
|
*/
|
|
|
|
|
valptr = (args[0][5] == 'r' && args[0][12] == 'f') ? &global.tune.frontend_rcvbuf :
|
|
|
|
|
(args[0][5] == 'r' && args[0][12] == 'b') ? &global.tune.backend_rcvbuf :
|
|
|
|
|
(args[0][5] == 's' && args[0][12] == 'f') ? &global.tune.frontend_sndbuf :
|
|
|
|
|
&global.tune.backend_sndbuf;
|
|
|
|
|
|
|
|
|
|
if (*valptr != 0) {
|
|
|
|
|
memprintf(err, "parsing [%s:%d] : ignoring '%s' which was already specified.\n", file, line, args[0]);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-18 12:50:02 -05:00
|
|
|
res = parse_size_err(args[1], &val);
|
|
|
|
|
if (res != NULL) {
|
|
|
|
|
memprintf(err, "parsing [%s:%d]: unexpected '%s' after size passed to '%s'", file, line, res, args[0]);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2023-10-03 09:33:46 -04:00
|
|
|
|
|
|
|
|
if (*(args[1]) == 0 || val <= 0) {
|
|
|
|
|
memprintf(err, "parsing [%s:%d] : '%s' expects a strictly positive integer argument.\n", file, line, args[0]);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*valptr = val;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* register "global" section keywords */
|
|
|
|
|
static struct cfg_kw_list dgram_cfg_kws = {ILH, {
|
|
|
|
|
{ CFG_GLOBAL, "tune.rcvbuf.backend", dgram_parse_tune_bufs },
|
|
|
|
|
{ CFG_GLOBAL, "tune.rcvbuf.frontend", dgram_parse_tune_bufs },
|
|
|
|
|
{ CFG_GLOBAL, "tune.sndbuf.backend", dgram_parse_tune_bufs },
|
|
|
|
|
{ CFG_GLOBAL, "tune.sndbuf.frontend", dgram_parse_tune_bufs },
|
|
|
|
|
{ 0, NULL, NULL }
|
|
|
|
|
}};
|
|
|
|
|
|
|
|
|
|
INITCALL1(STG_REGISTER, cfg_register_keywords, &dgram_cfg_kws);
|