From 2e154ce3af7dcd2254242b98d7360799269be731 Mon Sep 17 00:00:00 2001 From: claudio Date: Tue, 13 Apr 2021 08:21:12 +0000 Subject: [PATCH] Unbreak rtable regress test. Define _KERNEL in some crucial spots so that the include guard in rtsock.h is bypassed and critical defines like rtentry show up. Also remove the old RADIX bits, rtable code is art only for a while. --- regress/sys/net/rtable/Makefile.inc | 7 +------ regress/sys/net/rtable/delete/main.c | 14 ++++---------- regress/sys/net/rtable/fullfeed/main.c | 3 ++- regress/sys/net/rtable/kern_compat.h | 8 ++++---- regress/sys/net/rtable/util.c | 20 +++++++++++++++----- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/regress/sys/net/rtable/Makefile.inc b/regress/sys/net/rtable/Makefile.inc index 6654bac2836..1b9c5a0941a 100644 --- a/regress/sys/net/rtable/Makefile.inc +++ b/regress/sys/net/rtable/Makefile.inc @@ -1,13 +1,8 @@ -# $OpenBSD: Makefile.inc,v 1.7 2020/11/07 09:53:21 denis Exp $ +# $OpenBSD: Makefile.inc,v 1.8 2021/04/13 08:21:12 claudio Exp $ TOPDIR= ${.CURDIR}/.. -.ifdef RADIX -SRCS+= radix.c -.else SRCS+= art.c -CFLAGS+= -DART -.endif CPPFLAGS+= -I${TOPDIR} -Wall diff --git a/regress/sys/net/rtable/delete/main.c b/regress/sys/net/rtable/delete/main.c index 8357c0a992a..b377d0eb612 100644 --- a/regress/sys/net/rtable/delete/main.c +++ b/regress/sys/net/rtable/delete/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.6 2019/06/24 12:33:36 visa Exp $ */ +/* $OpenBSD: main.c,v 1.7 2021/04/13 08:21:12 claudio Exp $ */ /* * Copyright (c) 2015 Martin Pieuchot @@ -20,21 +20,17 @@ #include #include +#include +#include +#include #include #include #include #include "util.h" -#ifdef ART -#include -#include - -#include - extern void *rtable_get(unsigned int, sa_family_t); -#endif /* ART */ __dead void usage(void) @@ -62,12 +58,10 @@ main(int argc, char *argv[]) rtable_walk(0, AF_INET6, NULL, rtentry_dump, NULL); -#ifdef ART struct art_root *ar; ar = rtable_get(0, AF_INET6); assert(ar != NULL); assert(ar->ar_root.ref == NULL); -#endif /* ART */ return (0); } diff --git a/regress/sys/net/rtable/fullfeed/main.c b/regress/sys/net/rtable/fullfeed/main.c index fc5ddf95c9a..775a32f00b8 100644 --- a/regress/sys/net/rtable/fullfeed/main.c +++ b/regress/sys/net/rtable/fullfeed/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.4 2019/06/24 12:33:36 visa Exp $ */ +/* $OpenBSD: main.c,v 1.5 2021/04/13 08:21:12 claudio Exp $ */ /* * Copyright (c) 2015 Martin Pieuchot @@ -20,6 +20,7 @@ #include #include +#include #include #include diff --git a/regress/sys/net/rtable/kern_compat.h b/regress/sys/net/rtable/kern_compat.h index 4b45761f667..6515fe389f6 100644 --- a/regress/sys/net/rtable/kern_compat.h +++ b/regress/sys/net/rtable/kern_compat.h @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_compat.h,v 1.11 2020/11/07 09:53:21 denis Exp $ */ +/* $OpenBSD: kern_compat.h,v 1.12 2021/04/13 08:21:12 claudio Exp $ */ #ifndef _KERN_COMPAT_H_ #define _KERN_COMPAT_H_ @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -14,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -21,6 +23,7 @@ #include "srp_compat.h" +#define _KERNEL #define DIAGNOSTIC #define INET #define INET6 @@ -54,9 +57,6 @@ struct pool { #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) #endif -#define rtref(_rt) ((_rt)->rt_refcnt++) -#define rtfree(_rt) (assert(--(_rt)->rt_refcnt >= 0)) - #ifndef IPL_NONE #define IPL_NONE 0 #endif diff --git a/regress/sys/net/rtable/util.c b/regress/sys/net/rtable/util.c index 50756a1c2b5..3a962e3e6fb 100644 --- a/regress/sys/net/rtable/util.c +++ b/regress/sys/net/rtable/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.8 2018/12/03 18:39:42 bluhm Exp $ */ +/* $OpenBSD: util.c,v 1.9 2021/04/13 08:21:12 claudio Exp $ */ /* * Copyright (c) 2015 Martin Pieuchot @@ -52,7 +52,9 @@ #include #include +#define _KERNEL #include +#undef _KERNEL #include #include @@ -280,6 +282,18 @@ rt_maskedcopy(struct sockaddr *src, struct sockaddr *dst, memset(cp2, 0, (unsigned int)(cplim2 - cp2)); } +void +rtref(struct rtentry *rt) +{ + rt->rt_refcnt++; +} + +void +rtfree(struct rtentry *rt) +{ + assert(--(rt->rt_refcnt) >= 0); +} + void in_prefixlen2mask(struct in_addr *maskp, int plen) { @@ -341,11 +355,7 @@ rt_plentosa(sa_family_t af, int plen, struct sockaddr_in6 *sa_mask) struct sockaddr * rt_plen2mask(struct rtentry *rt, struct sockaddr_in6 *sa_mask) { -#ifndef ART - return (rt_mask(rt)); -#else return (rt_plentosa(rt_key(rt)->sa_family, rt_plen(rt), sa_mask)); -#endif /* ART */ } -- 2.20.1