Index: if_ppp.c =================================================================== RCS file: /cvs/src/sys/net/if_ppp.c,v retrieving revision 1.92 diff -u -p -r1.92 if_ppp.c --- if_ppp.c 2 Nov 2015 23:39:20 -0000 1.92 +++ if_ppp.c 3 Nov 2015 06:28:46 -0000 @@ -293,8 +293,7 @@ pppalloc(pid_t pid) #endif /* PPP_COMPRESS */ for (i = 0; i < NUM_NP; ++i) sc->sc_npmode[i] = NPMODE_ERROR; - sc->sc_npqueue = NULL; - sc->sc_npqtail = &sc->sc_npqueue; + ml_init(&sc->sc_npqueue); sc->sc_last_sent = sc->sc_last_recv = time_second; return sc; @@ -319,10 +318,7 @@ pppdealloc(struct ppp_softc *sc) ppp_pkt_free(pkt); while ((m = mq_dequeue(&sc->sc_inq)) != NULL) m_freem(m); - while ((m = sc->sc_npqueue) != NULL) { - sc->sc_npqueue = m->m_nextpkt; - m_freem(m); - } + ml_purge(&sc->sc_npqueue); m_freem(sc->sc_togo); sc->sc_togo = NULL; @@ -769,9 +765,7 @@ pppoutput(struct ifnet *ifp, struct mbuf s = splsoftnet(); if (mode == NPMODE_QUEUE) { /* XXX we should limit the number of packets on this queue */ - *sc->sc_npqtail = m0; - m0->m_nextpkt = NULL; - sc->sc_npqtail = &m0->m_nextpkt; + ml_enqueue(&sc->sc_npqueue, m0); } else { IFQ_ENQUEUE(&sc->sc_if.if_snd, m0, error); if (error) { @@ -793,6 +787,8 @@ bad: return (error); } + + /* * After a change in the NPmode for some NP, move packets from the * npqueue to the send queue or the fast queue as appropriate. @@ -801,13 +797,14 @@ bad: static void ppp_requeue(struct ppp_softc *sc) { - struct mbuf *m, **mpp; + struct mbuf_list ml = MBUF_LIST_INITIALIZER(); + struct mbuf *m; enum NPmode mode; int error; splsoftassert(IPL_SOFTNET); - for (mpp = &sc->sc_npqueue; (m = *mpp) != NULL; ) { + while ((m = ml_dequeue(&sc->sc_npqueue)) != NULL) { switch (PPP_PROTOCOL(mtod(m, u_char *))) { case PPP_IP: mode = sc->sc_npmode[NP_IP]; @@ -818,11 +815,6 @@ ppp_requeue(struct ppp_softc *sc) switch (mode) { case NPMODE_PASS: - /* - * This packet can now go on one of the queues to be sent. - */ - *mpp = m->m_nextpkt; - m->m_nextpkt = NULL; IFQ_ENQUEUE(&sc->sc_if.if_snd, m, error); if (error) { sc->sc_if.if_oerrors++; @@ -832,16 +824,15 @@ ppp_requeue(struct ppp_softc *sc) case NPMODE_DROP: case NPMODE_ERROR: - *mpp = m->m_nextpkt; m_freem(m); break; case NPMODE_QUEUE: - mpp = &m->m_nextpkt; + ml_enqueue(&ml, m); break; } } - sc->sc_npqtail = mpp; + sc->sc_npqueue = ml; } /* Index: if_pppvar.h =================================================================== RCS file: /cvs/src/sys/net/if_pppvar.h,v retrieving revision 1.17 diff -u -p -r1.17 if_pppvar.h --- if_pppvar.h 3 Jun 2015 00:50:09 -0000 1.17 +++ if_pppvar.h 3 Nov 2015 06:28:46 -0000 @@ -111,8 +111,7 @@ struct ppp_softc { struct mbuf_queue sc_inq; /* queue of input packets for daemon */ struct ifqueue sc_fastq; /* interactive output packet q */ struct mbuf *sc_togo; /* output packet ready to go */ - struct mbuf *sc_npqueue; /* output packets not to be sent yet */ - struct mbuf **sc_npqtail; /* ptr to last next ptr in npqueue */ + struct mbuf_list sc_npqueue; /* output packets not to be sent yet */ struct pppstat sc_stats; /* count of bytes/pkts sent/rcvd */ caddr_t sc_bpf; /* hook for BPF */ enum NPmode sc_npmode[NUM_NP]; /* what to do with each NP */