As a matter of fact it is, let me update the dummy part.

On Sat, Feb 14, 2026 at 1:57 PM Willy Tarreau <[email protected]> wrote:

> On Sat, Feb 14, 2026 at 01:24:06PM +0000, David Carlier wrote:
> > From: David Carlier <[email protected]>
> >
> > Precompute the maximum header name length from the atlas evidence
> > headers at init and hot-reload time. Use it in da_haproxy_fetch() to
> > skip headers early that cannot match any known DeviceAtlas evidence
> > header, avoiding unnecessary string copies and comparisons.
> > ---
> >  addons/deviceatlas/da.c | 23 +++++++++++++++++++++--
> >  1 file changed, 21 insertions(+), 2 deletions(-)
> >
> > diff --git a/addons/deviceatlas/da.c b/addons/deviceatlas/da.c
> > index 2c09c2272..0c3311b61 100644
> > --- a/addons/deviceatlas/da.c
> > +++ b/addons/deviceatlas/da.c
> > @@ -31,6 +31,7 @@ static struct {
> >       da_atlas_t atlas;
> >       da_evidence_id_t useragentid;
> >       da_severity_t loglevel;
> > +     size_t maxhdrlen;
> >       char separator;
> >       unsigned char daset:1;
> >  } global_deviceatlas = {
> > @@ -42,6 +43,7 @@ static struct {
> >       .atlasmap = NULL,
> >       .atlasfd = -1,
> >       .useragentid = 0,
> > +     .maxhdrlen = 0,
> >       .daset = 0,
> >       .separator = '|',
> >  };
> > @@ -224,6 +226,15 @@ static int init_deviceatlas(void)
> >
> >               global_deviceatlas.useragentid =
> da_atlas_header_evidence_id(&global_deviceatlas.atlas,
> >                       "user-agent");
> > +             {
> > +                     size_t hi;
> > +                     global_deviceatlas.maxhdrlen = 16;
> > +                     for (hi = 0; hi <
> global_deviceatlas.atlas.header_evidence_count; hi++) {
> > +                             size_t nl =
> strlen(global_deviceatlas.atlas.header_priorities[hi].name);
> > +                             if (nl > global_deviceatlas.maxhdrlen)
> > +                                     global_deviceatlas.maxhdrlen = nl;
> > +                     }
> > +             }
>
> This one fails to build with the dummy lib:
>
>     CC      addons/deviceatlas/da.o
>     CC      src/version.o
>   addons/deviceatlas/da.c: In function 'init_deviceatlas':
>   addons/deviceatlas/da.c:233:94: error: invalid use of undefined type
> 'struct header_evidence_entry'
>     233 |                                 size_t nl =
> strlen(global_deviceatlas.atlas.header_priorities[hi].name);
>         |
>                             ^
>   addons/deviceatlas/da.c:233:98: error: invalid use of undefined type
> 'struct header_evidence_entry'
>     233 |                                 size_t nl =
> strlen(global_deviceatlas.atlas.header_priorities[hi].name);
>         |
>                                 ^
>   addons/deviceatlas/da.c: In function 'da_haproxy_checkinst':
>   addons/deviceatlas/da.c:322:70: error: invalid use of undefined type
> 'struct header_evidence_entry'
>     322 |                             size_t nl =
> strlen(inst.header_priorities[hi].name);
>         |
>     ^
>   addons/deviceatlas/da.c:322:74: error: invalid use of undefined type
> 'struct header_evidence_entry'
>     322 |                             size_t nl =
> strlen(inst.header_priorities[hi].name);
>         |
>         ^
>
> It's because struct header_evidence_entry is never defined, so the
> compiler cannot know how to access the name field. As a hack I tried
> just this and it fixed it:
>
>   --- a/addons/deviceatlas/dummy/dac.h
>   +++ b/addons/deviceatlas/dummy/dac.h
>   @@ -492,6 +492,10 @@ size_t da_getpropcount(const da_deviceinfo_t *info);
>     * No user servicable parts inside: access should
>     * be via the functional API.
>     */
>   +struct header_evidence_entry {
>   +       char *name;
>   +};
>   +
>    struct da_atlas {
>        const struct atlas_image *image;
>        struct header_evidence_entry *header_priorities;
>
> However I don't know if it will even work with basic test files, so you
> may want to double-check this. Also I can confirm that the remaining
> patches do build correctly with this change applied.
>
> Regards,
> Willy
>

Reply via email to