MINOR: listener/protocol: add proto name in alerts

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.
This commit is contained in:
Valentine Krasnobaeva 2024-04-10 14:18:47 +02:00 committed by Willy Tarreau
parent c0ee2d78d7
commit 7041c078d6
2 changed files with 16 additions and 16 deletions

View 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;
}

View 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;