From 048b9d583ea17a970c009f89d82d7b0ba4c64aed Mon Sep 17 00:00:00 2001 From: Alexander Bluhm Date: Mon, 5 Feb 2024 23:16:40 +0000 Subject: Add netstat counter for route cache. To optimize route caching, count cache hits and misses. This is shown in netstat -s for both inet and inet6. Reuse the old IPv6 forward cache counter. Sort ip6s_wrongif consistently. For now only IPv4 cache counter has been implemented. OK mvs@ --- usr.bin/netstat/inet.c | 4 +++- usr.bin/netstat/inet6.c | 9 ++++----- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'usr.bin/netstat') diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index 94089d5b8a1..560b8594bd8 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inet.c,v 1.179 2023/09/04 23:00:36 bluhm Exp $ */ +/* $OpenBSD: inet.c,v 1.180 2024/02/05 23:16:39 bluhm Exp $ */ /* $NetBSD: inet.c,v 1.14 1995/10/03 21:42:37 thorpej Exp $ */ /* @@ -621,6 +621,8 @@ ip_stats(char *name) p(ips_inswcsum, "\t%lu input datagram%s software-checksummed\n"); 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"); + p1(ips_rtcachehit, "\t%lu route cache hit\n"); + p1(ips_rtcachemiss, "\t%lu route cache miss\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 diff --git a/usr.bin/netstat/inet6.c b/usr.bin/netstat/inet6.c index 38d63988b03..789ba6059fb 100644 --- a/usr.bin/netstat/inet6.c +++ b/usr.bin/netstat/inet6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inet6.c,v 1.56 2022/08/12 14:49:15 bluhm Exp $ */ +/* $OpenBSD: inet6.c,v 1.57 2024/02/05 23:16:39 bluhm Exp $ */ /* BSDI inet.c,v 2.3 1995/10/24 02:19:29 prb Exp */ /* * Copyright (c) 1983, 1988, 1993 @@ -371,7 +371,6 @@ ip6_stats(char *name) p(ip6s_cantfrag, "\t%llu datagram%s that can't be fragmented\n"); p(ip6s_badscope, "\t%llu packet%s that violated scope rules\n"); p(ip6s_notmember, "\t%llu multicast packet%s which we don't join\n"); - p(ip6s_wrongif, "\t%llu packet%s received on wrong interface\n"); for (first = 1, i = 0; i < 256; i++) if (ip6stat.ip6s_nxthist[i] != 0) { if (first) { @@ -478,9 +477,9 @@ ip6_stats(char *name) PRINT_SCOPESTAT(ip6s_sources_deprecated[i], i); } } - - p1(ip6s_forward_cachehit, "\t%llu forward cache hit\n"); - p1(ip6s_forward_cachemiss, "\t%llu forward cache miss\n"); + p1(ip6s_rtcachehit, "\t%llu route cache hit\n"); + p1(ip6s_rtcachemiss, "\t%llu route cache miss\n"); + p(ip6s_wrongif, "\t%llu packet%s received on wrong interface\n"); p(ip6s_idropped, "\t%llu input packet%s dropped due to no bufs, etc.\n"); #undef p -- cgit v1.2.3