git: c2e7a52374b3 - main - pf: move DIOCRCLRASTATS into libpfctl
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 30 Dec 2025 13:17:12 UTC
The branch main has been updated by kp:
URL: https://cgit.FreeBSD.org/src/commit/?id=c2e7a52374b3e4bef41c5cad4c24f158c870b476
commit c2e7a52374b3e4bef41c5cad4c24f158c870b476
Author: Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2025-12-29 09:45:48 +0000
Commit: Kristof Provost <kp@FreeBSD.org>
CommitDate: 2025-12-30 13:16:52 +0000
pf: move DIOCRCLRASTATS into libpfctl
Sponsored by: Rubicon Communications, LLC ("Netgate")
---
lib/libpfctl/libpfctl.c | 25 +++++++++++++++++++++++++
lib/libpfctl/libpfctl.h | 2 ++
sbin/pfctl/pfctl_radix.c | 18 +-----------------
3 files changed, 28 insertions(+), 17 deletions(-)
diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c
index 7e5a07ccd55a..6aac9a9c04ae 100644
--- a/lib/libpfctl/libpfctl.c
+++ b/lib/libpfctl/libpfctl.c
@@ -3843,3 +3843,28 @@ pfctl_get_astats(struct pfctl_handle *h, const struct pfr_table *tbl,
return (0);
}
+
+int
+pfctl_clr_astats(struct pfctl_handle *h, const struct pfr_table *tbl,
+ struct pfr_addr *addr, int size, int *nzero, int flags)
+{
+ struct pfioc_table io;
+
+ if (size < 0 || !tbl || (size && !addr)) {
+ errno = EINVAL;
+ return (-1);
+ }
+
+ bzero(&io, sizeof io);
+ io.pfrio_flags = flags;
+ io.pfrio_table = *tbl;
+ io.pfrio_buffer = addr;
+ io.pfrio_esize = sizeof(*addr);
+ io.pfrio_size = size;
+ if (ioctl(h->fd, DIOCRCLRASTATS, &io) == -1)
+ return (-1);
+ if (nzero)
+ *nzero = io.pfrio_nzero;
+ return (0);
+}
+
diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h
index 9576118fe146..b885497ab0e8 100644
--- a/lib/libpfctl/libpfctl.h
+++ b/lib/libpfctl/libpfctl.h
@@ -587,5 +587,7 @@ int pfctl_clear_addrs(struct pfctl_handle *h, const struct pfr_table *filter,
int pfctl_get_astats(struct pfctl_handle *h, const struct pfr_table *tbl,
struct pfr_astats *addr, int *size, int flags);
+int pfctl_clr_astats(struct pfctl_handle *h, const struct pfr_table *tbl,
+ struct pfr_addr *addr, int size, int *nzero, int flags);
#endif
diff --git a/sbin/pfctl/pfctl_radix.c b/sbin/pfctl/pfctl_radix.c
index 3ea127dd2451..4ae301756200 100644
--- a/sbin/pfctl/pfctl_radix.c
+++ b/sbin/pfctl/pfctl_radix.c
@@ -201,23 +201,7 @@ int
pfr_clr_astats(struct pfr_table *tbl, struct pfr_addr *addr, int size,
int *nzero, int flags)
{
- struct pfioc_table io;
-
- if (size < 0 || !tbl || (size && !addr)) {
- errno = EINVAL;
- return (-1);
- }
- bzero(&io, sizeof io);
- io.pfrio_flags = flags;
- io.pfrio_table = *tbl;
- io.pfrio_buffer = addr;
- io.pfrio_esize = sizeof(*addr);
- io.pfrio_size = size;
- if (ioctl(dev, DIOCRCLRASTATS, &io) == -1)
- return (-1);
- if (nzero)
- *nzero = io.pfrio_nzero;
- return (0);
+ return (pfctl_clr_astats(pfh, tbl, addr, size, nzero, flags));
}
int