From 7578bdf179c7036fa48c0d5b572924810eb8eaac Mon Sep 17 00:00:00 2001 From: David Gwynne Date: Fri, 16 Aug 2019 04:09:03 +0000 Subject: ifq_hdatalen should keep the mbuf it's looking at, not leak it. ie, use ifq_deq_rollback after looking at the head mbuf instead of ifq_deq_commit. this is used in tun/tap, where it had the effect that you'd get the datalen for the packet, and then when you try to read that many bytes it had gone. cool and normal. this was found by a student who was trying to do just that. i've always just read the packet into a large buffer. --- sys/net/ifq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/net/ifq.c b/sys/net/ifq.c index 302277c2e7b..20ad6c14b5e 100644 --- a/sys/net/ifq.c +++ b/sys/net/ifq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifq.c,v 1.33 2019/07/03 10:19:45 dlg Exp $ */ +/* $OpenBSD: ifq.c,v 1.34 2019/08/16 04:09:02 dlg Exp $ */ /* * Copyright (c) 2015 David Gwynne @@ -397,7 +397,7 @@ ifq_hdatalen(struct ifqueue *ifq) m = ifq_deq_begin(ifq); if (m != NULL) { len = m->m_pkthdr.len; - ifq_deq_commit(ifq, m); + ifq_deq_rollback(ifq, m); } return (len); -- cgit v1.2.3