Source-Changes-HG archive

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

[src/trunk]: src Modularize the pppoe driver



details:   https://anonhg.NetBSD.org/src/rev/a238a3137817
branches:  trunk
changeset: 817060:a238a3137817
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Sat Aug 06 23:46:30 2016 +0000

description:
Modularize the pppoe driver

diffstat:

 distrib/sets/lists/modules/mi     |   4 +-
 sys/modules/Makefile              |   3 +-
 sys/modules/if_pppoe/Makefile     |  15 ++++++
 sys/modules/if_pppoe/pppoe.ioconf |   7 +++
 sys/net/if_pppoe.c                |  88 +++++++++++++++++++++++++++++++++++++-
 5 files changed, 111 insertions(+), 6 deletions(-)

diffs (194 lines):

diff -r 4edf140344ef -r a238a3137817 distrib/sets/lists/modules/mi
--- a/distrib/sets/lists/modules/mi     Sat Aug 06 22:54:34 2016 +0000
+++ b/distrib/sets/lists/modules/mi     Sat Aug 06 23:46:30 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.91 2016/08/06 22:03:45 pgoyette Exp $
+# $NetBSD: mi,v 1.92 2016/08/06 23:46:30 pgoyette Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -128,6 +128,8 @@
 ./@MODULEDIR@/if_npflog/if_npflog.kmod         base-kernel-modules     kmod
 ./@MODULEDIR@/if_ppp                           base-kernel-modules     kmod
 ./@MODULEDIR@/if_ppp/if_ppp.kmod               base-kernel-modules     kmod
+./@MODULEDIR@/if_pppoe                         base-kernel-modules     kmod
+./@MODULEDIR@/if_pppoe/if_pppoe.kmod           base-kernel-modules     kmod
 ./@MODULEDIR@/if_sl                            base-kernel-modules     kmod
 ./@MODULEDIR@/if_sl/if_sl.kmod                 base-kernel-modules     kmod
 ./@MODULEDIR@/if_smsc                          base-kernel-modules     kmod
diff -r 4edf140344ef -r a238a3137817 sys/modules/Makefile
--- a/sys/modules/Makefile      Sat Aug 06 22:54:34 2016 +0000
+++ b/sys/modules/Makefile      Sat Aug 06 23:46:30 2016 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.173 2016/08/06 22:03:45 pgoyette Exp $
+#      $NetBSD: Makefile,v 1.174 2016/08/06 23:46:30 pgoyette Exp $
 
 .include <bsd.own.mk>
 
@@ -49,6 +49,7 @@
 SUBDIR+=       if_axen
 SUBDIR+=       if_npflog
 SUBDIR+=       if_ppp
+SUBDIR+=       if_pppoe
 SUBDIR+=       if_sl
 SUBDIR+=       if_smsc
 SUBDIR+=       if_strip
diff -r 4edf140344ef -r a238a3137817 sys/modules/if_pppoe/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/modules/if_pppoe/Makefile     Sat Aug 06 23:46:30 2016 +0000
@@ -0,0 +1,15 @@
+# $NetBSD: Makefile,v 1.1 2016/08/06 23:46:30 pgoyette Exp $
+
+.include "../Makefile.inc"
+
+.PATH:  ${S}/net
+
+KMOD=          if_pppoe
+IOCONF=                pppoe.ioconf
+SRCS=          if_pppoe.c
+
+CPPFLAGS+=     -DPPPOE_SERVER
+#CPPFLAGS+=    -DPPPOE_TERM_UNKNOWN_SESSIONS   # This should not be
+                                               # enabled by default
+
+.include <bsd.kmodule.mk>
diff -r 4edf140344ef -r a238a3137817 sys/modules/if_pppoe/pppoe.ioconf
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/modules/if_pppoe/pppoe.ioconf Sat Aug 06 23:46:30 2016 +0000
@@ -0,0 +1,7 @@
+#      $NetBSD: pppoe.ioconf,v 1.1 2016/08/06 23:46:30 pgoyette Exp $
+
+ioconf         pppoe
+
+include                "conf/files"
+
+pseudo-device   pppoe
diff -r 4edf140344ef -r a238a3137817 sys/net/if_pppoe.c
--- a/sys/net/if_pppoe.c        Sat Aug 06 22:54:34 2016 +0000
+++ b/sys/net/if_pppoe.c        Sat Aug 06 23:46:30 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_pppoe.c,v 1.111 2016/07/07 06:55:43 msaitoh Exp $ */
+/* $NetBSD: if_pppoe.c,v 1.112 2016/08/06 23:46:30 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,11 +30,10 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.111 2016/07/07 06:55:43 msaitoh Exp $");
-
-#include "pppoe.h"
+__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.112 2016/08/06 23:46:30 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
+#include "pppoe.h"
 #include "opt_pppoe.h"
 #endif
 
@@ -50,6 +49,8 @@
 #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>
@@ -210,6 +211,17 @@
 void
 pppoeattach(int count)
 {
+
+       /*
+        * Nothing to do here - all initialization happens as part
+        * of module init.
+        */
+}
+
+static void
+pppoeinit(void)
+{
+
        LIST_INIT(&pppoe_softc_list);
        if_clone_attach(&pppoe_cloner);
 
@@ -218,6 +230,16 @@
 }
 
 static int
+pppoedetach(void)
+{
+
+       softint_disestablish(pppoe_softintr);
+       if_clone_detach(&pppoe_cloner);
+
+       return 0;
+}
+
+static int
 pppoe_clone_create(struct if_clone *ifc, int unit)
 {
        struct pppoe_softc *sc;
@@ -1622,3 +1644,61 @@
        pppoe_enqueue(&ppoediscinq, m);
        return;
 }
+
+/*
+ * Module glue
+ */
+MODULE(MODULE_CLASS_DRIVER, if_pppoe, "sppp_subr");
+
+#ifdef _MODULE  
+CFDRIVER_DECL(pppoe, DV_IFNET, NULL);
+#endif
+ 
+static int
+if_pppoe_modcmd(modcmd_t cmd, void *arg)
+{
+       int error = 0;
+
+       switch (cmd) {
+       case MODULE_CMD_INIT:
+#ifdef _MODULE
+               error = config_cfdriver_attach(&pppoe_cd);
+               if (error) {
+                       aprint_error("%s: unable to register cfdriver for"
+                           "%s, error %d\n", __func__, pppoe_cd.cd_name,
+                           error);
+                       break;
+               }
+#endif  
+               /* Init the cloner etc. */
+               pppoeinit();
+               break;
+
+        case MODULE_CMD_FINI:
+               /*
+                * Make sure it's ok to detach - no units left, and
+                * line discipline is removed
+                */
+               if (!LIST_EMPTY(&pppoe_softc_list)) {
+                       error = EBUSY;
+                       break;
+               }
+               if ((error = pppoedetach()) != 0)
+                       break;
+#ifdef _MODULE
+               /* Remove device from autoconf database */
+               if ((error = config_cfdriver_detach(&pppoe_cd)) != 0) {
+                       aprint_error("%s: failed to detach %s cfdriver, error "
+                           "%d\n", __func__, pppoe_cd.cd_name, error);
+                       break;
+               }
+#endif
+               break;
+       case MODULE_CMD_STAT:
+       case MODULE_CMD_AUTOUNLOAD:
+       default:
+               error = ENOTTY;
+       }
+       return error;
+}
+



Home | Main Index | Thread Index | Old Index