Index | Thread | Search

From:
Theo Buehler <tb@theobuehler.org>
Subject:
Re: relayd: refactor config_getrelayfd
To:
Rafael Sadowski <rafael@sizeofvoid.org>
Cc:
tech@openbsd.org, "Kirill A. Korinsky" <kirill@korins.ky>
Date:
Thu, 29 Oct 2026 09:39:11 +0100

Download raw body.

Thread
On Thu, Oct 29, 2026 at 08:58:26AM +0100, Rafael Sadowski wrote:
> Based on tb@'s feedback below, you can find a suggestion for
> implementing this function properly with correct error handling.
> 
> Unknown fd types and imsgs without an fd are now treated as errors
> instead of being silently ignored.

One thing I've learned over the years is that you can never know what
dark magic is hidden in all the layers of relayd design. There might be
something completely unexpected depending on ignoring these. I suppose
there's only one way to know...

> As an improvement no orphan cert is created when the relay is unknown.
> 
> BTW the old code loves to trust imsg_get_fd blindly.
> 
> Feedback, OK?

I like it. This is a lot cleaner and makes the control flow and error
handling very obvious.

> +	default:
> +		log_warnx("%s: unknown type %d", __func__, crfd.type);
> +		goto fail;

Should this be a bit more explicit like "unexpected relay fd type %d"?

either way ok tb (fwiw).