From f5ad72e36ef9b3578db456cad0b1aeb5edd63fe3 Mon Sep 17 00:00:00 2001 From: David Gwynne Date: Fri, 9 Jul 2021 01:22:06 +0000 Subject: 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(-) (limited to 'sys/net') 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; -- cgit v1.2.3