From: bluhm Date: Tue, 19 Apr 2022 15:44:56 +0000 (+0000) Subject: Instead of a MP unsafe global variable to initialize at first use, X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=f35efbbd92e3578a75f34a9f51755cca8c7a903d;p=openbsd Instead of a MP unsafe global variable to initialize at first use, call rt_timer_init() from rtable_init(). OK mvs@ claudio@ --- diff --git a/sys/net/route.c b/sys/net/route.c index 21a5367d2aa..7eef232f9e8 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.402 2022/02/22 01:15:02 guenther Exp $ */ +/* $OpenBSD: route.c,v 1.403 2022/04/19 15:44:56 bluhm Exp $ */ /* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */ /* @@ -151,7 +151,6 @@ int ifatrash; /* ifas not in ifp list but not free */ 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, void *vifa, unsigned int rtableid) */ LIST_HEAD(, rttimer_queue) rttimer_queue_head; -static int rt_init_done = 0; #define RTTIMER_CALLOUT(r) { \ if (r->rtt_func != NULL) { \ @@ -1389,16 +1387,12 @@ 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 * @@ -1406,9 +1400,6 @@ 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); diff --git a/sys/net/route.h b/sys/net/route.h index 4a455662b84..99883769604 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -1,4 +1,4 @@ -/* $OpenBSD: route.h,v 1.187 2021/11/12 15:49:41 deraadt Exp $ */ +/* $OpenBSD: route.h,v 1.188 2022/04/19 15:44:56 bluhm Exp $ */ /* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */ /* @@ -451,6 +451,7 @@ void rtm_proposal(struct ifnet *, struct rt_addrinfo *, int, uint8_t); 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); diff --git a/sys/net/rtable.c b/sys/net/rtable.c index 44c4042d326..c5248ce339b 100644 --- a/sys/net/rtable.c +++ b/sys/net/rtable.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtable.c,v 1.76 2022/01/02 22:36:04 jsg Exp $ */ +/* $OpenBSD: rtable.c,v 1.77 2022/04/19 15:44:56 bluhm Exp $ */ /* * Copyright (c) 2014-2016 Martin Pieuchot @@ -184,6 +184,8 @@ rtable_init(void) if (rtable_add(0) != 0) panic("unable to create default routing table"); + + rt_timer_init(); } int