]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: listener/protocol: add proto name in alerts
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Wed, 10 Apr 2024 12:18:47 +0000 (14:18 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 12 Apr 2024 16:51:40 +0000 (18:51 +0200)
Frontend and listen sections allow unlimited number of bind statements, it is
often, when there is a bind statement per supported protocol, like below:

listen test
  mode http
  bind quic4@0.0.0.0:443 name quic ssl crt ...
  bind 0.0.0.0:443 name https ssl alpn http/1.1,h2 crt ...
  bind 0.0.0.0:8080 ...
  ...

It seems useful to show corresponded protocol name in alerts and warnings,
when problem occures with port binding, connection resuming or sharding. This
helps to figure out immediately, which bind statement has a wrong setting or
which protocol module is the root cause of the issue.

src/listener.c
src/protocol.c

index 8b20b55b041896b47ae3a6cac99b4a9d49368dfb..01740f003d44467c4eb014a9ef8ca7c4062335aa 100644 (file)
@@ -444,9 +444,9 @@ int default_resume_listener(struct listener *l)
                err = l->rx.proto->fam->bind(&l->rx, &errmsg);
                if (err != ERR_NONE) {
                        if (err & ERR_WARN)
-                               ha_warning("Resuming listener: %s\n", errmsg);
+                               ha_warning("Resuming listener: protocol %s: %s.\n", l->rx.proto->name, errmsg);
                        else if (err & ERR_ALERT)
-                               ha_alert("Resuming listener: %s\n", errmsg);
+                               ha_alert("Resuming listener: protocol %s: %s.\n", l->rx.proto->name, errmsg);
                        ha_free(&errmsg);
                        if (err & (ERR_FATAL | ERR_ABORT)) {
                                ret = 0;
@@ -461,9 +461,9 @@ int default_resume_listener(struct listener *l)
                BUG_ON(!l->rx.proto->listen);
                err = l->rx.proto->listen(l, msg, sizeof(msg));
                if (err & ERR_ALERT)
-                       ha_alert("Resuming listener: %s\n", msg);
+                       ha_alert("Resuming listener: protocol %s: %s.\n", l->rx.proto->name, msg);
                else if (err & ERR_WARN)
-                       ha_warning("Resuming listener: %s\n", msg);
+                       ha_warning("Resuming listener: protocol %s: %s.\n", l->rx.proto->name, msg);
 
                if (err & (ERR_FATAL | ERR_ABORT)) {
                        ret = 0;
@@ -1717,8 +1717,8 @@ int bind_complete_thread_setup(struct bind_conf *bind_conf, int *err_code)
                        else {
                                if (fe != global.cli_fe)
                                        ha_diag_warning("[%s:%d]: Disabling per-thread sharding for listener in"
-                                                       " %s '%s' because SO_REUSEPORT is disabled\n",
-                                                       bind_conf->file, bind_conf->line, proxy_type_str(fe), fe->id);
+                                                       " %s '%s' because SO_REUSEPORT is disabled for %s protocol.\n",
+                                                       bind_conf->file, bind_conf->line, proxy_type_str(fe), fe->id, li->rx.proto->name);
                                shards = 1;
                        }
                }
@@ -1731,8 +1731,8 @@ int bind_complete_thread_setup(struct bind_conf *bind_conf, int *err_code)
 
                /* We also need to check if an explicit shards count was set and cannot be honored */
                if (shards > 1 && !protocol_supports_flag(li->rx.proto, PROTO_F_REUSEPORT_SUPPORTED)) {
-                       ha_warning("[%s:%d]: Disabling sharding for listener in %s '%s' because SO_REUSEPORT is disabled\n",
-                                  bind_conf->file, bind_conf->line, proxy_type_str(fe), fe->id);
+                       ha_warning("[%s:%d]: Disabling sharding for listener in %s '%s' because SO_REUSEPORT is disabled for %s protocol.\n",
+                                  bind_conf->file, bind_conf->line, proxy_type_str(fe), fe->id, li->rx.proto->name);
                        shards = 1;
                }
 
index 25ed6b757e7397b089310ad80cd7ee79a38b123d..399835a887e7e4a1976f99db6c2a11a2f2906969 100644 (file)
@@ -157,13 +157,13 @@ int protocol_bind_all(int verbose)
                                struct proxy *px = listener->bind_conf->frontend;
 
                                if (lerr & ERR_ALERT)
-                                       ha_alert("Binding [%s:%d] for %s %s: %s\n",
+                                       ha_alert("Binding [%s:%d] for %s %s: protocol %s: %s.\n",
                                                 listener->bind_conf->file, listener->bind_conf->line,
-                                                proxy_type_str(px), px->id, errmsg);
+                                                proxy_type_str(px), px->id, proto->name, errmsg);
                                else if (lerr & ERR_WARN)
-                                       ha_warning("Binding [%s:%d] for %s %s: %s\n",
+                                       ha_warning("Binding [%s:%d] for %s %s: protocol %s: %s.\n",
                                                   listener->bind_conf->file, listener->bind_conf->line,
-                                                  proxy_type_str(px), px->id, errmsg);
+                                                  proxy_type_str(px), px->id, proto->name, errmsg);
                        }
                        if (lerr != ERR_NONE)
                                ha_free(&errmsg);
@@ -183,13 +183,13 @@ int protocol_bind_all(int verbose)
                                struct proxy *px = listener->bind_conf->frontend;
 
                                if (lerr & ERR_ALERT)
-                                       ha_alert("Starting [%s:%d] for %s %s: %s\n",
+                                       ha_alert("Starting [%s:%d] for %s %s: protocol %s: %s.\n",
                                                 listener->bind_conf->file, listener->bind_conf->line,
-                                                proxy_type_str(px), px->id, msg);
+                                                proxy_type_str(px), px->id, proto->name, msg);
                                else if (lerr & ERR_WARN)
-                                       ha_warning("Starting [%s:%d] for %s %s: %s\n",
+                                       ha_warning("Starting [%s:%d] for %s %s: protocol %s: %s.\n",
                                                   listener->bind_conf->file, listener->bind_conf->line,
-                                                  proxy_type_str(px), px->id, msg);
+                                                  proxy_type_str(px), px->id, proto->name, msg);
                        }
                        if (lerr & ERR_ABORT)
                                break;