On Wed, Mar 01, 2017 at 10:03:42PM +0100, Mike Belopuhov wrote:
> The diff below changes the policy to a head drop from the queue
> with the lowest priority than the packet we're trying to
> enqueue.
What you explain makes sense. OK bluhm@
> diff --git sys/net/ifq.c sys/net/ifq.c
> index 896b373c454..f678c2b01fd 100644
> --- sys/net/ifq.c
> +++ sys/net/ifq.c
> @@ -407,18 +407,35 @@ priq_free(unsigned int idx, void *pq)
> int
> priq_enq(struct ifqueue *ifq, struct mbuf *m)
> {
> struct priq *pq;
> struct mbuf_list *pl;
> -
> - if (ifq_len(ifq) >= ifq->ifq_maxlen)
> - return (ENOBUFS);
> + unsigned int prio;
>
> pq = ifq->ifq_q;
> KASSERT(m->m_pkthdr.pf.prio <= IFQ_MAXPRIO);
> pl = &pq->pq_lists[m->m_pkthdr.pf.prio];
>
> + /* Find a lower priority queue to drop from */
> + if (ifq_len(ifq) >= ifq->ifq_maxlen) {
> + for (prio = 0; prio < m->m_pkthdr.pf.prio; prio++) {
> + pl = &pq->pq_lists[prio];
> + if (ml_len(pl) > 0) {
> + m_freem(ml_dequeue(pl));
> + ifq->ifq_len--;
> + ifq->ifq_qdrops++;
> + break;
> + }
> + }
> + /*
> + * There's no lower priority queue that we can
> + * drop from so don't enqueue this one.
> + */
> + if (prio == m->m_pkthdr.pf.prio)
> + return (ENOBUFS);
> + }
> +
> ml_enqueue(pl, m);
>
> return (0);
> }
>
> --
> 2.12.0