Index | Thread | Search

From:
Theo Buehler <tb@theobuehler.org>
Subject:
Re: bgpd: add log_roa() and log_aspa()
To:
tech@openbsd.org
Date:
Wed, 10 Jan 2024 14:26:29 +0100

Download raw body.

Thread
On Wed, Jan 10, 2024 at 02:16:01PM +0100, Claudio Jeker wrote:
> On Wed, Jan 10, 2024 at 01:02:54PM +0100, Theo Buehler wrote:
> > On Wed, Jan 10, 2024 at 12:05:54PM +0100, Claudio Jeker wrote:
> > > Extract the code to print a roa or aspa entry from printconf and convert
> > > it into log_roa() and log_aspa().
> > > 
> > > Now log_aspa() is a bit complex because the size of the buffer is not
> > > known. This now mallocs a buffer large enough and then tries to reuse that
> > > buffer. I hope I did not screw this up too badly.
> > > 
> > > A follow up diff will use these log functions in the rtr code.
> > 
> > By definition of bikeshedding, simpler diffs generate more of it. Feel
> > free to ignore.
> > 
> > ok tb
> > 
> > > +	/* include enough space for header and trailer */
> > > +	if ((uint64_t)aspa->num > (SIZE_MAX / 12 - 72))
> > > +		goto fail;
> > > +	needed = (uint64_t)aspa->num * 12 + 72;
> > 
> > The 12 is a bit strange. How about using sizeof(asbuf)? Then you don't
> > need to cast twice.
> 
> The if () still needs the cast to make the compiler not bark since an
> uint32_t can never trigger the error on a 64bit arch.

Sigh. Of course.

New diff is ok.