Page MenuHomeFreeBSD

pf: Hash rule and pool addresses by type
AcceptedPublic

Authored by rcm on Fri, Oct 9, 6:55 PM.
Tags
None
Referenced Files
F176091794: D60545.diff
Fri, Oct 16, 1:05 AM
Unknown Object (File)
Wed, Oct 14, 12:28 AM
Unknown Object (File)
Wed, Oct 14, 12:28 AM
Unknown Object (File)
Tue, Oct 13, 10:23 PM
Unknown Object (File)
Mon, Oct 12, 2:55 PM
Unknown Object (File)
Mon, Oct 12, 2:51 PM
Unknown Object (File)
Mon, Oct 12, 1:33 PM
Unknown Object (File)
Mon, Oct 12, 8:42 AM

Details

Reviewers
kp
Summary

pf_hash_rule_addr() hashes the fields an address type uses, but leaves
out the prefix length of an interface address: "from ($if)/24" and
"from ($if)/25" hash the same. pf_hash_pool() hashes a pool address
as a whole struct, pointer union cleared.

Hash both the same way, by type, and include the prefix length of an
interface address. This changes the hash of every rule with an
interface address or a pool: "set keepcounters" starts such rules at
zero once, on the first load after the change, and until both pfsync
peers run this version their ruleset checksums differ, so a state one
imports from the other is bound to the default rule, as with any
difference between the rulesets.

Add a regression test.

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

Test Plan

Regression test included

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

rcm requested review of this revision.Fri, Oct 9, 6:55 PM
sys/netpfil/pf/pf_ioctl.c
1372–1373

If struct pf_addr_wrap's member type was a enum you would not need the default: case. It will also allow the compiler to do more checks. Note that PF_ADD_* constants are already enum. It just needs a name.

This revision is now accepted and ready to land.Mon, Oct 12, 9:28 AM