Module Name:    src
Committed By:   pgoyette
Date:           Tue Mar  6 05:46:06 UTC 2018

Modified Files:
        src/sys/compat/common [pgoyette-compat]: compat_mod.c
            uipc_syscalls_40.c
        src/sys/net [pgoyette-compat]: if.c

Log Message:
Untangle some networking compat code so we can build a kernel with
networking and MODULAR, but without any actual COMPAT_* code (ie,
assuming that all the compat stuff can be added later via modules).


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.24.14.1 src/sys/compat/common/compat_mod.c
cvs rdiff -u -r1.15 -r1.15.2.1 src/sys/compat/common/uipc_syscalls_40.c
cvs rdiff -u -r1.419 -r1.419.2.1 src/sys/net/if.c

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_mod.c
diff -u src/sys/compat/common/compat_mod.c:1.24 src/sys/compat/common/compat_mod.c:1.24.14.1
--- src/sys/compat/common/compat_mod.c:1.24	Sat Nov  5 23:30:22 2016
+++ src/sys/compat/common/compat_mod.c	Tue Mar  6 05:46:06 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_mod.c,v 1.24 2016/11/05 23:30:22 pgoyette Exp $	*/
+/*	$NetBSD: compat_mod.c,v 1.24.14.1 2018/03/06 05:46:06 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.24 2016/11/05 23:30:22 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.24.14.1 2018/03/06 05:46:06 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -65,6 +65,16 @@ __KERNEL_RCSID(0, "$NetBSD: compat_mod.c
 static struct sysctllog *compat_clog = NULL;
 #endif
 
+#ifdef COMPAT_40
+void if_40_init(void);
+void if_40_fini(void);
+#endif
+
+#ifdef COMPAT_50
+void if_50_init(void);
+void if_50_fini(void);
+#endif
+
 MODULE(MODULE_CLASS_EXEC, compat, NULL);
 
 int	ttcompat(struct tty *, u_long, void *, int, struct lwp *);
@@ -238,6 +248,12 @@ compat_modcmd(modcmd_t cmd, void *arg)
 		ttcompatvec = ttcompat;
 		if_43_init();
 #endif
+#ifdef COMPAT_40
+		if_40_init();
+#endif
+#ifdef COMPAT_50
+		if_50_init();
+#endif
 #ifdef COMPAT_16
 #if defined(COMPAT_SIGCONTEXT)
 		KASSERT(emul_netbsd.e_sigobject == NULL);
@@ -337,4 +353,7 @@ compat_sysctl_fini(void)
 #if defined(COMPAT_43)
 	if_43_fini();
 #endif
+#ifdef COMPAT_50
+	if_50_fini();
+#endif
 }

Index: src/sys/compat/common/uipc_syscalls_40.c
diff -u src/sys/compat/common/uipc_syscalls_40.c:1.15 src/sys/compat/common/uipc_syscalls_40.c:1.15.2.1
--- src/sys/compat/common/uipc_syscalls_40.c:1.15	Wed Nov 22 15:25:34 2017
+++ src/sys/compat/common/uipc_syscalls_40.c	Tue Mar  6 05:46:06 2018
@@ -1,9 +1,9 @@
-/*	$NetBSD: uipc_syscalls_40.c,v 1.15 2017/11/22 15:25:34 martin Exp $	*/
+/*	$NetBSD: uipc_syscalls_40.c,v 1.15.2.1 2018/03/06 05:46:06 pgoyette Exp $	*/
 
 /* written by Pavel Cahyna, 2006. Public domain. */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_40.c,v 1.15 2017/11/22 15:25:34 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_40.c,v 1.15.2.1 2018/03/06 05:46:06 pgoyette Exp $");
 
 /*
  * System call interface to the socket abstraction.
@@ -151,3 +151,22 @@ release_exit:
 	return error;
 }
 #endif
+#if defined(COMPAT_40)
+static int (*orig_compat_ifconf)(u_long, void *);
+static void (*orig_compat_ifconf(u_long, void *);
+ 
+void      
+if_40_init(void)
+{
+ 
+	orig_compat_ifconf = vec_compat_ifconf; 
+	vec_compat_ifconf = compat_ifconf;
+}
+ 
+void
+if_40_fini(void)
+{
+ 
+	vec_compat_ifconf = orig_compat_ifconf;
+}
+#endif /* defined(COMPAT_40) */

