]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: log-forward: use str2receiver() to parse the dgram-bind address
authorWilly Tarreau <w@1wt.eu>
Wed, 16 Sep 2020 13:22:19 +0000 (15:22 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 16 Sep 2020 20:08:08 +0000 (22:08 +0200)
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.

doc/configuration.txt
src/log.c

index ce7bdf109d0dfc29d43b2e5e9dece18ebb1e6669..3757a50027db9026383ce167bd39f9bd177172cb 100644 (file)
@@ -2752,10 +2752,10 @@ log-forward <name>
 
 dgram-bind <addr> [param*]
   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
-  "udp6@". This supports for some of the "bind" parameters found in 5.1
-  paragraph among which "interface", "namespace" or "transparent", the other
-  ones being silently ignored as irrelevant for UDP/syslog case.
+  listeners are allowed. Addresses must be in IPv4 or IPv6 form,followed by a
+  port. This supports for some of the "bind" parameters found in 5.1 paragraph
+  among which "interface", "namespace" or "transparent", the other ones being
+  silently ignored as irrelevant for UDP/syslog case.
 
 log global
 log <address> [len <length>] [format <format>] [sample <ranges>:<smp_size>]
index 8e4606af3c26ff99423d99099e8f9e9c0f95d9e4..ee998705155153b9cac190980fdc2a8e51731f1d 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -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,
                                            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) {
                                indent_msg(&errmsg, 2);
                                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;
                }
                list_for_each_entry(l, &bind_conf->listeners, by_bind) {
-                       /* Currently, only UDP handlers are allowed */
-                       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;
-                       }
+                       /* the fact that the sockets are of type dgram is guaranteed by str2receiver() */
                        l->maxaccept = global.tune.maxaccept ? global.tune.maxaccept : 64;
                        global.maxsock++;
                }