From nobody Wed Jul 03 13:20:20 2024 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 4WDgPd0sDsz5PH8P; Wed, 03 Jul 2024 13:20:21 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WDgPc6V9Dz4pFj; Wed, 3 Jul 2024 13:20:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1720012820; 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=SYsaVz5D6plohFZbwbC5SAhzSVHvK3i/8K/s5/A468Y=; b=v/9pD+mTlfW2Db6YabFqsyLVau5oyrb2aLn3AbCCEh/qfYbZjV1DZwW+1QmMvoxVm6bod0 MbwiU1XnKdUb/pPcdq5CcxrjoVm8m/LkYG1T677EW6qAk3Ii0X7utg3uqzPrkyX0FV4KC4 BHUXUUAVVbwOrtYL0doTHzOmEKX59ZK4ZPHRtJp+NU0GFXTG3uNN1ZfOKh1/hd2ZWrSwK8 dxDRYI5GEWzJJMrHgRoncv3IMQvH1k4+Yt9Op0HEUnuENis7Ht70kQRkIzhKBPw4I6evjk oGuZFSuHo/TXJ/bVjDUMFmBOvTxT2LD+k9k5sT+k4hCZoqBU1SkB9nHxwSjXxA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1720012820; a=rsa-sha256; cv=none; b=Cz14TjziHoOcyvvAjlquxVWfqdfSLSdauSHdK4FMIYkZqY12yb9Bqcr/FFk0wRPdGFTBBc +0DOzYsdFgJsXb1nObMa5k/jzvN0XMxmDHvt/ISV4f78QonnCDONqLkW/ceLMlUEdDIsCD QYdgfoG3hOepHdGcCfALSloATEnf87kFA+ra7P/j1M09ybwAydlic7eRIkvfzzTbdv+VB+ dfAZhxPsjiv9ToDioW8LV3fFpybNYiQQppvM63pwofvotIYhE+Vq7ain87duNaNH/VHJVe ijNCXBYJJfW2tr+INR/uztaH5x9fwli2hTCMnpnmtXgfgzHplU1MCS19eSXjhw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1720012820; 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=SYsaVz5D6plohFZbwbC5SAhzSVHvK3i/8K/s5/A468Y=; b=uUSB79vwJxdFjTtqtzYMi1j5l0O1kvMkV1emJnOjsDk2jMeYV3hl4RD2JgSTYAIZInwYI/ 2xH1e4XUbRX1nn+O5LOJBDhrcS0Dx2e3/icpPaf0B3t6jAq1cyJVSmym7NKx6RBj89NbhK 0cgT+x5ABQBe/rEHk0q3y81C9wwaEg66kH3EpkMxXMz6LzRXYmjaHh9nYxz8iTFLJuNBwJ dHYbcZ+BG+aQwq/lk07M4hhmnbMVTW91VWF1eai5DNM6QkDO9aROKhU4BN0d7mOGiD45rr GjoPRltDvXgHN9404/azd3VeCWW9iDBsctBdzJLXwum4utCbf3BqPD/SVZG/pA== 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 4WDgPc65cgzYJ5; Wed, 3 Jul 2024 13:20:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 463DKKce047427; Wed, 3 Jul 2024 13:20:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 463DKKrE047424; Wed, 3 Jul 2024 13:20:20 GMT (envelope-from git) Date: Wed, 3 Jul 2024 13:20:20 GMT Message-Id: <202407031320.463DKKrE047424@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Zhenlei Huang Subject: git: 07d138afc7e5 - main - if_pflog: Limit the maximum unit via the new KPI 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: zlei X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 07d138afc7e5efee73368459dd047493713056cf Auto-Submitted: auto-generated The branch main has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=07d138afc7e5efee73368459dd047493713056cf commit 07d138afc7e5efee73368459dd047493713056cf Author: Zhenlei Huang AuthorDate: 2024-07-03 13:14:09 +0000 Commit: Zhenlei Huang CommitDate: 2024-07-03 13:14:09 +0000 if_pflog: Limit the maximum unit via the new KPI The cloner has the ability to limit the maximum unit. Employ it to do that rather than roll our own. No functional change intended. Reviewed by: kp MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D45767 --- sys/netpfil/pf/if_pflog.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sys/netpfil/pf/if_pflog.c b/sys/netpfil/pf/if_pflog.c index 8b849b0b9376..6035ba635116 100644 --- a/sys/netpfil/pf/if_pflog.c +++ b/sys/netpfil/pf/if_pflog.c @@ -105,14 +105,16 @@ VNET_DEFINE(struct ifnet *, pflogifs[PFLOGIFS_MAX]); /* for fast access */ static void pflogattach(int npflog __unused) { - int i; + int i; + for (i = 0; i < PFLOGIFS_MAX; i++) V_pflogifs[i] = NULL; struct if_clone_addreq req = { .create_f = pflog_clone_create, .destroy_f = pflog_clone_destroy, - .flags = IFC_F_AUTOUNIT, + .flags = IFC_F_AUTOUNIT | IFC_F_LIMITUNIT, + .maxunit = PFLOGIFS_MAX - 1, }; V_pflog_cloner = ifc_attach_cloner(pflogname, &req); struct ifc_data ifd = { .unit = 0 }; @@ -125,8 +127,7 @@ pflog_clone_create(struct if_clone *ifc, char *name, size_t maxlen, { struct ifnet *ifp; - if (ifd->unit >= PFLOGIFS_MAX) - return (EINVAL); + MPASS(ifd->unit < PFLOGIFS_MAX); ifp = if_alloc(IFT_PFLOG); if_initname(ifp, pflogname, ifd->unit);