-/* $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>
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;
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",
*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);
ifiq->ifiq_packets = 0;
ifiq->ifiq_bytes = 0;
+ ifiq->ifiq_fdrops = 0;
ifiq->ifiq_qdrops = 0;
ifiq->ifiq_errors = 0;
struct mbuf *m;
uint64_t packets;
uint64_t bytes = 0;
+ uint64_t fdrops = 0;
unsigned int len;
#if NBPFILTER > 0
caddr_t if_bpf;
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);
}
mtx_enter(&ifiq->ifiq_mtx);
ifiq->ifiq_packets += packets;
ifiq->ifiq_bytes += bytes;
+ ifiq->ifiq_fdrops += fdrops;
mtx_leave(&ifiq->ifiq_mtx);
return (0);
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))) {