History log of /src/sbin/pfctl/pfctl_parser.c (Results 1 – 25 of 252)
Revision Date Author Comments
# e28dfd6b 12-Jan-2026 Kristof Provost <kp@FreeBSD.org>

pfctl: make the source limiter output match the input

When printing source limiters use the same keywords as we accept on
input, that is use 'entries' for the entries value (not 'limit') and
'limit'

pfctl: make the source limiter output match the input

When printing source limiters use the same keywords as we accept on
input, that is use 'entries' for the entries value (not 'limit') and
'limit' for the limit value (and not 'states').

Update the test case to match.

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

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 ...


# 7af7d6d6 12-Jan-2026 Kristof Provost <kp@FreeBSD.org>

pfctl: distinguish broadcast and PPP peer addresses

pfctl_parser.c, ifa_load() should distinguish between broadcast
and PPP peer address when it populates interface table for rule
parser.

OK @claud

pfctl: distinguish broadcast and PPP peer addresses

pfctl_parser.c, ifa_load() should distinguish between broadcast
and PPP peer address when it populates interface table for rule
parser.

OK @claudio, OK @dlg

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

show more ...


# 393243a3 12-Jan-2026 Kristof Provost <kp@FreeBSD.org>

pfctl: ifa_load() in pfctl_parser.c may attempt to read beyond the buffer.

The current ifa_load() is not paranoid enough when it deals with
information which comes from kernel. The function just ign

pfctl: ifa_load() in pfctl_parser.c may attempt to read beyond the buffer.

The current ifa_load() is not paranoid enough when it deals with
information which comes from kernel. The function just ignores
sa_len member in socket address returned getifaddrs().

The issue has been reported by anton@. The idea for fix here comes
fromy claudio@.

OK @claudio, @deraadt

Obtained from: OpenBSD, sashan <sashan@openbsd.org>, a48d060175
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 ...


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

pfctl: refactor 'rule_numbers' variable

The 'rule_numbers' is used for more than just displaying rule numbers.
Rename it and move the actual opts checking into the relevant functions.

Sponsored by:

pfctl: refactor 'rule_numbers' variable

The 'rule_numbers' is used for more than just displaying rule numbers.
Rename it and move the actual opts checking into the relevant functions.

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

show more ...


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

pfctl: print once shot rule expiration time

We already track this in the kernel and pass it to userspace, we may as well
show users.

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


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

pf: simplify expiration of 'once' rules.

let packet to mark 'once' rule as expired. The rule
will be removed by pfctl(8) when rules are updated.

OK kn@

Obtained from: OpenBSD, sashan <sashan@openb

pf: simplify expiration of 'once' rules.

let packet to mark 'once' rule as expired. The rule
will be removed by pfctl(8) when rules are updated.

OK kn@

Obtained from: OpenBSD, sashan <sashan@openbsd.org>, a21b78cad0
Obtained from: OpenBSD, jmc <jmc@openbsd.org>, 588f4160c8
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")


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

pfctl: One shot rules can be used in pf.conf by specifying a "once" filter option.

ok henning, mcbride

Obtained from: OpenBSD, mikeb <mikeb@openbsd.org>, 44b1b5a8a9
Sponsored by: Rubicon Communicat

pfctl: One shot rules can be used in pf.conf by specifying a "once" filter option.

ok henning, mcbride

Obtained from: OpenBSD, mikeb <mikeb@openbsd.org>, 44b1b5a8a9
Sponsored by: Rubicon Communications, LLC ("Netgate")

show more ...


# 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 ...


# 79a0959a 20-Aug-2025 Kristof Provost <kp@FreeBSD.org>

pfctl: add af-to and other missing action types in print_rule()

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


# c2d03a92 20-Aug-2025 Kristof Provost <kp@FreeBSD.org>

pfctl: fix anchortypes bounds test

found by "buffer overflow 'anchortypes' 10 <= 12" smatch error
feedback and ok sashan@, ok miod@ on an earlier version

Obtained from: OpenBSD, jsg <jsg@openbsd.or

pfctl: fix anchortypes bounds test

