Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Jul 2002 22:58:59 -0700
From:      Brooks Davis <brooks@one-eyed-alien.net>
To:        net@freebsd.org
Subject:   ppp(4) cloning review request
Message-ID:  <20020723225859.A20811@Odin.AC.HMC.Edu>

next in thread | raw e-mail | index | archive | help

--LZvS9be/3tNcYl/X
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

I have attached a patch which adds cloning and unloading support to the
ppp(4) kernel PPP device.  I would like to commit it in the next few
days.  Please review.

A few notes:

- In the pppalloc() function, there is an attempt to follow the sl(4)
  cloning where interfaces are allocated when someone wants to hook ppp
  up to a tty.  While I think this code should work, it's untested
  because pppd(8) has too many assumptions about the interface already
  existing.  In fact, nearly the first thing it does it tries to do an
  ioctl operation on ppp0 to see if there are ppp devices around.

- The unload is a bit ugly because line disciplines don't really
  appear to be meant to be unhooked.

Thanks,
Brooks

Index: share/man/man4/ppp.4
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/cvs/src/share/man/man4/ppp.4,v
retrieving revision 1.6
diff -u -p -r1.6 ppp.4
--- share/man/man4/ppp.4	1 May 2001 09:15:13 -0000	1.6
+++ share/man/man4/ppp.4	22 Jul 2002 20:48:26 -0000
@@ -41,7 +41,7 @@
 .Nm ppp
 .Nd point to point protocol network interface
 .Sh SYNOPSIS
-.Cd "device ppp" Op Ar count
+.Cd "device ppp"
 .Sh DESCRIPTION
 The
 .Nm
@@ -53,6 +53,17 @@ interface can use various types of compr
 the
 .Xr sl 4
 protocol.
+.Pp
+Each
+.Nm
+interface is created at runtime using interface cloning.
+This is most easily done with the
+.Xr ifconfig 8
+.Cm create
+command or using the
+.Va cloned_interfaces
+variable in
+.Xr rc.conf 5 .
 .Sh DIAGNOSTICS
 .Bl -diag
 .It ppp%d: af%d not supported.
Index: sys/conf/NOTES
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/cvs/src/sys/conf/NOTES,v
retrieving revision 1.1059
diff -u -p -r1.1059 NOTES
--- sys/conf/NOTES	21 Jul 2002 23:20:29 -0000	1.1059
+++ sys/conf/NOTES	22 Jul 2002 20:13:22 -0000
@@ -432,7 +432,7 @@ device		disc			#Discard device (ds0, ds1
 device		tap			#Virtual Ethernet driver
 device		tun			#Tunnel driver (ppp(8), nos-tun(8))
 device		sl			#Serial Line IP
-device		ppp	2		#Point-to-point protocol
+device		ppp			#Point-to-point protocol
 options 	PPP_BSDCOMP		#PPP BSD-compress support
 options 	PPP_DEFLATE		#PPP zlib/deflate/gzip support
 options 	PPP_FILTER		#enable bpf filtering (needs bpf)
Index: sys/conf/files
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/cvs/src/sys/conf/files,v
retrieving revision 1.672
diff -u -p -r1.672 files
--- sys/conf/files	23 Jul 2002 06:33:08 -0000	1.672
+++ sys/conf/files	23 Jul 2002 08:22:13 -0000
@@ -1020,7 +1020,7 @@ net/if_iso88025subr.c	optional token
 net/if_loop.c		optional loop
 net/if_media.c		standard
 net/if_mib.c		standard
-net/if_ppp.c		count ppp
+net/if_ppp.c		optional ppp
 net/if_sl.c		optional sl
 net/if_spppsubr.c	optional sppp
 net/if_spppsubr.c	optional i4bisppp
Index: sys/alpha/conf/GENERIC
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/cvs/src/sys/alpha/conf/GENERIC,v
retrieving revision 1.146
diff -u -p -r1.146 GENERIC
--- sys/alpha/conf/GENERIC	23 Jul 2002 06:36:23 -0000	1.146
+++ sys/alpha/conf/GENERIC	23 Jul 2002 08:21:45 -0000
@@ -160,7 +160,7 @@ device		random		# Entropy device
 device		loop		# Network loopback
 device		ether		# Ethernet support
 device		sl		# Kernel SLIP
