diff options
Diffstat (limited to 'sys/net/if_ppp.c')
-rw-r--r-- | sys/net/if_ppp.c | 62 |
1 files changed, 47 insertions, 15 deletions
diff --git a/sys/net/if_ppp.c b/sys/net/if_ppp.c index 96fbe46d218..b057ba38669 100644 --- a/sys/net/if_ppp.c +++ b/sys/net/if_ppp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ppp.c,v 1.22 2001/06/27 03:49:53 angelos Exp $ */ +/* $OpenBSD: if_ppp.c,v 1.23 2001/06/27 06:07:42 kjc Exp $ */ /* $NetBSD: if_ppp.c,v 1.39 1997/05/17 21:11:59 christos Exp $ */ /* @@ -199,10 +199,11 @@ pppattach() 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; + IFQ_SET_MAXLEN(&sc->sc_if.if_snd, IFQ_MAXLEN); sc->sc_inq.ifq_maxlen = IFQ_MAXLEN; sc->sc_fastq.ifq_maxlen = IFQ_MAXLEN; sc->sc_rawq.ifq_maxlen = IFQ_MAXLEN; + IFQ_SET_READY(&sc->sc_if.if_snd); if_attach(&sc->sc_if); #if NBPFILTER > 0 bpfattach(&sc->sc_bpf, &sc->sc_if, DLT_PPP, PPP_HDRLEN); @@ -636,6 +637,7 @@ pppoutput(ifp, m0, dst, rtp) enum NPmode mode; int len; struct mbuf *m; + ALTQ_DECL(struct altq_pktattr pktattr;) if (sc->sc_devp == NULL || (ifp->if_flags & IFF_RUNNING) == 0 || ((ifp->if_flags & IFF_UP) == 0 && dst->sa_family != AF_UNSPEC)) { @@ -643,6 +645,8 @@ pppoutput(ifp, m0, dst, rtp) goto bad; } + IFQ_CLASSIFY(&ifp->if_snd, m0, dst->sa_family, &pktattr); + /* * Compute PPP header. */ @@ -759,16 +763,29 @@ pppoutput(ifp, m0, dst, rtp) m0->m_nextpkt = NULL; sc->sc_npqtail = &m0->m_nextpkt; } else { - ifq = (m0->m_flags & M_HIGHPRI)? &sc->sc_fastq: &ifp->if_snd; - if (IF_QFULL(ifq) && dst->sa_family != AF_UNSPEC) { - IF_DROP(ifq); + if ((m0->m_flags & M_HIGHPRI) +#ifdef ALTQ + && ALTQ_IS_ENABLED(&sc->sc_if.if_snd) == 0 +#endif + ) { + ifq = &sc->sc_fastq; + if (IF_QFULL(ifq) && dst->sa_family != AF_UNSPEC) { + IF_DROP(ifq); + m_freem(m0); + error = ENOBUFS; + } + else { + IF_ENQUEUE(ifq, m0); + error = 0; + } + } else + IFQ_ENQUEUE(&sc->sc_if.if_snd, m0, &pktattr, error); + if (error) { splx(s); sc->sc_if.if_oerrors++; sc->sc_stats.ppp_oerrors++; - error = ENOBUFS; - goto bad; + return (error); } - IF_ENQUEUE(ifq, m0); (*sc->sc_start)(sc); } ifp->if_opackets++; @@ -794,6 +811,7 @@ ppp_requeue(sc) struct mbuf *m, **mpp; struct ifqueue *ifq; enum NPmode mode; + int error; for (mpp = &sc->sc_npqueue; (m = *mpp) != NULL; ) { switch (PPP_PROTOCOL(mtod(m, u_char *))) { @@ -811,13 +829,27 @@ ppp_requeue(sc) */ *mpp = m->m_nextpkt; m->m_nextpkt = NULL; - ifq = (m->m_flags & M_HIGHPRI)? &sc->sc_fastq: &sc->sc_if.if_snd; - if (IF_QFULL(ifq)) { - IF_DROP(ifq); + if ((m->m_flags & M_HIGHPRI) +#ifdef ALTQ + && ALTQ_IS_ENABLED(&sc->sc_if.if_snd) == 0 +#endif + ) { + ifq = &sc->sc_fastq; + if (IF_QFULL(ifq)) { + IF_DROP(ifq); + m_freem(m); + error = ENOBUFS; + } + else { + IF_ENQUEUE(ifq, m); + error = 0; + } + } else + IFQ_ENQUEUE(&sc->sc_if.if_snd, m, NULL, error); + if (error) { sc->sc_if.if_oerrors++; sc->sc_stats.ppp_oerrors++; - } else - IF_ENQUEUE(ifq, m); + } break; case NPMODE_DROP: @@ -869,7 +901,7 @@ ppp_dequeue(sc) */ IF_DEQUEUE(&sc->sc_fastq, m); if (m == NULL) - IF_DEQUEUE(&sc->sc_if.if_snd, m); + IFQ_DEQUEUE(&sc->sc_if.if_snd, m); if (m == NULL) return NULL; @@ -995,7 +1027,7 @@ pppintr() s = splsoftnet(); 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)) { + && (IFQ_IS_EMPTY(&sc->sc_if.if_snd) == 0 || sc->sc_fastq.ifq_head)) { s2 = splimp(); sc->sc_flags |= SC_TBUSY; splx(s2); |