HomeFreeBSD

pf: Convert struct pf_addr_wrap before sending it over netlink

Description

pf: Convert struct pf_addr_wrap before sending it over netlink

The struct pf_addr_wrap when used inside of kernel operates on pointers to
tables or interfaces. When reading a ruleset the struct must contain
counters calculated from the aforementioned tables and interfaces. Both the
pointers and the resulting counters are stored in an union and thus can't be
present in the struct at the same time.

The original ioctl code handles this by making a copy of struct pf_addr_wrap
for pool addresses, accessing the table or interface structures by their
pointers, calculating the counter values and storing them in place of those
pointers in the copy. Then this copy is sent over ioctl.

Use this mechanism for netlink too. Create a copy of src/dst addresses. Use
the existing function pf_addr_copyout() to convert pointers to counters both
for src/dst and pool addresses.

Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D46291

Details

Provenance
vegeta_tuxpowered.netAuthored on Aug 15 2024, 9:07 AM
kpCommitted on Aug 15 2024, 9:11 AM
Reviewer
kp
Differential Revision
D46291: pf: Convert struct pf_addr_wrap before sending it over netlink
Parents
rG6c479edc6164: pf: Fix indentation in struct pf_ksrc_node
Branches
Unknown
Tags
Unknown