From nobody Fri Feb 24 19:27:04 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PNfzD39L5z3trLc; Fri, 24 Feb 2023 19:27:04 +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 4PNfzD2W2fz3jvn; Fri, 24 Feb 2023 19:27:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677266824; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=zdyTZvmv9tLG06aoutqggXLePaqyZUN9PIVAYVAB1t0=; b=H9xl6O1DYbMYfqH3J+HTa0pLLEsk9/dYLcYe/J51HwBghlK25kSOUydkBFX5Eo1GYOF7vP JucN5ODxyVkMPW3VGEI+4imGJ/LdKy6QNl/NRt7HpeRgNy5u8YGJwMnNQQeYe1fDCo4zyK f0oHNvihXCymMBs4ZpytMzqZTPDn8ptmgmkdQV4+l+1t/1Nbs7b2dS0tOfAubHe4hkEbTE lbwpgl9n5Mpt+iHG5ZcqNsy1Lg4BNSbBrehBPKV9b8N3Kp67MptXndHnS4sFL5CknPApHF UCNMa7QMXZpKQxgTFml9jJEG9u4tBaVKS5SGAiGsDKsYHnSKJw9xAgFOSKrVWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677266824; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=zdyTZvmv9tLG06aoutqggXLePaqyZUN9PIVAYVAB1t0=; b=Sk+NQph/eydH5bx06jXoS5TKmKST+Mn+uP3NXgIGwPOl527upJtYG8h9vMKi1Lq91GQxea iNiSpfLiES9fP/NIAJua9VwUKA/xJXzMla9B7DnBS751QtD4Riy942OuM61aOuUq//Ahoy jCsZUNECmG7IGsyq/q3Wo+kE7SxPHhSmRmiudhxLdK2OLLCquYAgU4skR194QnsL0rrYzW t66Bew6cJu2U6oZjVWDNEe/TSDF1YWnB9bswyC6ui5baDTPkh17ig9RPeIuJktMFsxAzdU RLqgyySSK1o8u2+vy5DFZexeQHcx0EOtu0LMJ2gWsZ4eFb1jePnSHqFvgh/Fhw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1677266824; a=rsa-sha256; cv=none; b=XgLIsdNENACXr5dSv9w3HvZsSLfR0bwsheTyOxVUkC0fF2Vm58geZbg88uQKdU3I6LD1i3 3vZSg2hiPbsTysbyn8a1s43pBiYAFZ3N/qf/8jHiTspexXubQXm1C/OAXdFNgEocRDRDC1 dynEgGZ86s3f3gqnMUbc7JA2inx83f2096T5ZRturxCkTpynym/uM5P3/altEmNJnbvQ9h Hea5fd+8CdwfsaCBZrji0foK9NfBaaK+PES9v09v7b3Gj2n95/d1ZO6RH+sc2qX/aQZrxF xAVLwfy6CtYlgoqFOpW8ESJv4ple6DJ5oLZslaBkEprZkrZ0CDVe76mz3hut4A== 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 4PNfzD1XJmzbJT; Fri, 24 Feb 2023 19:27:04 +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 31OJR4cM066943; Fri, 24 Feb 2023 19:27:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31OJR4w1066942; Fri, 24 Feb 2023 19:27:04 GMT (envelope-from git) Date: Fri, 24 Feb 2023 19:27:04 GMT Message-Id: <202302241927.31OJR4w1066942@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 83158c68934b - main - time: s/ppsratecheck/eventratecheck List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 83158c68934b4fae6897bbe1694cf9a7f4b9c0b1 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=83158c68934b4fae6897bbe1694cf9a7f4b9c0b1 commit 83158c68934b4fae6897bbe1694cf9a7f4b9c0b1 Author: Mateusz Guzik AuthorDate: 2023-02-23 12:49:11 +0000 Commit: Mateusz Guzik CommitDate: 2023-02-24 19:26:36 +0000 time: s/ppsratecheck/eventratecheck The routine is used as a general event-limiting routine in places which have nothing to do with packets. Provide a define to keep everything happy. Reviewed by: rew Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D38746 --- sys/kern/kern_time.c | 18 +++++++++--------- sys/sys/time.h | 3 ++- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 658f6df0b386..fd4e89d61b15 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -1098,21 +1098,21 @@ ratecheck(struct timeval *lasttime, const struct timeval *mininterval) } /* - * ppsratecheck(): packets (or events) per second limitation. + * eventratecheck(): events per second limitation. * * Return 0 if the limit is to be enforced (e.g. the caller - * should drop a packet because of the rate limitation). + * should ignore the event because of the rate limitation). * - * maxpps of 0 always causes zero to be returned. maxpps of -1 + * maxeps of 0 always causes zero to be returned. maxeps of -1 * always causes 1 to be returned; this effectively defeats rate * limiting. * * Note that we maintain the struct timeval for compatibility * with other bsd systems. We reuse the storage and just monitor - * clock ticks for minimal overhead. + * clock ticks for minimal overhead. */ int -ppsratecheck(struct timeval *lasttime, int *curpps, int maxpps) +eventratecheck(struct timeval *lasttime, int *cureps, int maxeps) { int now; @@ -1124,11 +1124,11 @@ ppsratecheck(struct timeval *lasttime, int *curpps, int maxpps) now = ticks; if (lasttime->tv_sec == 0 || (u_int)(now - lasttime->tv_sec) >= hz) { lasttime->tv_sec = now; - *curpps = 1; - return (maxpps != 0); + *cureps = 1; + return (maxeps != 0); } else { - (*curpps)++; /* NB: ignore potential overflow */ - return (maxpps < 0 || *curpps <= maxpps); + (*cureps)++; /* NB: ignore potential overflow */ + return (maxeps < 0 || *cureps <= maxeps); } } diff --git a/sys/sys/time.h b/sys/sys/time.h index 20375b9a82af..673de65a688c 100644 --- a/sys/sys/time.h +++ b/sys/sys/time.h @@ -578,7 +578,8 @@ void getboottimebin(struct bintime *boottimebin); /* Other functions */ int itimerdecr(struct itimerval *itp, int usec); int itimerfix(struct timeval *tv); -int ppsratecheck(struct timeval *, int *, int); +int eventratecheck(struct timeval *, int *, int); +#define ppsratecheck(t, c, m) eventratecheck(t, c, m) int ratecheck(struct timeval *, const struct timeval *); void timevaladd(struct timeval *t1, const struct timeval *t2); void timevalsub(struct timeval *t1, const struct timeval *t2);