Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Move if_43.c back into the shared Makefile.sysio where i...
details: https://anonhg.NetBSD.org/src/rev/9c4d99b409aa
branches: trunk
changeset: 348758:9c4d99b409aa
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Sat Nov 05 23:30:22 2016 +0000
description:
Move if_43.c back into the shared Makefile.sysio where it really
belongs.
Update the code to invoke the two routines compat_cvtcmd() and
compat_ifioctl() through indirect pointers. Initialize those
pointers in sys/net/if.c and update them in the compat module's
initialization code.
Addresses the issue pointed out in PR kern/51598
diffstat:
sys/compat/common/Makefile | 5 +---
sys/compat/common/Makefile.sysio | 4 +-
sys/compat/common/compat_mod.c | 11 +++++++--
sys/compat/common/if_43.c | 34 ++++++++++++++++++++++++++++--
sys/compat/common/if_43.h | 44 ++++++++++++++++++++++++++++++++++++++++
sys/net/if.c | 36 +++++++++++++++++++++++++-------
6 files changed, 114 insertions(+), 20 deletions(-)
diffs (269 lines):
diff -r 60725320e1af -r 9c4d99b409aa sys/compat/common/Makefile
--- a/sys/compat/common/Makefile Sat Nov 05 23:09:37 2016 +0000
+++ b/sys/compat/common/Makefile Sat Nov 05 23:30:22 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.59 2016/11/03 22:23:03 pgoyette Exp $
+# $NetBSD: Makefile,v 1.60 2016/11/05 23:30:22 pgoyette Exp $
LIB= compat
NOPIC= # defined
@@ -11,9 +11,6 @@
# Common compatibility code, used by all emulations
SRCS= compat_exec.c compat_util.c
-# Compatability code for 4.3BSD
-SRCS+= if_43.c
-
# Include compatability code common to libcompat and the compat module
.include "Makefile.sysio"
diff -r 60725320e1af -r 9c4d99b409aa sys/compat/common/Makefile.sysio
--- a/sys/compat/common/Makefile.sysio Sat Nov 05 23:09:37 2016 +0000
+++ b/sys/compat/common/Makefile.sysio Sat Nov 05 23:30:22 2016 +0000
@@ -1,10 +1,10 @@
-# $NetBSD: Makefile.sysio,v 1.6 2016/11/03 22:23:03 pgoyette Exp $
+# $NetBSD: Makefile.sysio,v 1.7 2016/11/05 23:30:22 pgoyette Exp $
# Sources for syscall and ioctl compatibility across the versions.
# Compatibility code for 4.3BSD
SRCS+= kern_exit_43.c kern_info_43.c kern_resource_43.c kern_sig_43.c \
- tty_43.c uipc_syscalls_43.c vfs_syscalls_43.c vm_43.c
+ tty_43.c uipc_syscalls_43.c vfs_syscalls_43.c vm_43.c if_43.c
# Compatibility code for NetBSD 0.9
SRCS+= kern_info_09.c
diff -r 60725320e1af -r 9c4d99b409aa sys/compat/common/compat_mod.c
--- a/sys/compat/common/compat_mod.c Sat Nov 05 23:09:37 2016 +0000
+++ b/sys/compat/common/compat_mod.c Sat Nov 05 23:30:22 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_mod.c,v 1.23 2015/12/05 01:59:51 pgoyette Exp $ */
+/* $NetBSD: compat_mod.c,v 1.24 2016/11/05 23:30:22 pgoyette Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.23 2015/12/05 01:59:51 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.24 2016/11/05 23:30:22 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -59,11 +59,12 @@
#include <compat/common/compat_util.h>
#include <compat/common/compat_mod.h>
+#include <compat/common/if_43.h>
#if defined(COMPAT_09) || defined(COMPAT_43) || defined(COMPAT_50)
static struct sysctllog *compat_clog = NULL;
#endif
-
+
MODULE(MODULE_CLASS_EXEC, compat, NULL);
int ttcompat(struct tty *, u_long, void *, int, struct lwp *);
@@ -235,6 +236,7 @@
#ifdef COMPAT_43
KASSERT(ttcompatvec == NULL);
ttcompatvec = ttcompat;
+ if_43_init();
#endif
#ifdef COMPAT_16
#if defined(COMPAT_SIGCONTEXT)
@@ -332,4 +334,7 @@
#if defined(COMPAT_09) || defined(COMPAT_43) || defined(COMPAT_50)
sysctl_teardown(&compat_clog);
#endif
+#if defined(COMPAT_43)
+ if_43_fini();
+#endif
}
diff -r 60725320e1af -r 9c4d99b409aa sys/compat/common/if_43.c
--- a/sys/compat/common/if_43.c Sat Nov 05 23:09:37 2016 +0000
+++ b/sys/compat/common/if_43.c Sat Nov 05 23:30:22 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_43.c,v 1.12 2016/07/25 08:30:19 ozaki-r Exp $ */
+/* $NetBSD: if_43.c,v 1.13 2016/11/05 23:30:22 pgoyette Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1990, 1993
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_43.c,v 1.12 2016/07/25 08:30:19 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_43.c,v 1.13 2016/11/05 23:30:22 pgoyette Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@@ -73,7 +73,7 @@
#include <compat/sys/sockio.h>
#include <compat/common/compat_util.h>
-
+#include <compat/common/if_43.h>
#include <uvm/uvm_extern.h>
u_long
@@ -280,3 +280,31 @@
return error;
}
+
+#if defined(COMPAT_43)
+static u_long (*orig_compat_cvtcmd)(u_long);
+static int (*orig_compat_ifioctl)(struct socket *, u_long, u_long,
+ void *, struct lwp *);
+
+void
+if_43_init(void)
+{
+ extern u_long (*vec_compat_cvtcmd)(u_long);
+ extern int (*vec_compat_ifioctl)(struct socket *, u_long, u_long,
+ void *, struct lwp *);
+
+ orig_compat_cvtcmd = vec_compat_cvtcmd;
+ vec_compat_cvtcmd = compat_cvtcmd;
+
+ orig_compat_ifioctl = vec_compat_ifioctl;
+ vec_compat_ifioctl = compat_ifioctl;
+}
+
+void
+if_43_fini(void)
+{
+
+ vec_compat_cvtcmd = orig_compat_cvtcmd;
+ vec_compat_ifioctl = orig_compat_ifioctl;
+}
+#endif /* defined(COMPAT_43) */
diff -r 60725320e1af -r 9c4d99b409aa sys/compat/common/if_43.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/common/if_43.h Sat Nov 05 23:30:22 2016 +0000
@@ -0,0 +1,44 @@
+/* $NetBSD: if_43.h,v 1.1 2016/11/05 23:30:22 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 2016 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_IF_43_H_
+#define _COMPAT_IF_43_H_
+
+#if defined(COMPAT_43)
+extern u_long (*vec_compat_cvtcmd)(u_long);
+extern int (*vec_compat_ifioctl)(struct socket *, u_long, u_long,
+ void *, struct lwp *);
+
+void if_43_init(void);
+void if_43_fini(void);
+#endif
+
+#endif /* !_COMPAT_IF_43_H_ */
diff -r 60725320e1af -r 9c4d99b409aa sys/net/if.c
--- a/sys/net/if.c Sat Nov 05 23:09:37 2016 +0000
+++ b/sys/net/if.c Sat Nov 05 23:30:22 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.c,v 1.360 2016/10/28 05:52:05 ozaki-r Exp $ */
+/* $NetBSD: if.c,v 1.361 2016/11/05 23:30:22 pgoyette Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.360 2016/10/28 05:52:05 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.361 2016/11/05 23:30:22 pgoyette Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -227,6 +227,25 @@
static void sysctl_net_pktq_setup(struct sysctllog **, int);
#endif
+/*
+ * Pointer to stub or real compat_cvtcmd() depending on presence of
+ * the compat module
+ */
+u_long stub_compat_cvtcmd(u_long);
+u_long (*vec_compat_cvtcmd)(u_long) = stub_compat_cvtcmd;
+
+/* Similarly, pointer to compat_ifioctl() if it is present */
+
+int (*vec_compat_ifioctl)(struct socket *, u_long, u_long, void *,
+ struct lwp *) = NULL;
+
+/* The stub version of compat_cvtcmd() */
+u_long stub_compat_cvtcmd(u_long cmd)
+{
+
+ return cmd;
+}
+
static int
if_listener_cb(kauth_cred_t cred, kauth_action_t action, void *cookie,
void *arg0, void *arg1, void *arg2, void *arg3)
@@ -2769,7 +2788,7 @@
}
#ifdef COMPAT_OIFREQ
- cmd = compat_cvtcmd(cmd);
+ cmd = (*vec_compat_cvtcmd)(cmd);
if (cmd != ocmd) {
oifr = data;
data = ifr = &ifrb;
@@ -2866,11 +2885,12 @@
error = EOPNOTSUPP;
else {
#ifdef COMPAT_OSOCK
- error = compat_ifioctl(so, ocmd, cmd, data, l);
-#else
- error = (*so->so_proto->pr_usrreqs->pr_ioctl)(so,
- cmd, data, ifp);
+ if (vec_compat_ifioctl != NULL)
+ error = (*vec_compat_ifioctl)(so, ocmd, cmd, data, l);
+ else
#endif
+ error = (*so->so_proto->pr_usrreqs->pr_ioctl)(so,
+ cmd, data, ifp);
}
if (((oif_flags ^ ifp->if_flags) & IFF_UP) != 0) {
@@ -3015,7 +3035,7 @@
struct ifreq ifrb;
struct oifreq *oifr = NULL;
u_long ocmd = cmd;
- cmd = compat_cvtcmd(cmd);
+ cmd = (*vec_compat_cvtcmd)(cmd);
if (cmd != ocmd) {
oifr = (struct oifreq *)(void *)ifr;
ifr = &ifrb;
Home |
Main Index |
Thread Index |
Old Index