On Mon, Mar 21, 2022 at 05:51:36PM +0100, Theo Buehler wrote:
> On Mon, Mar 21, 2022 at 05:16:53PM +0100, Claudio Jeker wrote:
> > In struct rib_entry bgpd keeps the 'best' or active prefix cached.
> > Now to support more than one one prefix per path (for ECMP and add-path)
> > I need the ability to access the previous element. The currently used
> > LIST macros do not support that. So I want to switch that to TAILQ but
> > the TAILQ head is 2 pointers not 1 and so I need to free a pointer from
> > struct rib_entry. Also this active cache makes less sense with multiple
> > paths.
> >
> > Access to the active prefix is replaced with the better named
> > prefix_best() which returns the LIST_FIRST entry if that one is eligible.
>
> Missed one bit in prefix_evaluate_all():
>
> /usr/src/usr.sbin/bgpd/rde_rib.c:1526:17: error: no member named 'active' in
> 'struct rib_entry'
> p == re->active)
> ~~ ^
Arrg, this happens when you go too fast. I missed to extract that bit from
another tree. That just needs to be replaced with a prefix_best(re) call.
> With that fixed, ok
>
> tiny nit below:
>
> > Index: rde_decide.c
> > ===================================================================
> > RCS file: /cvs/src/usr.sbin/bgpd/rde_decide.c,v
> > retrieving revision 1.89
> > diff -u -p -r1.89 rde_decide.c
> > --- rde_decide.c 3 Mar 2022 13:06:15 -0000 1.89
> > +++ rde_decide.c 21 Mar 2022 16:03:05 -0000
> > @@ -443,6 +443,23 @@ prefix_eligible(struct prefix *p)
> > return 1;
> > }
> >
> > +struct prefix *
> > +prefix_best(struct rib_entry *re)
> > +{
> > + struct prefix *xp;
> > + struct rib *rib;
> > +
> > + rib = re_rib(re);
> > + if (rib->flags & F_RIB_NOEVALUATE)
> > + /* decision process is turned off */
> > + return NULL;
> > +
> > + xp = LIST_FIRST(&re->prefix_h);
>
> Use tab instead of 8 spaces for indent
Fixed.
> > + if (xp != NULL && !prefix_eligible(xp))
> > + xp = NULL;
> > + return xp;
> > +}
> > +
>
--
:wq Claudio