History log of /src/lib/libpfctl/libpfctl.c (Results 1 – 25 of 150)
Revision Date Author Comments
# 281282e9 13-Feb-2026 Kristof Provost <kp@FreeBSD.org>

pf: convert DIOCRTSTADDRS to netlink

Sponsored by: Rubicon Communications, LLC ("Netgate")


# 1e7665e3 12-Feb-2026 Kristof Provost <kp@FreeBSD.org>

libpfctl: verify all parsers

List all currently defined parsers in 'all_parsers', and pass them to
SNL_VERIFY_PARSERS(). This will detect incorrect odering in parsers,
which will help us detect othe

libpfctl: verify all parsers

List all currently defined parsers in 'all_parsers', and pass them to
SNL_VERIFY_PARSERS(). This will detect incorrect odering in parsers,
which will help us detect otherwise subtle bugs.

Sponsored by: Rubicon Communications, LLC ("Netgate")

show more ...


# 363b57d5 12-Feb-2026 Eric A. Borisch <eborisch@gmail.com>

libpfctl: Sort order of snl attribute parser

snl atttribute parsers must be sorted by type, so PF_GS_BCOUNTERS
(16) must follow PF_GF_PCOUNTERS (15). Fix ordering and add a call
to SNL_VERIFY_PARSE

libpfctl: Sort order of snl attribute parser

snl atttribute parsers must be sorted by type, so PF_GS_BCOUNTERS
(16) must follow PF_GF_PCOUNTERS (15). Fix ordering and add a call
to SNL_VERIFY_PARSERS.

Without this fix, byte counters reported by 'pfctl -s info' with
a loginterface are always zero.

PR: 291763
MFC after: 1 week
Reviewed by: kp
Signed-off-by: eborisch@gmail.com

show more ...


# 8716d8c7 12-Jan-2026 Kristof Provost <kp@FreeBSD.org>

pf: configurable action on limiter exceeded

This change extends pf(4) limiters so administrator
can specify action the rule executes when limit is
reached. By default when limit is reached the limit

pf: configurable action on limiter exceeded

This change extends pf(4) limiters so administrator
can specify action the rule executes when limit is
reached. By default when limit is reached the limiter
overrides action specified by rule to no-match.
If administrator wants to block packet instead then
rule with limiter should be changed to:

pass in from any to any state limiter test (block)

OK dlg@

Obtained from: OpenBSD, sashan <sashan@openbsd.org>, 04394254d9
Sponsored by: Rubicon Communications, LLC ("Netgate")

show more ...


# c72fb110 06-Jan-2026 Kristof Provost <kp@FreeBSD.org>

pf: convert state limiter interface to netlink

This is a new feature with new ioctl calls, so we can safely remove them
right now.

Sponsored by: Rubicon Communications, LLC ("Netgate")


# 46164812 30-Dec-2025 Kristof Provost <kp@FreeBSD.org>

pf: introduce source and state limiters

both source and state limiters can provide constraints on the number
of states that a set of rules can create, and optionally the rate
at which they are creat

pf: introduce source and state limiters

both source and state limiters can provide constraints on the number
of states that a set of rules can create, and optionally the rate
at which they are created. state limiters have a single limit, but
source limiters apply limits against a source address (or network).
the source address entries are dynamically created and destroyed,
and are also limited.

this started out because i was struggling to understand the source and
state tracking options in pf.conf, and looking at the code made it
worse. it looked like some functionality was missing, and the code also
did some things that surprised me. taking a step back from it, even it
if did work, what is described doesn't work well outside very simple
environments.

the functionality i'm talking about is most of the stuff in the
Stateful Tracking Options section of pf.conf(4).

some of the problems are illustrated one of the simplest options:
the "max number" option that limits the number of states that a
rule is allowed to create:

- wiring limits up to rules is a problem because when you load a
new ruleset the limit is reset, allowing more states to be created
than you intended.
- a single "rule" in pf.conf can expand to multiple rules in the
kernel thanks to things like macro expansion for multiple ports.
"max 1000" on a line in pf.conf could end up being many times
that in effect.
- when a state limit on a rule is reached, the packet is dropped.
this makes it difficult to do other things with the packet, such a
redirect it to a tarpit or another server that replies with an
outage notices or such.

a state limiter solves these problems. the example from the pf.conf.5
change demonstrates this:

An example use case for a state limiter is to restrict the number of
connections allowed to a service that is accessible via multiple
protocols, e.g. a DNS server that can be accessed by both TCP and UDP on
port 53, DNS-over-TLS on TCP port 853, and DNS-over-HTTPS on TCP port 443
can be limited to 1000 concurrent connections:

state limiter "dns-server" id 1 limit 1000

pass in proto { tcp udp } to port domain state limiter "dns-server"
pass in proto tcp to port { 853 443 } state limiter "dns-server"

a single limit across all these protocols can't be implemented with
per rule state limits, and any limits that were applied are reset
if the ruleset is reloaded.

