MINOR: log-forward: use str2receiver() to parse the dgram-bind address

Thanks to this we don't need to specify "udp@" as it's implicitly a
datagram type listener that is expected, so any AF_INET/AF_INET4 address
will work.
This commit is contained in:
Willy Tarreau 2020-09-16 15:22:19 +02:00
parent aa333123f2
commit 26ff5dabc0
2 changed files with 6 additions and 12 deletions

View File

@ -2752,10 +2752,10 @@ log-forward <name>
dgram-bind <addr> [param*] dgram-bind <addr> [param*]
Used to configure a UDP log listener to receive messages to forward. Only UDP Used to configure a UDP log listener to receive messages to forward. Only UDP
listeners are allowed, the address must be prefixed using "udp@", "udp4@" or listeners are allowed. Addresses must be in IPv4 or IPv6 form,followed by a
"udp6@". This supports for some of the "bind" parameters found in 5.1 port. This supports for some of the "bind" parameters found in 5.1 paragraph
paragraph among which "interface", "namespace" or "transparent", the other among which "interface", "namespace" or "transparent", the other ones being
ones being silently ignored as irrelevant for UDP/syslog case. silently ignored as irrelevant for UDP/syslog case.
log global log global
log <address> [len <length>] [format <format>] [sample <ranges>:<smp_size>] log <address> [len <length>] [format <format>] [sample <ranges>:<smp_size>]

View File

@ -3625,7 +3625,7 @@ int cfg_parse_log_forward(const char *file, int linenum, char **args, int kwm)
bind_conf = bind_conf_alloc(cfg_log_forward, file, linenum, bind_conf = bind_conf_alloc(cfg_log_forward, file, linenum,
NULL, xprt_get(XPRT_RAW)); NULL, xprt_get(XPRT_RAW));
if (!str2listener(args[1], cfg_log_forward, bind_conf, file, linenum, &errmsg)) { if (!str2receiver(args[1], cfg_log_forward, bind_conf, file, linenum, &errmsg)) {
if (errmsg && *errmsg) { if (errmsg && *errmsg) {
indent_msg(&errmsg, 2); indent_msg(&errmsg, 2);
ha_alert("parsing [%s:%d] : '%s %s' : %s\n", file, linenum, args[0], args[1], errmsg); ha_alert("parsing [%s:%d] : '%s %s' : %s\n", file, linenum, args[0], args[1], errmsg);
@ -3638,13 +3638,7 @@ int cfg_parse_log_forward(const char *file, int linenum, char **args, int kwm)
goto out; goto out;
} }
list_for_each_entry(l, &bind_conf->listeners, by_bind) { list_for_each_entry(l, &bind_conf->listeners, by_bind) {
/* Currently, only UDP handlers are allowed */ /* the fact that the sockets are of type dgram is guaranteed by str2receiver() */
if (l->rx.proto->sock_domain != AF_CUST_UDP4 && l->rx.proto->sock_domain != AF_CUST_UDP6) {
ha_alert("parsing [%s:%d] : '%s %s' : error, listening address must be prefixed using 'udp@', 'udp4@' or 'udp6@' %s.\n",
file, linenum, args[0], args[1], args[2]);
err_code |= ERR_ALERT | ERR_FATAL;
goto out;
}
l->maxaccept = global.tune.maxaccept ? global.tune.maxaccept : 64; l->maxaccept = global.tune.maxaccept ? global.tune.maxaccept : 64;
global.maxsock++; global.maxsock++;
} }