From owner-dev-commits-src-branches@freebsd.org Wed Apr 7 15:48:14 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 52A165BB0F3; Wed, 7 Apr 2021 15:48:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFphD5WB6z3mNg; Wed, 7 Apr 2021 15:48:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 83F9021B5E; Wed, 7 Apr 2021 15:48:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 137FmC09034101; Wed, 7 Apr 2021 15:48:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 137FmCab034100; Wed, 7 Apr 2021 15:48:12 GMT (envelope-from git) Date: Wed, 7 Apr 2021 15:48:12 GMT Message-Id: <202104071548.137FmCab034100@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 60fa37b7d60a - stable/12 - dummynet: Move packet counters into dn_cfg MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 60fa37b7d60a2d1ebbdb6be38a7603251d8d92c7 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 15:48:16 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=60fa37b7d60a2d1ebbdb6be38a7603251d8d92c7 commit 60fa37b7d60a2d1ebbdb6be38a7603251d8d92c7 Author: Kristof Provost AuthorDate: 2021-03-09 15:27:31 +0000 Commit: Kristof Provost CommitDate: 2021-04-07 15:25:38 +0000 dummynet: Move packet counters into dn_cfg Move the packets counters into the dn_cfg struct. This reduces the global name space use for dummynet and will make future work for things like vnet support and re-use in pf easier. Reviewed by: donner MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D29245 (cherry picked from commit cd5671efc0190ba0f9eb41bba42e703277af20c3) --- sys/netpfil/ipfw/dn_aqm.h | 5 +---- sys/netpfil/ipfw/dn_sched_fq_codel.h | 2 +- sys/netpfil/ipfw/dn_sched_fq_pie.c | 2 +- sys/netpfil/ipfw/ip_dn_io.c | 24 ++++++++---------------- sys/netpfil/ipfw/ip_dn_private.h | 5 +++++ 5 files changed, 16 insertions(+), 22 deletions(-) diff --git a/sys/netpfil/ipfw/dn_aqm.h b/sys/netpfil/ipfw/dn_aqm.h index d01e98ebeafa..a8f6c39c0a8c 100644 --- a/sys/netpfil/ipfw/dn_aqm.h +++ b/sys/netpfil/ipfw/dn_aqm.h @@ -54,9 +54,6 @@ typedef int32_t aqm_stime_t; /* Macro for variable bounding */ #define BOUND_VAR(x,l,h) ((x) > (h)? (h) : ((x) > (l)? (x) : (l))) -/* sysctl variable to count number of dropped packets */ -extern unsigned long io_pkt_drop; - /* * Structure for holding data and function pointers that together represent a * AQM algorithm. @@ -138,7 +135,7 @@ update_stats(struct dn_queue *q, int len, int drop) if (drop) { qni->drops++; sni->drops++; - io_pkt_drop++; + dn_cfg.io_pkt_drop++; } else { /*update queue stats */ qni->length += inc; diff --git a/sys/netpfil/ipfw/dn_sched_fq_codel.h b/sys/netpfil/ipfw/dn_sched_fq_codel.h index 4b65781e0bef..e8685caca8d3 100644 --- a/sys/netpfil/ipfw/dn_sched_fq_codel.h +++ b/sys/netpfil/ipfw/dn_sched_fq_codel.h @@ -104,7 +104,7 @@ fq_update_stats(struct fq_codel_flow *q, struct fq_codel_si *si, int len, si->main_q.ni.drops ++; q->stats.drops ++; si->_si.ni.drops ++; - io_pkt_drop ++; + dn_cfg.io_pkt_drop ++; } if (!drop || (drop && len < 0)) { diff --git a/sys/netpfil/ipfw/dn_sched_fq_pie.c b/sys/netpfil/ipfw/dn_sched_fq_pie.c index 3960ea8ad6ae..2f61ca3de94e 100644 --- a/sys/netpfil/ipfw/dn_sched_fq_pie.c +++ b/sys/netpfil/ipfw/dn_sched_fq_pie.c @@ -299,7 +299,7 @@ fq_update_stats(struct fq_pie_flow *q, struct fq_pie_si *si, int len, si->main_q.ni.drops ++; q->stats.drops ++; si->_si.ni.drops ++; - io_pkt_drop ++; + dn_cfg.io_pkt_drop ++; } if (!drop || (drop && len < 0)) { diff --git a/sys/netpfil/ipfw/ip_dn_io.c b/sys/netpfil/ipfw/ip_dn_io.c index f14532ce9af0..760a24ed041f 100644 --- a/sys/netpfil/ipfw/ip_dn_io.c +++ b/sys/netpfil/ipfw/ip_dn_io.c @@ -87,14 +87,6 @@ static long tick_lost; /* Lost(coalesced) ticks number. */ /* Adjusted vs non-adjusted curr_time difference (ticks). */ static long tick_diff; -static unsigned long io_pkt; -static unsigned long io_pkt_fast; - -#ifdef NEW_AQM -unsigned long io_pkt_drop; -#else -static unsigned long io_pkt_drop; -#endif /* * We use a heap to store entities for which we have pending timer events. * The heap is checked at every tick and all entities with expired events @@ -223,13 +215,13 @@ SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, fsk_count, SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, queue_count, CTLFLAG_RD, DC(queue_count), 0, "Number of queues"); SYSCTL_ULONG(_net_inet_ip_dummynet, OID_AUTO, io_pkt, - CTLFLAG_RD, &io_pkt, 0, + CTLFLAG_RD, DC(io_pkt), 0, "Number of packets passed to dummynet."); SYSCTL_ULONG(_net_inet_ip_dummynet, OID_AUTO, io_pkt_fast, - CTLFLAG_RD, &io_pkt_fast, 0, + CTLFLAG_RD, DC(io_pkt_fast), 0, "Number of packets bypassed dummynet scheduler."); SYSCTL_ULONG(_net_inet_ip_dummynet, OID_AUTO, io_pkt_drop, - CTLFLAG_RD, &io_pkt_drop, 0, + CTLFLAG_RD, DC(io_pkt_drop), 0, "Number of packets dropped by dummynet."); #undef DC SYSEND @@ -535,7 +527,7 @@ dn_enqueue(struct dn_queue *q, struct mbuf* m, int drop) return (0); drop: - io_pkt_drop++; + dn_cfg.io_pkt_drop++; q->ni.drops++; ni->drops++; FREE_PKT(m); @@ -871,7 +863,7 @@ dummynet_io(struct mbuf **m0, int dir, struct ip_fw_args *fwa) int fs_id = (fwa->rule.info & IPFW_INFO_MASK) + ((fwa->rule.info & IPFW_IS_PIPE) ? 2*DN_MAX_ID : 0); DN_BH_WLOCK(); - io_pkt++; + dn_cfg.io_pkt++; /* we could actually tag outside the lock, but who cares... */ if (tag_mbuf(m, dir, fwa)) goto dropit; @@ -907,7 +899,7 @@ dummynet_io(struct mbuf **m0, int dir, struct ip_fw_args *fwa) m = *m0 = NULL; /* dn_enqueue already increases io_pkt_drop */ - io_pkt_drop--; + dn_cfg.io_pkt_drop--; goto dropit; } @@ -945,7 +937,7 @@ dummynet_io(struct mbuf **m0, int dir, struct ip_fw_args *fwa) tag->m_tag_cookie = MTAG_IPFW_RULE; tag->m_tag_id = 0; - io_pkt_fast++; + dn_cfg.io_pkt_fast++; if (m->m_nextpkt != NULL) { printf("dummynet: fast io: pkt chain detected!\n"); m->m_nextpkt = NULL; @@ -961,7 +953,7 @@ done: return 0; dropit: - io_pkt_drop++; + dn_cfg.io_pkt_drop++; DN_BH_WUNLOCK(); if (m) FREE_PKT(m); diff --git a/sys/netpfil/ipfw/ip_dn_private.h b/sys/netpfil/ipfw/ip_dn_private.h index 61c61130525c..a318a8e3be37 100644 --- a/sys/netpfil/ipfw/ip_dn_private.h +++ b/sys/netpfil/ipfw/ip_dn_private.h @@ -131,6 +131,11 @@ struct dn_parms { int fsk_count; int queue_count; + /* packet counters */ + unsigned long io_pkt; + unsigned long io_pkt_fast; + unsigned long io_pkt_drop; + /* ticks and other stuff */ uint64_t curr_time; /* flowsets and schedulers are in hash tables, with 'hash_size'