Page MenuHomeFreeBSD

pf: Do not hash pool address pointers into rule hashes
Needs ReviewPublic

Authored by rcm on Mon, Oct 5, 3:15 PM.
Tags
None
Referenced Files
F175440198: D60370.diff
Sat, Oct 10, 9:23 PM
F175433084: D60370.id188723.diff
Sat, Oct 10, 7:55 PM
F175393261: D60370.id189276.diff
Sat, Oct 10, 12:56 PM
F175389186: D60370.id188723.diff
Sat, Oct 10, 12:11 PM
F175373701: D60370.id188723.diff
Sat, Oct 10, 9:25 AM
F175373692: D60370.diff
Sat, Oct 10, 9:25 AM
F175373621: D60370.id189276.diff
Sat, Oct 10, 9:24 AM
F175372109: D60370.diff
Sat, Oct 10, 9:08 AM

Details

Reviewers
kp
Summary

pf_hash_pool() hashes the first address of a pool as a whole struct
pf_addr_wrap, including the union that holds the kernel's pfi_dynaddr
or pfr_ktable pointer.

An interface pool such as "-> ($ext_if)" gets a new pfi_dynaddr on
every load, so with "set keepcounters" the rule never matches its
predecessor and loses its counters on every reload. The pointers also
differ between hosts: once a filter rule in the main ruleset has an
interface or table pool, pfsync peers disagree on the ruleset checksum
and bind every synced state to the default rule.

Hash the address with that union cleared. The rest of the address,
including the prefix length of an interface address, is hashed as
before, and the hash of a rule with a plain address pool does not
change.

Fixes: c6bcf6e6fd50 ("pf: include all elements when hashing rules")
MFC after: 1 week
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.Mon, Oct 5, 3:15 PM
rcm changed the visibility from "Public (No Login Required)" to "rcm (R. Christian McDonald)".Mon, Oct 5, 3:45 PM
rcm changed the edit policy from "All Users" to "rcm (R. Christian McDonald)".
rcm retitled this revision from pf: do not hash pool address pointers into rule hashes to pf: Do not hash pool address pointers into rule hashes.
rcm edited the summary of this revision. (Show Details)

This revision drops only the pointer from the hash instead of re-hashing the address by field. The per-field hashing will follow in a separate review once this has landed; it likely deserves it's own MFC decision anyway.

rcm changed the visibility from "rcm (R. Christian McDonald)" to "Public (No Login Required)".Fri, Oct 9, 6:43 PM
rcm changed the edit policy from "rcm (R. Christian McDonald)" to "All Users".