-device		ppp	1	# Kernel PPP
+device		ppp		# Kernel PPP
 device		tun		# Packet tunnel.
 device		pty		# Pseudo-ttys (telnet etc)
 device		md		# Memory "disks"
Index: sys/i386/conf/GENERIC
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/cvs/src/sys/i386/conf/GENERIC,v
retrieving revision 1.352
diff -u -p -r1.352 GENERIC
--- sys/i386/conf/GENERIC	23 Jul 2002 06:35:08 -0000	1.352
+++ sys/i386/conf/GENERIC	23 Jul 2002 08:23:09 -0000
@@ -215,7 +215,7 @@ device		random		# Entropy device
 device		loop		# Network loopback
 device		ether		# Ethernet support
 device		sl		# Kernel SLIP
-device		ppp	1	# Kernel PPP
+device		ppp		# Kernel PPP
 device		tun		# Packet tunnel.
 device		pty		# Pseudo-ttys (telnet etc)
 device		md		# Memory "disks"
Index: sys/ia64/conf/GENERIC
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/cvs/src/sys/ia64/conf/GENERIC,v
retrieving revision 1.34
diff -u -p -r1.34 GENERIC
--- sys/ia64/conf/GENERIC	23 Jul 2002 06:38:47 -0000	1.34
+++ sys/ia64/conf/GENERIC	23 Jul 2002 08:23:26 -0000
@@ -148,7 +148,7 @@ device		random		# Entropy device
 device		loop		# Network loopback
 device		ether		# Ethernet support
 device		sl		# Kernel SLIP
-device		ppp	1	# Kernel PPP
+device		ppp		# Kernel PPP
 device		tun		# Packet tunnel.
 device		pty		# Pseudo-ttys (telnet etc)
 device		md		# Memory "disks"
Index: sys/pc98/conf/GENERIC
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/cvs/src/sys/pc98/conf/GENERIC,v
retrieving revision 1.210
diff -u -p -r1.210 GENERIC
--- sys/pc98/conf/GENERIC	23 Jul 2002 06:37:14 -0000	1.210
+++ sys/pc98/conf/GENERIC	23 Jul 2002 08:24:19 -0000
@@ -202,7 +202,7 @@ device		random		# Entropy device
 device		loop		# Network loopback
 device		ether		# Ethernet support
 device		sl		# Kernel SLIP
-device		ppp	1	# Kernel PPP
+device		ppp		# Kernel PPP
 device		tun		# Packet tunnel.
 device		pty		# Pseudo-ttys (telnet etc)
 device		md		# Memory "disks"
Index: sys/sparc64/conf/GENERIC
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/cvs/src/sys/sparc64/conf/GENERIC,v
retrieving revision 1.27
diff -u -p -r1.27 GENERIC
--- sys/sparc64/conf/GENERIC	23 Jul 2002 06:37:40 -0000	1.27
+++ sys/sparc64/conf/GENERIC	23 Jul 2002 08:24:29 -0000
@@ -163,7 +163,7 @@ device		random		# Entropy device
 device		loop		# Network loopback
 device		ether		# Ethernet support
 device		sl		# Kernel SLIP
-device		ppp	1	# Kernel PPP
+device		ppp		# Kernel PPP
 device		tun		# Packet tunnel.
 device		pty		# Pseudo-ttys (telnet etc)
 device		md		# Memory "disks"
Index: sys/modules/if_ppp//Makefile
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/cvs/src/sys/modules/if_ppp/Makefile,v
retrieving revision 1.29
diff -u -p -r1.29 Makefile
--- sys/modules/if_ppp//Makefile	11 Jan 2002 15:48:48 -0000	1.29
+++ sys/modules/if_ppp//Makefile	23 Jul 2002 07:00:57 -0000
@@ -4,9 +4,8 @@
=20
 KMOD=3D	if_ppp
 SRCS=3D	if_ppp.c ppp_tty.c slcompress.c \
-	opt_inet.h opt_ipx.h opt_ppp.h ppp.h vnode_if.h
+	opt_inet.h opt_ipx.h opt_ppp.h vnode_if.h
=20
-NPPP?=3D		2
 PPP_BSDCOMP?=3D	1	# 0/1
 PPP_DEFLATE?=3D	1	# 0/1
 PPP_FILTER?=3D	1	# 0/1 - requires bpf to be configured in kernel
