summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2021-07-09 01:22:06 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2021-07-09 01:22:06 +0000
commitf5ad72e36ef9b3578db456cad0b1aeb5edd63fe3 (patch)
tree2ad931b35db14f276156b80c51f4e13ed2069a43 /sys/net
parent8f03d357d0d9a7b038fbd4dffba99fb011e06174 (diff)
ifq_hdatalen can return 0 if ifq_empty is true, which avoids locks.
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/ifq.c5
1 files changed, 4 insertions, 1 deletions
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 <dlg@openbsd.org>
@@ -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;