Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/pgoyette-compat]: src/sys Untangle some networking compat code so we can...



details:   https://anonhg.NetBSD.org/src/rev/d00465a5d441
branches:  pgoyette-compat
changeset: 320952:d00465a5d441
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Tue Mar 06 05:46:06 2018 +0000

description:
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).

diffstat:

 sys/compat/common/compat_mod.c       |  23 ++++++++++++++++-
 sys/compat/common/uipc_syscalls_40.c |  23 ++++++++++++++++-
 sys/net/if.c                         |  46 +++++++++++++++++++++++++++++++----
 3 files changed, 82 insertions(+), 10 deletions(-)

diffs (193 lines):

diff -r 6eeed8c02970 -r d00465a5d441 sys/compat/common/compat_mod.c
--- a/sys/compat/common/compat_mod.c    Tue Mar 06 05:44:37 2018 +0000
+++ b/sys/compat/common/compat_mod.c    Tue Mar 06 05:46:06 2018 +0000
@@ -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 @@
 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 @@
                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 @@
 #if defined(COMPAT_43)
        if_43_fini();
 #endif
+#ifdef COMPAT_50
+       if_50_fini();
+#endif
 }
diff -r 6eeed8c02970 -r d00465a5d441 sys/compat/common/uipc_syscalls_40.c
--- a/sys/compat/common/uipc_syscalls_40.c      Tue Mar 06 05:44:37 2018 +0000
+++ b/sys/compat/common/uipc_syscalls_40.c      Tue Mar 06 05:46:06 2018 +0000
@@ -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 @@
        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) */
diff -r 6eeed8c02970 -r d00465a5d441 sys/net/if.c
--- a/sys/net/if.c      Tue Mar 06 05:44:37 2018 +0000
+++ b/sys/net/if.c      Tue Mar 06 05:46:06 2018 +0000
@@ -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 @@
 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 @@
        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 @@
 #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 @@
        if (cmd != ocmd) {
                oifr = data;
                data = ifr = &ifrb;
-               ifreqo2n(oifr, ifr);
+               (*vec_compat_ifreqo2n)(oifr, ifr);
        } else
 #endif
                ifr = data;
@@ -3394,7 +3428,7 @@
        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



Home | Main Index | Thread Index | Old Index