@@ -43,8 +42,5 @@ opt_ppp.h:
 .if ${PPP_FILTER} > 0
 	echo "#define PPP_FILTER ${PPP_FILTER}" >> ${.TARGET}
 .endif
-
-ppp.h:
-	echo "#define NPPP ${NPPP}" > ${.TARGET}
=20
 .include <bsd.kmod.mk>
Index: sys/net/if_ppp.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/cvs/src/sys/net/if_ppp.c,v
retrieving revision 1.79
diff -u -p -r1.79 if_ppp.c
--- sys/net/if_ppp.c	4 Apr 2002 21:03:28 -0000	1.79
+++ sys/net/if_ppp.c	28 Apr 2002 17:11:41 -0000
@@ -73,8 +73,6 @@
 /* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */
 /* from NetBSD: if_ppp.c,v 1.15.2.2 1994/07/28 05:17:58 cgd Exp */
=20
-#include "ppp.h"
-
 #include "opt_inet.h"
 #include "opt_ipx.h"
 #include "opt_ppp.h"
@@ -130,10 +128,13 @@
 #include <net/ppp_comp.h>
 #endif
=20
-static struct ppp_softc ppp_softc[NPPP];
+#define PPPNAME		"ppp"
+static MALLOC_DEFINE(M_PPP, PPPNAME, "PPP interface");
+static LIST_HEAD(, ppp_softc) ppp_softc_list;
=20
 /* XXX layering violation */
 extern void	pppasyncattach(void *);
+extern void	pppasyncdetach(void);
=20
 static int	pppsioctl(struct ifnet *ifp, u_long cmd, caddr_t data);
 static void	pppintr(void);
