Module Name: src
Committed By: pgoyette
Date: Thu Mar 15 05:10:06 UTC 2018
Modified Files:
src/distrib/sets/lists/modules [pgoyette-compat]: mi
src/sys/compat/common [pgoyette-compat]: rtsock_70.c
src/sys/kern [pgoyette-compat]: uipc_usrreq.c
src/sys/modules [pgoyette-compat]: Makefile
src/sys/net [pgoyette-compat]: rtsock.c
Added Files:
src/sys/compat/common [pgoyette-compat]: compat_70_mod.c
src/sys/compat/net [pgoyette-compat]: route_70.h
src/sys/modules/compat_70 [pgoyette-compat]: Makefile
Log Message:
Create a separate module for COMPAT_70 code only, and untangle the
70 compat code from the current.
To generate a diff of this commit:
cvs rdiff -u -r1.114.2.2 -r1.114.2.3 src/distrib/sets/lists/modules/mi
cvs rdiff -u -r0 -r1.1.2.1 src/sys/compat/common/compat_70_mod.c
cvs rdiff -u -r1.2 -r1.2.2.1 src/sys/compat/common/rtsock_70.c
cvs rdiff -u -r0 -r1.1.2.1 src/sys/compat/net/route_70.h
cvs rdiff -u -r1.183 -r1.183.2.1 src/sys/kern/uipc_usrreq.c
cvs rdiff -u -r1.202.2.2 -r1.202.2.3 src/sys/modules/Makefile
cvs rdiff -u -r0 -r1.1.2.1 src/sys/modules/compat_70/Makefile
cvs rdiff -u -r1.238 -r1.238.2.1 src/sys/net/rtsock.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/distrib/sets/lists/modules/mi
diff -u src/distrib/sets/lists/modules/mi:1.114.2.2 src/distrib/sets/lists/modules/mi:1.114.2.3
--- src/distrib/sets/lists/modules/mi:1.114.2.2 Fri Mar 9 01:47:14 2018
+++ src/distrib/sets/lists/modules/mi Thu Mar 15 05:10:05 2018
@@ -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
Index: src/sys/compat/common/rtsock_70.c
diff -u src/sys/compat/common/rtsock_70.c:1.2 src/sys/compat/common/rtsock_70.c:1.2.2.1
--- src/sys/compat/common/rtsock_70.c:1.2 Sat Dec 16 09:10:30 2017
+++ src/sys/compat/common/rtsock_70.c Thu Mar 15 05:10:05 2018
@@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: rtsock_70.c,
#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)
Index: src/sys/kern/uipc_usrreq.c
diff -u src/sys/kern/uipc_usrreq.c:1.183 src/sys/kern/uipc_usrreq.c:1.183.2.1
--- src/sys/kern/uipc_usrreq.c:1.183 Sat Feb 17 20:19:36 2018
+++ src/sys/kern/uipc_usrreq.c Thu Mar 15 05:10:05 2018
@@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.
#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 lwp_t *unp_thread_lwp;
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 @@ unp_output(struct mbuf *m, struct mbuf *
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_send(struct socket *so, struct mbuf
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 @@ uipc_ctloutput(int op, struct socket *so
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 @@ uipc_ctloutput(int op, struct socket *so
case LOCAL_CONNWAIT:
OPTSET(UNP_CONNWAIT);
break;
-#ifdef COMPAT_SOCKCRED70
case LOCAL_OCREDS:
OPTSET(UNP_OWANTCRED);
break;
-#endif
}
break;
#undef OPTSET
@@ -648,12 +659,13 @@ uipc_ctloutput(int op, struct socket *so
optval = OPTBIT(UNP_WANTCRED);
error = sockopt_setint(sopt, optval);
break;
-#ifdef COMPAT_SOCKCRED70
case LOCAL_OCREDS:
- optval = OPTBIT(UNP_OWANTCRED);
- error = sockopt_setint(sopt, optval);
- break;
-#endif
+ if (*vec_ocreds_valid) {
+ optval = OPTBIT(UNP_OWANTCRED);
+ error = sockopt_setint(sopt, optval);
+ break;
+ }
+ /* FALLTHROUGH */
#undef OPTBIT
default:
Index: src/sys/modules/Makefile
diff -u src/sys/modules/Makefile:1.202.2.2 src/sys/modules/Makefile:1.202.2.3
--- src/sys/modules/Makefile:1.202.2.2 Fri Mar 9 01:45:46 2018
+++ src/sys/modules/Makefile Thu Mar 15 05:10:05 2018
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.202.2.2 2018/03/09 01:45:46 pgoyette Exp $
+# $NetBSD: Makefile,v 1.202.2.3 2018/03/15 05:10:05 pgoyette Exp $
.include <bsd.own.mk>
@@ -27,7 +27,11 @@ SUBDIR+= clockctl
SUBDIR+= crypto
SUBDIR+= coda
SUBDIR+= coda5
-SUBDIR+= compat
+SUBDIR+= compat compat_70
+#ifdef NOTYET
+SUBDIR+= compat_60 compat_50 compat_40 compat_30 compat_20 compat_16
+SUBDIR+= compat_14 compat_13 compat_12 compat_10 compat_09
+#endif
SUBDIR+= compat_ossaudio
SUBDIR+= compat_sysv
SUBDIR+= coredump
Index: src/sys/net/rtsock.c
diff -u src/sys/net/rtsock.c:1.238 src/sys/net/rtsock.c:1.238.2.1
--- src/sys/net/rtsock.c:1.238 Thu Jan 25 03:09:05 2018
+++ src/sys/net/rtsock.c Thu Mar 15 05:10:06 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: rtsock.c,v 1.238 2018/01/25 03:09:05 ozaki-r Exp $ */
+/* $NetBSD: rtsock.c,v 1.238.2.1 2018/03/15 05:10:06 pgoyette Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.238 2018/01/25 03:09:05 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.238.2.1 2018/03/15 05:10:06 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -100,10 +100,10 @@ extern void sctp_add_ip_address(struct i
extern void sctp_delete_ip_address(struct ifaddr *);
#endif
-#if defined(COMPAT_14) || defined(COMPAT_50) || defined(COMPAT_70)
#include <compat/net/if.h>
#include <compat/net/route.h>
-#endif
+#include <compat/net/route_70.h>
+
#ifdef COMPAT_RTSOCK
#define RTM_XVERSION RTM_OVERSION
#define RTM_XNEWADDR RTM_ONEWADDR
@@ -193,6 +193,24 @@ static bool rt_updating = false;
static kcondvar_t rt_update_cv;
#endif
+#ifndef COMPAT_RTSOCK
+static int
+sysctl_iflist_addr(struct rt_walkarg *, struct ifaddr *, struct rt_addrinfo *);
+
+/*
+ * Compat linkage
+ */
+static void stub_70_rt_newaddrmsg1(int cmd, struct ifaddr*ifa)
+{
+
+ /* nothing */
+}
+
+void (*vec_70_rt_newaddrmsg1)(int, struct ifaddr *) = stub_70_rt_newaddrmsg1;
+int (*vec_70_iflist_addr)(struct rt_walkarg *, struct ifaddr *,
+ struct rt_addrinfo *)= sysctl_iflist_addr;
+#endif
+
static void
rt_adjustcount(int af, int cnt)
{
@@ -1601,9 +1619,7 @@ COMPATNAME(rt_newaddrmsg)(int cmd, struc
default:
panic("%s: unknown command %d", __func__, cmd);
}
-#ifdef COMPAT_70
- compat_70_rt_newaddrmsg1(ncmd, ifa);
-#endif
+ (*vec_70_rt_newaddrmsg1)(ncmd, ifa);
info.rti_info[RTAX_IFA] = sa = ifa->ifa_addr;
KASSERT(ifp->if_dl != NULL);
info.rti_info[RTAX_IFP] = ifp->if_dl->ifa_addr;
@@ -1830,6 +1846,7 @@ sysctl_iflist_if(struct ifnet *ifp, stru
return error;
}
+#ifndef COMPAT_RTSOCK /* XXX need to include the stuff in COMPAT_50 */
static int
sysctl_iflist_addr(struct rt_walkarg *w, struct ifaddr *ifa,
struct rt_addrinfo *info)
@@ -1855,6 +1872,7 @@ sysctl_iflist_addr(struct rt_walkarg *w,
}
return error;
}
+#endif /* XXX */
static int
sysctl_iflist(int af, struct rt_walkarg *w, int type)
@@ -1865,8 +1883,6 @@ sysctl_iflist(int af, struct rt_walkarg
int cmd, len, error = 0;
int (*iflist_if)(struct ifnet *, struct rt_walkarg *,
struct rt_addrinfo *, size_t);
- int (*iflist_addr)(struct rt_walkarg *, struct ifaddr *,
- struct rt_addrinfo *);
int s;
struct psref psref;
int bound;
@@ -1875,27 +1891,23 @@ sysctl_iflist(int af, struct rt_walkarg
case NET_RT_IFLIST:
cmd = RTM_IFINFO;
iflist_if = sysctl_iflist_if;
- iflist_addr = sysctl_iflist_addr;
break;
#ifdef COMPAT_14
case NET_RT_OOOIFLIST:
cmd = RTM_OOIFINFO;
iflist_if = compat_14_iflist;
- iflist_addr = compat_70_iflist_addr;
break;
#endif
#ifdef COMPAT_50
case NET_RT_OOIFLIST:
cmd = RTM_OIFINFO;
iflist_if = compat_50_iflist;
- iflist_addr = compat_70_iflist_addr;
break;
#endif
#ifdef COMPAT_70
case NET_RT_OIFLIST:
cmd = RTM_IFINFO;
iflist_if = sysctl_iflist_if;
- iflist_addr = compat_70_iflist_addr;
break;
#endif
default:
@@ -1938,7 +1950,7 @@ sysctl_iflist(int af, struct rt_walkarg
info.rti_info[RTAX_IFA] = ifa->ifa_addr;
info.rti_info[RTAX_NETMASK] = ifa->ifa_netmask;
info.rti_info[RTAX_BRD] = ifa->ifa_dstaddr;
- error = iflist_addr(w, ifa, &info);
+ error = (*vec_70_iflist_addr)(w, ifa, &info);
_s = pserialize_read_enter();
ifa_release(ifa, &_psref);
Added files:
Index: src/sys/compat/common/compat_70_mod.c
diff -u /dev/null src/sys/compat/common/compat_70_mod.c:1.1.2.1
--- /dev/null Thu Mar 15 05:10:06 2018
+++ src/sys/compat/common/compat_70_mod.c Thu Mar 15 05:10:05 2018
@@ -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;
+ }
+}
Index: src/sys/compat/net/route_70.h
diff -u /dev/null src/sys/compat/net/route_70.h:1.1.2.1
--- /dev/null Thu Mar 15 05:10:06 2018
+++ src/sys/compat/net/route_70.h Thu Mar 15 05:10:05 2018
@@ -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_ */
Index: src/sys/modules/compat_70/Makefile
diff -u /dev/null src/sys/modules/compat_70/Makefile:1.1.2.1
--- /dev/null Thu Mar 15 05:10:06 2018
+++ src/sys/modules/compat_70/Makefile Thu Mar 15 05:10:05 2018
@@ -0,0 +1,13 @@
+# $NetBSD: Makefile,v 1.1.2.1 2018/03/15 05:10:05 pgoyette Exp $
+
+.include "../Makefile.inc"
+
+.PATH: ${S}/compat/common
+
+KMOD= compat
+
+CPPFLAGS+= -DCOMPAT_70 -DCOMPAT_80
+
+SRCS+= compat_70_mod.c rtsock_70.c uipc_usrreq_70.c
+
+.include <bsd.kmodule.mk>