From: Theo Buehler Subject: Re: bgpd: fix for aspa_table_equal To: tech@openbsd.org Date: Mon, 14 Sep 2026 10:10:07 +0200 On Mon, Sep 14, 2026 at 09:58:38AM +0200, Claudio Jeker wrote: > In some edge cases the aspa_table_equal function may return true even > though the tables are not the same. > > The trivial case is: > aspa-set { > customer-as 1 provider-as { 4 5 6 } > customer-as 2 provider-as { 10 11 } > } > vs. > aspa-set { > customer-as 1 provider-as { 5 6 } > customer-as 2 provider-as { 10 11 4 } > } > > Right now the code checks the customer-as list comparing just the AS and > then looking at the flat array of all provider-as numbers. Since in the > above case both are the same (AS 4 moved sets but remains in the same > location in the flat array) the function reports equality even though > the tables are not equal. > > Checking the number of provider-as per customer-as is enough to fix this. I think your description is a bit too short. ok tb > > OK? > -- > :wq Claudio > > Index: rde_aspa.c > =================================================================== > RCS file: /cvs/src/usr.sbin/bgpd/rde_aspa.c,v > diff -u -p -r1.8 rde_aspa.c > --- rde_aspa.c 30 Aug 2026 23:43:22 -0000 1.8 > +++ rde_aspa.c 14 Sep 2026 07:29:02 -0000 > @@ -459,9 +459,12 @@ aspa_table_equal(const struct rde_aspa * > if (ra->maxset != rb->maxset || > ra->maxdata != rb->maxdata) > return 0; > - for (i = 0; i < ra->maxset; i++) > + for (i = 0; i < ra->maxset; i++) { > if (ra->sets[i].as != rb->sets[i].as) > return 0; > + if (ra->sets[i].num != rb->sets[i].num) > + return 0; > + } > if (memcmp(ra->data, rb->data, ra->maxdata * sizeof(ra->data[0])) != 0) > return 0; > >