Skip to content

Commit

Permalink
if_pflog: Limit the maximum unit via the new KPI
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
gmshake authored and fichtner committed Aug 9, 2024
1 parent 02b0415 commit a91e2fb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions sys/netpfil/pf/if_pflog.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand All @@ -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);
Expand Down

0 comments on commit a91e2fb

Please sign in to comment.