Index: distrib/sets/lists/modules/mi
===================================================================
RCS file: /cvsroot/src/distrib/sets/lists/modules/mi,v
retrieving revision 1.87
diff -u -p -r1.87 mi
--- distrib/sets/lists/modules/mi 4 Aug 2016 23:54:45 -0000 1.87
+++ distrib/sets/lists/modules/mi 5 Aug 2016 08:35:12 -0000
@@ -198,6 +198,8 @@
./@MODULEDIR@/pf/pf.kmod base-kernel-modules kmod
./@MODULEDIR@/portal base-obsolete obsolete
./@MODULEDIR@/portal/portal.kmod base-obsolete obsolete
+./@MODULEDIR@/ppp base-kernel-modules kmod
+./@MODULEDIR@/ppp/ppp.kmod base-kernel-modules kmod
./@MODULEDIR@/ppp_bsdcomp base-kernel-modules kmod
./@MODULEDIR@/ppp_bsdcomp/ppp_bsdcomp.kmod base-kernel-modules kmod
./@MODULEDIR@/ppp_deflate base-kernel-modules kmod
Index: sys/modules/Makefile
===================================================================
RCS file: /cvsroot/src/sys/modules/Makefile,v
retrieving revision 1.168
diff -u -p -r1.168 Makefile
--- sys/modules/Makefile 4 Aug 2016 23:53:47 -0000 1.168
+++ sys/modules/Makefile 5 Aug 2016 08:49:06 -0000
@@ -79,6 +79,7 @@ SUBDIR+= opencrypto
SUBDIR+= overlay
SUBDIR+= pciverbose
SUBDIR+= pf
+SUBDIR+= ppp
SUBDIR+= ppp_bsdcomp
SUBDIR+= ppp_deflate
SUBDIR+= procfs
Index: sys/net/bsd-comp.c
===================================================================
RCS file: /cvsroot/src/sys/net/bsd-comp.c,v
retrieving revision 1.20
diff -u -p -r1.20 bsd-comp.c
--- sys/net/bsd-comp.c 29 Nov 2008 23:15:20 -0000 1.20
+++ sys/net/bsd-comp.c 5 Aug 2016 08:56:54 -0000
@@ -1090,7 +1090,7 @@ bsd_decompress(void *state, struct mbuf
#endif /* DEBUG */
}
-MODULE(MODULE_CLASS_MISC, ppp_bsdcomp, NULL);
+MODULE(MODULE_CLASS_MISC, ppp_bsdcomp, "ppp");
static int
ppp_bsdcomp_modcmd(modcmd_t cmd, void *arg)
Index: sys/net/if_ppp.c
===================================================================
RCS file: /cvsroot/src/sys/net/if_ppp.c,v
retrieving revision 1.152
diff -u -p -r1.152 if_ppp.c
--- sys/net/if_ppp.c 10 Jun 2016 13:27:16 -0000 1.152
+++ sys/net/if_ppp.c 5 Aug 2016 08:56:54 -0000
@@ -104,9 +104,8 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.152 2016/06/10 13:27:16 ozaki-r Exp $");
-#include "ppp.h"
-
#ifdef _KERNEL_OPT
+#include "ppp.h"
#include "opt_inet.h"
#include "opt_gateway.h"
#include "opt_ppp.h"
@@ -133,6 +132,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1
#include <sys/kauth.h>
#include <sys/intr.h>
#include <sys/socketvar.h>
+#include <sys/device.h>
+#include <sys/module.h>
#include <net/if.h>
#include <net/if_types.h>
@@ -181,6 +182,8 @@ static void ppp_ifstart(struct ifnet *if
static void pppintr(void *);
+extern struct linesw ppp_disc;
+
/*
* Some useful mbuf macros not in mbuf.h.
*/
@@ -214,11 +217,11 @@ struct if_clone ppp_cloner =
IF_CLONE_INITIALIZER("ppp", ppp_clone_create, ppp_clone_destroy);
#ifdef PPP_COMPRESS
-ONCE_DECL(ppp_compressor_mtx_init);
static LIST_HEAD(, compressor) ppp_compressors = { NULL };
static kmutex_t ppp_compressors_mtx;
static int ppp_compressor_init(void);
+static int ppp_compressor_destroy(void);
static struct compressor *ppp_get_compressor(uint8_t);
static void ppp_compressor_rele(struct compressor *);
#endif /* PPP_COMPRESS */
@@ -230,7 +233,16 @@ static void ppp_compressor_rele(struct c
void
pppattach(int n __unused)
{
- extern struct linesw ppp_disc;
+
+ /*
+ * Nothing to do here, initialization is handled by the
+ * module initialization code in pppinit() below).
+ */
+}
+
+static void
+pppinit(void)
+{
if (ttyldisc_attach(&ppp_disc) != 0)
panic("pppattach");
@@ -238,7 +250,18 @@ pppattach(int n __unused)
mutex_init(&ppp_list_lock, MUTEX_DEFAULT, IPL_NONE);
LIST_INIT(&ppp_softc_list);
if_clone_attach(&ppp_cloner);
- RUN_ONCE(&ppp_compressor_mtx_init, ppp_compressor_init);
+}
+
+static int
+pppdetach(void)
+{
+ int error;
+
+ if (!LIST_EMPTY(&ppp_softc_list))
+ error = EBUSY;
+ if (error == 0)
+ error = ttyldisc_detach(&ppp_disc);
+ return error;
}
static struct ppp_softc *
@@ -1798,6 +1821,14 @@ ppp_compressor_init(void)
return 0;
}
+static int
+ppp_compressor_destroy(void)
+{
+
+ mutex_destroy(&ppp_compressors_mtx);
+ return 0;
+}
+
static void
ppp_compressor_rele(struct compressor *cp)
{
@@ -1865,8 +1896,6 @@ ppp_register_compressor(struct compresso
int error = 0;
size_t i;
- RUN_ONCE(&ppp_compressor_mtx_init, ppp_compressor_init);
-
mutex_enter(&ppp_compressors_mtx);
for (i = 0; i < ncomp; i++) {
if (ppp_get_compressor_noload(pc[i].compress_proto,
@@ -1907,3 +1936,74 @@ ppp_unregister_compressor(struct compres
return error;
}
+
+/*
+ * Module infrastructure
+ */
+
+#ifdef PPP_FILTER
+#define PPP_DEP "bpf_filter,"
+#else
+#define PPP_DEP
+#endif
+
+MODULE(MODULE_CLASS_DRIVER, ppp, PPP_DEP "slcompress");
+
+#ifdef _MODULE
+CFDRIVER_DECL(ppp, DV_IFNET, NULL);
+#endif
+
+static int
+ppp_modcmd(modcmd_t cmd, void *arg)
+{
+ int error = 0;
+
+ switch (cmd) {
+ case MODULE_CMD_INIT:
+ /* Init the compressor sub-sub-system */
+ ppp_compressor_init();
+
+#ifdef _MODULE
+ error = config_cfdriver_attach(&ppp_cd);
+ if (error) {
+ aprint_error("%s: unable to register cfdriver for"
+ "%s, error %d\n", __func__, ppp_cd.cd_name, error);
+ ppp_compressor_destroy();
+ break;
+ }
+
+#endif
+ /* Init the unit list and line discipline stuff */
+ pppinit();
+ break;
+
+ case MODULE_CMD_FINI:
+ /*
+ * Make sure it's ok to detach - no units left, and
+ * line discipline is removed
+ */
+ error = pppdetach();
+ if (error != 0)
+ break;
+#ifdef _MODULE
+ /* Remove device from autoconf database */
+ error = config_cfdriver_detach(&ppp_cd);
+ if (error) {
+ aprint_error("%s: failed to detach %s cfdriver, "
+ "error %d\n", __func__, ppp_cd.cd_name, error);
+ break;
+ }
+#endif
+ ppp_compressor_destroy();
+ break;
+
+ case MODULE_CMD_STAT:
+ error = ENOTTY;
+ break;
+ default:
+ error = ENOTTY;
+ break;
+ }
+
+ return error;
+}
Index: sys/net/ppp-deflate.c
===================================================================
RCS file: /cvsroot/src/sys/net/ppp-deflate.c,v
retrieving revision 1.21
diff -u -p -r1.21 ppp-deflate.c
--- sys/net/ppp-deflate.c 5 Apr 2016 23:44:05 -0000 1.21
+++ sys/net/ppp-deflate.c 5 Aug 2016 08:56:54 -0000
@@ -664,7 +664,7 @@ z_incomp(void *arg, struct mbuf *mi)
state->stats.unc_packets++;
}
-MODULE(MODULE_CLASS_MISC, ppp_deflate, "zlib");
+MODULE(MODULE_CLASS_MISC, ppp_deflate, "zlib,ppp");
static int
ppp_deflate_modcmd(modcmd_t cmd, void *arg)
Index: sys/net/ppp_tty.c
===================================================================
RCS file: /cvsroot/src/sys/net/ppp_tty.c,v
retrieving revision 1.61
diff -u -p -r1.61 ppp_tty.c
--- sys/net/ppp_tty.c 20 Jun 2016 06:46:37 -0000 1.61
+++ sys/net/ppp_tty.c 5 Aug 2016 08:56:54 -0000
@@ -95,9 +95,8 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ppp_tty.c,v 1.61 2016/06/20 06:46:37 knakahara Exp $");
-#include "ppp.h"
-
#ifdef _KERNEL_OPT
+#include "ppp.h"
#include "opt_ppp.h"
#endif
#define VJC