HomeFreeBSD

pf: Fix parsing of long table names

Description

pf: Fix parsing of long table names

When parsing the nvlist for a struct pf_addr_wrap we unconditionally
tried to parse "ifname". This broke for PF_ADDR_TABLE when the table
name was longer than IFNAMSIZ. PF_TABLE_NAME_SIZE is longer than
IFNAMSIZ, so this is a valid configuration.

Only parse (or return) ifname or tblname for the corresponding
pf_addr_wrap type.

This manifested as a failure to set rules such as these, where the pfctl
optimiser generated an automatic table:

pass in proto tcp to 192.168.0.1 port ssh
pass in proto tcp to 192.168.0.2 port ssh
pass in proto tcp to 192.168.0.3 port ssh
pass in proto tcp to 192.168.0.4 port ssh
pass in proto tcp to 192.168.0.5 port ssh
pass in proto tcp to 192.168.0.6 port ssh
pass in proto tcp to 192.168.0.7 port ssh

Reported by: Florian Smeets
Tested by: Florian Smeets
Reviewed by: donner
X-MFC-With: 5c11c5a3655842a176124ef2334fcdf830422c8a
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29962

(cherry picked from commit 402dfb0a8d2c6417cb9bff4460ef250a42b0aa05)

Details

Provenance
kpAuthored on Apr 24 2021, 1:55 PM
Reviewer
rG5c11c5a36558: pfctl: Move to DIOCADDRULENV
Differential Revision
D29962: pf: Fix parsing of long table names
Parents
rG4e1c728f1926: UPDATING: Add an entry for commit 272f39942254
Branches
Unknown
Tags
Unknown