the existing source-track implementation appears to be incomplete,
i could only see code for "source-track global", but not "source-track
rule". source-track global is too heavy and unweildy a hammer, and
source-track rule would suffer the same issues around rule lifetimes
and expansions that the "max number" state tracking config above has.

a slightly expanded example from the pf.conf.5 change for source limiters:

An example use for a source limiter is the mitigation of denial of
service caused by the exhaustion of firewall resources by network or port
scans from outside the network. The states created by any one scanner
from any one source address can be limited to avoid impacting other
sources. Below, up to 10000 IPv4 hosts and IPv6 /64 networks from the
external network are each limited to a maximum of 1000 connections, and
are rate limited to creating 100 states over a 10 second interval:

source limiter "internet" id 1 entries 10000 \
limit 1000 rate 100/10 \
inet6 mask 64

block in on egress
pass in quick on egress source limiter "internet"
pass in on egress proto tcp probability 20% rdr-to $tarpit

the extra bit is if the source limiter doesn't have "space" for the
state, the rule doesn't match and you can fall through to tarpitting
20% of the tcp connections for fun.

i've been using this in anger in production for over 3 years now.

sashan@ has been poking me along (slowly) to get it in a good enough
shape for the tree for a long time. it's been one of those years.

bluhm@ says this doesnt break the regress tests.
ok sashan@

Obtained from: OpenBSD, dlg <dlg@openbsd.org>, 8463cae72e
Sponsored by: Rubicon Communications, LLC ("Netgate")

show more ...


# 96c7e70c 29-Dec-2025 Kristof Provost <kp@FreeBSD.org>

pf: convert DIOCRCLRASTATS to netlink

Sponsored by: Rubicon Communications, LLC ("Netgate")


# c2e7a523 29-Dec-2025 Kristof Provost <kp@FreeBSD.org>

pf: move DIOCRCLRASTATS into libpfctl

Sponsored by: Rubicon Communications, LLC ("Netgate")


# 823ebd7c 21-Dec-2025 Kristof Provost <kp@FreeBSD.org>

libpfctl: export a get states variant that takes a pfctl_handle

Sponsored by: Rubicon Communications, LLC ("Netgate")


# ad7f49f9 17-Dec-2025 Kristof Provost <kp@FreeBSD.org>

libpfctl: fix tstats address count

Reported by: Marcos Mendoza <mmendoza@netgate.com>
See also: https://redmine.pfsense.org/issues/16588
Sponsored by: Rubicon Communications, LLC ("Netgate")


# 08f54dfc 04-Dec-2025 Kristof Provost <kp@FreeBSD.org>

pf: convert DIOCRGETASTATS to netlink

Sponsored by: Rubicon Communications, LLC ("Netgate")


# 4aa79010 02-Dec-2025 Kristof Provost <kp@FreeBSD.org>

pfctl: move astats query into libpfctl

Sponsored by: Rubicon Communications, LLC ("Netgate")


# 238ad591 25-Nov-2025 Kristof Provost <kp@FreeBSD.org>

libpfctl: improve error handling

If we fail to open /dev/pf don't try to close it again. That would result in
errno getting overwritten by close(), hiding potentially useful information.

MFC after:

libpfctl: improve error handling

If we fail to open /dev/pf don't try to close it again. That would result in
errno getting overwritten by close(), hiding potentially useful information.

MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")

show more ...


# f27e44e2 04-Nov-2025 Kristof Provost <kp@FreeBSD.org>

pf: convert DIOCRGETADDRS to netlink

Sponsored by: Rubicon Communications, LLC ("Netgate")


# 9bb1c46b 03-Nov-2025 Kristof Provost <kp@FreeBSD.org>

libpfctl: fix error handling

In two cases we returned E2BIG where it should have been a boolean ('false').

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")


# 08ed87a4 31-Oct-2025 Kristof Provost <kp@FreeBSD.org>

pf: convert DIOCRSETADDRS to netlink

The list of addresses is potentially very large. Larger than we can fit in a
single netlink request, so we indicate via the PFR_FLAG_START/PFR_FLAG_DONE
flags wh

pf: convert DIOCRSETADDRS to netlink

The list of addresses is potentially very large. Larger than we can fit in a
single netlink request, so we indicate via the PFR_FLAG_START/PFR_FLAG_DONE
flags when we start and finish, so the kernel can work out which addresses need
to be removed.

Sponsored by: Rubicon Communications, LLC ("Netgate")

show more ...


# a943a96a 25-Oct-2025 Jose Luis Duran <jlduran@FreeBSD.org>

libpfctl: Fix displaying deeply nested anchors

Set the number of rulesets (i.e., anchors) directly attached to the
anchor and its path in pfctl_get_ruleset().

While here, add a test to document thi

libpfctl: Fix displaying deeply nested anchors

Set the number of rulesets (i.e., anchors) directly attached to the
anchor and its path in pfctl_get_ruleset().

