Hi,
There are some places in ip and ip6 input where operations fail due
to out of memory. I think a generic idropped counter is useful for
those.
ok?
bluhm
Index: sys/netinet/ip_input.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_input.c,v
retrieving revision 1.377
diff -u -p -r1.377 ip_input.c
--- sys/netinet/ip_input.c 6 Aug 2022 15:57:59 -0000 1.377
+++ sys/netinet/ip_input.c 11 Aug 2022 16:14:03 -0000
@@ -1372,8 +1372,10 @@ save_rte(struct mbuf *m, u_char *option,
return;
mtag = m_tag_get(PACKET_TAG_SRCROUTE, sizeof(*isr), M_NOWAIT);
- if (mtag == NULL)
+ if (mtag == NULL) {
+ ipstat_inc(ips_idropped);
return;
+ }
isr = (struct ip_srcrt *)(mtag + 1);
memcpy(isr->isr_hdr, option, olen);
@@ -1406,8 +1408,10 @@ ip_srcroute(struct mbuf *m0)
if (isr->isr_nhops == 0)
return (NULL);
m = m_get(M_DONTWAIT, MT_SOOPTS);
- if (m == NULL)
+ if (m == NULL) {
+ ipstat_inc(ips_idropped);
return (NULL);
+ }
#define OPTSIZ (sizeof(isr->isr_nop) + sizeof(isr->isr_hdr))
Index: sys/netinet/ip_var.h
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_var.h,v
retrieving revision 1.95
diff -u -p -r1.95 ip_var.h
--- sys/netinet/ip_var.h 4 Aug 2022 18:05:09 -0000 1.95
+++ sys/netinet/ip_var.h 11 Aug 2022 17:31:19 -0000
@@ -70,7 +70,7 @@ struct ipstat {
u_long ips_noproto; /* unknown or unsupported protocol */
u_long ips_delivered; /* datagrams delivered to upper level*/
u_long ips_localout; /* total ip packets generated here */
- u_long ips_odropped; /* lost packets due to nobufs, etc. */
+ u_long ips_odropped; /* lost output due to nobufs, etc. */
u_long ips_reassembled; /* total packets reassembled ok */
u_long ips_fragmented; /* datagrams successfully fragmented */
u_long ips_ofragments; /* output fragments created */
@@ -88,6 +88,7 @@ struct ipstat {
u_long ips_outswcsum; /* software checksummed on output */
u_long ips_notmember; /* multicasts for unregistered groups */
u_long ips_wrongif; /* packet received on wrong interface */
+ u_long ips_idropped; /* lost input due to nobufs, etc. */
};
struct ipoption {
@@ -115,7 +116,7 @@ enum ipstat_counters {
ips_noproto, /* unknown or unsupported protocol */
ips_delivered, /* datagrams delivered to upper level*/
ips_localout, /* total ip packets generated here */
- ips_odropped, /* lost packets due to nobufs, etc. */
+ ips_odropped, /* lost output packets due to nobufs, etc. */
ips_reassembled, /* total packets reassembled ok */
ips_fragmented, /* datagrams successfully fragmented */
ips_ofragments, /* output fragments created */
@@ -133,6 +134,7 @@ enum ipstat_counters {
ips_outswcsum, /* software checksummed on output */
ips_notmember, /* multicasts for unregistered groups */
ips_wrongif, /* packet received on wrong interface */
+ ips_idropped, /* lost input packets due to nobufs, etc. */
ips_ncounters
};
Index: sys/netinet6/ip6_input.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/ip6_input.c,v
retrieving revision 1.250
diff -u -p -r1.250 ip6_input.c
--- sys/netinet6/ip6_input.c 6 Aug 2022 15:57:59 -0000 1.250
+++ sys/netinet6/ip6_input.c 11 Aug 2022 16:17:30 -0000
@@ -1217,8 +1217,10 @@ ip6_pullexthdr(struct mbuf *m, size_t of
n = NULL;
}
}
- if (!n)
+ if (n == NULL) {
+ ip6stat_inc(ip6s_idropped);
return NULL;
+ }
n->m_len = 0;
if (elen >= m_trailingspace(n)) {
Index: sys/netinet6/ip6_var.h
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/ip6_var.h,v
retrieving revision 1.93
diff -u -p -r1.93 ip6_var.h
--- sys/netinet6/ip6_var.h 29 Jun 2022 22:45:24 -0000 1.93
+++ sys/netinet6/ip6_var.h 11 Aug 2022 17:31:01 -0000
@@ -153,7 +153,7 @@ struct ip6stat {
u_int64_t ip6s_redirectsent; /* packets forwarded on same net */
u_int64_t ip6s_delivered; /* datagrams delivered to upper level*/
u_int64_t ip6s_localout; /* total ip packets generated here */
- u_int64_t ip6s_odropped; /* lost packets due to nobufs, etc. */
+ u_int64_t ip6s_odropped; /* lost output due to nobufs, etc. */
u_int64_t ip6s_reassembled; /* total packets reassembled ok */
u_int64_t ip6s_fragmented; /* datagrams successfully fragmented */
u_int64_t ip6s_ofragments; /* output fragments created */
@@ -198,7 +198,8 @@ struct ip6stat {
u_int64_t ip6s_forward_cachehit;
u_int64_t ip6s_forward_cachemiss;
- u_int64_t ip6s_wrongif;
+ u_int64_t ip6s_wrongif; /* packet received on wrong interface */
+ u_int64_t ip6s_idropped; /* lost input due to nobufs, etc. */
};
#ifdef _KERNEL
@@ -245,6 +246,8 @@ enum ip6stat_counters {
ip6s_forward_cachehit = ip6s_sources_deprecated + 16,
ip6s_forward_cachemiss,
ip6s_wrongif,
+ ip6s_idropped,
+
ip6s_ncounters,
};
Index: usr.bin/netstat/inet.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/usr.bin/netstat/inet.c,v
retrieving revision 1.173
diff -u -p -r1.173 inet.c
--- usr.bin/netstat/inet.c 5 Dec 2021 22:36:19 -0000 1.173
+++ usr.bin/netstat/inet.c 11 Aug 2022 16:29:17 -0000
@@ -612,6 +612,7 @@ ip_stats(char *name)
p(ips_outswcsum, "\t%lu output datagram%s software-checksummed\n");
p(ips_notmember, "\t%lu multicast packet%s which we don't join\n");
p(ips_wrongif, "\t%lu packet%s received on wrong interface\n");
+ p(ips_idropped, "\t%lu input packet%s dropped due to no bufs, etc.\n");
#undef p
#undef p1
}
Index: usr.bin/netstat/inet6.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/usr.bin/netstat/inet6.c,v
retrieving revision 1.55
diff -u -p -r1.55 inet6.c
--- usr.bin/netstat/inet6.c 26 Jan 2021 18:22:35 -0000 1.55
+++ usr.bin/netstat/inet6.c 11 Aug 2022 16:29:17 -0000
@@ -481,6 +481,8 @@ ip6_stats(char *name)
p1(ip6s_forward_cachehit, "\t%llu forward cache hit\n");
p1(ip6s_forward_cachemiss, "\t%llu forward cache miss\n");
+ p(ip6s_idropped,
+ "\t%llu input packet%s dropped due to no bufs, etc.\n");
#undef p
#undef p1
}