git: 956acdce0505 - main - loopback: Account for packet drops
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 14 Apr 2026 19:47:41 UTC
The branch main has been updated by gallatin:
URL: https://cgit.FreeBSD.org/src/commit/?id=956acdce0505ca8028d287d3b44789c623c8f37e
commit 956acdce0505ca8028d287d3b44789c623c8f37e
Author: Andrew Gallatin <gallatin@FreeBSD.org>
AuthorDate: 2026-04-14 19:43:28 +0000
Commit: Andrew Gallatin <gallatin@FreeBSD.org>
CommitDate: 2026-04-14 19:43:28 +0000
loopback: Account for packet drops
Make loopback packet drops more obvious by reporting them
in interface stats visable via netstat -ni
Since loopback uses netisr, packets can be dropped if the
netisr queue overflows. These drops are visible via
netisr -Q, but its not an obvious place to look.
Differential Revision: https://reviews.freebsd.org/D56356
Reviewed by: glebius, tuexen
Sponsored by: Netflix
---
sys/net/if_loop.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c
index 37309260a0d3..2ff265d5d1e7 100644
--- a/sys/net/if_loop.c
+++ b/sys/net/if_loop.c
@@ -350,9 +350,13 @@ if_simloop(struct ifnet *ifp, struct mbuf *m, int af, int hlen)
m_freem(m);
return (EAFNOSUPPORT);
}
- if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
- if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len);
- netisr_queue(isr, m); /* mbuf is free'd on failure. */
+ if (netisr_queue(isr, m) == 0) {
+ if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
+ if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len);
+ } else {
+ /* mbuf is free'd on failure. */
+ if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1);
+ }
return (0);
}