On Tue, Apr 19, 2022 at 08:46:06AM +0200, Claudio Jeker wrote:
> On Tue, Apr 19, 2022 at 12:07:49AM +0200, Alexander Bluhm wrote:
> > Hi,
> >
> > Instead of using a MP unsafe global variable, just call rt_timer_init()
> > from route_init().
> >
> > ok?
>
> Wouldn't it be better to move this into rtable_init?
> route_init() is called by domaininit() as the last init function
> (routedomain is the last domain in domains[].
I see the problem. ip_init() and icmp6_init() create the queue
before route_init() has been initialized.
Calling rt_timer_init() from rtable_init() fixes it.
ok?
bluhm
Index: net/route.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/net/route.c,v
retrieving revision 1.402
diff -u -p -r1.402 route.c
--- net/route.c 22 Feb 2022 01:15:02 -0000 1.402
+++ net/route.c 19 Apr 2022 14:48:26 -0000
@@ -151,7 +151,6 @@ int ifatrash; /* ifas not in ifp list
struct pool rtentry_pool; /* pool for rtentry structures */
struct pool rttimer_pool; /* pool for rttimer structures */
-void rt_timer_init(void);
int rt_setgwroute(struct rtentry *, u_int);
void rt_putgwroute(struct rtentry *);
int rtflushclone1(struct rtentry *, void *, u_int);
@@ -1362,7 +1361,6 @@ rt_ifa_purge_walker(struct rtentry *rt,
*/
LIST_HEAD(, rttimer_queue) rttimer_queue_head;
-static int rt_init_done = 0;
#define RTTIMER_CALLOUT(r) { \
if (r->rtt_func != NULL) { \
@@ -1389,25 +1387,18 @@ rt_timer_init(void)
{
static struct timeout rt_timer_timeout;
- if (rt_init_done)
- panic("rt_timer_init: already initialized");
-
pool_init(&rttimer_pool, sizeof(struct rttimer), 0, IPL_SOFTNET, 0,
"rttmr", NULL);
LIST_INIT(&rttimer_queue_head);
timeout_set_proc(&rt_timer_timeout, rt_timer_timer, &rt_timer_timeout);
timeout_add_sec(&rt_timer_timeout, 1);
- rt_init_done = 1;
}
struct rttimer_queue *
rt_timer_queue_create(u_int timeout)
{
struct rttimer_queue *rtq;
-
- if (rt_init_done == 0)
- rt_timer_init();
if ((rtq = malloc(sizeof(*rtq), M_RTABLE, M_NOWAIT|M_ZERO)) == NULL)
return (NULL);
Index: net/route.h
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/net/route.h,v
retrieving revision 1.187
diff -u -p -r1.187 route.h
--- net/route.h 12 Nov 2021 15:49:41 -0000 1.187
+++ net/route.h 19 Apr 2022 14:47:26 -0000
@@ -451,6 +451,7 @@ void rtm_proposal(struct ifnet *, struc
int rt_setgate(struct rtentry *, struct sockaddr *, u_int);
struct rtentry *rt_getll(struct rtentry *);
+void rt_timer_init(void);
int rt_timer_add(struct rtentry *,
void(*)(struct rtentry *, struct rttimer *),
struct rttimer_queue *, u_int);
Index: net/rtable.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/net/rtable.c,v
retrieving revision 1.76
diff -u -p -r1.76 rtable.c
--- net/rtable.c 2 Jan 2022 22:36:04 -0000 1.76
+++ net/rtable.c 19 Apr 2022 14:48:46 -0000
@@ -184,6 +184,8 @@ rtable_init(void)
if (rtable_add(0) != 0)
panic("unable to create default routing table");
+
+ rt_timer_init();
}
int