aboutsummaryrefslogtreecommitdiff
path: root/sbin/pfctl
diff options
context:
space:
mode:
authorKristof Provost <kp@FreeBSD.org>2024-01-04 09:50:14 +0000
committerKristof Provost <kp@FreeBSD.org>2024-01-04 22:10:24 +0000
commit66cacc141d372fdfa624a380bac6880ecf809994 (patch)
tree8a0bad064b94917dbd30de4771c1fb1ca355d95d /sbin/pfctl
parent32df0124f467eff3e4691090fecb022dbdaa1e25 (diff)
downloadsrc-66cacc141d372fdfa624a380bac6880ecf809994.tar.gz
src-66cacc141d372fdfa624a380bac6880ecf809994.zip
Diffstat (limited to 'sbin/pfctl')
-rw-r--r--sbin/pfctl/pfctl.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c
index 2702c701f9cc..217bf31b3301 100644
--- a/sbin/pfctl/pfctl.c
+++ b/sbin/pfctl/pfctl.c
@@ -132,7 +132,7 @@ static const char *showopt;
static const char *debugopt;
static char *anchoropt;
static const char *optiopt = NULL;
-static const char *pf_device = "/dev/pf";
+static const char *pf_device = PF_DEVICE;
static char *ifaceopt;
static char *tableopt;
static const char *tblcmdopt;
@@ -144,6 +144,7 @@ int loadopt;
int altqsupport;
int dev = -1;
+struct pfctl_handle *pfh = NULL;
static int first_title = 1;
static int labels = 0;
@@ -312,7 +313,7 @@ pfctl_enable(int dev, int opts)
{
int ret;
- if ((ret = pfctl_startstop(1)) != 0) {
+ if ((ret = pfctl_startstop(pfh, 1)) != 0) {
if (ret == EEXIST)
errx(1, "pf already enabled");
else if (ret == ESRCH)
@@ -335,7 +336,7 @@ pfctl_disable(int dev, int opts)
{
int ret;
- if ((ret = pfctl_startstop(0)) != 0) {
+ if ((ret = pfctl_startstop(pfh, 0)) != 0) {
if (ret == ENOENT)
errx(1, "pf not enabled");
else
@@ -1665,7 +1666,7 @@ pfctl_show_creators(int opts)
uint32_t creators[16];
size_t count = nitems(creators);
- ret = pfctl_get_creatorids(creators, &count);
+ ret = pfctl_get_creatorids(pfh, creators, &count);
if (ret != 0)
errx(ret, "Failed to retrieve creators");
@@ -3079,6 +3080,9 @@ main(int argc, char *argv[])
altqsupport = 1;
#endif
}
+ pfh = pfctl_open(pf_device);
+ if (pfh == NULL)
+ err(1, "Failed to open netlink");
if (opts & PF_OPT_DISABLE)
if (pfctl_disable(dev, opts))