? smr_compat.h Index: kern_compat.h =================================================================== RCS file: /cvs/src/regress/sys/net/rtable/kern_compat.h,v diff -u -p -r1.16 kern_compat.h --- kern_compat.h 11 Nov 2023 07:34:54 -0000 1.16 +++ kern_compat.h 13 Jun 2025 05:49:06 -0000 @@ -23,10 +23,14 @@ #include #include #include +#include #include +#include "smr_compat.h" #include "srp_compat.h" +#define membar_producer() __sync_synchronize() + #define _KERNEL #define DIAGNOSTIC #define INET @@ -65,6 +69,8 @@ struct pool { #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) #endif +#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) + #ifndef IPL_NONE #define IPL_NONE 0 #endif @@ -89,5 +95,16 @@ extern struct domain *domains[]; struct rtentry; int rt_hash(struct rtentry *, const struct sockaddr *, uint32_t *); + +#define READ_ONCE(x) ({ \ + typeof(x) __tmp = *(volatile typeof(x) *)&(x); \ + __tmp; \ +}) + +#define WRITE_ONCE(x, val) ({ \ + typeof(x) __tmp = (val); \ + *(volatile typeof(x) *)&(x) = __tmp; \ + __tmp; \ +}) #endif /* _KERN_COMPAT_H_ */ Index: util.c =================================================================== RCS file: /cvs/src/regress/sys/net/rtable/util.c,v diff -u -p -r1.16 util.c --- util.c 14 Feb 2025 06:25:00 -0000 1.16 +++ util.c 13 Jun 2025 05:49:06 -0000 @@ -1,4 +1,3 @@ -/* $OpenBSD: util.c,v 1.16 2025/02/14 06:25:00 anton Exp $ */ /* * Copyright (c) 2015 Martin Pieuchot @@ -52,6 +51,7 @@ #undef _KERNEL #include "srp_compat.h" +#include "smr_compat.h" #include #include @@ -262,14 +262,16 @@ rtentry_delete(struct rtentry *rt, void struct sockaddr_in6 sa_mask; struct sockaddr *mask = rt_plen2mask(rt, &sa_mask); int error; + unsigned int refs; assert(rt_plen(rt) == rtable_satoplen(af, mask)); - + refs = refcnt_read(&rt->rt_refcnt); + assert(refs > 0); if ((error = rtable_delete(0, rt_key(rt), mask, rt)) != 0) { inet_net_satop(af, rt_key(rt), rt_plen(rt), dest, sizeof(dest)); errx(1, "can't rm route: %s, %s", dest, strerror(error)); } - assert(refcnt_read(&rt->rt_refcnt) == 0); + assert(refcnt_read(&rt->rt_refcnt) == refs - 1); return (0); } @@ -576,4 +578,28 @@ rt_hash(struct rtentry *rt, const struct void rt_timer_init(void) { +} + +/* + * SMR stuff + */ + +unsigned int smr_crit; + +void +smr_read_enter(void) +{ + smr_crit++; +} + +void +smr_read_leave(void) +{ + smr_crit++; +} + +void +SMR_ASSERT_CRITICAL(void) +{ + assert(smr_crit > 0); } Index: delete/main.c =================================================================== RCS file: /cvs/src/regress/sys/net/rtable/delete/main.c,v diff -u -p -r1.7 main.c --- delete/main.c 13 Apr 2021 08:21:12 -0000 1.7 +++ delete/main.c 13 Jun 2025 05:49:06 -0000 @@ -21,6 +21,8 @@ #include #include #include + +#include #include #include @@ -58,10 +60,10 @@ main(int argc, char *argv[]) rtable_walk(0, AF_INET6, NULL, rtentry_dump, NULL); - struct art_root *ar; + struct art *ar; ar = rtable_get(0, AF_INET6); assert(ar != NULL); - assert(ar->ar_root.ref == NULL); + assert(art_is_empty(ar)); return (0); } Index: fullfeed/Makefile =================================================================== RCS file: /cvs/src/regress/sys/net/rtable/fullfeed/Makefile,v diff -u -p -r1.2 Makefile --- fullfeed/Makefile 7 Sep 2016 20:53:34 -0000 1.2 +++ fullfeed/Makefile 13 Jun 2025 05:49:06 -0000 @@ -3,7 +3,6 @@ PROG= fullfeed SRCS= main.c util.c rtable.c - REGRESS_TARGETS+= inet inet6 # XXX route entries are sorted because the radix tree stores dup chains