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
This commit is contained in:
Zhenlei Huang 2024-07-03 21:14:09 +08:00
parent a2cac544a6
commit 07d138afc7

View file

@ -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);