Module Name: src Committed By: pgoyette Date: Sat Dec 9 15:21:02 UTC 2023
Modified Files: src/sys/compat/common: compat_90_mod.c compat_mod.h files.common src/sys/kern: compat_stub.c src/sys/modules/compat_90: Makefile src/sys/netinet6: icmp6.c in6.c nd6.c src/sys/sys: compat_stub.h Added Files: src/sys/compat/common: net_inet6_nd_90.c Log Message: Modularize the COMPAT_90 code that resulted from the removal of netinet6/nd6 from the kernel. Now, the minimal compat code can be successfully loaded and unloaded along with the rest of the COMPAT_90 code. XXX pullup-10 - hopefully before RC2 To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/compat/common/compat_90_mod.c cvs rdiff -u -r1.9 -r1.10 src/sys/compat/common/compat_mod.h cvs rdiff -u -r1.10 -r1.11 src/sys/compat/common/files.common cvs rdiff -u -r0 -r1.1 src/sys/compat/common/net_inet6_nd_90.c cvs rdiff -u -r1.22 -r1.23 src/sys/kern/compat_stub.c cvs rdiff -u -r1.1 -r1.2 src/sys/modules/compat_90/Makefile cvs rdiff -u -r1.254 -r1.255 src/sys/netinet6/icmp6.c cvs rdiff -u -r1.290 -r1.291 src/sys/netinet6/in6.c cvs rdiff -u -r1.280 -r1.281 src/sys/netinet6/nd6.c cvs rdiff -u -r1.26 -r1.27 src/sys/sys/compat_stub.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/compat/common/compat_90_mod.c diff -u src/sys/compat/common/compat_90_mod.c:1.4 src/sys/compat/common/compat_90_mod.c:1.5 --- src/sys/compat/common/compat_90_mod.c:1.4 Mon Dec 19 23:19:51 2022 +++ src/sys/compat/common/compat_90_mod.c Sat Dec 9 15:21:01 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: compat_90_mod.c,v 1.4 2022/12/19 23:19:51 pgoyette Exp $ */ +/* $NetBSD: compat_90_mod.c,v 1.5 2023/12/09 15:21:01 pgoyette Exp $ */ /*- * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #endif #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: compat_90_mod.c,v 1.4 2022/12/19 23:19:51 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: compat_90_mod.c,v 1.5 2023/12/09 15:21:01 pgoyette Exp $"); #include <sys/systm.h> #include <sys/module.h> @@ -50,14 +50,21 @@ int compat_90_init(void) { + net_inet6_nd_90_init(); return vfs_syscalls_90_init(); } int compat_90_fini(void) { + int error; - return vfs_syscalls_90_fini(); + error = vfs_syscalls_90_fini(); + if (error != 0) + return error; + + net_inet6_nd_90_fini(); + return error; } MODULE(MODULE_CLASS_EXEC, compat_90, "compat_100"); Index: src/sys/compat/common/compat_mod.h diff -u src/sys/compat/common/compat_mod.h:1.9 src/sys/compat/common/compat_mod.h:1.10 --- src/sys/compat/common/compat_mod.h:1.9 Fri Aug 18 19:41:18 2023 +++ src/sys/compat/common/compat_mod.h Sat Dec 9 15:21:01 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: compat_mod.h,v 1.9 2023/08/18 19:41:18 christos Exp $ */ +/* $NetBSD: compat_mod.h,v 1.10 2023/12/09 15:21:01 pgoyette Exp $ */ /*- * Copyright (c) 2013, 2019 The NetBSD Foundation, Inc. @@ -46,6 +46,8 @@ int compat_90_init(void); int compat_90_fini(void); int vfs_syscalls_90_init(void); int vfs_syscalls_90_fini(void); +int net_inet6_nd_90_init(void); +int net_inet6_nd_90_fini(void); #endif #ifdef COMPAT_80 Index: src/sys/compat/common/files.common diff -u src/sys/compat/common/files.common:1.10 src/sys/compat/common/files.common:1.11 --- src/sys/compat/common/files.common:1.10 Fri Aug 18 19:41:18 2023 +++ src/sys/compat/common/files.common Sat Dec 9 15:21:01 2023 @@ -1,4 +1,4 @@ -# $NetBSD: files.common,v 1.10 2023/08/18 19:41:18 christos Exp $ +# $NetBSD: files.common,v 1.11 2023/12/09 15:21:01 pgoyette Exp $ # # Generic utility files, used by various compat options. @@ -109,6 +109,7 @@ file compat/common/if_media_80.c compat # Compatibility code for NetBSD 9.0 file compat/common/compat_90_mod.c compat_90 file compat/common/vfs_syscalls_90.c compat_90 +file compat/common/net_inet6_nd_90.c compat_90 # Compatibility code for NetBSD 10.0 file compat/common/compat_100_mod.c compat_100 Index: src/sys/kern/compat_stub.c diff -u src/sys/kern/compat_stub.c:1.22 src/sys/kern/compat_stub.c:1.23 --- src/sys/kern/compat_stub.c:1.22 Mon Aug 9 20:49:10 2021 +++ src/sys/kern/compat_stub.c Sat Dec 9 15:21:01 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: compat_stub.c,v 1.22 2021/08/09 20:49:10 andvar Exp $ */ +/* $NetBSD: compat_stub.c,v 1.23 2023/12/09 15:21:01 pgoyette Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -286,4 +286,8 @@ struct coredump_elf64_hook_t coredump_el struct uvm_coredump_walkmap_hook_t uvm_coredump_walkmap_hook; struct uvm_coredump_count_segs_hook_t uvm_coredump_count_segs_hook; +/* + * Hooks for interacting with remnants of netinet6/nd6 removal + */ +struct net_inet6_nd_90_hook_t net_inet6_nd_90_hook; Index: src/sys/modules/compat_90/Makefile diff -u src/sys/modules/compat_90/Makefile:1.1 src/sys/modules/compat_90/Makefile:1.2 --- src/sys/modules/compat_90/Makefile:1.1 Sun Sep 22 22:59:39 2019 +++ src/sys/modules/compat_90/Makefile Sat Dec 9 15:21:01 2023 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.1 2019/09/22 22:59:39 christos Exp $ +# $NetBSD: Makefile,v 1.2 2023/12/09 15:21:01 pgoyette Exp $ .include "../Makefile.inc" @@ -9,6 +9,7 @@ KMOD= compat_90 CPPFLAGS+= -DCOMPAT_90 SRCS+= compat_90_mod.c +SRCS+= net_inet6_nd_90.c SRCS+= vfs_syscalls_90.c .include <bsd.kmodule.mk> Index: src/sys/netinet6/icmp6.c diff -u src/sys/netinet6/icmp6.c:1.254 src/sys/netinet6/icmp6.c:1.255 --- src/sys/netinet6/icmp6.c:1.254 Fri Oct 28 05:25:36 2022 +++ src/sys/netinet6/icmp6.c Sat Dec 9 15:21:02 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: icmp6.c,v 1.254 2022/10/28 05:25:36 ozaki-r Exp $ */ +/* $NetBSD: icmp6.c,v 1.255 2023/12/09 15:21:02 pgoyette Exp $ */ /* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */ /* @@ -62,7 +62,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.254 2022/10/28 05:25:36 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.255 2023/12/09 15:21:02 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -2896,26 +2896,6 @@ icmp6_redirect_timeout(struct rtentry *r } } -#ifdef COMPAT_90 -/* - * sysctl helper routine for the net.inet6.icmp6.nd6 nodes. silly? - */ -static int -sysctl_net_inet6_icmp6_nd6(SYSCTLFN_ARGS) -{ - (void)&name; - (void)&l; - (void)&oname; - - if (namelen != 0) - return (EINVAL); - - return (nd6_sysctl(rnode->sysctl_num, oldp, oldlenp, - /*XXXUNCONST*/ - __UNCONST(newp), newlen)); -} -#endif - static int sysctl_net_inet6_icmp6_stats(SYSCTLFN_ARGS) { @@ -3098,22 +3078,6 @@ sysctl_net_inet6_icmp6_setup(struct sysc NULL, 0, &nd6_debug, 0, CTL_NET, PF_INET6, IPPROTO_ICMPV6, ICMPV6CTL_ND6_DEBUG, CTL_EOL); -#ifdef COMPAT_90 - sysctl_createv(clog, 0, NULL, NULL, - CTLFLAG_PERMANENT, - CTLTYPE_STRUCT, "nd6_drlist", - SYSCTL_DESCR("Default router list"), - sysctl_net_inet6_icmp6_nd6, 0, NULL, 0, - CTL_NET, PF_INET6, IPPROTO_ICMPV6, - OICMPV6CTL_ND6_DRLIST, CTL_EOL); - sysctl_createv(clog, 0, NULL, NULL, - CTLFLAG_PERMANENT, - CTLTYPE_STRUCT, "nd6_prlist", - SYSCTL_DESCR("Prefix list"), - sysctl_net_inet6_icmp6_nd6, 0, NULL, 0, - CTL_NET, PF_INET6, IPPROTO_ICMPV6, - OICMPV6CTL_ND6_PRLIST, CTL_EOL); -#endif sysctl_createv(clog, 0, NULL, NULL, CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_BOOL, "reflect_pmtu", Index: src/sys/netinet6/in6.c diff -u src/sys/netinet6/in6.c:1.290 src/sys/netinet6/in6.c:1.291 --- src/sys/netinet6/in6.c:1.290 Thu Dec 7 16:47:44 2023 +++ src/sys/netinet6/in6.c Sat Dec 9 15:21:02 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: in6.c,v 1.290 2023/12/07 16:47:44 pgoyette Exp $ */ +/* $NetBSD: in6.c,v 1.291 2023/12/09 15:21:02 pgoyette Exp $ */ /* $KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $ */ /* @@ -62,7 +62,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.290 2023/12/07 16:47:44 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.291 2023/12/09 15:21:02 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -105,24 +105,8 @@ __KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.29 #include <netinet6/in6_ifattach.h> #include <netinet6/scope6_var.h> -/* XXX - * - * The COMPAT_* code here, along with call-sites in nd6.c and - * icmp6.c, needs to be reworked to use compat hooks. As it - * stands right now, the compat code only gets built if it is - * iincluded in the kernel at build time; building and loading - * compat_* modules will not include this compat code! - * - * XXX - */ - -#ifdef COMPAT_50 -#include <compat/netinet6/in6_var.h> -#endif -#ifdef COMPAT_90 #include <compat/netinet6/in6_var.h> #include <compat/netinet6/nd6.h> -#endif MALLOC_DEFINE(M_IP6OPT, "ip6_options", "IPv6 options"); Index: src/sys/netinet6/nd6.c diff -u src/sys/netinet6/nd6.c:1.280 src/sys/netinet6/nd6.c:1.281 --- src/sys/netinet6/nd6.c:1.280 Wed Oct 11 09:13:51 2023 +++ src/sys/netinet6/nd6.c Sat Dec 9 15:21:02 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: nd6.c,v 1.280 2023/10/11 09:13:51 msaitoh Exp $ */ +/* $NetBSD: nd6.c,v 1.281 2023/12/09 15:21:02 pgoyette Exp $ */ /* $KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $ */ /* @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.280 2023/10/11 09:13:51 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.281 2023/12/09 15:21:02 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -57,6 +57,7 @@ __KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.28 #include <sys/queue.h> #include <sys/cprng.h> #include <sys/workqueue.h> +#include <sys/compat_stub.h> #include <net/if.h> #include <net/if_dl.h> @@ -77,10 +78,8 @@ __KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.28 #include <netinet/icmp6.h> #include <netinet6/icmp6_private.h> -#ifdef COMPAT_90 #include <compat/netinet6/in6_var.h> #include <compat/netinet6/nd6.h> -#endif #define ND6_SLOWTIMER_INTERVAL (60 * 60) /* 1 hour */ #define ND6_RECALC_REACHTM_INTERVAL (60 * 120) /* 2 hours */ @@ -1673,17 +1672,22 @@ nd6_sysctl( size_t newlen ) { + int error; if (newp) return EPERM; switch (name) { -#ifdef COMPAT_90 + +/* call the nd6 compat_90 hook to validate the nd6-related names */ case OICMPV6CTL_ND6_DRLIST: /* FALLTHROUGH */ case OICMPV6CTL_ND6_PRLIST: - *oldlenp = 0; - return 0; -#endif + MODULE_HOOK_CALL(net_inet6_nd_90_hook, (name), ENOPROTOOPT, + error); + if (error == 0) + *oldlenp = 0; + return error; + case ICMPV6CTL_ND6_MAXQLEN: return 0; default: Index: src/sys/sys/compat_stub.h diff -u src/sys/sys/compat_stub.h:1.26 src/sys/sys/compat_stub.h:1.27 --- src/sys/sys/compat_stub.h:1.26 Mon Jul 31 17:41:18 2023 +++ src/sys/sys/compat_stub.h Sat Dec 9 15:21:02 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: compat_stub.h,v 1.26 2023/07/31 17:41:18 christos Exp $ */ +/* $NetBSD: compat_stub.h,v 1.27 2023/12/09 15:21:02 pgoyette Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -402,4 +402,9 @@ struct proc; struct trapframe; MODULE_HOOK(amd64_oosyscall_hook, int, (struct proc *, struct trapframe *)); +/* + * Hook for compat_90 to deal with removal of nd6 from the kernel + */ +MODULE_HOOK(net_inet6_nd_90_hook, int, (int)); + #endif /* _SYS_COMPAT_STUB_H */ Added files: Index: src/sys/compat/common/net_inet6_nd_90.c diff -u /dev/null src/sys/compat/common/net_inet6_nd_90.c:1.1 --- /dev/null Sat Dec 9 15:21:02 2023 +++ src/sys/compat/common/net_inet6_nd_90.c Sat Dec 9 15:21:01 2023 @@ -0,0 +1,130 @@ +/* $NetBSD: net_inet6_nd_90.c,v 1.1 2023/12/09 15:21:01 pgoyette Exp $ */ + +/* $NetBSD: net_inet6_nd_90.c,v 1.1 2023/12/09 15:21:01 pgoyette Exp $ */ +/* $KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: net_inet6_nd_90.c,v 1.1 2023/12/09 15:21:01 pgoyette Exp $"); + +#if defined(_KERNEL_OPT) +#include "opt_compat_netbsd.h" +#endif + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/namei.h> +#include <sys/filedesc.h> +#include <sys/kernel.h> +#include <sys/sysctl.h> + +#include <net/if.h> + +#include <netinet/in.h> + +#include <netinet/icmp6.h> +#include <netinet/ip6.h> + +#include <netinet6/in6_var.h> +#include <netinet6/nd6.h> + +#include <sys/compat_stub.h> + +#include <compat/common/compat_mod.h> + +static struct sysctllog *nd6_clog; + +/* + * sysctl helper routine for the net.inet6.icmp6.nd6 nodes. silly? + */ +static int +sysctl_net_inet6_icmp6_nd6(SYSCTLFN_ARGS) +{ + (void)&name; + (void)&l; + (void)&oname; + + if (namelen != 0) + return (EINVAL); + + return (nd6_sysctl(rnode->sysctl_num, oldp, oldlenp, + /*XXXUNCONST*/ + __UNCONST(newp), newlen)); +} +int real_net_inet6_nd_90(int); + +/* + * the hook is only called for valid codes, so the mere presence + * of the hook means success. + */ +/* ARGSUSED */ +int +real_net_inet6_nd_90(int name) +{ + + return 0; +} + +int +net_inet6_nd_90_init(void) +{ + int error; + + error = sysctl_createv(&nd6_clog, 0, NULL, NULL, + CTLFLAG_PERMANENT, + CTLTYPE_STRUCT, "nd6_drlist", + SYSCTL_DESCR("Default router list"), + sysctl_net_inet6_icmp6_nd6, 0, NULL, 0, + CTL_NET, PF_INET6, IPPROTO_ICMPV6, + OICMPV6CTL_ND6_DRLIST, CTL_EOL); + if (error != 0) + return error; + + error = sysctl_createv(&nd6_clog, 0, NULL, NULL, + CTLFLAG_PERMANENT, + CTLTYPE_STRUCT, "nd6_prlist", + SYSCTL_DESCR("Prefix list"), + sysctl_net_inet6_icmp6_nd6, 0, NULL, 0, + CTL_NET, PF_INET6, IPPROTO_ICMPV6, + OICMPV6CTL_ND6_PRLIST, CTL_EOL); + + MODULE_HOOK_SET(net_inet6_nd_90_hook, real_net_inet6_nd_90); + return error; +} + +int +net_inet6_nd_90_fini(void) +{ + + sysctl_teardown(&nd6_clog); + MODULE_HOOK_UNSET(net_inet6_nd_90_hook); + return 0; +}