Index: ifq.c =================================================================== RCS file: /cvs/src/sys/net/ifq.c,v retrieving revision 1.22 diff -u -p -r1.22 ifq.c --- ifq.c 25 Jan 2018 14:04:36 -0000 1.22 +++ ifq.c 11 Dec 2018 01:29:16 -0000 @@ -357,6 +357,21 @@ ifq_dequeue(struct ifqueue *ifq) return (m); } +int +ifq_hdatalen(struct ifqueue *ifq) +{ + struct mbuf *m; + int len = 0; + + m = ifq_deq_begin(ifq); + if (m != NULL) { + len = m->m_pkthdr.len; + ifq_deq_commit(ifq, m); + } + + return (len); +} + unsigned int ifq_purge(struct ifqueue *ifq) { Index: ifq.h =================================================================== RCS file: /cvs/src/sys/net/ifq.h,v retrieving revision 1.20 diff -u -p -r1.20 ifq.h --- ifq.h 4 Jan 2018 11:02:57 -0000 1.20 +++ ifq.h 11 Dec 2018 01:29:16 -0000 @@ -396,6 +396,8 @@ struct ifq_ops { void (*ifqop_free)(unsigned int, void *); }; +extern const struct ifq_ops * const ifq_priq_ops; + /* * Interface send queues. */ @@ -409,6 +411,7 @@ struct mbuf *ifq_deq_begin(struct ifqueu void ifq_deq_commit(struct ifqueue *, struct mbuf *); void ifq_deq_rollback(struct ifqueue *, struct mbuf *); struct mbuf *ifq_dequeue(struct ifqueue *); +int ifq_hdatalen(struct ifqueue *); void ifq_mfreem(struct ifqueue *, struct mbuf *); void ifq_mfreeml(struct ifqueue *, struct mbuf_list *); unsigned int ifq_purge(struct ifqueue *); @@ -422,6 +425,12 @@ void ifq_barrier(struct ifqueue *); #define ifq_empty(_ifq) (ifq_len(_ifq) == 0) #define ifq_set_maxlen(_ifq, _l) ((_ifq)->ifq_maxlen = (_l)) +static inline int +ifq_is_priq(struct ifqueue *ifq) +{ + return (ifq->ifq_ops == ifq_priq_ops); +} + static inline void ifq_set_oactive(struct ifqueue *ifq) { @@ -459,8 +468,6 @@ ifq_idx(struct ifqueue *ifq, unsigned in } #define IFQ_ASSERT_SERIALIZED(_ifq) KASSERT(ifq_is_serialized(_ifq)) - -extern const struct ifq_ops * const ifq_priq_ops; /* ifiq */ Index: if_tun.c =================================================================== RCS file: /cvs/src/sys/net/if_tun.c,v retrieving revision 1.182 diff -u -p -r1.182 if_tun.c --- if_tun.c 12 Nov 2018 06:35:37 -0000 1.182 +++ if_tun.c 11 Dec 2018 01:29:16 -0000 @@ -670,8 +670,7 @@ tun_dev_ioctl(struct tun_softc *tp, u_lo tp->tun_flags &= ~TUN_ASYNC; break; case FIONREAD: - *(int *)data = ifq_empty(&tp->tun_if.if_snd) ? - 0 : tp->tun_if.if_mtu; + *(int *)data = ifq_hdatalen(&tp->tun_if.if_snd); break; case TIOCSPGRP: tp->tun_pgid = *(int *)data;