Index: net/if.c =================================================================== RCS file: /cvs/src/sys/net/if.c,v retrieving revision 1.327 diff -u -p -r1.327 if.c --- net/if.c 7 Apr 2015 10:46:20 -0000 1.327 +++ net/if.c 9 Apr 2015 10:50:36 -0000 @@ -126,7 +126,8 @@ void if_attachsetup(struct ifnet *); void if_attachdomain1(struct ifnet *); void if_attach_common(struct ifnet *); -void if_detach_queues(struct ifnet *, struct ifqueue *); +int if_detach_filter(void *, const struct mbuf *); +void if_detach_queues(struct ifnet *, struct niqueue *); void if_detached_start(struct ifnet *); int if_detached_ioctl(struct ifnet *, u_long, caddr_t); @@ -591,7 +592,7 @@ if_detach(struct ifnet *ifp) */ #define IF_DETACH_QUEUES(x) \ do { \ - extern struct ifqueue x; \ + extern struct niqueue x; \ if_detach_queues(ifp, & x); \ } while (0) IF_DETACH_QUEUES(arpintrq); @@ -643,38 +644,31 @@ do { \ splx(s); } -void -if_detach_queues(struct ifnet *ifp, struct ifqueue *q) +int +if_detach_filter(void *ctx, const struct mbuf *m) { - struct mbuf *m, *prev = NULL, *next; - int prio; + struct ifnet *ifp = ctx; - for (prio = 0; prio <= IFQ_MAXPRIO; prio++) { - for (m = q->ifq_q[prio].head; m; m = next) { - next = m->m_nextpkt; #ifdef DIAGNOSTIC - if ((m->m_flags & M_PKTHDR) == 0) { - prev = m; - continue; - } -#endif - if (m->m_pkthdr.rcvif != ifp) { - prev = m; - continue; - } - - if (prev) - prev->m_nextpkt = m->m_nextpkt; - else - q->ifq_q[prio].head = m->m_nextpkt; - if (q->ifq_q[prio].tail == m) - q->ifq_q[prio].tail = prev; - q->ifq_len--; - - m->m_nextpkt = NULL; - m_freem(m); - IF_DROP(q); - } + if ((m->m_flags & M_PKTHDR) == 0) + return (0); +#endif + + return (m->m_pkthdr.rcvif == ifp); +} + +void +if_detach_queues(struct ifnet *ifp, struct niqueue *niq) +{ + struct mbuf *m0, *m; + + m0 = niq_filter(niq, if_detach_filter, ifp); + while (m0 != NULL) { + m = m0; + m0 = m->m_nextpkt; + + m->m_nextpkt = NULL; + m_freem(m); } } Index: net/if_ethersubr.c =================================================================== RCS file: /cvs/src/sys/net/if_ethersubr.c,v retrieving revision 1.191 diff -u -p -r1.191 if_ethersubr.c --- net/if_ethersubr.c 7 Apr 2015 10:46:20 -0000 1.191 +++ net/if_ethersubr.c 9 Apr 2015 10:50:36 -0000 @@ -458,9 +458,9 @@ ether_input(struct mbuf *m, void *hdr) { struct ifnet *ifp0, *ifp; struct ether_header *eh = hdr; - struct ifqueue *inq; + struct niqueue *inq; u_int16_t etype; - int s, llcfound = 0; + int llcfound = 0; struct llc *l; struct arpcom *ac; #if NTRUNK > 0 @@ -607,22 +607,15 @@ ether_input(struct mbuf *m, void *hdr) } } - /* - * Schedule softnet interrupt and enqueue packet within the same spl. - */ - s = splnet(); decapsulate: - switch (etype) { case ETHERTYPE_IP: - schednetisr(NETISR_IP); inq = &ipintrq; break; case ETHERTYPE_ARP: if (ifp->if_flags & IFF_NOARP) goto dropanyway; - schednetisr(NETISR_ARP); inq = &arpintrq; break; @@ -630,14 +623,13 @@ decapsulate: if (ifp->if_flags & IFF_NOARP) goto dropanyway; revarpinput(m); /* XXX queue? */ - goto done; + return (1); #ifdef INET6 /* * Schedule IPv6 software interrupt for incoming IPv6 packet. */ case ETHERTYPE_IPV6: - schednetisr(NETISR_IPV6); inq = &ip6intrq; break; #endif /* INET6 */ @@ -645,14 +637,12 @@ decapsulate: case ETHERTYPE_PPPOEDISC: case ETHERTYPE_PPPOE: #ifndef PPPOE_SERVER - if (m->m_flags & (M_MCAST | M_BCAST)) { - m_freem(m); - goto done; - } + if (m->m_flags & (M_MCAST | M_BCAST)) + goto dropanyway; #endif M_PREPEND(m, sizeof(*eh), M_DONTWAIT); if (m == NULL) - goto done; + return (1); eh_tmp = mtod(m, struct ether_header *); /* @@ -667,7 +657,7 @@ decapsulate: if ((session = pipex_pppoe_lookup_session(m)) != NULL) { pipex_pppoe_input(m, session); - goto done; + return (1); } } #endif @@ -675,15 +665,12 @@ decapsulate: inq = &pppoediscinq; else inq = &pppoeinq; - - schednetisr(NETISR_PPPOE); break; #endif #ifdef MPLS case ETHERTYPE_MPLS: case ETHERTYPE_MPLS_MCAST: inq = &mplsintrq; - schednetisr(NETISR_MPLS); break; #endif default: @@ -702,21 +689,19 @@ decapsulate: m_adj(m, 6); M_PREPEND(m, sizeof(*eh), M_DONTWAIT); if (m == NULL) - goto done; + return (1); *mtod(m, struct ether_header *) = *eh; goto decapsulate; } - goto dropanyway; - dropanyway: default: - m_freem(m); - goto done; + goto dropanyway; } } - IF_INPUT_ENQUEUE(inq, m); -done: - splx(s); + niq_enqueue(inq, m); + return (1); +dropanyway: + m_freem(m); return (1); } Index: net/if_loop.c =================================================================== RCS file: /cvs/src/sys/net/if_loop.c,v retrieving revision 1.64 diff -u -p -r1.64 if_loop.c --- net/if_loop.c 14 Mar 2015 03:38:51 -0000 1.64 +++ net/if_loop.c 9 Apr 2015 10:50:36 -0000 @@ -203,8 +203,7 @@ int looutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, struct rtentry *rt) { - int s, isr; - struct ifqueue *ifq = 0; + struct niqueue *ifq = NULL; if ((m->m_flags & M_PKTHDR) == 0) panic("looutput: no header mbuf"); @@ -231,18 +230,15 @@ looutput(struct ifnet *ifp, struct mbuf case AF_INET: ifq = &ipintrq; - isr = NETISR_IP; break; #ifdef INET6 case AF_INET6: ifq = &ip6intrq; - isr = NETISR_IPV6; break; #endif /* INET6 */ #ifdef MPLS case AF_MPLS: ifq = &mplsintrq; - isr = NETISR_MPLS; break; #endif /* MPLS */ default: @@ -251,18 +247,13 @@ looutput(struct ifnet *ifp, struct mbuf m_freem(m); return (EAFNOSUPPORT); } - s = splnet(); - if (IF_QFULL(ifq)) { - IF_DROP(ifq); - m_freem(m); - splx(s); + + if (niq_enqueue(ifq, m) != 0) return (ENOBUFS); - } - IF_ENQUEUE(ifq, m); - schednetisr(isr); + ifp->if_ipackets++; ifp->if_ibytes += m->m_pkthdr.len; - splx(s); + return (0); } Index: net/if_mpe.c =================================================================== RCS file: /cvs/src/sys/net/if_mpe.c,v retrieving revision 1.42 diff -u -p -r1.42 if_mpe.c --- net/if_mpe.c 26 Mar 2015 11:02:44 -0000 1.42 +++ net/if_mpe.c 9 Apr 2015 10:50:36 -0000 @@ -371,7 +371,7 @@ mpe_input(struct mbuf *m, struct ifnet * u_int8_t ttl) { struct ip *ip; - int s, hlen; + int hlen; /* label -> AF lookup */ @@ -408,10 +408,8 @@ mpe_input(struct mbuf *m, struct ifnet * if (ifp && ifp->if_bpf) bpf_mtap_af(ifp->if_bpf, AF_INET, m, BPF_DIRECTION_IN); #endif - s = splnet(); - IF_INPUT_ENQUEUE(&ipintrq, m); - schednetisr(NETISR_IP); - splx(s); + + niq_enqueue(&ipintrq, m); } #ifdef INET6 @@ -420,7 +418,6 @@ mpe_input6(struct mbuf *m, struct ifnet u_int8_t ttl) { struct ip6_hdr *ip6hdr; - int s; /* label -> AF lookup */ @@ -443,9 +440,7 @@ mpe_input6(struct mbuf *m, struct ifnet if (ifp && ifp->if_bpf) bpf_mtap_af(ifp->if_bpf, AF_INET6, m, BPF_DIRECTION_IN); #endif - s = splnet(); - IF_INPUT_ENQUEUE(&ip6intrq, m); - schednetisr(NETISR_IPV6); - splx(s); + + niq_enqueue(&ip6intrq, m); } #endif /* INET6 */ Index: net/if_ppp.c =================================================================== RCS file: /cvs/src/sys/net/if_ppp.c,v retrieving revision 1.81 diff -u -p -r1.81 if_ppp.c --- net/if_ppp.c 18 Mar 2015 12:23:15 -0000 1.81 +++ net/if_ppp.c 9 Apr 2015 10:50:36 -0000 @@ -232,7 +232,7 @@ ppp_clone_create(struct if_clone *ifc, i sc->sc_if.if_output = pppoutput; sc->sc_if.if_start = ppp_ifstart; IFQ_SET_MAXLEN(&sc->sc_if.if_snd, IFQ_MAXLEN); - IFQ_SET_MAXLEN(&sc->sc_inq, IFQ_MAXLEN); + mq_init(&sc->sc_inq, IFQ_MAXLEN, IPL_NET); IFQ_SET_MAXLEN(&sc->sc_fastq, IFQ_MAXLEN); IFQ_SET_MAXLEN(&sc->sc_rawq, IFQ_MAXLEN); IFQ_SET_READY(&sc->sc_if.if_snd); @@ -329,12 +329,8 @@ pppdealloc(struct ppp_softc *sc) break; m_freem(m); } - for (;;) { - IF_DEQUEUE(&sc->sc_inq, m); - if (m == NULL) - break; + while ((m = mq_dequeue(&sc->sc_inq)) != NULL) m_freem(m); - } for (;;) { IF_DEQUEUE(&sc->sc_fastq, m); if (m == NULL) @@ -398,7 +394,7 @@ pppioctl(struct ppp_softc *sc, u_long cm switch (cmd) { case FIONREAD: - *(int *)data = IFQ_LEN(&sc->sc_inq); + *(int *)data = mq_len(&sc->sc_inq); break; case PPPIOCGUNIT: @@ -1225,7 +1221,6 @@ static void ppp_inproc(struct ppp_softc *sc, struct mbuf *m) { struct ifnet *ifp = &sc->sc_if; - struct ifqueue *inq; int s, ilen, xlen, proto, rv; u_char *cp, adrs, ctrl; struct mbuf *mp, *dmp = NULL; @@ -1462,44 +1457,44 @@ ppp_inproc(struct ppp_softc *sc, struct m->m_pkthdr.len -= PPP_HDRLEN; m->m_data += PPP_HDRLEN; m->m_len -= PPP_HDRLEN; - schednetisr(NETISR_IP); - inq = &ipintrq; + + if (niq_enqueue(&ipintrq, m) != 0) + rv = 0; /* failure */ + else + rv = 1; /* ipintrq success */ break; default: /* * Some other protocol - place on input queue for read(). */ - inq = &sc->sc_inq; - rv = 1; + if (mq_enqueue(&sc->sc_inq, m) != 0) { + if_congestion(); + rv = 0; /* failure */ + } else + rv = 2; /* input queue */ break; } - /* - * Put the packet on the appropriate input queue. - */ - s = splnet(); - if (IF_QFULL(inq)) { - IF_DROP(inq); - splx(s); + if (rv == 0) { + /* failure */ if (sc->sc_flags & SC_DEBUG) printf("%s: input queue full\n", ifp->if_xname); ifp->if_iqdrops++; - if_congestion(); - goto bad; + goto dropped; } - IF_ENQUEUE(inq, m); - splx(s); + ifp->if_ipackets++; ifp->if_ibytes += ilen; - if (rv) + if (rv == 2) (*sc->sc_ctlp)(sc); return; bad: m_freem(m); + dropped: sc->sc_if.if_ierrors++; sc->sc_stats.ppp_ierrors++; } Index: net/if_pppoe.c =================================================================== RCS file: /cvs/src/sys/net/if_pppoe.c,v retrieving revision 1.44 diff -u -p -r1.44 if_pppoe.c --- net/if_pppoe.c 14 Mar 2015 03:38:51 -0000 1.44 +++ net/if_pppoe.c 9 Apr 2015 10:50:36 -0000 @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -146,8 +147,8 @@ struct pppoe_softc { }; /* incoming traffic will be queued here */ -struct ifqueue pppoediscinq; -struct ifqueue pppoeinq; +struct niqueue pppoediscinq = NIQUEUE_INITIALIZER(IFQ_MAXLEN, NETISR_PPPOE); +struct niqueue pppoeinq = NIQUEUE_INITIALIZER(IFQ_MAXLEN, NETISR_PPPOE); /* input routines */ static void pppoe_disc_input(struct mbuf *); @@ -200,9 +201,6 @@ pppoeattach(int count) { LIST_INIT(&pppoe_softc_list); if_clone_attach(&pppoe_cloner); - - IFQ_SET_MAXLEN(&pppoediscinq, IFQ_MAXLEN); - IFQ_SET_MAXLEN(&pppoeinq, IFQ_MAXLEN); } /* Create a new interface. */ @@ -359,27 +357,14 @@ void pppoeintr(void) { struct mbuf *m; - int s; splsoftassert(IPL_SOFTNET); - - for (;;) { - s = splnet(); - IF_DEQUEUE(&pppoediscinq, m); - splx(s); - if (m == NULL) - break; + + while ((m = niq_dequeue(&pppoediscinq)) != NULL) pppoe_disc_input(m); - } - for (;;) { - s = splnet(); - IF_DEQUEUE(&pppoeinq, m); - splx(s); - if (m == NULL) - break; + while ((m = niq_dequeue(&pppoeinq)) != NULL) pppoe_data_input(m); - } } /* Analyze and handle a single received packet while not in session state. */ Index: net/if_pppoe.h =================================================================== RCS file: /cvs/src/sys/net/if_pppoe.h,v retrieving revision 1.5 diff -u -p -r1.5 if_pppoe.h --- net/if_pppoe.h 28 Aug 2008 13:10:54 -0000 1.5 +++ net/if_pppoe.h 9 Apr 2015 10:50:36 -0000 @@ -66,8 +66,8 @@ struct pppoeconnectionstate { #ifdef _KERNEL -extern struct ifqueue pppoediscinq; -extern struct ifqueue pppoeinq; +extern struct niqueue pppoediscinq; +extern struct niqueue pppoeinq; void pppoeintr(void); Index: net/if_pppvar.h =================================================================== RCS file: /cvs/src/sys/net/if_pppvar.h,v retrieving revision 1.15 diff -u -p -r1.15 if_pppvar.h --- net/if_pppvar.h 7 Dec 2003 15:41:27 -0000 1.15 +++ net/if_pppvar.h 9 Apr 2015 10:50:36 -0000 @@ -98,7 +98,7 @@ struct ppp_softc { u_int16_t sc_mru; /* max receive unit */ pid_t sc_xfer; /* used in transferring unit */ struct ifqueue sc_rawq; /* received packets */ - struct ifqueue sc_inq; /* queue of input packets for daemon */ + 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 */ Index: net/if_pppx.c =================================================================== RCS file: /cvs/src/sys/net/if_pppx.c,v retrieving revision 1.36 diff -u -p -r1.36 if_pppx.c --- net/if_pppx.c 10 Feb 2015 21:56:10 -0000 1.36 +++ net/if_pppx.c 9 Apr 2015 10:50:36 -0000 @@ -317,9 +317,9 @@ pppxwrite(dev_t dev, struct uio *uio, in /* struct pppx_dev *pxd = pppx_dev2pxd(dev); */ struct pppx_hdr *th; struct mbuf *top, **mp, *m; - struct ifqueue *ifq; + struct niqueue *ifq; int tlen, mlen; - int isr, s, error = 0; + int error = 0; if (uio->uio_resid < sizeof(*th) || uio->uio_resid > MCLBYTES) return (EMSGSIZE); @@ -381,12 +381,10 @@ pppxwrite(dev_t dev, struct uio *uio, in switch (ntohl(th->pppx_proto)) { case AF_INET: ifq = &ipintrq; - isr = NETISR_IP; break; #ifdef INET6 case AF_INET6: ifq = &ip6intrq; - isr = NETISR_IPV6; break; #endif default: @@ -394,16 +392,8 @@ pppxwrite(dev_t dev, struct uio *uio, in return (EAFNOSUPPORT); } - s = splnet(); - if (IF_QFULL(ifq)) { - IF_DROP(ifq); - splx(s); - m_freem(top); + if (niq_enqueue(ifq, m) != 0) return (ENOBUFS); - } - IF_ENQUEUE(ifq, top); - schednetisr(isr); - splx(s); return (error); } Index: net/if_spppsubr.c =================================================================== RCS file: /cvs/src/sys/net/if_spppsubr.c,v retrieving revision 1.131 diff -u -p -r1.131 if_spppsubr.c --- net/if_spppsubr.c 18 Mar 2015 12:23:15 -0000 1.131 +++ net/if_spppsubr.c 9 Apr 2015 10:50:36 -0000 @@ -437,11 +437,10 @@ void sppp_input(struct ifnet *ifp, struct mbuf *m) { struct ppp_header ht; - struct ifqueue *inq = 0; + struct niqueue *inq = NULL; struct sppp *sp = (struct sppp *)ifp; struct timeval tv; int debug = ifp->if_flags & IFF_DEBUG; - int s; if (ifp->if_flags & IFF_UP) { /* Count received bytes, add hardware framing */ @@ -458,9 +457,10 @@ sppp_input(struct ifnet *ifp, struct mbu SPP_FMT "input packet is too small, %d bytes\n", SPP_ARGS(ifp), m->m_pkthdr.len); drop: + m_freem (m); + dropped: ++ifp->if_ierrors; ++ifp->if_iqdrops; - m_freem (m); return; } @@ -538,7 +538,6 @@ sppp_input(struct ifnet *ifp, struct mbu return; case PPP_IP: if (sp->state[IDX_IPCP] == STATE_OPENED) { - schednetisr (NETISR_IP); inq = &ipintrq; sp->pp_last_activity = tv.tv_sec; } @@ -551,7 +550,6 @@ sppp_input(struct ifnet *ifp, struct mbu return; case PPP_IPV6: if (sp->state[IDX_IPV6CP] == STATE_OPENED) { - schednetisr (NETISR_IPV6); inq = &ip6intrq; sp->pp_last_activity = tv.tv_sec; } @@ -580,12 +578,10 @@ sppp_input(struct ifnet *ifp, struct mbu m_freem (m); return; case ETHERTYPE_IP: - schednetisr (NETISR_IP); inq = &ipintrq; break; #ifdef INET6 case ETHERTYPE_IPV6: - schednetisr (NETISR_IPV6); inq = &ip6intrq; break; #endif @@ -605,20 +601,13 @@ sppp_input(struct ifnet *ifp, struct mbu if (! (ifp->if_flags & IFF_UP) || ! inq) goto drop; - /* Check queue. */ - s = splnet(); - if (IF_QFULL (inq)) { + if (niq_enqueue(inq, m) != 0) { /* Queue overflow. */ - IF_DROP(inq); - splx(s); if (debug) log(LOG_DEBUG, SPP_FMT "protocol queue overflow\n", SPP_ARGS(ifp)); - if_congestion(); - goto drop; + goto dropped; } - IF_ENQUEUE(inq, m); - splx(s); } /* Index: net/if_tun.c =================================================================== RCS file: /cvs/src/sys/net/if_tun.c,v retrieving revision 1.135 diff -u -p -r1.135 if_tun.c --- net/if_tun.c 1 Apr 2015 14:29:54 -0000 1.135 +++ net/if_tun.c 9 Apr 2015 10:50:36 -0000 @@ -780,10 +780,9 @@ tunwrite(dev_t dev, struct uio *uio, int { struct tun_softc *tp; struct ifnet *ifp; - struct ifqueue *ifq; + struct niqueue *ifq; u_int32_t *th; struct mbuf *top, **mp, *m; - int isr; int error=0, s, tlen, mlen; if ((tp = tun_lookup(minor(dev))) == NULL) @@ -887,12 +886,10 @@ tunwrite(dev_t dev, struct uio *uio, int switch (ntohl(*th)) { case AF_INET: ifq = &ipintrq; - isr = NETISR_IP; break; #ifdef INET6 case AF_INET6: ifq = &ip6intrq; - isr = NETISR_IPV6; break; #endif default: @@ -900,20 +897,14 @@ tunwrite(dev_t dev, struct uio *uio, int return (EAFNOSUPPORT); } - s = splnet(); - if (IF_QFULL(ifq)) { - IF_DROP(ifq); - splx(s); + if (niq_enqueue(ifq, m) != 0) { ifp->if_collisions++; - m_freem(top); - if_congestion(); return (ENOBUFS); } - IF_ENQUEUE(ifq, top); - schednetisr(isr); + ifp->if_ipackets++; ifp->if_ibytes += top->m_pkthdr.len; - splx(s); + return (error); } Index: net/pipex.c =================================================================== RCS file: /cvs/src/sys/net/pipex.c,v retrieving revision 1.66 diff -u -p -r1.66 pipex.c --- net/pipex.c 18 Mar 2015 12:23:15 -0000 1.66 +++ net/pipex.c 9 Apr 2015 10:50:36 -0000 @@ -1161,7 +1161,7 @@ pipex_ip_input(struct mbuf *m0, struct p { struct ifnet *ifp; struct ip *ip; - int s, len; + int len; int is_idle; /* change recvif */ @@ -1223,28 +1223,21 @@ pipex_ip_input(struct mbuf *m0, struct p bpf_mtap_af(ifp->if_bpf, AF_INET, m0, BPF_DIRECTION_IN); #endif - s = splnet(); - if (IF_QFULL(&ipintrq)) { - IF_DROP(&ipintrq); + if (niq_enqueue(&ipintrq, m0) != 0) { ifp->if_collisions++; - if_congestion(); - splx(s); - goto drop; + goto dropped; } - IF_ENQUEUE(&ipintrq, m0); - schednetisr(NETISR_IP); ifp->if_ipackets++; ifp->if_ibytes += len; session->stat.ipackets++; session->stat.ibytes += len; - splx(s); - return; drop: if (m0 != NULL) m_freem(m0); +dropped: session->stat.ierrors++; } @@ -1254,7 +1247,7 @@ pipex_ip6_input(struct mbuf *m0, struct { struct ifnet *ifp; struct ip6_hdr *ip6; - int s, len; + int len; /* change recvif */ m0->m_pkthdr.rcvif = session->pipex_iface->ifnet_this; @@ -1297,28 +1290,18 @@ pipex_ip6_input(struct mbuf *m0, struct bpf_mtap_af(ifp->if_bpf, AF_INET6, m0, BPF_DIRECTION_IN); #endif - s = splnet(); - if (IF_QFULL(&ip6intrq)) { - IF_DROP(&ip6intrq); + if (niq_enqueue(&ip6intrq, m0) != 0) { ifp->if_collisions++; - if_congestion(); - splx(s); - goto drop; + goto dropped; } - IF_ENQUEUE(&ip6intrq, m0); - schednetisr(NETISR_IPV6); ifp->if_ipackets++; ifp->if_ibytes += len; session->stat.ipackets++; session->stat.ibytes += len; - splx(s); - return; -drop: - if (m0 != NULL) - m_freem(m0); +dropped: session->stat.ierrors++; } #endif Index: net/ppp_tty.c =================================================================== RCS file: /cvs/src/sys/net/ppp_tty.c,v retrieving revision 1.31 diff -u -p -r1.31 ppp_tty.c --- net/ppp_tty.c 10 Feb 2015 21:56:10 -0000 1.31 +++ net/ppp_tty.c 9 Apr 2015 10:50:36 -0000 @@ -303,7 +303,9 @@ pppread(struct tty *tp, struct uio *uio, splx(s); return 0; } - if (!IF_IS_EMPTY(&sc->sc_inq)) + /* Get the packet from the input queue */ + m0 = mq_dequeue(&sc->sc_inq); + if (m0 != NULL) break; if ((tp->t_state & TS_CARR_ON) == 0 && (tp->t_cflag & CLOCAL) == 0 && (tp->t_state & TS_ISOPEN)) { @@ -323,9 +325,6 @@ pppread(struct tty *tp, struct uio *uio, /* Pull place-holder byte out of canonical queue */ getc(&tp->t_canq); - - /* Get the packet from the input queue */ - IF_DEQUEUE(&sc->sc_inq, m0); splx(s); for (m = m0; m && uio->uio_resid; m = m->m_next) Index: netinet/if_ether.c =================================================================== RCS file: /cvs/src/sys/netinet/if_ether.c,v retrieving revision 1.149 diff -u -p -r1.149 if_ether.c --- netinet/if_ether.c 24 Mar 2015 12:58:43 -0000 1.149 +++ netinet/if_ether.c 9 Apr 2015 10:50:36 -0000 @@ -57,6 +57,7 @@ #include #include #include +#include #include #include @@ -97,7 +98,8 @@ void in_arpinput(struct mbuf *); LIST_HEAD(, llinfo_arp) llinfo_arp; struct pool arp_pool; /* pool for llinfo_arp structures */ -struct ifqueue arpintrq; +/* XXX hate magic numbers */ +struct niqueue arpintrq = NIQUEUE_INITIALIZER(50, NETISR_ARP); int arp_inuse, arp_allocated; int arp_maxtries = 5; int arpinit_done; @@ -159,7 +161,6 @@ arp_rtrequest(int req, struct rtentry *r arpinit_done = 1; pool_init(&arp_pool, sizeof(struct llinfo_arp), 0, 0, 0, "arp", NULL); - IFQ_SET_MAXLEN(&arpintrq, 50); /* XXX hate magic numbers */ /* * We generate expiration times from time.tv_sec * so avoid accidently creating permanent routes. @@ -497,14 +498,9 @@ arpintr(void) { struct mbuf *m; struct arphdr *ar; - int s, len; + int len; - for (;;) { - s = splnet(); - IF_DEQUEUE(&arpintrq, m); - splx(s); - if (m == NULL) - break; + while ((m = niq_dequeue(&arpintrq)) != NULL) { #ifdef DIAGNOSTIC if ((m->m_flags & M_PKTHDR) == 0) panic("arpintr"); Index: netinet/if_ether.h =================================================================== RCS file: /cvs/src/sys/netinet/if_ether.h,v retrieving revision 1.55 diff -u -p -r1.55 if_ether.h --- netinet/if_ether.h 24 Mar 2015 12:58:43 -0000 1.55 +++ netinet/if_ether.h 9 Apr 2015 10:50:36 -0000 @@ -188,7 +188,7 @@ struct sockaddr_inarp { extern u_int8_t etherbroadcastaddr[ETHER_ADDR_LEN]; extern u_int8_t ether_ipmulticast_min[ETHER_ADDR_LEN]; extern u_int8_t ether_ipmulticast_max[ETHER_ADDR_LEN]; -extern struct ifqueue arpintrq; +extern struct niqueue arpintrq; void arpwhohas(struct arpcom *, struct in_addr *); void arpintr(void); Index: netinet/in.h =================================================================== RCS file: /cvs/src/sys/netinet/in.h,v retrieving revision 1.112 diff -u -p -r1.112 in.h --- netinet/in.h 9 Feb 2015 12:18:19 -0000 1.112 +++ netinet/in.h 9 Apr 2015 10:50:36 -0000 @@ -785,7 +785,7 @@ __END_DECLS #ifdef _KERNEL extern int inetctlerrmap[]; -extern struct ifqueue ipintrq; /* ip packet input queue */ +extern struct niqueue ipintrq; /* ip packet input queue */ extern struct in_addr zeroin_addr; struct mbuf; Index: netinet/ip_divert.c =================================================================== RCS file: /cvs/src/sys/netinet/ip_divert.c,v retrieving revision 1.32 diff -u -p -r1.32 ip_divert.c --- netinet/ip_divert.c 24 Jan 2015 00:29:06 -0000 1.32 +++ netinet/ip_divert.c 9 Apr 2015 10:50:36 -0000 @@ -82,11 +82,10 @@ int divert_output(struct inpcb *inp, struct mbuf *m, struct mbuf *nam, struct mbuf *control) { - struct ifqueue *inq; struct sockaddr_in *sin; struct socket *so; struct ifaddr *ifa; - int s, error = 0, min_hdrlen = 0, dir; + int error = 0, min_hdrlen = 0, dir; struct ip *ip; u_int16_t off; @@ -149,8 +148,6 @@ divert_output(struct inpcb *inp, struct } m->m_pkthdr.rcvif = ifa->ifa_ifp; - inq = &ipintrq; - /* * Recalculate IP and protocol checksums for the inbound packet * since the userspace application may have modified the packet @@ -160,10 +157,7 @@ divert_output(struct inpcb *inp, struct ip->ip_sum = in_cksum(m, off); in_proto_cksum_out(m, NULL); - s = splnet(); - IF_INPUT_ENQUEUE(inq, m); - schednetisr(NETISR_IP); - splx(s); + niq_enqueue(&ipintrq, m); } else { error = ip_output(m, NULL, &inp->inp_route, IP_ALLOWBROADCAST | IP_RAWOUTPUT, NULL, NULL, 0); Index: netinet/ip_ether.c =================================================================== RCS file: /cvs/src/sys/netinet/ip_ether.c,v retrieving revision 1.70 diff -u -p -r1.70 ip_ether.c --- netinet/ip_ether.c 19 Dec 2014 17:14:40 -0000 1.70 +++ netinet/ip_ether.c 9 Apr 2015 10:50:36 -0000 @@ -280,8 +280,6 @@ void mplsip_decap(struct mbuf *m, int iphlen) { struct gif_softc *sc; - struct ifqueue *ifq; - int s; etheripstat.etherip_ipackets++; @@ -330,22 +328,12 @@ mplsip_decap(struct mbuf *m, int iphlen) pf_pkt_addr_changed(m); #endif - ifq = &mplsintrq; - s = splnet(); - if (IF_QFULL(ifq)) { - IF_DROP(ifq); - m_freem(m); + if (niq_enqueue(&mplsintrq, m) != 0) { etheripstat.etherip_qfull++; - splx(s); DPRINTF(("mplsip_input(): packet dropped because of full " "queue\n")); - return; } - IF_ENQUEUE(ifq, m); - schednetisr(NETISR_MPLS); - splx(s); - return; } #endif Index: netinet/ip_gre.c =================================================================== RCS file: /cvs/src/sys/netinet/ip_gre.c,v retrieving revision 1.53 diff -u -p -r1.53 ip_gre.c --- netinet/ip_gre.c 18 Mar 2015 01:12:16 -0000 1.53 +++ netinet/ip_gre.c 9 Apr 2015 10:50:36 -0000 @@ -93,8 +93,7 @@ int gre_input2(struct mbuf *m, int hlen, u_char proto) { struct greip *gip; - int s; - struct ifqueue *ifq; + struct niqueue *ifq; struct gre_softc *sc; u_short flags; u_int af; @@ -168,7 +167,6 @@ gre_input2(struct mbuf *m, int hlen, u_c #ifdef INET6 case ETHERTYPE_IPV6: ifq = &ip6intrq; - schednetisr(NETISR_IPV6); af = AF_INET6; break; #endif @@ -181,7 +179,6 @@ gre_input2(struct mbuf *m, int hlen, u_c case ETHERTYPE_MPLS: case ETHERTYPE_MPLS_MCAST: ifq = &mplsintrq; - schednetisr(NETISR_MPLS); af = AF_MPLS; break; #endif @@ -209,9 +206,7 @@ gre_input2(struct mbuf *m, int hlen, u_c pf_pkt_addr_changed(m); #endif - s = splnet(); /* possible */ - IF_INPUT_ENQUEUE(ifq, m); - splx(s); + niq_enqueue(ifq, m); return (1); /* packet is done, no further processing needed */ } @@ -271,9 +266,8 @@ gre_mobile_input(struct mbuf *m, ...) { struct ip *ip; struct mobip_h *mip; - struct ifqueue *ifq; struct gre_softc *sc; - int hlen, s; + int hlen; va_list ap; u_char osrc = 0; int msiz; @@ -339,16 +333,12 @@ gre_mobile_input(struct mbuf *m, ...) ip->ip_sum = 0; ip->ip_sum = in_cksum(m,(ip->ip_hl << 2)); - ifq = &ipintrq; - #if NBPFILTER > 0 if (sc->sc_if.if_bpf) bpf_mtap_af(sc->sc_if.if_bpf, AF_INET, m, BPF_DIRECTION_IN); #endif - s = splnet(); /* possible */ - IF_INPUT_ENQUEUE(ifq, m); - splx(s); + niq_enqueue(&ipintrq, m); } /* Index: netinet/ip_input.c =================================================================== RCS file: /cvs/src/sys/netinet/ip_input.c,v retrieving revision 1.247 diff -u -p -r1.247 ip_input.c --- netinet/ip_input.c 14 Mar 2015 03:38:52 -0000 1.247 +++ netinet/ip_input.c 9 Apr 2015 10:50:36 -0000 @@ -49,6 +49,7 @@ #include #include #include +#include #include #include @@ -113,7 +114,7 @@ int ip_frags = 0; int *ipctl_vars[IPCTL_MAXID] = IPCTL_VARS; -struct ifqueue ipintrq; +struct niqueue ipintrq = NIQUEUE_INITIALIZER(IFQ_MAXLEN, NETISR_IP); struct pool ipqent_pool; struct pool ipq_pool; @@ -169,7 +170,6 @@ ip_init(void) pr->pr_protocol < IPPROTO_MAX) ip_protox[pr->pr_protocol] = pr - inetsw; LIST_INIT(&ipq); - IFQ_SET_MAXLEN(&ipintrq, IFQ_MAXLEN); if (ip_mtudisc != 0) ip_mtudisc_timeout_q = rt_timer_queue_create(ip_mtudisc_timeout); @@ -192,18 +192,12 @@ void ipintr(void) { struct mbuf *m; - int s; - for (;;) { - /* - * Get next datagram off input queue and get IP header - * in first mbuf. - */ - s = splnet(); - IF_DEQUEUE(&ipintrq, m); - splx(s); - if (m == NULL) - return; + /* + * Get next datagram off input queue and get IP header + * in first mbuf. + */ + while ((m = niq_dequeue(&ipintrq)) != NULL) { #ifdef DIAGNOSTIC if ((m->m_flags & M_PKTHDR) == 0) panic("ipintr no HDR"); @@ -1616,7 +1610,7 @@ ip_sysctl(int *name, u_int namelen, void ipsec_def_comp, sizeof(ipsec_def_comp))); case IPCTL_IFQUEUE: - return (sysctl_ifq(name + 1, namelen - 1, + return (sysctl_niq(name + 1, namelen - 1, oldp, oldlenp, newp, newlen, &ipintrq)); case IPCTL_STATS: return (sysctl_rdstruct(oldp, oldlenp, newp, Index: netinet/ip_ipip.c =================================================================== RCS file: /cvs/src/sys/netinet/ip_ipip.c,v retrieving revision 1.56 diff -u -p -r1.56 ip_ipip.c --- netinet/ip_ipip.c 19 Dec 2014 17:14:40 -0000 1.56 +++ netinet/ip_ipip.c 9 Apr 2015 10:50:36 -0000 @@ -146,15 +146,14 @@ ipip_input(struct mbuf *m, int iphlen, s struct sockaddr_in *sin; struct ifnet *ifp; struct ifaddr *ifa; - struct ifqueue *ifq = NULL; + struct niqueue *ifq = NULL; struct ip *ipo; u_int rdomain; #ifdef INET6 struct sockaddr_in6 *sin6; struct ip6_hdr *ip6; #endif - int isr; - int mode, hlen, s; + int mode, hlen; u_int8_t itos, otos; u_int8_t v; sa_family_t af; @@ -352,13 +351,11 @@ ipip_input(struct mbuf *m, int iphlen, s switch (proto) { case IPPROTO_IPV4: ifq = &ipintrq; - isr = NETISR_IP; af = AF_INET; break; #ifdef INET6 case IPPROTO_IPV6: ifq = &ip6intrq; - isr = NETISR_IPV6; af = AF_INET6; break; #endif @@ -374,23 +371,12 @@ ipip_input(struct mbuf *m, int iphlen, s pf_pkt_addr_changed(m); #endif - s = splnet(); /* isn't it already? */ - if (IF_QFULL(ifq)) { - IF_DROP(ifq); - m_freem(m); + if (niq_enqueue(ifq, m) != 0) { ipipstat.ipips_qfull++; - - splx(s); - DPRINTF(("ipip_input(): packet dropped because of full " "queue\n")); return; } - - IF_ENQUEUE(ifq, m); - schednetisr(isr); - splx(s); - return; } int Index: netinet/ipsec_input.c =================================================================== RCS file: /cvs/src/sys/netinet/ipsec_input.c,v retrieving revision 1.127 diff -u -p -r1.127 ipsec_input.c --- netinet/ipsec_input.c 26 Mar 2015 12:21:37 -0000 1.127 +++ netinet/ipsec_input.c 9 Apr 2015 10:50:36 -0000 @@ -708,28 +708,18 @@ ah4_input(struct mbuf *m, ...) int ah4_input_cb(struct mbuf *m, ...) { - struct ifqueue *ifq = &ipintrq; - int s = splnet(); - /* * Interface pointer is already in first mbuf; chop off the * `outer' header and reschedule. */ - if (IF_QFULL(ifq)) { - IF_DROP(ifq); + if (niq_enqueue(&ipintrq, m) != 0) { ahstat.ahs_qfull++; - splx(s); - - m_freem(m); DPRINTF(("ah4_input_cb(): dropped packet because of full " "IP queue\n")); return ENOBUFS; } - IF_ENQUEUE(ifq, m); - schednetisr(NETISR_IP); - splx(s); return 0; } @@ -764,27 +754,17 @@ esp4_input(struct mbuf *m, ...) int esp4_input_cb(struct mbuf *m, ...) { - struct ifqueue *ifq = &ipintrq; - int s = splnet(); - /* * Interface pointer is already in first mbuf; chop off the * `outer' header and reschedule. */ - if (IF_QFULL(ifq)) { - IF_DROP(ifq); + if (niq_enqueue(&ipintrq, m) != 0) { espstat.esps_qfull++; - splx(s); - - m_freem(m); DPRINTF(("esp4_input_cb(): dropped packet because of full " "IP queue\n")); return ENOBUFS; } - IF_ENQUEUE(ifq, m); - schednetisr(NETISR_IP); - splx(s); return 0; } @@ -806,26 +786,15 @@ ipcomp4_input(struct mbuf *m, ...) int ipcomp4_input_cb(struct mbuf *m, ...) { - struct ifqueue *ifq = &ipintrq; - int s = splnet(); - /* * Interface pointer is already in first mbuf; chop off the * `outer' header and reschedule. */ - if (IF_QFULL(ifq)) { - IF_DROP(ifq); + if (niq_enqueue(&ipintrq, m) != 0) { ipcompstat.ipcomps_qfull++; - splx(s); - - m_freem(m); DPRINTF(("ipcomp4_input_cb(): dropped packet because of full IP queue\n")); return ENOBUFS; } - - IF_ENQUEUE(ifq, m); - schednetisr(NETISR_IP); - splx(s); return 0; } Index: netinet6/in6.h =================================================================== RCS file: /cvs/src/sys/netinet6/in6.h,v retrieving revision 1.80 diff -u -p -r1.80 in6.h --- netinet6/in6.h 9 Feb 2015 12:23:22 -0000 1.80 +++ netinet6/in6.h 9 Apr 2015 10:50:36 -0000 @@ -418,7 +418,7 @@ typedef __socklen_t socklen_t; /* length #ifdef _KERNEL extern u_char inet6ctlerrmap[]; -extern struct ifqueue ip6intrq; /* IP6 packet input queue */ +extern struct niqueue ip6intrq; /* IP6 packet input queue */ extern struct in6_addr zeroin6_addr; struct mbuf; Index: netinet6/ip6_divert.c =================================================================== RCS file: /cvs/src/sys/netinet6/ip6_divert.c,v retrieving revision 1.32 diff -u -p -r1.32 ip6_divert.c --- netinet6/ip6_divert.c 24 Jan 2015 00:29:06 -0000 1.32 +++ netinet6/ip6_divert.c 9 Apr 2015 10:50:36 -0000 @@ -86,11 +86,10 @@ int divert6_output(struct inpcb *inp, struct mbuf *m, struct mbuf *nam, struct mbuf *control) { - struct ifqueue *inq; struct sockaddr_in6 *sin6; struct socket *so; struct ifaddr *ifa; - int s, error = 0, min_hdrlen = 0, nxt = 0, off, dir; + int error = 0, min_hdrlen = 0, nxt = 0, off, dir; struct ip6_hdr *ip6; m->m_pkthdr.rcvif = NULL; @@ -159,8 +158,6 @@ divert6_output(struct inpcb *inp, struct } m->m_pkthdr.rcvif = ifa->ifa_ifp; - inq = &ip6intrq; - /* * Recalculate the protocol checksum for the inbound packet * since the userspace application may have modified the packet @@ -168,10 +165,7 @@ divert6_output(struct inpcb *inp, struct */ in6_proto_cksum_out(m, NULL); - s = splnet(); - IF_INPUT_ENQUEUE(inq, m); - schednetisr(NETISR_IPV6); - splx(s); + niq_enqueue(&ip6intrq, m); /* return error on q full? */ } else { error = ip6_output(m, NULL, &inp->inp_route6, IP_ALLOWBROADCAST | IP_RAWOUTPUT, NULL, NULL, NULL); Index: netinet6/ip6_input.c =================================================================== RCS file: /cvs/src/sys/netinet6/ip6_input.c,v retrieving revision 1.140 diff -u -p -r1.140 ip6_input.c --- netinet6/ip6_input.c 14 Mar 2015 03:38:52 -0000 1.140 +++ netinet6/ip6_input.c 9 Apr 2015 10:50:36 -0000 @@ -113,7 +113,7 @@ #endif struct in6_ifaddrhead in6_ifaddr; -struct ifqueue ip6intrq; +struct niqueue ip6intrq = NIQUEUE_INITIALIZER(IFQ_MAXLEN, NETISR_IPV6); struct ip6stat ip6stat; @@ -144,7 +144,6 @@ ip6_init(void) pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW && pr->pr_protocol < IPPROTO_MAX) ip6_protox[pr->pr_protocol] = pr - inet6sw; - IFQ_SET_MAXLEN(&ip6intrq, IFQ_MAXLEN); TAILQ_INIT(&in6_ifaddr); ip6_randomid_init(); nd6_init(); @@ -168,17 +167,10 @@ ip6_init2(void *dummy) void ip6intr(void) { - int s; struct mbuf *m; - for (;;) { - s = splnet(); - IF_DEQUEUE(&ip6intrq, m); - splx(s); - if (m == NULL) - return; + while ((m = niq_dequeue(&ip6intrq)) != NULL) ip6_input(m); - } } extern struct route_in6 ip6_forward_rt; @@ -1452,7 +1444,7 @@ ip6_sysctl(int *name, u_int namelen, voi } return (error); case IPV6CTL_IFQUEUE: - return (sysctl_ifq(name + 1, namelen - 1, + return (sysctl_niq(name + 1, namelen - 1, oldp, oldlenp, newp, newlen, &ip6intrq)); default: if (name[0] < IPV6CTL_MAXID) Index: netmpls/mpls.h =================================================================== RCS file: /cvs/src/sys/netmpls/mpls.h,v retrieving revision 1.30 diff -u -p -r1.30 mpls.h --- netmpls/mpls.h 26 Mar 2015 11:02:44 -0000 1.30 +++ netmpls/mpls.h 9 Apr 2015 10:50:36 -0000 @@ -160,7 +160,7 @@ void mpe_input6(struct mbuf *, struct if extern int mpls_raw_usrreq(struct socket *, int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *); -extern struct ifqueue mplsintrq; /* MPLS input queue */ +extern struct niqueue mplsintrq; /* MPLS input queue */ extern int mpls_defttl; extern int mpls_mapttl_ip; extern int mpls_mapttl_ip6; Index: netmpls/mpls_input.c =================================================================== RCS file: /cvs/src/sys/netmpls/mpls_input.c,v retrieving revision 1.42 diff -u -p -r1.42 mpls_input.c --- netmpls/mpls_input.c 23 Dec 2014 03:24:08 -0000 1.42 +++ netmpls/mpls_input.c 9 Apr 2015 10:50:36 -0000 @@ -40,7 +40,7 @@ #include -struct ifqueue mplsintrq; +struct niqueue mplsintrq = NIQUEUE_INITIALIZER(IFQ_MAXLEN, NETISR_MPLS); #ifdef MPLS_DEBUG #define MPLS_LABEL_GET(l) ((ntohl((l) & MPLS_LABEL_MASK)) >> MPLS_LABEL_OFFSET) @@ -57,22 +57,15 @@ struct mbuf *mpls_do_error(struct mbuf * void mpls_init(void) { - IFQ_SET_MAXLEN(&mplsintrq, IFQ_MAXLEN); } void mplsintr(void) { struct mbuf *m; - int s; - for (;;) { - /* Get next datagram of input queue */ - s = splnet(); - IF_DEQUEUE(&mplsintrq, m); - splx(s); - if (m == NULL) - return; + /* Get next datagram of input queue */ + while ((m = niq_dequeue(&mplsintrq)) != NULL) { #ifdef DIAGNOSTIC if ((m->m_flags & M_PKTHDR) == 0) panic("mplsintr no HDR"); @@ -91,7 +84,7 @@ mpls_input(struct mbuf *m) struct rtentry *rt = NULL; struct rt_mpls *rt_mpls; u_int8_t ttl; - int i, s, hasbos; + int i, hasbos; if (!ISSET(ifp->if_xflags, IFXF_MPLS)) { m_freem(m); @@ -158,10 +151,7 @@ mpls_input(struct mbuf *m) do_v4: if (mpls_ip_adjttl(m, ttl)) goto done; - s = splnet(); - IF_INPUT_ENQUEUE(&ipintrq, m); - schednetisr(NETISR_IP); - splx(s); + niq_enqueue(&ipintrq, m); goto done; } continue; @@ -171,10 +161,7 @@ do_v4: do_v6: if (mpls_ip6_adjttl(m, ttl)) goto done; - s = splnet(); - IF_INPUT_ENQUEUE(&ip6intrq, m); - schednetisr(NETISR_IPV6); - splx(s); + niq_enqueue(&ip6intrq, m); goto done; } continue; @@ -241,19 +228,13 @@ do_v6: case AF_INET: if (mpls_ip_adjttl(m, ttl)) break; - s = splnet(); - IF_INPUT_ENQUEUE(&ipintrq, m); - schednetisr(NETISR_IP); - splx(s); + niq_enqueue(&ipintrq, m); break; #ifdef INET6 case AF_INET6: if (mpls_ip6_adjttl(m, ttl)) break; - s = splnet(); - IF_INPUT_ENQUEUE(&ip6intrq, m); - schednetisr(NETISR_IPV6); - splx(s); + niq_enqueue(&ip6intrq, m); break; #endif default: Index: netmpls/mpls_raw.c =================================================================== RCS file: /cvs/src/sys/netmpls/mpls_raw.c,v retrieving revision 1.10 diff -u -p -r1.10 mpls_raw.c --- netmpls/mpls_raw.c 5 Dec 2014 15:50:04 -0000 1.10 +++ netmpls/mpls_raw.c 9 Apr 2015 10:50:36 -0000 @@ -135,7 +135,7 @@ mpls_sysctl(int *name, u_int namelen, vo switch (name[0]) { case MPLSCTL_IFQUEUE: - return (sysctl_ifq(name + 1, namelen - 1, + return (sysctl_niq(name + 1, namelen - 1, oldp, oldlenp, newp, newlen, &mplsintrq)); default: return sysctl_int_arr(mplsctl_vars, name, namelen,