@@ -143,6 +144,11 @@ static void	ppp_ccp(struct ppp_softc *,=20
 static void	ppp_ccp_closed(struct ppp_softc *);
 static void	ppp_inproc(struct ppp_softc *, struct mbuf *);
 static void	pppdumpm(struct mbuf *m0);
+static int	ppp_clone_create(struct if_clone *, int);
+static void	ppp_clone_destroy(struct ifnet *);
+
+static struct if_clone ppp_cloner =3D IF_CLONE_INITIALIZER(PPPNAME,
+    ppp_clone_create, ppp_clone_destroy, 0, IF_MAXUNIT);
=20
 /*
  * Some useful mbuf macros not in mbuf.h.
@@ -186,18 +192,15 @@ static struct compressor *ppp_compressor
 };
 #endif /* PPP_COMPRESS */
=20
-/*
- * Called from boot code to establish ppp interfaces.
- */
-static void
-pppattach(void)
+static int
+ppp_clone_create(struct if_clone *ifc, int unit)
 {
-    register struct ppp_softc *sc;
-    register int i =3D 0;
+	struct ppp_softc	*sc;
=20
-    for (sc =3D ppp_softc; i < NPPP; sc++) {
-	sc->sc_if.if_name =3D "ppp";
-	sc->sc_if.if_unit =3D i++;
+	sc =3D malloc(sizeof(struct ppp_softc), M_PPP, M_WAITOK | M_ZERO);
+	sc->sc_if.if_softc =3D sc;
+	sc->sc_if.if_name =3D PPPNAME;
+	sc->sc_if.if_unit =3D unit;
 	sc->sc_if.if_mtu =3D PPP_MTU;
 	sc->sc_if.if_flags =3D IFF_POINTOPOINT | IFF_MULTICAST;
 	sc->sc_if.if_type =3D IFT_PPP;
@@ -208,18 +211,29 @@ pppattach(void)
 	sc->sc_inq.ifq_maxlen =3D IFQ_MAXLEN;
 	sc->sc_fastq.ifq_maxlen =3D IFQ_MAXLEN;
 	sc->sc_rawq.ifq_maxlen =3D IFQ_MAXLEN;
-        mtx_init(&sc->sc_inq.ifq_mtx, "ppp_inq", NULL, MTX_DEF);
-        mtx_init(&sc->sc_fastq.ifq_mtx, "ppp_fastq", NULL, MTX_DEF);
-        mtx_init(&sc->sc_rawq.ifq_mtx, "ppp_rawq", NULL, MTX_DEF);
+	mtx_init(&sc->sc_inq.ifq_mtx, "ppp_inq", NULL, MTX_DEF);
+	mtx_init(&sc->sc_fastq.ifq_mtx, "ppp_fastq", NULL, MTX_DEF);
+	mtx_init(&sc->sc_rawq.ifq_mtx, "ppp_rawq", NULL, MTX_DEF);
 	if_attach(&sc->sc_if);
 	bpfattach(&sc->sc_if, DLT_PPP, PPP_HDRLEN);
-    }
-    register_netisr(NETISR_PPP, pppintr);
-    /*
-     * XXX layering violation - if_ppp can work over any lower level
-     * transport that cares to attach to it.
-     */
-    pppasyncattach(NULL);
+	LIST_INSERT_HEAD(&ppp_softc_list, sc, sc_list);
+
+	return 1;
+}
+
+static void
+ppp_clone_destroy(struct ifnet *ifp)
+{
+	struct ppp_softc	*sc;
+
+	sc =3D ifp->if_softc;
+
+	LIST_REMOVE(sc, sc_list);
+	bpfdetach(ifp);
+	if_detach(ifp);
+	mtx_destroy(&sc->sc_rawq.ifq_mtx);
+	mtx_destroy(&sc->sc_fastq.ifq_mtx);
+	mtx_destroy(&sc->sc_inq.ifq_mtx);
 }
=20
 static int
@@ -227,10 +241,27 @@ ppp_modevent(module_t mod, int type, voi
 {=20
 	switch (type) {=20
 	case MOD_LOAD:=20
-		pppattach();
+		if_clone_attach(&ppp_cloner);
+
+		register_netisr(NETISR_PPP, pppintr);
+		/*
+		 * XXX layering violation - if_ppp can work over any lower
+		 * level transport that cares to attach to it.
+		 */
+		pppasyncattach(NULL);
 		break;=20
 	case MOD_UNLOAD:=20
-		printf("if_ppp module unload - not possible for this module type\n");=20
+		/* XXX: layering violation */
+		pppasyncdetach();
+
+		unregister_netisr(NETISR_PPP);
+
+		if_clone_detach(&ppp_cloner);
+
+		while (!LIST_EMPTY(&ppp_softc_list))
+			ppp_clone_destroy(
+			    &LIST_FIRST(&ppp_softc_list)->sc_if);
+
 		return EINVAL;=20
 	}=20
 	return 0;=20
@@ -251,18 +282,32 @@ struct ppp_softc *
 pppalloc(pid)
     pid_t pid;
 {
-    int nppp, i;
+    int i;
+    char tmpname[IFNAMSIZ];
+    struct ifnet *ifp;
     struct ppp_softc *sc;
=20
-    for (nppp =3D 0, sc =3D ppp_softc; nppp < NPPP; nppp++, sc++)
+    LIST_FOREACH(sc, &ppp_softc_list, sc_list) {
 	if (sc->sc_xfer =3D=3D pid) {
 	    sc->sc_xfer =3D 0;
 	    return sc;
 	}
-    for (nppp =3D 0, sc =3D ppp_softc; nppp < NPPP; nppp++, sc++)
+    }
+    LIST_FOREACH(sc, &ppp_softc_list, sc_list) {
 	if (sc->sc_devp =3D=3D NULL)
 	    break;
-    if (nppp >=3D NPPP)
+    }
+    /* Try to clone an interface if we don't have a free one */
+    if (sc =3D=3D NULL) {
+	strcpy(tmpname, PPPNAME);
+	if (if_clone_create(tmpname, sizeof(tmpname)) !=3D 0)
+	    return NULL;
+	ifp =3D ifunit(tmpname);
+	if (ifp =3D=3D NULL)
+	    return NULL;
+	sc =3D ifp->if_softc;
+    }
+    if (sc =3D=3D NULL || sc->sc_devp !=3D NULL)
 	return NULL;
=20
     sc->sc_flags =3D 0;
@@ -574,7 +619,7 @@ pppsioctl(ifp, cmd, data)
     caddr_t data;
 {
     struct thread *td =3D curthread;	/* XXX */
-    register struct ppp_softc *sc =3D &ppp_softc[ifp->if_unit];
+    register struct ppp_softc *sc =3D ifp->if_softc;
     register struct ifaddr *ifa =3D (struct ifaddr *)data;
     register struct ifreq *ifr =3D (struct ifreq *)data;
     struct ppp_stats *psp;
@@ -704,7 +749,7 @@ pppoutput(ifp, m0, dst, rtp)
     struct sockaddr *dst;
     struct rtentry *rtp;
 {
-    register struct ppp_softc *sc =3D &ppp_softc[ifp->if_unit];
+    register struct ppp_softc *sc =3D ifp->if_softc;
     int protocol, address, control;
     u_char *cp;
     int s, error;
@@ -1085,11 +1130,10 @@ static void
 pppintr()
 {
     struct ppp_softc *sc;
-    int i, s;
+    int s;
     struct mbuf *m;
=20
-    sc =3D ppp_softc;
-    for (i =3D 0; i < NPPP; ++i, ++sc) {
+    LIST_FOREACH(sc, &ppp_softc_list, sc_list) {
 	s =3D splimp();
 	if (!(sc->sc_flags & SC_TBUSY)
 	    && (sc->sc_if.if_snd.ifq_head || sc->sc_fastq.ifq_head)) {
Index: sys/net/if_pppvar.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/cvs/src/sys/net/if_pppvar.h,v
retrieving revision 1.19
diff -u -p -r1.19 if_pppvar.h
--- sys/net/if_pppvar.h	24 Mar 2002 09:34:04 -0000	1.19
+++ sys/net/if_pppvar.h	13 Apr 2002 03:36:14 -0000
@@ -96,6 +96,7 @@ struct ppp_softc {
 	u_short	sc_outfcs;		/* FCS so far for output packet */
 	u_char	sc_rawin[16];		/* chars as received */
 	int	sc_rawin_count;		/* # in sc_rawin */
+	LIST_ENTRY(ppp_softc) sc_list;
 };
=20
 struct	ppp_softc *pppalloc(pid_t pid);
Index: sys/net/ppp_tty.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/cvs/src/sys/net/ppp_tty.c,v
retrieving revision 1.50
diff -u -p -r1.50 ppp_tty.c
--- sys/net/ppp_tty.c	1 Apr 2002 21:31:03 -0000	1.50
+++ sys/net/ppp_tty.c	25 May 2002 21:15:47 -0000
@@ -114,6 +114,7 @@ static void	ppplogchar(struct ppp_softc=20
=20
 /* XXX called from if_ppp.c - layering violation */
 void		pppasyncattach(void *);
+void		pppasyncdetach(void);
=20
 /*
  * Some useful mbuf macros not in mbuf.h.
@@ -146,6 +147,7 @@ void		pppasyncattach(void *);
  * Define the PPP line discipline.
  */
=20
+static struct linesw pppnodisc;
 static struct linesw pppdisc =3D {
 	pppopen,	pppclose,	pppread,	pppwrite,
 	ppptioctl,	pppinput,	pppstart,	ttymodem,
@@ -156,8 +158,17 @@ void
 pppasyncattach(dummy)
     void *dummy;
 {
+    /* save previous entry for detach */
+    pppnodisc =3D linesw[PPPDISC];
     /* register line discipline */
     linesw[PPPDISC] =3D pppdisc;
+}
+
+void
+pppasyncdetach()
+{
+	/* deregister line discipline */
+	linesw[PPPDISC] =3D pppnodisc;
 }
=20
 /*

--=20
Any statement of the form "X is the one, true Y" is FALSE.
PGP fingerprint 655D 519C 26A7 82E7 2529  9BF0 5D8E 8BE9 F238 1AD4

--LZvS9be/3tNcYl/X
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9PkIiXY6L6fI4GtQRAjiIAJ9DWSDtwnXUduklxrsC64Kmvvm4EgCgtKVR
f3awAVR94+dTYxpmyFqXCaY=
=bVi7
-----END PGP SIGNATURE-----

--LZvS9be/3tNcYl/X--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020723225859.A20811>