From nobody Sat Jul 20 14:44:30 2024 X-Original-To: dev-commits-src-all@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 4WR8St3TnJz5RnZb; Sat, 20 Jul 2024 14:44:30 +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 4WR8St2tKdz4Lww; Sat, 20 Jul 2024 14:44:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721486670; 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=zesnpKGNI5R/3KR6xz0saYsJe9L9pnYl+DvprYA2Jm4=; b=EVxL7B6zGm4nsue1IJOnt94tUhUX+s9aoWw1r2IIdx/iSt9CK2HqE3iMsqZprXYIr6vMCe GZhwXjQbBbS7VjyOLDDgrmuWRyAKD6din+qNwTPACmSnYDWgS3Kp7vIN6OasSI8f0gVbms h2Z6EunnxRRtZfKQ7ge5CJ+09TEgFUdhWgHOZQJVKt1c65N8/U9ByWfh9WHG1+8zVNayhU 8dy/ag2u50uua8xkoQwYZCiqN2aTCshaaKH9ywkdIsEEjHQ3pdCmX1bIpAKktKw0nXFZjs JSudCOsfpQJYt7jkPgkSoB9VqG/nhTzxISw1YUwIy25+NWsHLgHcNx/++dq76Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721486670; a=rsa-sha256; cv=none; b=pytWUuUuLENCli6nLj53ECZGcnaUjzmMt8WlCpmq6cdyB4BB90Rzl5dPs/b2lEA37CT9Yp AYVDTYnn1Czy07NFfZmIdvN9sP6erXU87RTZrUGDNfAk5b4ybGN1eV5GH87Ydw59lA9tGm E7i/7YjQSJ9kIjtxrMoFZjeUYaiD8ee3eeshBbutVTtFYEpNj5MX2ZKv8q6CGBThd79Iwm Q2B/mxx4aK3Eh2lI4k1o6z3WPKug/GJsn4YTOF3kwrPbZbjU4Af5uAULqnfouHqkCwRM/s ufDIz7debwXDTfq9QNvJcMDzAU0JX+V8uzxd3d8aYfUxYuck6jcYdn92vp6Ojg== 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=1721486670; 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=zesnpKGNI5R/3KR6xz0saYsJe9L9pnYl+DvprYA2Jm4=; b=wnJPl9GIr5FOr6FbW5asY7bRMjxM6XdkSgFjznNxmuq4Xb3mM9lThXjMkJrWSp2stN2/1n 8/QyPu2FiNPBFNy8FN+cFota0YmzHQ/oldrxgpgcKG8vHsDumElsPtFtTENjRIxzSevM37 MW6FpB21uKpNYWuzGIzCsth7RMZU1vQ0EmGA7dFeSRTWXnCBXMduslBNwegf1Ipq/4zQSs nhuJL8QDTeUY0Df+8i4oapOyIXvOlkacx/3tOjuh2JTC2zqzd6ee2352PnFnfgLIrGWteL f9tfIrZluRSnQL/+CNvmigAF3dvIqOadICQuynj3YJoUziCqEwZtTVApFCwNWA== 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 4WR8St1RnNzL2W; Sat, 20 Jul 2024 14:44:30 +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 46KEiUIU028230; Sat, 20 Jul 2024 14:44:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46KEiUAI028227; Sat, 20 Jul 2024 14:44:30 GMT (envelope-from git) Date: Sat, 20 Jul 2024 14:44:30 GMT Message-Id: <202407201444.46KEiUAI028227@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Zhenlei Huang Subject: git: ca735be05c59 - stable/14 - if_pflog: Limit the maximum unit via the new KPI List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/stable/14 X-Git-Reftype: branch X-Git-Commit: ca735be05c59f83e107213e41517bef1a5d10108 Auto-Submitted: auto-generated The branch stable/14 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=ca735be05c59f83e107213e41517bef1a5d10108 commit ca735be05c59f83e107213e41517bef1a5d10108 Author: Zhenlei Huang AuthorDate: 2024-07-03 13:14:09 +0000 Commit: Zhenlei Huang CommitDate: 2024-07-20 14:42:59 +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 (cherry picked from commit 07d138afc7e5efee73368459dd047493713056cf) --- 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 53fe36343c75..b143aae1434a 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);