Index: src/sys/net/if.c
diff -u src/sys/net/if.c:1.419 src/sys/net/if.c:1.419.2.1
--- src/sys/net/if.c:1.419	Tue Jan 30 10:40:02 2018
+++ src/sys/net/if.c	Tue Mar  6 05:46:06 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.419 2018/01/30 10:40:02 ozaki-r Exp $	*/
+/*	$NetBSD: if.c,v 1.419.2.1 2018/03/06 05:46:06 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.419 2018/01/30 10:40:02 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.419.2.1 2018/03/06 05:46:06 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -254,6 +254,20 @@ u_long (*vec_compat_cvtcmd)(u_long) = st
 int (*vec_compat_ifioctl)(struct socket *, u_long, u_long, void *,
 	struct lwp *) = NULL;
 
+/*
+ * And a few more
+ */
+int stub_compat_ifdatareq(struct lwp *, u_long, void *);
+int (*vec_compat_ifdatareq)(struct lwp *, u_long, void *) =
+    stub_compat_ifdatareq;
+
+void stub_compat_ifreqo2n(struct oifreq *, struct ifreq *);
+void (*vec_compat_ifreqo2n)(struct oifreq *, struct ifreq *) =
+    stub_compat_ifreqo2n;
+
+int stub_compat_ifconf(u_long, void *);
+int (*vec_compat_ifconf)(u_long, void *) = stub_compat_ifconf;
+
 /* The stub version of compat_cvtcmd() */
 u_long stub_compat_cvtcmd(u_long cmd)
 {
@@ -261,6 +275,26 @@ u_long stub_compat_cvtcmd(u_long cmd)
 	return cmd;
 }
 
+/* The stub version of compat_ifdatareq() */
+int stub_compat_ifdatareq(struct lwp *l, u_long cmd, void *data)
+{
+
+	return EINVAL;
+}
+
+/* The stub version of compat_ifreqo2n() */
+void stub_compat_ifreqo2n(struct oifreq *old, struct ifreq *new)
+{
+
+}
+
+/* The stub version of compat_ifconf() */
+int stub_compat_ifconf(u_long cmd, void *data)
+{
+
+	return EINVAL;
+}
+
 static int
 if_listener_cb(kauth_cred_t cred, kauth_action_t action, void *cookie,
     void *arg0, void *arg1, void *arg2, void *arg3)
@@ -3117,12 +3151,12 @@ doifioctl(struct socket *so, u_long cmd,
 #ifdef COMPAT_OIFREQ
 	case OSIOCGIFCONF:
 	case OOSIOCGIFCONF:
-		return compat_ifconf(cmd, data);
+		return (*vec_compat_ifconf)(cmd, data);
 #endif
 #ifdef COMPAT_OIFDATA
 	case OSIOCGIFDATA:
 	case OSIOCZIFDATA:
-		return compat_ifdatareq(l, cmd, data);
+		return (*vec_compat_ifdatareq)(l, cmd, data);
 #endif
 	case SIOCGIFCONF:
 		return ifconf(cmd, data);
@@ -3135,7 +3169,7 @@ doifioctl(struct socket *so, u_long cmd,
 	if (cmd != ocmd) {
 		oifr = data;
 		data = ifr = &ifrb;
-		ifreqo2n(oifr, ifr);
+		(*vec_compat_ifreqo2n)(oifr, ifr);
 	} else
 #endif
 		ifr = data;
@@ -3394,7 +3428,7 @@ ifreq_setaddr(u_long cmd, struct ifreq *
 	if (cmd != ocmd) {
 		oifr = (struct oifreq *)(void *)ifr;
 		ifr = &ifrb;
-		ifreqo2n(oifr, ifr);
+		(*vec_compat_ifreqo2n)(oifr, ifr);
 		len = sizeof(oifr->ifr_addr);
 	} else
 #endif

Reply via email to