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.
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);
}