On Tue, Aug 02, 2022 at 01:44:42PM +0200, Theo Buehler wrote:
> On Tue, Aug 02, 2022 at 12:34:40PM +0200, Claudio Jeker wrote:
> > On startup we load the routing table in bgpd and at that moment a cleanup
> > of old bgpd routes should happen. I noticed this is not the case because
> > fib_sync is not set and so send_rtmsg() just returns.
> > I think we need to force fib_sync in fetchtable() to make sure the cleanup
> > happens correctly.
> 
> If I understand correctly, this ignores the fs flag of ktable_new() for
> the fetchtable() call. In particular, 'fib-update no' is ignored in this
> situation. Is that intentional?

I think it is. At least I thought that even with 'fib-update no' bgpd
should cleanup the FIB. Now that may be a problem when people run multiple
bgpds with 'fib-update no'.

I see if I can find a solution that is a smaller hammer to fix this.

> > 
> > OK?
> > -- 
> > :wq Claudio
> > 
> > Index: kroute.c
> > ===================================================================
> > RCS file: /cvs/src/usr.sbin/bgpd/kroute.c,v
> > retrieving revision 1.285
> > diff -u -p -r1.285 kroute.c
> > --- kroute.c        28 Jul 2022 14:05:13 -0000      1.285
> > +++ kroute.c        2 Aug 2022 10:13:59 -0000
> > @@ -2726,6 +2726,7 @@ fetchtable(struct ktable *kt)
> >     char                    *buf = NULL, *next, *lim;
> >     struct rt_msghdr        *rtm;
> >     struct kroute_full       kf;
> > +   int                      fib_sync;
> >  
> >     mib[0] = CTL_NET;
> >     mib[1] = PF_ROUTE;
> > @@ -2754,6 +2755,10 @@ fetchtable(struct ktable *kt)
> >             }
> >     }
> >  
> > +   /* force fib_sync on during fetch */
> > +   fib_sync = kt->fib_sync;
> > +   kt->fib_sync = 1;
> > +
> >     lim = buf + len;
> >     for (next = buf; next < lim; next += rtm->rtm_msglen) {
> >             rtm = (struct rt_msghdr *)next;
> > @@ -2768,6 +2773,8 @@ fetchtable(struct ktable *kt)
> >             else
> >                     kroute_insert(kt, &kf);
> >     }
> > +   kt->fib_sync = fib_sync;
> > +
> >     free(buf);
> >     return (0);
> >  }
> > 
> 

-- 
:wq Claudio

Reply via email to