Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Jul 2024 13:20:20 GMT
From:      Zhenlei Huang <zlei@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 07d138afc7e5 - main - if_pflog: Limit the maximum unit via the new KPI
Message-ID:  <202407031320.463DKKrE047424@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by zlei:

URL: https://cgit.FreeBSD.org/src/commit/?id=07d138afc7e5efee73368459dd047493713056cf

commit 07d138afc7e5efee73368459dd047493713056cf
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2024-07-03 13:14:09 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202407031320.463DKKrE047424>