git: ca735be05c59 - stable/14 - if_pflog: Limit the maximum unit via the new KPI
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 20 Jul 2024 14:44:30 UTC
The branch stable/14 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=ca735be05c59f83e107213e41517bef1a5d10108 commit ca735be05c59f83e107213e41517bef1a5d10108 Author: Zhenlei Huang <zlei@FreeBSD.org> AuthorDate: 2024-07-03 13:14:09 +0000 Commit: Zhenlei Huang <zlei@FreeBSD.org> 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);