summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2018-12-11 01:33:05 +0000
committerdlg <dlg@openbsd.org>2018-12-11 01:33:05 +0000
commitd3e32c05551e2291a39637ae289f760ee3c280b4 (patch)
treec50c7b99dbe6c4a044a284cc0613c13389e04e9b
parentsplit ether_output into resolution, encapsulation, and output functions (diff)
downloadwireguard-openbsd-d3e32c05551e2291a39637ae289f760ee3c280b4.tar.xz
wireguard-openbsd-d3e32c05551e2291a39637ae289f760ee3c280b4.zip
add ifq_hdatalen for getting the size of the packet at the head of an ifq
this gets the locks right, and returns 0 if there's no packet available. ok stsp@
-rw-r--r--sys/net/ifq.c17
-rw-r--r--sys/net/ifq.h3
2 files changed, 18 insertions, 2 deletions
diff --git a/sys/net/ifq.c b/sys/net/ifq.c
index d790f433a6e..f0674ce9315 100644
--- a/sys/net/ifq.c
+++ b/sys/net/ifq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ifq.c,v 1.22 2018/01/25 14:04:36 mpi Exp $ */
+/* $OpenBSD: ifq.c,v 1.23 2018/12/11 01:33:05 dlg Exp $ */
/*
* Copyright (c) 2015 David Gwynne <dlg@openbsd.org>
@@ -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)
{
diff --git a/sys/net/ifq.h b/sys/net/ifq.h
index 3ce402b34c1..304ee5a2bc6 100644
--- a/sys/net/ifq.h
+++ b/sys/net/ifq.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ifq.h,v 1.20 2018/01/04 11:02:57 tb Exp $ */
+/* $OpenBSD: ifq.h,v 1.21 2018/12/11 01:33:05 dlg Exp $ */
/*
* Copyright (c) 2015 David Gwynne <dlg@openbsd.org>
@@ -409,6 +409,7 @@ struct mbuf *ifq_deq_begin(struct ifqueue *);
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 *);