While here, add a test to document this behavior.

PR: 290478
Reviewed by: kp
Fixes: 041ce1d690f1 ("pfctl: recursively flush rules and tables")
MFC after: 2 days
Differential Revision: https://reviews.freebsd.org/D53358

show more ...


# bdb205c5 01-Oct-2025 Kristof Provost <kp@FreeBSD.org>

libpfctl: fix memory leak in pfctl_get_status()

Remember to also free ncounters.

Fixes: c00aca9a71 ("pf: Show pf fragment reassembly counters.")
MFC after: 3 days
Sponsored by: Rubicon Communicati

libpfctl: fix memory leak in pfctl_get_status()

Remember to also free ncounters.

Fixes: c00aca9a71 ("pf: Show pf fragment reassembly counters.")
MFC after: 3 days
Sponsored by: Rubicon Communications, LLC ("Netgate")

show more ...


# b84666f7 28-Aug-2025 Kristof Provost <kp@FreeBSD.org>

pf: export expiration time as time_t

time_t has a different size on different platforms (i.e. 32-bit on i386, 64-bit
on others). Rather than always exporting it as 64-bits use the platform-native
si

pf: export expiration time as time_t

time_t has a different size on different platforms (i.e. 32-bit on i386, 64-bit
on others). Rather than always exporting it as 64-bits use the platform-native
size.
This means we can safely write directly into a time_t variable, which we can't
do on i386 eif we export 64 bits.

Sponsored by: Rubicon Communications, LLC ("Netgate")

show more ...


# b9d652bb 27-Aug-2025 Kristof Provost <kp@FreeBSD.org>

pf: print 'once' rule expire time

Obtained from: OpenBSD, sashan <sashan@openbsd.org>, 8cf23eed7f
Sponsored by: Rubicon Communications, LLC ("Netgate")


# c00aca9a 21-Aug-2025 Kristof Provost <kp@FreeBSD.org>

pf: Show pf fragment reassembly counters.

Framgent count and statistics are stored in struct pf_status. From
there pfctl(8) and systat(1) collect and show them. Note that pfctl
-s info needs the -

pf: Show pf fragment reassembly counters.

Framgent count and statistics are stored in struct pf_status. From
there pfctl(8) and systat(1) collect and show them. Note that pfctl
-s info needs the -v switch to show fragments.

input claudio@; OK henning@

Obtained from: OpenBSD, bluhm <bluhm@openbsd.org>, 19e99d0613
Sponsored by: Rubicon Communications, LLC ("Netgate")

show more ...


# 932ec59d 12-Aug-2025 Kristof Provost <kp@FreeBSD.org>

pf: fix ICMP type/code representation

internal representation of icmp type/code in pfctl(8)/pf(4) does not
fit into u_int8_t. Issue has been noticed and kindly reported by
amalinin _at_ bh0.amt.ru v

pf: fix ICMP type/code representation

internal representation of icmp type/code in pfctl(8)/pf(4) does not
fit into u_int8_t. Issue has been noticed and kindly reported by
amalinin _at_ bh0.amt.ru via bugs@.

OK bluhm@

Obtained from: OpenBSD, sashan <sashan@openbsd.org>, 1fdb608f55
Sponsored by: Rubicon Communications, LLC ("Netgate")

show more ...


# 094a6028 18-Aug-2025 Kristof Provost <kp@FreeBSD.org>

pf: fix potential infinite loop adding/deleting addresses in tables

The 'nadd' returned by these calls is the number of addresses actually added
or deleted. It can differ from the number userspace s

pf: fix potential infinite loop adding/deleting addresses in tables

The 'nadd' returned by these calls is the number of addresses actually added
or deleted. It can differ from the number userspace sent to the kernel if the
addresses are already present (or not present for the delete case).
This meant that if all of the addresses were already handled the kernel would
return zero, putting us in an infinite loop.

Handle this, and extend the test case to provoke this scenario.

Reported by: netchild@
Fixes: bad279e12deb ("pf: convert DIOCRDELADDRS to netlink")
Fixes: 8b388995b8b2 ("pf: convert DIOCRADDADDRS to netlink")
Sponsored by: Rubicon Communications, LLC ("Netgate")

show more ...


# bad279e1 01-Aug-2025 Kristof Provost <kp@FreeBSD.org>

pf: convert DIOCRDELADDRS to netlink

Sponsored by: Rubicon Communications, LLC ("Netgate")


# 8b388995 14-Jul-2025 Kristof Provost <kp@FreeBSD.org>

pf: convert DIOCRADDADDRS to netlink

Add up to 64 addresses at once. We are limited by the netlink socket buffer, so
we can only add a limited number at once.

Sponsored by: Rubicon Communications,

pf: convert DIOCRADDADDRS to netlink

Add up to 64 addresses at once. We are limited by the netlink socket buffer, so
we can only add a limited number at once.

Sponsored by: Rubicon Communications, LLC ("Netgate")

show more ...


123456