Index | Thread | Search

From:
Rafael Sadowski <rafael@sizeofvoid.org>
Subject:
Re: relayd: reclassify log levels
To:
Omar Polo <op@omarpolo.com>, Claudio Jeker <cjeker@diehard.n-r-g.com>
Cc:
tech@openbsd.org
Date:
Sat, 7 Nov 2026 13:17:41 +0100

Download raw body.

Thread
Hi Omar, Hi Claudio,

Thanks, Claudio. I always go through the "imsg + log" dance, whether
with or without the x. I think I've come up with a mnemonic now.

Thanks, Omar, for the feedback. I've been playing around with the logs
some more and am still trying to find a sensible way forward. Please
take a look at "relayd: 1/2: separate loglevel in warn,info,debug and
add log option" on tech@

I created a new diff with a minor change that has worked well during
developing on "log level warn|info|debug". New diff below

On Thu Nov 05, 2026 at 10:03:16PM +0100, Omar Polo wrote:
> Rafael Sadowski <rafael@sizeofvoid.org> wrote:
> > OK?
> 
> two questions but otherwise makes sense to me (but i'm not a relayd user :)
> 
> > commit 7bdd895e0ef8ce3d5b2c8bbc4ec3a431cc454375
> > Author: Rafael Sadowski <rafael@sizeofvoid.org>
> > Date:   Tue Nov 3 22:04:19 2026 +0100
> > 
> >     relayd: reclassify log levels
> >     
> >     Some messages do not set errno, so they correspond to log_warnx rather
> >     than warn. Some debug messages are actually warnings, others are simply
> >     informational.
> > 
> > diff --git a/ca.c b/ca.c
> > index beb86d5..a6e28b5 100644
> > --- a/ca.c
> > +++ b/ca.c
> > @@ -259,7 +259,7 @@ ca_dispatch_relay(int fd, struct privsep_proc *p, struct imsg *imsg)
> >  			if (proc_composev_imsg(env->sc_ps, PROC_RELAY,
> >  			    cko.cko_proc, imsg_get_type(imsg), -1, -1, iov,
> >  			    c) == -1)
> > -				log_warn("%s: proc_composev_imsg", __func__);
> > +				log_warnx("%s: proc_composev_imsg", __func__);
> 
> but imsg_compose() (which is the fallible thingy in proc_composev_imsg
> AFAIK) sets errno, no?  (maybe not super useful but still.)

Yes it does. fixed.

> 
> >  			break;
> >  		}
> >  
> > [...]
> > diff --git a/relay.c b/relay.c
> > index 1f28ccd..42a56a3 100644
> > --- a/relay.c
> > +++ b/relay.c
> > [...]
> > @@ -1582,7 +1582,7 @@ relay_connect_retry(int fd, short sig, void *arg)
> >  		if (errno == ENFILE || errno == EMFILE)
> >  			log_warn("%s: session %d: deferring forward",
> >  			    __func__, con->se_id);
> 
> maybe delete this
> 
> > -		log_debug("%s: session %d: "
> > +		log_warnx("%s: session %d: "
> >  		    "forward failed: %s, %s", __func__,
> >  		    con->se_id, strerror(errno),
> >  		    con->se_retry ? "next retry" : "last retry");
> 
> if we're promoting this to a warn level?

Thanks, thats got me thinking.

> 
> > @@ -1651,7 +1651,7 @@ relay_connect(struct rsession *con)
> > [...]
> 

diff --git a/check_icmp.c b/check_icmp.c
index 46d01fa..81dfc2c 100644
--- a/check_icmp.c
+++ b/check_icmp.c
@@ -309,7 +309,7 @@ recv_icmp(int s, short event, void *arg)
 	    (struct sockaddr *)&ss, &slen);
 	if (r == -1 || r != ICMP_BUF_SIZE) {
 		if (r == -1 && errno != EAGAIN && errno != EINTR)
-			log_debug("%s: receive error", __func__);
+			log_warn("%s: receive error", __func__);
 		goto retry;
 	}
 
diff --git a/pfe.c b/pfe.c
index 4c42cf4..4acbbcc 100644
--- a/pfe.c
+++ b/pfe.c
@@ -579,7 +579,7 @@ disable_table(struct ctl_conn *c, struct ctl_id *id)
 	    &table->conf.id, sizeof(table->conf.id)) == -1)
 		log_warn("%s: proc_compose", __func__);
 
-	log_debug("%s: table %d", __func__, table->conf.id);
+	log_info("table %s disabled", table->conf.name);
 	pfe_sync();
 	return (0);
 }
@@ -617,7 +617,7 @@ enable_table(struct ctl_conn *c, struct ctl_id *id)
 	    &table->conf.id, sizeof(table->conf.id)) == -1)
 		log_warn("%s: proc_compose", __func__);
 
-	log_debug("%s: table %d", __func__, table->conf.id);
+	log_info("table %s enabled", table->conf.name);
 	pfe_sync();
 	return (0);
 }
@@ -666,7 +666,7 @@ disable_host(struct ctl_conn *c, struct ctl_id *id, struct host *host)
 	    &host->conf.id, sizeof(host->conf.id)) == -1)
 		log_warn("%s: proc_compose", __func__);
 
-	log_debug("%s: host %d", __func__, host->conf.id);
+	log_info("host %s disabled", host->conf.name);
 
 	if (!host->conf.parentid) {
 		/* Disable all children */
@@ -722,7 +722,7 @@ enable_host(struct ctl_conn *c, struct ctl_id *id, struct host *host)
 	    &host->conf.id, sizeof(host->conf.id)) == -1)
 		log_warn("%s: proc_compose", __func__);
 
-	log_debug("%s: host %d", __func__, host->conf.id);
+	log_info("host %s enabled", host->conf.name);
 
 	if (!host->conf.parentid) {
 		/* Enable all children */
diff --git a/pfe_route.c b/pfe_route.c
index 49c2f4b..26ab194 100644
--- a/pfe_route.c
+++ b/pfe_route.c
@@ -196,9 +196,8 @@ pfe_route(struct relayd *env, struct ctl_netroute *crt)
 	return (0);
 
  bad:
-	log_debug("%s: failed to %s gateway %s: %d %s", __func__,
-	    HOST_ISUP(crt->up) ? "add" : "delete", gwname,
-	    errno, strerror(errno));
+	log_warn("%s: failed to %s gateway %s", __func__,
+	    HOST_ISUP(crt->up) ? "add" : "delete", gwname);
 
 	return (-1);
 }
diff --git a/relayd.c b/relayd.c
index 1b4f177..e65c593 100644
--- a/relayd.c
+++ b/relayd.c
@@ -394,6 +394,7 @@ parent_configure_done(struct relayd *env)
 			    0) == -1)
 				fatal("%s: proc_compose", __func__);
 		}
+		log_info("configuration loaded");
 	}
 }