From 01ae73c5eb2d059ceb1d1734f72282cefb78d440 Mon Sep 17 00:00:00 2001 From: dlg Date: Fri, 9 Jul 2021 01:22:05 +0000 Subject: [PATCH] ifq_hdatalen can return 0 if ifq_empty is true, which avoids locks. --- sys/net/ifq.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/net/ifq.c b/sys/net/ifq.c index 51eaaf44343..d61e5934624 100644 --- a/sys/net/ifq.c +++ b/sys/net/ifq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifq.c,v 1.43 2021/02/20 04:37:26 dlg Exp $ */ +/* $OpenBSD: ifq.c,v 1.44 2021/07/09 01:22:05 dlg Exp $ */ /* * Copyright (c) 2015 David Gwynne @@ -500,6 +500,9 @@ ifq_hdatalen(struct ifqueue *ifq) struct mbuf *m; int len = 0; + if (ifq_empty(ifq)) + return (0); + m = ifq_deq_begin(ifq); if (m != NULL) { len = m->m_pkthdr.len; -- 2.20.1