found by "buffer overflow 'anchortypes' 10 <= 12" smatch error
feedback and ok sashan@, ok miod@ on an earlier version

Obtained from: OpenBSD, jsg <jsg@openbsd.org>, 730c5d0121
Sponsored by: Rubicon Communications, LLC ("Netgate")

show more ...


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

pfctl: Rewrite some ugly for loops

This fixes a few KNF issues and ugly line wrapping by using a local
version of nitems(); fix two bsearch() on top.

ok claudio

FreeBSD note: we already used nitem

pfctl: Rewrite some ugly for loops

This fixes a few KNF issues and ugly line wrapping by using a local
version of nitems(); fix two bsearch() on top.

ok claudio

FreeBSD note: we already used nitems(), but now pick up the use of size_t over
unsigned int.

Obtained from: OpenBSD, tb <tb@openbsd.org>, 3d49904c6e
Sponsored by: Rubicon Communications, LLC ("Netgate")

show more ...


# 65c31863 01-Aug-2025 Kajetan Staszkiewicz <ks@FreeBSD.org>

pf: Add prefer-ipv6-nexthop option for route-to pools

Now that pf is aware of address family of each pool address and source
tracking uses distinct address family for source and redirection
adddress

pf: Add prefer-ipv6-nexthop option for route-to pools

Now that pf is aware of address family of each pool address and source
tracking uses distinct address family for source and redirection
adddresses it is possible to add a new pool option prefer-ipv6-nexthop
which enables routing of IPv4 packets over IPv6 next hops for rules
with the route-to option.

Add a pool option flag PF_POOL_IPV6NH, apply it to pools with a keyword
prefer-ipv6-nexthop.

Modify pf_map_addr() to handle pools with addresses of different
families. Use *naf as a hint about what address family the forwarded
packet is, then pick from the pool addresses of family that can be used
as a next hop for the forwarded packet, controlled by the PF_POOL_IPV6NH
flag. For NAT pools this flag is never set and thus pf_map_addr()
will return an IP address of the same family as the forwarded packet.
For route-to pools when the flag is enabled IPv6 addresses can be
returned or IPv4 packets.

In pf_route() check rt_af, it is not guaranteed to be AF_INET anymore
because pf_map_addr() could have changed it (as *naf).

Add tests for behaviour of pf_map_addr() both with PF_POOL_IPV6NH and
without, for single IP addresses, prefixes and subnets.

Reviewed by: kp
Sponsored by: InnoGames GmbH
Differential Revision: https://reviews.freebsd.org/D50781

show more ...


# d2761422 31-Jul-2025 Kajetan Staszkiewicz <ks@FreeBSD.org>

pf: Use different address family for source and redirection address

The function pf_map_addr() and source tracking operate on a single
address family. This made sense before introducing address fami

pf: Use different address family for source and redirection address

The function pf_map_addr() and source tracking operate on a single
address family. This made sense before introducing address family
translation. When combining af-to with route-to or with sticky-address,
the next-hop or the NAT address are of different address family than
the source address. For example in NAT64 scenaro an IPv6 source address
is translated to an IPv4 address and routed over IPv4 gateway.

Make source nodes dual-AF, that is have a separate source AF and
redirection AF. Store route AF in struct pf_kstate, export it to pfctl.
When loading rules with redirection pools with pfctl store address
family of each address. When printing states don't deduce next-hop's
address family from af-to, use the one stored in state.

Reviewed by: kp
Approved by: kp
Sponsored by: InnoGames GmbH
Differential Revision: https://reviews.freebsd.org/D51659

show more ...


# 7250fc4e 08-Jul-2025 Kristof Provost <kp@FreeBSD.org>

pflog: improve uid logging

Sometimes a user ID was logged in pflog(4) although the logopt of
the rule did not specify it. Check the option again for the log
rule in case another rule has triggered

pflog: improve uid logging

Sometimes a user ID was logged in pflog(4) although the logopt of
the rule did not specify it. Check the option again for the log
rule in case another rule has triggered a socket lookup. Remove
logopt group, it is not documented and cannot work as struct pfloghdr
does not contain a gid. Rename PF_LOG_SOCKET_LOOKUP to PF_LOG_USER
to express what it does. The lookup involved is only an implemntation
detail.
OK kn@ sashan@ mvs@

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

