From owner-svn-src-all@FreeBSD.ORG Tue Dec 29 23:58:33 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1742C1065670; Tue, 29 Dec 2009 23:58:33 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0573F8FC13; Tue, 29 Dec 2009 23:58:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nBTNwWvx041005; Tue, 29 Dec 2009 23:58:32 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nBTNwWpM041001; Tue, 29 Dec 2009 23:58:32 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <200912292358.nBTNwWpM041001@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Tue, 29 Dec 2009 23:58:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r201243 - in stable/7: sys/netipsec usr.bin/netstat X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Dec 2009 23:58:33 -0000 Author: bz Date: Tue Dec 29 23:58:32 2009 New Revision: 201243 URL: http://svn.freebsd.org/changeset/base/201243 Log: MFC r199946: Add more statistics variables for IPcomp. Try to version the struct in a backward compatible way. People asked for the versioning of the stats structs in general before. Note: old netstat binaries, as only consumer, continue to work as they are still using kvm but will not display the new stats. [1] Discussed with: rwatson [1] (for stable/8) Modified: stable/7/sys/netipsec/ipcomp_var.h stable/7/sys/netipsec/xform_ipcomp.c stable/7/usr.bin/netstat/ipsec.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/usr.bin/netstat/ (props changed) Modified: stable/7/sys/netipsec/ipcomp_var.h ============================================================================== --- stable/7/sys/netipsec/ipcomp_var.h Tue Dec 29 23:47:21 2009 (r201242) +++ stable/7/sys/netipsec/ipcomp_var.h Tue Dec 29 23:58:32 2009 (r201243) @@ -41,6 +41,7 @@ */ #define IPCOMP_ALG_MAX 8 +#define IPCOMPSTAT_VERSION 1 struct ipcompstat { u_int32_t ipcomps_hdrops; /* Packet shorter than header shows */ u_int32_t ipcomps_nopf; /* Protocol family not supported */ @@ -58,6 +59,9 @@ struct ipcompstat { u_int32_t ipcomps_pdrops; /* Packet blocked due to policy */ u_int32_t ipcomps_crypto; /* "Crypto" processing failure */ u_int32_t ipcomps_hist[IPCOMP_ALG_MAX];/* Per-algorithm op count */ + u_int32_t version; /* Version of this structure. */ + u_int32_t ipcomps_threshold; /* Packet < comp. algo. threshold. */ + u_int32_t ipcomps_uncompr; /* Compression was useles. */ }; #ifdef _KERNEL Modified: stable/7/sys/netipsec/xform_ipcomp.c ============================================================================== --- stable/7/sys/netipsec/xform_ipcomp.c Tue Dec 29 23:47:21 2009 (r201242) +++ stable/7/sys/netipsec/xform_ipcomp.c Tue Dec 29 23:58:32 2009 (r201243) @@ -347,7 +347,7 @@ ipcomp_output( * See RFC 3173, 2.2. Non-Expansion Policy. */ if (m->m_pkthdr.len <= ipcompx->minlen) { - /* XXX-BZ V_ipcompstat.threshold++; */ + ipcompstat.ipcomps_threshold++; return ipsec_process_done(m, isr); } @@ -571,8 +571,10 @@ ipcomp_output_cb(struct cryptop *crp) goto bad; } } else { - /* compression was useless, we have lost time */ - /* XXX add statistic */ + /* Compression was useless, we have lost time. */ + ipcompstat.ipcomps_uncompr++; + DPRINTF(("%s: compressions was useless %d - %d <= %d\n", + __func__, crp->crp_ilen, skip, crp->crp_olen)); /* XXX remember state to not compress the next couple * of packets, RFC 3173, 2.2. Non-Expansion Policy */ } @@ -606,6 +608,8 @@ static struct xformsw ipcomp_xformsw = { static void ipcomp_attach(void) { + + ipcompstat.version = IPCOMPSTAT_VERSION; xform_register(&ipcomp_xformsw); } SYSINIT(ipcomp_xform_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_MIDDLE, ipcomp_attach, NULL); Modified: stable/7/usr.bin/netstat/ipsec.c ============================================================================== --- stable/7/usr.bin/netstat/ipsec.c Tue Dec 29 23:47:21 2009 (r201242) +++ stable/7/usr.bin/netstat/ipsec.c Tue Dec 29 23:58:32 2009 (r201243) @@ -418,6 +418,7 @@ esp_stats(u_long off, const char *name, static void print_ipcompstats(const struct ipcompstat *ipcompstat) { + uint32_t version; #define p32(f, m) if (ipcompstat->f || sflag <= 1) \ printf("\t%u" m, (unsigned int)ipcompstat->f, plural(ipcompstat->f)) #define p64(f, m) if (ipcompstat->f || sflag <= 1) \ @@ -425,6 +426,11 @@ print_ipcompstats(const struct ipcompsta #define hist(f, n, t) \ ipsec_hist_new((f), sizeof(f)/sizeof(f[0]), (n), (t)); +#ifndef IPCOMPSTAT_VERSION + version = 0; +#else + version = ipcompstat->version; +#endif p32(ipcomps_hdrops, " packet%s shorter than header shows\n"); p32(ipcomps_nopf, " packet%s dropped; protocol family not supported\n"); p32(ipcomps_notdb, " packet%s dropped; no TDB\n"); @@ -441,6 +447,10 @@ print_ipcompstats(const struct ipcompsta p32(ipcomps_pdrops, " packet%s blocked due to policy\n"); p32(ipcomps_crypto, " crypto processing failure%s\n"); hist(ipcompstat->ipcomps_hist, ipsec_compnames, "COMP output"); + if (version >= 1) { + p32(ipcomps_threshold, " packet%s sent uncompressed; size < compr. algo. threshold\n"); + p32(ipcomps_uncompr, " packet%s sent uncompressed; compression was useless\n"); + } #undef p32 #undef p64