rwlock(9) acquisition.
Reported-by: syzbot+fbe3acb4886adeef31e0@syzkaller.appspotmail.com
-/* $OpenBSD: route.c,v 1.415 2023/01/21 17:35:01 mvs Exp $ */
+/* $OpenBSD: route.c,v 1.416 2023/01/28 10:17:16 mvs Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
#include <sys/queue.h>
#include <sys/pool.h>
#include <sys/atomic.h>
-#include <sys/rwlock.h>
#include <net/if.h>
#include <net/if_var.h>
#define ROUNDUP(a) (a>0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
-struct rwlock rt_lock = RWLOCK_INITIALIZER("rtlck");
-
/* Give some jitter to hash, to avoid synchronization between routers. */
static uint32_t rt_hashjitter;
* It should also be higher to let the ARP layer find
* cloned routes instead of the cloning one.
*/
- RT_LOCK();
+ KERNEL_LOCK();
error = rtrequest(RTM_RESOLVE, &info, rt->rt_priority - 1, &rt,
rtableid);
- RT_UNLOCK();
+ KERNEL_UNLOCK();
if (error) {
rtm_miss(RTM_MISS, &info, 0, RTP_NONE, 0, error, rtableid);
} else {
-/* $OpenBSD: route.h,v 1.197 2023/01/21 17:35:01 mvs Exp $ */
+/* $OpenBSD: route.h,v 1.198 2023/01/28 10:17:16 mvs Exp $ */
/* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */
/*
#ifdef _KERNEL
#include <sys/percpu.h>
-#include <sys/rwlock.h>
-
-extern struct rwlock rt_lock;
-
-#define RT_LOCK() rw_enter_write(&rt_lock)
-#define RT_UNLOCK() rw_exit_write(&rt_lock)
-#define RT_ASSERT_LOCKED() rw_assert_wrlock(&rt_lock)
enum rtstat_counters {
rts_badredirect, /* bogus redirect calls */
-/* $OpenBSD: if_ether.c,v 1.253 2023/01/21 17:35:01 mvs Exp $ */
+/* $OpenBSD: if_ether.c,v 1.254 2023/01/28 10:17:16 mvs Exp $ */
/* $NetBSD: if_ether.c,v 1.31 1996/05/11 12:59:58 mycroft Exp $ */
/*
if (ifp->if_flags & (IFF_NOARP|IFF_STATICARP))
goto bad;
- RT_LOCK();
+ KERNEL_LOCK();
/*
* Re-check since we grab the route lock after the first check.
* rtrequest_delete() can be called with shared netlock. From
* route lock here and are safe. XXXSMP
*/
if (!ISSET(rt->rt_flags, RTF_LLINFO)) {
- RT_UNLOCK();
+ KERNEL_UNLOCK();
goto bad;
}
la = (struct llinfo_arp *)rt->rt_llinfo;
}
}
- RT_UNLOCK();
+ KERNEL_UNLOCK();
return (EAGAIN);
bad:
} else if (rt != NULL) {
int error;
- RT_LOCK();
+ KERNEL_LOCK();
error = arpcache(ifp, ea, rt);
- RT_UNLOCK();
+ KERNEL_UNLOCK();
if (error)
goto out;
}
unsigned int len;
int changed = 0;
- RT_ASSERT_LOCKED();
+ KERNEL_ASSERT_LOCKED();
KASSERT(sdl != NULL);
/*