show more ...


# 7b0b4fca 08-Jul-2025 Kristof Provost <kp@FreeBSD.org>

pfctl: getifaddrs() can return entries where ifa_addr is NULL

Check for this before accessing anything in ifa_addr.
ok claudio@

Obtained from: OpenBSD, benno <benno@openbsd.org>, ff7f497850
Sponsor

pfctl: getifaddrs() can return entries where ifa_addr is NULL

Check for this before accessing anything in ifa_addr.
ok claudio@

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

show more ...


# 4982db38 09-Jul-2025 Dag-Erling Smørgrav <des@FreeBSD.org>

pfctl: Fix 32-bit build.

Fixes: 19973701098c8
Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D51230


# 19973701 03-Jul-2025 Kristof Provost <kp@FreeBSD.org>

pfctl: Use -1 to indicate an invalid uid/gid, not UID_MAX and GID_MAX.

This is the userland portion. OK deraadt@ sashan@

Obtained from: OpenBSD, millert <millert@openbsd.org>, b4de054894
Sponsored

pfctl: Use -1 to indicate an invalid uid/gid, not UID_MAX and GID_MAX.

This is the userland portion. OK deraadt@ sashan@

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

show more ...


# beb3c25d 02-Jul-2025 Kristof Provost <kp@FreeBSD.org>

pfctl: Fail on invalid netmasks when filling tables

Fix a regression of revision 1.326 "Zap v4mask and v6mask in host()" which
allowed CIDR networks with more than one "/" to be loaded into tables.

pfctl: Fail on invalid netmasks when filling tables

Fix a regression of revision 1.326 "Zap v4mask and v6mask in host()" which
allowed CIDR networks with more than one "/" to be loaded into tables.

I took care of this code path with regard to rules coming the ruleset
parser, which aborts earlier on such invalid specifications, but missed
`-T add 1/2/3' and the like.

Analyzed and fixed by Petr Hoffmann <petr dot hoffmann at oracle dot com>,
thanks!

OK deraadt

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

show more ...


# ada0846f 02-Jul-2025 Kristof Provost <kp@FreeBSD.org>

pfctl: Reuse copy_satopfaddr() when killing entries

Recently introduced in pfctl_parser.c r1.333, this helper nicely
simplifies code when copying IPs based on their address family, so use
it in five

pfctl: Reuse copy_satopfaddr() when killing entries

Recently introduced in pfctl_parser.c r1.333, this helper nicely
simplifies code when copying IPs based on their address family, so use
it in five other places when killing state or source node entries.

All addresses copied in these code paths result from either
pfctl_parse_host() or pfctl_addrprefix() which guarantee the address
family set to AF_INET or AF_INET6. Therefore, effectively relaxing the
case of unhandled families from errx(3) in callers to warnx(3) in
copy_satopfaddr() is safe since it's never reached.

OK sashan

Obtained from: OpenBSD, kn <kn@openbsd.org>, 0ff82421d8
Sponsored by: Rubicon Communications, LLC ("Netgate")

show more ...


# 204fae3f 30-Jun-2025 Kristof Provost <kp@FreeBSD.org>

pfctl: robustness improvement on address family

The kernel does not set the address family for the socket addresses
that are used for netmask, broadcast, and destination address. In
pfctl(8) take t

pfctl: robustness improvement on address family

The kernel does not set the address family for the socket addresses
that are used for netmask, broadcast, and destination address. In
pfctl(8) take the family of the interface address and write it to
the other addresses. This fixes some bugs when copy_satopfaddr()
copied only part of IPv6 addresses. Print a warning if the address
family is unknown.
OK kn@

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

show more ...


# e98d6da4 27-Jun-2025 Kristof Provost <kp@FreeBSD.org>

pfctl: Avoid unneeded variable in gen_dynnode()

OK bluhm

Obtained from: OpenBSD, kn <kn@openbsd.org>, 9e1cf8ac88
Sponsored by: Rubicon Communications, LLC ("Netgate")


1234567891011