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
This commit is contained in:
Andrew Gallatin committed 2026-04-14 15:43:28 -04:00
1 parent f707cc00ed
commit 956acdce05
1 file changed
+7 -3
+7 -3
View File
@@ -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);
}