Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Sep 1999 23:07:08 -0400 (EDT)
From:      bloom@acm.org
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   kern/13770: Almost clone update for kernel ppp implementation
Message-ID:  <199909160307.XAA00598@jbloom.ne.mediaone.net>

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

>Number:         13770
>Category:       kern
>Synopsis:       Almost clone update for kernel ppp implementation
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Sep 15 20:10:01 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator:     Jim Bloom
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
none
>Environment:

	Kernel mode ppp using pppd

>Description:

	Give PPP the "almost-clone" update.  The kernel configuration no longer
	requires the number of PPP interfaces to be specified when running
	config(8).  PPP interfaces will be created upon demand.

>How-To-Repeat:
>Fix:
	
	Here are the diffs for the the changes.


	--- sys/pc98/conf/GENERIC98.orig	Wed Sep 15 22:44:24 1999
	+++ sys/pc98/conf/GENERIC98	Wed Sep 15 22:44:42 1999
	@@ -246,7 +246,7 @@
	 pseudo-device	loop
	 pseudo-device	ether
	 pseudo-device	sl	1
	-pseudo-device	ppp	1
	+pseudo-device	ppp
	 pseudo-device	tun	
	 pseudo-device	pty
	 pseudo-device	gzip		# Exec gzipped a.out's


	--- sys/i386/conf/GENERIC.orig	Wed Sep 15 22:42:24 1999
	+++ sys/i386/conf/GENERIC	Wed Sep 15 22:42:51 1999
	@@ -194,7 +194,7 @@
	 pseudo-device	loop		# Network loopback
	 pseudo-device	ether		# Ethernet support
	 pseudo-device	sl	1	# Kernel SLIP
	-pseudo-device	ppp	1	# Kernel PPP
	+pseudo-device	ppp		# Kernel PPP
	 pseudo-device	tun		# Packet tunnel, for ppp(1)
	 pseudo-device	pty		# Pseudo-ttys (telnet etc)
	 pseudo-device	gzip		# Exec gzipped a.out's


	--- sys/i386/conf/LINT.orig	Mon Aug 16 16:12:03 1999
	+++ sys/i386/conf/LINT	Wed Sep 15 22:43:26 1999
	@@ -406,7 +406,7 @@
	 pseudo-device	disc			#Discard device
	 pseudo-device	tun			#Tunnel driver (ppp(8), nos-tun(8))
	 pseudo-device	sl	2		#Serial Line IP
	-pseudo-device	ppp	2		#Point-to-point protocol
	+pseudo-device	ppp			#Point-to-point protocol
	 pseudo-device	streams
	 options PPP_BSDCOMP			#PPP BSD-compress support
	 options PPP_DEFLATE			#PPP zlib/deflate/gzip support


	--- sys/i386/conf/PCCARD.orig	Wed Sep 15 22:43:54 1999
	+++ sys/i386/conf/PCCARD	Wed Sep 15 22:43:56 1999
	@@ -190,7 +190,7 @@
	 pseudo-device	loop		# Network loopback
	 pseudo-device	ether		# Ethernet support
	 pseudo-device	sl	1	# Kernel SLIP
	-pseudo-device	ppp	1	# Kernel PPP
	+pseudo-device	ppp		# Kernel PPP
	 pseudo-device	tun		# Packet tunnel, for ppp(1)
	 pseudo-device	pty		# Pseudo-ttys (telnet etc)
	 pseudo-device	gzip		# Exec gzipped a.out's


	--- sys/net/if_ppp.c.orig	Sat Aug 14 22:53:14 1999
	+++ sys/net/if_ppp.c	Tue Aug 31 15:23:04 1999
	@@ -95,6 +95,7 @@
	 #include <sys/kernel.h>
	 #include <sys/time.h>
	 #include <sys/malloc.h>
	+#include <sys/queue.h>
	 
	 #include <net/if.h>
	 #include <net/if_types.h>
	@@ -138,7 +139,7 @@
	 #include <net/ppp_comp.h>
	 #endif
	 
	-struct ppp_softc ppp_softc[NPPP];
	+MALLOC_DEFINE(M_PPP, "PPP", "PPP data");
	 
	 /* XXX layering violation */
	 extern void	pppasyncattach __P((void *));
	@@ -146,6 +147,7 @@
	 static void	pppattach __P((void *));
	 PSEUDO_SET(pppattach, if_ppp);
	 
	+static struct ppp_softc *pppcreate __P((void));
	 static int	pppsioctl __P((struct ifnet *ifp, u_long cmd, caddr_t data));
	 static void	pppintr __P((void));
	 
	@@ -197,6 +199,9 @@
	 };
	 #endif /* PPP_COMPRESS */
	 
	+/* List of state elements. */
	+static SLIST_HEAD(ppp_softc_list, ppp_softc) ppp_softc;
	+
	 /*
	  * Called from boot code to establish ppp interfaces.
	  */
	@@ -204,27 +209,12 @@
	 pppattach(dummy)
	     void *dummy;
	 {
	-    register struct ppp_softc *sc;
	-    register int i = 0;
	-
	-    for (sc = ppp_softc; i < NPPP; sc++) {
	-	sc->sc_if.if_name = "ppp";
	-	sc->sc_if.if_unit = i++;
	-	sc->sc_if.if_mtu = PPP_MTU;
	-	sc->sc_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
	-	sc->sc_if.if_type = IFT_PPP;
	-	sc->sc_if.if_hdrlen = PPP_HDRLEN;
	-	sc->sc_if.if_ioctl = pppsioctl;
	-	sc->sc_if.if_output = pppoutput;
	-	sc->sc_if.if_snd.ifq_maxlen = IFQ_MAXLEN;
	-	sc->sc_inq.ifq_maxlen = IFQ_MAXLEN;
	-	sc->sc_fastq.ifq_maxlen = IFQ_MAXLEN;
	-	sc->sc_rawq.ifq_maxlen = IFQ_MAXLEN;
	-	if_attach(&sc->sc_if);
	-#if NBPF > 0
	-	bpfattach(&sc->sc_if, DLT_PPP, PPP_HDRLEN);
	-#endif
	-    }
	+    SLIST_INIT(&ppp_softc);
	+    /*
	+     * Create the first device to indicate that the kernel supports PPP.
	+     * Any more devices needed will be created when they are first used.
	+     */
	+    (void) pppcreate();
	     register_netisr(NETISR_PPP, pppintr);
	     /*
	      * XXX layering violation - if_ppp can work over any lower level
	@@ -233,6 +223,35 @@
	     pppasyncattach(dummy);
	 }
	 
	+static struct ppp_softc *
	+pppcreate(void)
	+{
	+    register struct ppp_softc *sc;
	+    static int unit = 0;
	+
	+    MALLOC(sc, struct ppp_softc *, sizeof(*sc), M_PPP, M_WAITOK);
	+    bzero(sc, sizeof(*sc));
	+    sc->sc_if.if_name = "ppp";
	+    sc->sc_if.if_unit = unit++;
	+    sc->sc_if.if_mtu = PPP_MTU;
	+    sc->sc_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
	+    sc->sc_if.if_type = IFT_PPP;
	+    sc->sc_if.if_hdrlen = PPP_HDRLEN;
	+    sc->sc_if.if_ioctl = pppsioctl;
	+    sc->sc_if.if_output = pppoutput;
	+    sc->sc_if.if_snd.ifq_maxlen = IFQ_MAXLEN;
	+    sc->sc_inq.ifq_maxlen = IFQ_MAXLEN;
	+    sc->sc_fastq.ifq_maxlen = IFQ_MAXLEN;
	+    sc->sc_rawq.ifq_maxlen = IFQ_MAXLEN;
	+    sc->sc_if.if_softc = sc;
	+    if_attach(&sc->sc_if);
	+#if NBPF > 0
	+    bpfattach(&sc->sc_if, DLT_PPP, PPP_HDRLEN);
	+#endif
	+    SLIST_INSERT_HEAD(&ppp_softc, sc, sc_list);
	+    return(sc);
	+}
	+
	 /*
	  * Allocate a ppp interface unit and initialize it.
	  */
	@@ -240,19 +259,19 @@
	 pppalloc(pid)
	     pid_t pid;
	 {
	-    int nppp, i;
	+    int i;
	     struct ppp_softc *sc;
	 
	-    for (nppp = 0, sc = ppp_softc; nppp < NPPP; nppp++, sc++)
	+    SLIST_FOREACH(sc, &ppp_softc, sc_list)
		if (sc->sc_xfer == pid) {
		    sc->sc_xfer = 0;
		    return sc;
		}
	-    for (nppp = 0, sc = ppp_softc; nppp < NPPP; nppp++, sc++)
	+    SLIST_FOREACH(sc, &ppp_softc, sc_list)
		if (sc->sc_devp == NULL)
		    break;
	-    if (nppp >= NPPP)
	-	return NULL;
	+    if (sc == NULL)
	+	sc = pppcreate();
	 
	     sc->sc_flags = 0;
	     sc->sc_mru = PPP_MRU;
	@@ -564,7 +583,7 @@
	     caddr_t data;
	 {
	     struct proc *p = curproc;	/* XXX */
	-    register struct ppp_softc *sc = &ppp_softc[ifp->if_unit];
	+    register struct ppp_softc *sc = ifp->if_softc;
	     register struct ifaddr *ifa = (struct ifaddr *)data;
	     register struct ifreq *ifr = (struct ifreq *)data;
	     struct ppp_stats *psp;
	@@ -694,7 +713,7 @@
	     struct sockaddr *dst;
	     struct rtentry *rtp;
	 {
	-    register struct ppp_softc *sc = &ppp_softc[ifp->if_unit];
	+    register struct ppp_softc *sc = ifp->if_softc;
	     int protocol, address, control;
	     u_char *cp;
	     int s, error;
	@@ -1077,11 +1096,10 @@
	 pppintr()
	 {
	     struct ppp_softc *sc;
	-    int i, s;
	+    int s;
	     struct mbuf *m;
	 
	-    sc = ppp_softc;
	-    for (i = 0; i < NPPP; ++i, ++sc) {
	+    SLIST_FOREACH(sc, &ppp_softc, sc_list) {
		s = splimp();
		if (!(sc->sc_flags & SC_TBUSY)
		    && (sc->sc_if.if_snd.ifq_head || sc->sc_fastq.ifq_head)) {


	--- sys/net/if_pppvar.h.orig	Sun Jun  7 13:12:04 1998
	+++ sys/net/if_pppvar.h	Tue Aug 31 10:13:08 1999
	@@ -83,6 +83,7 @@
	 #ifdef	VJC
		struct	slcompress *sc_comp; 	/* vjc control buffer */
	 #endif
	+	SLIST_ENTRY(ppp_softc) sc_list;	/* list of ppp units */
	 
		/* Device-dependent part for async lines. */
		ext_accm sc_asyncmap;		/* async control character map */
	@@ -97,8 +98,6 @@
		u_char	sc_rawin[16];		/* chars as received */
		int	sc_rawin_count;		/* # in sc_rawin */
	 };
	-
	-extern struct ppp_softc ppp_softc[NPPP];
	 
	 struct	ppp_softc *pppalloc __P((pid_t pid));
	 void	pppdealloc __P((struct ppp_softc *sc));


	--- sys/net/ppp_tty.c.orig	Fri May 21 23:06:26 1999
	+++ sys/net/ppp_tty.c	Tue Aug 31 10:13:08 1999
	@@ -90,6 +90,7 @@
	 #include <sys/conf.h>
	 #include <sys/uio.h>
	 #include <sys/vnode.h>
	+#include <sys/queue.h>
	 
	 #ifdef __i386__
	 #include <i386/isa/intr_machdep.h>

>Release-Note:
>Audit-Trail:
>Unformatted:


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




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