summaryrefslogtreecommitdiff
path: root/sys/net/ifq.c
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2023-01-09 03:37:45 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2023-01-09 03:37:45 +0000
commitd97f595517ff4fe0d1040edd90626e2b64500d3e (patch)
tree9bcf126880cbe431ce44a329b49fce3d31e06304 /sys/net/ifq.c
parent254ed9a82a0c7ee754d0fbbd364cce0761327960 (diff)
count the number times a packet was dropped by bpf as fdrops.
Diffstat (limited to 'sys/net/ifq.c')
-rw-r--r--sys/net/ifq.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/sys/net/ifq.c b/sys/net/ifq.c
index 99777327d73..ce91a6569ee 100644
--- a/sys/net/ifq.c
+++ b/sys/net/ifq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ifq.c,v 1.47 2022/11/22 03:40:53 dlg Exp $ */
+/* $OpenBSD: ifq.c,v 1.48 2023/01/09 03:37:44 dlg Exp $ */
/*
* Copyright (c) 2015 David Gwynne <dlg@openbsd.org>
@@ -579,6 +579,7 @@ ifq_mfreeml(struct ifqueue *ifq, struct mbuf_list *ml)
struct ifiq_kstat_data {
struct kstat_kv kd_packets;
struct kstat_kv kd_bytes;
+ struct kstat_kv kd_fdrops;
struct kstat_kv kd_qdrops;
struct kstat_kv kd_errors;
struct kstat_kv kd_qlen;
@@ -592,6 +593,8 @@ static const struct ifiq_kstat_data ifiq_kstat_tpl = {
KSTAT_KV_T_COUNTER64, KSTAT_KV_U_PACKETS),
KSTAT_KV_UNIT_INITIALIZER("bytes",
KSTAT_KV_T_COUNTER64, KSTAT_KV_U_BYTES),
+ KSTAT_KV_UNIT_INITIALIZER("fdrops",
+ KSTAT_KV_T_COUNTER64, KSTAT_KV_U_PACKETS),
KSTAT_KV_UNIT_INITIALIZER("qdrops",
KSTAT_KV_T_COUNTER64, KSTAT_KV_U_PACKETS),
KSTAT_KV_UNIT_INITIALIZER("errors",
@@ -614,6 +617,7 @@ ifiq_kstat_copy(struct kstat *ks, void *dst)
*kd = ifiq_kstat_tpl;
kstat_kv_u64(&kd->kd_packets) = ifiq->ifiq_packets;
kstat_kv_u64(&kd->kd_bytes) = ifiq->ifiq_bytes;
+ kstat_kv_u64(&kd->kd_fdrops) = ifiq->ifiq_fdrops;
kstat_kv_u64(&kd->kd_qdrops) = ifiq->ifiq_qdrops;
kstat_kv_u64(&kd->kd_errors) = ifiq->ifiq_errors;
kstat_kv_u32(&kd->kd_qlen) = ml_len(&ifiq->ifiq_ml);
@@ -641,6 +645,7 @@ ifiq_init(struct ifiqueue *ifiq, struct ifnet *ifp, unsigned int idx)
ifiq->ifiq_packets = 0;
ifiq->ifiq_bytes = 0;
+ ifiq->ifiq_fdrops = 0;
ifiq->ifiq_qdrops = 0;
ifiq->ifiq_errors = 0;
@@ -684,6 +689,7 @@ ifiq_input(struct ifiqueue *ifiq, struct mbuf_list *ml)
struct mbuf *m;
uint64_t packets;
uint64_t bytes = 0;
+ uint64_t fdrops = 0;
unsigned int len;
#if NBPFILTER > 0
caddr_t if_bpf;
@@ -707,9 +713,10 @@ ifiq_input(struct ifiqueue *ifiq, struct mbuf_list *ml)
ml_init(ml);
while ((m = ml_dequeue(&ml0)) != NULL) {
- if ((*ifp->if_bpf_mtap)(if_bpf, m, BPF_DIRECTION_IN))
+ if ((*ifp->if_bpf_mtap)(if_bpf, m, BPF_DIRECTION_IN)) {
m_freem(m);
- else
+ fdrops++;
+ } else
ml_enqueue(ml, m);
}
@@ -717,6 +724,7 @@ ifiq_input(struct ifiqueue *ifiq, struct mbuf_list *ml)
mtx_enter(&ifiq->ifiq_mtx);
ifiq->ifiq_packets += packets;
ifiq->ifiq_bytes += bytes;
+ ifiq->ifiq_fdrops += fdrops;
mtx_leave(&ifiq->ifiq_mtx);
return (0);
@@ -727,6 +735,7 @@ ifiq_input(struct ifiqueue *ifiq, struct mbuf_list *ml)
mtx_enter(&ifiq->ifiq_mtx);
ifiq->ifiq_packets += packets;
ifiq->ifiq_bytes += bytes;
+ ifiq->ifiq_fdrops += fdrops;
len = ml_len(&ifiq->ifiq_ml);
if (__predict_true(!ISSET(ifp->if_xflags, IFXF_MONITOR))) {