Index: ifq.c =================================================================== RCS file: /cvs/src/sys/net/ifq.c,v retrieving revision 1.6 diff -u -p -r1.6 ifq.c --- ifq.c 24 Jan 2017 03:57:35 -0000 1.6 +++ ifq.c 2 Mar 2017 00:31:53 -0000 @@ -29,7 +29,7 @@ * priq glue */ unsigned int priq_idx(unsigned int, const struct mbuf *); -int priq_enq(struct ifqueue *, struct mbuf *); +struct mbuf *priq_enq(struct ifqueue *, struct mbuf *); struct mbuf *priq_deq_begin(struct ifqueue *, void **); void priq_deq_commit(struct ifqueue *, struct mbuf *, void *); void priq_purge(struct ifqueue *, struct mbuf_list *); @@ -225,7 +225,8 @@ ifq_attach(struct ifqueue *ifq, const st ifq->ifq_q = newq; while ((m = ml_dequeue(&ml)) != NULL) { - if (ifq->ifq_ops->ifqop_enq(ifq, m) != 0) { + m = ifq->ifq_ops->ifqop_enq(ifq, m); + if (m != NULL) { ifq->ifq_qdrops++; ml_enqueue(&free_ml, m); } else @@ -252,13 +253,14 @@ ifq_destroy(struct ifqueue *ifq) } int -ifq_enqueue_try(struct ifqueue *ifq, struct mbuf *m) +ifq_enqueue(struct ifqueue *ifq, struct mbuf *m) { + struct mbuf *dm; int rv; mtx_enter(&ifq->ifq_mtx); - rv = ifq->ifq_ops->ifqop_enq(ifq, m); - if (rv == 0) { + dm = ifq->ifq_ops->ifqop_enq(ifq, m); + if (dm == NULL) { ifq->ifq_len++; ifq->ifq_packets++; @@ -269,19 +271,14 @@ ifq_enqueue_try(struct ifqueue *ifq, str ifq->ifq_qdrops++; mtx_leave(&ifq->ifq_mtx); - return (rv); -} - -int -ifq_enqueue(struct ifqueue *ifq, struct mbuf *m) -{ - int err; - - err = ifq_enqueue_try(ifq, m); - if (err != 0) - m_freem(m); + if (dm == NULL) + rv = 0; + else { + m_freem(dm); + rv = ENOBUFS; + } - return (err); + return (rv); } struct mbuf * @@ -403,14 +400,14 @@ priq_free(unsigned int idx, void *pq) free(pq, M_DEVBUF, sizeof(struct priq)); } -int +struct mbuf * priq_enq(struct ifqueue *ifq, struct mbuf *m) { struct priq *pq; struct priq_list *pl; if (ifq_len(ifq) >= ifq->ifq_maxlen) - return (ENOBUFS); + return (m); pq = ifq->ifq_q; KASSERT(m->m_pkthdr.pf.prio <= IFQ_MAXPRIO); @@ -423,7 +420,7 @@ priq_enq(struct ifqueue *ifq, struct mbu pl->tail->m_nextpkt = m; pl->tail = m; - return (0); + return (NULL); } struct mbuf * Index: ifq.h =================================================================== RCS file: /cvs/src/sys/net/ifq.h,v retrieving revision 1.9 diff -u -p -r1.9 ifq.h --- ifq.h 24 Jan 2017 10:08:30 -0000 1.9 +++ ifq.h 2 Mar 2017 00:31:53 -0000 @@ -117,25 +117,21 @@ struct ifqueue { * the ifqueue. All the pending mbufs are removed from the previous * conditioner and requeued on the new. * - * === ifq_enqueue() and ifq_enqueue_try() + * === ifq_enqueue() * - * ifq_enqueue() and ifq_enqueue_try() attempt to fit an mbuf onto the - * ifqueue. If the current traffic conditioner rejects the packet it - * wont be queued and will be counted as a drop. ifq_enqueue() will - * free the mbuf on the callers behalf if the packet is rejected. - * ifq_enqueue_try() does not free the mbuf, allowing the caller to - * reuse it. + * ifq_enqueue() attempts to fit an mbuf onto the ifqueue. The + * current traffic conditioner may drop a packet to make space on the + * queue. * * === ifq_start() * - * Once a packet has been successfully queued with ifq_enqueue() or - * ifq_enqueue_try(), the network card is notified with a call to - * if_start(). If an interface is marked with IFXF_MPSAFE in its - * if_xflags field, if_start() calls ifq_start() to dispatch the - * interfaces start routine. Calls to ifq_start() run in the ifqueue - * serialisation context, guaranteeing that only one instance of - * ifp->if_start() will be running in the system at any point in time. - * + * Once a packet has been successfully queued with ifq_enqueue(), + * the network card is notified with a call to if_start(). If an + * interface is marked with IFXF_MPSAFE in its if_xflags field, + * if_start() calls ifq_start() to dispatch the interfaces start + * routine. Calls to ifq_start() run in the ifqueue serialisation + * context, guaranteeing that only one instance of ifp->if_start() + * will be running in the system at any point in time. * * == Traffic conditioners API * @@ -324,7 +320,7 @@ struct ifqueue { struct ifq_ops { unsigned int (*ifqop_idx)(unsigned int, const struct mbuf *); - int (*ifqop_enq)(struct ifqueue *, struct mbuf *); + struct mbuf *(*ifqop_enq)(struct ifqueue *, struct mbuf *); struct mbuf *(*ifqop_deq_begin)(struct ifqueue *, void **); void (*ifqop_deq_commit)(struct ifqueue *, struct mbuf *, void *); @@ -341,7 +337,6 @@ struct ifq_ops { void ifq_init(struct ifqueue *, struct ifnet *, unsigned int); void ifq_attach(struct ifqueue *, const struct ifq_ops *, void *); void ifq_destroy(struct ifqueue *); -int ifq_enqueue_try(struct ifqueue *, struct mbuf *); int ifq_enqueue(struct ifqueue *, struct mbuf *); struct mbuf *ifq_deq_begin(struct ifqueue *); void ifq_deq_commit(struct ifqueue *, struct mbuf *); Index: hfsc.c =================================================================== RCS file: /cvs/src/sys/net/hfsc.c,v retrieving revision 1.35 diff -u -p -r1.35 hfsc.c --- hfsc.c 24 Jan 2017 03:57:35 -0000 1.35 +++ hfsc.c 2 Mar 2017 00:31:53 -0000 @@ -260,7 +260,7 @@ struct pool hfsc_class_pl, hfsc_internal */ unsigned int hfsc_idx(unsigned int, const struct mbuf *); -int hfsc_enq(struct ifqueue *, struct mbuf *); +struct mbuf *hfsc_enq(struct ifqueue *, struct mbuf *); struct mbuf *hfsc_deq_begin(struct ifqueue *, void **); void hfsc_deq_commit(struct ifqueue *, struct mbuf *, void *); void hfsc_purge(struct ifqueue *, struct mbuf_list *); @@ -650,7 +650,7 @@ hfsc_nextclass(struct hfsc_class *cl) return (cl); } -int +struct mbuf * hfsc_enq(struct ifqueue *ifq, struct mbuf *m) { struct hfsc_if *hif = ifq->ifq_q; @@ -660,14 +660,14 @@ hfsc_enq(struct ifqueue *ifq, struct mbu cl->cl_children != NULL) { cl = hif->hif_defaultclass; if (cl == NULL) - return (ENOBUFS); + return (m); cl->cl_pktattr = NULL; } if (ml_len(&cl->cl_q.q) >= cl->cl_q.qlimit) { /* drop occurred. mbuf needs to be freed */ PKTCNTR_INC(&cl->cl_stats.drop_cnt, m->m_pkthdr.len); - return (ENOBUFS); + return (m); } ml_enqueue(&cl->cl_q.q, m); @@ -677,7 +677,7 @@ hfsc_enq(struct ifqueue *ifq, struct mbu if (ml_len(&cl->cl_q.q) == 1) hfsc_set_active(hif, cl, m->m_pkthdr.len); - return (0); + return (NULL); } struct mbuf *