Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/pgoyette-compat]: src Create a separate module for COMPAT_70 code only, ...
details: https://anonhg.NetBSD.org/src/rev/a18b2391a70e
branches: pgoyette-compat
changeset: 321027:a18b2391a70e
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Thu Mar 15 05:10:05 2018 +0000
description:
Create a separate module for COMPAT_70 code only, and untangle the
70 compat code from the current.
diffstat:
distrib/sets/lists/modules/mi | 4 +-
sys/compat/common/compat_70_mod.c | 81 +++++++++++++++++++++++++++++++++++++++
sys/compat/common/rtsock_70.c | 22 +++++++++-
sys/compat/net/route_70.h | 46 ++++++++++++++++++++++
sys/kern/uipc_usrreq.c | 52 +++++++++++++++---------
sys/modules/Makefile | 8 ++-
sys/modules/compat_70/Makefile | 13 ++++++
sys/net/rtsock.c | 40 ++++++++++++------
8 files changed, 227 insertions(+), 39 deletions(-)
diffs (truncated from 494 to 300 lines):
diff -r 31a66e66d120 -r a18b2391a70e distrib/sets/lists/modules/mi
--- a/distrib/sets/lists/modules/mi Wed Mar 14 22:26:15 2018 +0000
+++ b/distrib/sets/lists/modules/mi Thu Mar 15 05:10:05 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.114.2.2 2018/03/09 01:47:14 pgoyette Exp $
+# $NetBSD: mi,v 1.114.2.3 2018/03/15 05:10:05 pgoyette Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -68,6 +68,8 @@
./@MODULEDIR@/coda5/coda5.kmod base-kernel-modules kmod
./@MODULEDIR@/compat base-kernel-modules kmod
./@MODULEDIR@/compat/compat.kmod base-kernel-modules kmod
+./@MODULEDIR@/compat_70 base-kernel-modules kmod
+./@MODULEDIR@/compat_70/compat_70.kmod base-kernel-modules kmod
./@MODULEDIR@/compat_ossaudio base-kernel-modules kmod
./@MODULEDIR@/compat_ossaudio/compat_ossaudio.kmod base-kernel-modules kmod
./@MODULEDIR@/compat_sysv base-kernel-modules kmod
diff -r 31a66e66d120 -r a18b2391a70e sys/compat/common/compat_70_mod.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/common/compat_70_mod.c Thu Mar 15 05:10:05 2018 +0000
@@ -0,0 +1,81 @@
+/* $NetBSD: compat_70_mod.c,v 1.1.2.1 2018/03/15 05:10:05 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software developed for The NetBSD Foundation
+ * by Andrew Doran.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+/*
+ * Linkage for the compat module: spaghetti.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: compat_70_mod.c,v 1.1.2.1 2018/03/15 05:10:05 pgoyette Exp $");
+
+#ifdef _KERNEL_OPT
+#include "opt_compat_netbsd.h"
+#include "opt_compat_43.h"
+#include "opt_ntp.h"
+#include "opt_sysv.h"
+#include "opt_lfs.h"
+#endif
+
+#include <sys/systm.h>
+#include <sys/module.h>
+#include <sys/sysctl.h>
+
+#include <net/if.h>
+#include <net/route.h>
+
+#include <compat/common/compat_util.h>
+#include <compat/common/compat_mod.h>
+#include <compat/sys/sockio.h>
+
+#include <compat/net/route.h>
+#include <compat/net/route_70.h>
+
+MODULE(MODULE_CLASS_EXEC, compat_70, NULL); /* XXX No compat_80 yet */
+
+static int
+compat_70_modcmd(modcmd_t cmd, void *arg)
+{
+
+ switch (cmd) {
+ case MODULE_CMD_INIT:
+ vec_ocreds_valid = true;
+ rtsock_70_init();
+ return 0;
+
+ case MODULE_CMD_FINI:
+ rtsock_70_fini();
+ vec_ocreds_valid = false;
+ return 0;
+
+ default:
+ return ENOTTY;
+ }
+}
diff -r 31a66e66d120 -r a18b2391a70e sys/compat/common/rtsock_70.c
--- a/sys/compat/common/rtsock_70.c Wed Mar 14 22:26:15 2018 +0000
+++ b/sys/compat/common/rtsock_70.c Thu Mar 15 05:10:05 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtsock_70.c,v 1.2 2017/12/16 09:10:30 maxv Exp $ */
+/* $NetBSD: rtsock_70.c,v 1.2.2.1 2018/03/15 05:10:05 pgoyette Exp $ */
/*
* Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtsock_70.c,v 1.2 2017/12/16 09:10:30 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock_70.c,v 1.2.2.1 2018/03/15 05:10:05 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -42,6 +42,24 @@
#include <compat/net/if.h>
#include <compat/net/route.h>
+#include <compat/net/route_70.h>
+
+static void (*orig_70_rt_newaddrmsg1)(int, struct ifaddr *);
+
+void
+rtsock_70_init(void)
+{
+
+ orig_70_rt_newaddrmsg1 = vec_70_rt_newaddrmsg1;
+ vec_70_rt_newaddrmsg1 = compat_70_rt_newaddrmsg1;
+}
+
+void
+rtsock_70_fini(void)
+{
+
+ vec_70_rt_newaddrmsg1 = orig_70_rt_newaddrmsg1;
+}
void
compat_70_rt_newaddrmsg1(int cmd, struct ifaddr *ifa)
diff -r 31a66e66d120 -r a18b2391a70e sys/compat/net/route_70.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/net/route_70.h Thu Mar 15 05:10:05 2018 +0000
@@ -0,0 +1,46 @@
+/* $NetBSD: route_70.h,v 1.1.2.1 2018/03/15 05:10:05 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Paul Goyette
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#ifndef _COMPAT_NET_ROUTE_70_H_
+#define _COMPAT_NET_ROUTE_70_H_
+
+/* compat interfaces */
+
+void rtsock_70_init(void);
+void rtsock_70_fini(void);
+
+extern void (*vec_70_rt_newaddrmsg1)(int, struct ifaddr *);
+extern int (*vec_70_iflist_addr)(struct rt_walkarg *, struct ifaddr *,
+ struct rt_addrinfo *);
+
+extern bool vec_ocreds_valid;
+
+#endif /* !_COMPAT_NET_ROUTE_70_H_ */
diff -r 31a66e66d120 -r a18b2391a70e sys/kern/uipc_usrreq.c
--- a/sys/kern/uipc_usrreq.c Wed Mar 14 22:26:15 2018 +0000
+++ b/sys/kern/uipc_usrreq.c Thu Mar 15 05:10:05 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_usrreq.c,v 1.183 2018/02/17 20:19:36 christos Exp $ */
+/* $NetBSD: uipc_usrreq.c,v 1.183.2.1 2018/03/15 05:10:05 pgoyette Exp $ */
/*-
* Copyright (c) 1998, 2000, 2004, 2008, 2009 The NetBSD Foundation, Inc.
@@ -96,7 +96,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.183 2018/02/17 20:19:36 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.183.2.1 2018/03/15 05:10:05 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -124,9 +124,7 @@
#include <sys/kernel.h>
#include <sys/kthread.h>
-#ifdef COMPAT_70
#include <compat/sys/socket.h>
-#endif
/*
* Unix communications domain.
@@ -197,6 +195,22 @@
static SLIST_HEAD(,file) unp_thread_discard;
static int unp_defer;
+/* Compat interface */
+
+static struct mbuf *stub_compat_70_unp_addsockcred(lwp_t *, struct mbuf *);
+struct mbuf *(*vec_compat_70_unp_addsockcred)(struct lwp *, struct mbuf *) =
+ stub_compat_70_unp_addsockcred;
+
+struct mbuf *stub_compat_70_unp_addsockcred(struct lwp *lwp,
+ struct mbuf *control)
+{
+
+ /* just return our initial argument */
+ return control;
+}
+
+bool *vec_ocreds_valid = false;
+
/*
* Initialize Unix protocols.
*/
@@ -336,10 +350,8 @@
sun = &sun_noname;
if (unp->unp_conn->unp_flags & UNP_WANTCRED)
control = unp_addsockcred(curlwp, control);
-#ifdef COMPAT_SOCKCRED70
if (unp->unp_conn->unp_flags & UNP_OWANTCRED)
- control = compat_70_unp_addsockcred(curlwp, control);
-#endif
+ control = (*vec_compat_70_unp_addsockcred)(curlwp, control);
if (sbappendaddr(&so2->so_rcv, (const struct sockaddr *)sun, m,
control) == 0) {
so2->so_rcv.sb_overflowed++;
@@ -512,16 +524,14 @@
unp->unp_conn->unp_flags &= ~UNP_WANTCRED;
control = unp_addsockcred(l, control);
}
-#ifdef COMPAT_SOCKCRED70
if (unp->unp_conn->unp_flags & UNP_OWANTCRED) {
/*
* Credentials are passed only once on
* SOCK_STREAM and SOCK_SEQPACKET.
*/
unp->unp_conn->unp_flags &= ~UNP_OWANTCRED;
- control = compat_70_unp_addsockcred(l, control);
+ control = (*vec_compat_70_unp_addsockcred)(l, control);
}
-#endif
/*
* Send to paired receive port, and then reduce
* send buffer hiwater marks to maintain backpressure.
@@ -595,11 +605,14 @@
case PRCO_SETOPT:
switch (sopt->sopt_name) {
+ case LOCAL_OCREDS:
+ if (!*vec_ocreds_valid) {
+ error = ENOPROTOOPT;
+ break;
+ }
+ /* FALLTHROUGH */
case LOCAL_CREDS:
case LOCAL_CONNWAIT:
-#ifdef COMPAT_SOCKCRED70
- case LOCAL_OCREDS:
-#endif
error = sockopt_getint(sopt, &optval);
if (error)
break;
@@ -616,11 +629,9 @@
case LOCAL_CONNWAIT:
OPTSET(UNP_CONNWAIT);
break;
-#ifdef COMPAT_SOCKCRED70
Home |
Main Index |
Thread Index |
Old Index