Index: net/if.c =================================================================== RCS file: /cvs/src/sys/net/if.c,v retrieving revision 1.329 diff -u -p -r1.329 if.c --- net/if.c 10 Apr 2015 13:58:20 -0000 1.329 +++ net/if.c 10 Apr 2015 14:00:50 -0000 @@ -2162,8 +2162,8 @@ ifpromisc(struct ifnet *ifp, int pswitch } int -sysctl_ifq(int *name, u_int namelen, void *oldp, size_t *oldlenp, - void *newp, size_t newlen, struct ifqueue *ifq) +sysctl_mq(int *name, u_int namelen, void *oldp, size_t *oldlenp, + void *newp, size_t newlen, struct mbuf_queue *mq) { /* All sysctl names at this level are terminal. */ if (namelen != 1) @@ -2171,34 +2171,12 @@ sysctl_ifq(int *name, u_int namelen, voi switch (name[0]) { case IFQCTL_LEN: - return (sysctl_rdint(oldp, oldlenp, newp, ifq->ifq_len)); + return (sysctl_rdint(oldp, oldlenp, newp, mq_len(mq))); case IFQCTL_MAXLEN: return (sysctl_int(oldp, oldlenp, newp, newlen, - &ifq->ifq_maxlen)); + &mq->mq_maxlen)); /* XXX directly accessing maxlen */ case IFQCTL_DROPS: - return (sysctl_rdint(oldp, oldlenp, newp, ifq->ifq_drops)); - default: - return (EOPNOTSUPP); - } - /* NOTREACHED */ -} - -int -sysctl_niq(int *name, u_int namelen, void *oldp, size_t *oldlenp, - void *newp, size_t newlen, struct niqueue *niq) -{ - /* All sysctl names at this level are terminal. */ - if (namelen != 1) - return (ENOTDIR); - - switch (name[0]) { - case IFQCTL_LEN: - return (sysctl_rdint(oldp, oldlenp, newp, niq_len(niq))); - case IFQCTL_MAXLEN: - return (sysctl_int(oldp, oldlenp, newp, newlen, - &niq->ni_q.mq_maxlen)); /* XXX */ - case IFQCTL_DROPS: - return (sysctl_rdint(oldp, oldlenp, newp, niq_drops(niq))); + return (sysctl_rdint(oldp, oldlenp, newp, mq_drops(mq))); default: return (EOPNOTSUPP); } Index: net/if_var.h =================================================================== RCS file: /cvs/src/sys/net/if_var.h,v retrieving revision 1.24 diff -u -p -r1.24 if_var.h --- net/if_var.h 7 Apr 2015 10:46:20 -0000 1.24 +++ net/if_var.h 10 Apr 2015 14:00:50 -0000 @@ -411,6 +411,8 @@ int niq_enlist(struct niqueue *, struct #define niq_filter(_q, _f, _c) mq_filter(&(_q)->ni_q, (_f), (_c)) #define niq_len(_q) mq_len(&(_q)->ni_q) #define niq_drops(_q) mq_drops(&(_q)->ni_q) +#define sysctl_niq(_n, _l, _op, _olp, _np, _nl, _niq) \ + sysctl_mq((_n), (_l), (_op), (_olp), (_np), (_nl), &(_niq)->ni_q) extern struct ifnet_head ifnet; extern struct ifnet *lo0ifp; @@ -441,10 +443,8 @@ void if_clone_detach(struct if_clone *); int if_clone_create(const char *); int if_clone_destroy(const char *); -int sysctl_ifq(int *, u_int, void *, size_t *, void *, size_t, - struct ifqueue *); -int sysctl_niq(int *, u_int, void *, size_t *, void *, size_t, - struct niqueue *); +int sysctl_mq(int *, u_int, void *, size_t *, void *, size_t, + struct mbuf_queue *); int loioctl(struct ifnet *, u_long, caddr_t); void loopattach(int); Index: net/pipex.c =================================================================== RCS file: /cvs/src/sys/net/pipex.c,v retrieving revision 1.68 diff -u -p -r1.68 pipex.c --- net/pipex.c 10 Apr 2015 13:58:20 -0000 1.68 +++ net/pipex.c 10 Apr 2015 14:00:51 -0000 @@ -100,8 +100,8 @@ struct timeout pipex_timer_ch; /* call int pipex_prune = 1; /* walk list every seconds */ /* pipex traffic queue */ -struct ifqueue pipexinq; -struct ifqueue pipexoutq; +struct mbuf_queue pipexinq = MBUF_QUEUE_INITIALIZER(IFQ_MAXLEN, IPL_NET); +struct mbuf_queue pipexoutq = MBUF_QUEUE_INITIALIZER(IFQ_MAXLEN, IPL_NET); void *pipex_softintr = NULL; Static void pipex_softintr_handler(void *); @@ -144,9 +144,7 @@ pipex_init(void) LIST_INIT(&pipex_id_hashtable[i]); for (i = 0; i < nitems(pipex_peer_addr_hashtable); i++) LIST_INIT(&pipex_peer_addr_hashtable[i]); - /* queue and softintr init */ - IFQ_SET_MAXLEN(&pipexinq, IFQ_MAXLEN); - IFQ_SET_MAXLEN(&pipexoutq, IFQ_MAXLEN); + /* softintr init */ pipex_softintr = softintr_establish(IPL_SOFTNET, pipex_softintr_handler, NULL); } @@ -718,18 +716,11 @@ pipex_ppp_dequeue(void) struct pipex_session *pkt_session; u_int16_t proto; struct mbuf *m; - int c, s; + struct mbuf_list ml; /* ppp output */ - for (c = 0; c < PIPEX_DEQUEUE_LIMIT; c++) { - s = splnet(); - IF_DEQUEUE(&pipexoutq, m); - if (m == NULL) { - splx(s); - break; - } - splx(s); - + mq_delist(&pipexoutq, &ml); + while ((m = ml_dequeue(&ml)) != NULL) { pkt_session = m->m_pkthdr.ph_cookie; if (pkt_session == NULL) { m_freem(m); @@ -765,15 +756,8 @@ pipex_ppp_dequeue(void) } /* ppp input */ - for (c = 0; c < PIPEX_DEQUEUE_LIMIT; c++) { - s = splnet(); - IF_DEQUEUE(&pipexinq, m); - if (m == NULL) { - splx(s); - break; - } - splx(s); - + mq_delist(&pipexinq, &ml); + while ((m = ml_dequeue(&ml)) != NULL) { pkt_session = m->m_pkthdr.ph_cookie; if (pkt_session == NULL) { m_freem(m); @@ -781,42 +765,21 @@ pipex_ppp_dequeue(void) } pipex_ppp_input(m, pkt_session, 0); } - - /* - * When packet remains in queue, it is necessary - * to re-schedule software interrupt. - */ - s = splnet(); - if (!IF_IS_EMPTY(&pipexinq) || !IF_IS_EMPTY(&pipexoutq)) - softintr_schedule(pipex_softintr); - splx(s); } Static int pipex_ppp_enqueue(struct mbuf *m0, struct pipex_session *session, - struct ifqueue *queue) + struct mbuf_queue *mq) { - int s; - m0->m_pkthdr.ph_cookie = session; /* XXX need to support other protocols */ m0->m_pkthdr.ph_ppp_proto = PPP_IP; - s = splnet(); - if (IF_QFULL(queue)) { - IF_DROP(queue); - splx(s); - goto fail; - } - IF_ENQUEUE(queue, m0); - splx(s); + if (mq_enqueue(mq, m0) != 0) + return (1); softintr_schedule(pipex_softintr); return (0); - -fail: - /* caller is responsible for freeing m0 */ - return (1); } /*********************************************************************** @@ -878,7 +841,7 @@ pipex_timer(void *ignored_arg) * mbuf queued in pipexinq or pipexoutq may have a * refererce to this session. */ - if (!IF_IS_EMPTY(&pipexinq) || !IF_IS_EMPTY(&pipexoutq)) + if (!mq_empty(&pipexinq) || !mq_empty(&pipexoutq)) continue; pipex_destroy_session(session); @@ -966,7 +929,7 @@ pipex_ip_output(struct mbuf *m0, struct is_idle = 0; m0 = ip_is_idle_packet(m0, &is_idle); if (m0 == NULL) - goto drop; + goto dropped; if (is_idle == 0) /* update expire time */ session->stat.idle_time = 0; @@ -976,19 +939,20 @@ pipex_ip_output(struct mbuf *m0, struct if ((session->ppp_flags & PIPEX_PPP_ADJUST_TCPMSS) != 0) { m0 = adjust_tcp_mss(m0, session->peer_mru); if (m0 == NULL) - goto drop; + goto dropped; } } else m0->m_flags &= ~(M_BCAST|M_MCAST); /* output ip packets to the session tunnel */ if (pipex_ppp_enqueue(m0, session, &pipexoutq)) - goto drop; + goto dropped; return; drop: if (m0 != NULL) m_freem(m0); +dropped: session->stat.oerrors++; } @@ -1323,10 +1287,13 @@ pipex_common_input(struct pipex_session } /* input ppp packets to kernel session */ - if (pipex_ppp_enqueue(m0, session, &pipexinq) == 0) + if (pipex_ppp_enqueue(m0, session, &pipexinq) != 0) + goto dropped; + else return (NULL); drop: m_freem(m0); +dropped: session->stat.ierrors++; return (NULL); @@ -3071,10 +3038,10 @@ pipex_sysctl(int *name, u_int namelen, v return (sysctl_int(oldp, oldlenp, newp, newlen, &pipex_enable)); case PIPEXCTL_INQ: - return (sysctl_ifq(name + 1, namelen - 1, + return (sysctl_mq(name + 1, namelen - 1, oldp, oldlenp, newp, newlen, &pipexinq)); case PIPEXCTL_OUTQ: - return (sysctl_ifq(name + 1, namelen - 1, + return (sysctl_mq(name + 1, namelen - 1, oldp, oldlenp, newp, newlen, &pipexoutq)); default: return (ENOPROTOOPT); Index: net/pipex_local.h =================================================================== RCS file: /cvs/src/sys/net/pipex_local.h,v retrieving revision 1.21 diff -u -p -r1.21 pipex_local.h --- net/pipex_local.h 1 Dec 2014 06:55:05 -0000 1.21 +++ net/pipex_local.h 10 Apr 2015 14:00:51 -0000 @@ -49,7 +49,6 @@ #define PIPEX_HASH_SIZE (PIPEX_MAX_SESSION/PIPEX_HASH_DIV) #define PIPEX_HASH_MASK (PIPEX_HASH_SIZE-1) #define PIPEX_CLOSE_TIMEOUT 30 -#define PIPEX_DEQUEUE_LIMIT (IFQ_MAXLEN >> 1) #define PIPEX_PPPMINLEN 5 /* minimum PPP header length is 1 and minimum ppp payload length is 4 */ @@ -427,7 +426,7 @@ Static struct mbuf *ip_is_idle Static void pipex_session_log (struct pipex_session *, int, const char *, ...) __attribute__((__format__(__printf__,3,4))); Static uint32_t pipex_sockaddr_hash_key(struct sockaddr *); Static int pipex_sockaddr_compar_addr(struct sockaddr *, struct sockaddr *); -Static int pipex_ppp_enqueue (struct mbuf *, struct pipex_session *, struct ifqueue *); +Static int pipex_ppp_enqueue (struct mbuf *, struct pipex_session *, struct mbuf_queue *); Static void pipex_ppp_dequeue (void); Static void pipex_timer_start (void); Static void pipex_timer_stop (void);