X-Git-Url: https://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=ultrix%2Fif_ppp.c;h=d93f5d3e8c6c8f407d8795911cff812d9b4a21cf;hp=1aaf5cd59313a0b137a74f401d1057fde10122d5;hb=383401cdb046c2038cd2d45e9b1427c9c1f62238;hpb=c5871dbfa014bb554c101e65150c48fc8ba80c7b diff --git a/ultrix/if_ppp.c b/ultrix/if_ppp.c index 1aaf5cd..d93f5d3 100644 --- a/ultrix/if_ppp.c +++ b/ultrix/if_ppp.c @@ -72,7 +72,7 @@ * Robert Olsson and Paul Mackerras. */ -/* $Id: if_ppp.c,v 1.10 1996/07/01 01:24:25 paulus Exp $ */ +/* $Id: if_ppp.c,v 1.13 1997/03/04 03:45:17 paulus Exp $ */ /* 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 */ @@ -120,6 +120,8 @@ #include "ppp-comp.h" #endif +static int pppsioctl(struct ifnet *, int, caddr_t); +static int pppoutput(struct ifnet *, struct mbuf *, struct sockaddr *); static void ppp_requeue __P((struct ppp_softc *)); static void ppp_outpkt __P((struct ppp_softc *)); static void ppp_ccp __P((struct ppp_softc *, struct mbuf *m, int rcvd)); @@ -189,7 +191,6 @@ pppattach() sc->sc_if.if_mtu = PPP_MTU; sc->sc_if.if_flags = IFF_POINTOPOINT; 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; @@ -232,7 +233,7 @@ pppalloc(pid) KM_ALLOC(sc->sc_comp, struct slcompress *, sizeof(struct slcompress), KM_DEVBUF, KM_NOARG); if (sc->sc_comp) - sl_compress_init(sc->sc_comp, -1); + sl_compress_init(sc->sc_comp); #endif #ifdef PPP_COMPRESS sc->sc_xc_state = NULL; @@ -384,7 +385,7 @@ pppioctl(sc, cmd, data, flag) return EPERM; if (sc->sc_comp) { s = splnet(); - sl_compress_init(sc->sc_comp, *(int *)data); + sl_compress_setup(sc->sc_comp, *(int *)data); splx(s); } break; @@ -601,6 +602,8 @@ pppoutput(ifp, m0, dst) struct ip *ip; struct ifqueue *ifq; enum NPmode mode; + int len; + struct mbuf *m; if (sc->sc_devp == NULL || (ifp->if_flags & IFF_RUNNING) == 0 || ((ifp->if_flags & IFF_UP) == 0 && dst->sa_family != AF_UNSPEC)) { @@ -681,6 +684,10 @@ pppoutput(ifp, m0, dst) *cp++ = protocol & 0xff; m0->m_len += PPP_HDRLEN; + len = 0; + for (m = m0; m != 0; m = m->m_next) + len += m->m_len; + if (sc->sc_flags & SC_LOG_OUTPKT) { printf("ppp%d output: ", ifp->if_unit); pppdumpm(m0); @@ -724,7 +731,6 @@ pppoutput(ifp, m0, dst) (*sc->sc_start)(sc); } ifp->if_opackets++; - ifp->if_obytes += len; splx(s); return (0); @@ -788,7 +794,7 @@ ppp_requeue(sc) /* * Transmitter has finished outputting some stuff; - * remember to call sc->sc_start later at splsoftnet. + * remember to call sc->sc_start later at splnet. */ void ppp_restart(sc) @@ -803,7 +809,7 @@ ppp_restart(sc) /* * Get a packet to send. This procedure is intended to be called at - * splsoftnet, since it may involve time-consuming operations such as + * splnet, since it may involve time-consuming operations such as * applying VJ compression, packet compression, address/control and/or * protocol field compression to the packet. */ @@ -894,13 +900,18 @@ ppp_dequeue(sc) for (mp = m; mp != NULL; mp = mp->m_next) slen += mp->m_len; clen = (*sc->sc_xcomp->compress) - (sc->sc_xc_state, &mcomp, m, slen, - (sc->sc_flags & SC_CCP_UP? sc->sc_if.if_mtu: 0)); + (sc->sc_xc_state, &mcomp, m, slen, sc->sc_if.if_mtu + PPP_HDRLEN); if (mcomp != NULL) { - m_freem(m); - m = mcomp; - cp = mtod(m, u_char *); - protocol = cp[3]; + if (sc->sc_flags & SC_CCP_UP) { + /* Send the compressed packet instead of the original. */ + m_freem(m); + m = mcomp; + cp = mtod(m, u_char *); + protocol = cp[3]; + } else { + /* Can't transmit compressed packets until CCP is up. */ + m_freem(mcomp); + } } } #endif /* PPP_COMPRESS */ @@ -929,7 +940,7 @@ ppp_dequeue(sc) } /* - * Software interrupt routine, called at splsoftnet. + * Software interrupt routine, called at splnet. */ void pppintr() @@ -939,7 +950,7 @@ pppintr() struct mbuf *m; sc = ppp_softc; - s = splsoftnet(); + s = splnet(); for (i = 0; i < NPPP; ++i, ++sc) { if (!(sc->sc_flags & SC_TBUSY) && (sc->sc_if.if_snd.ifq_head || sc->sc_fastq.ifq_head)) { @@ -1350,7 +1361,6 @@ ppp_inproc(sc, m) smp_unlock(&lock->lk_ifqueue); splx(s); ifp->if_ipackets++; - ifp->if_ibytes += ilen; if (rv) (*sc->sc_ctlp)(sc);