HomeFreeBSD

netlink: fix snl_writer and linear_buffer re-allocation logic

Description

netlink: fix snl_writer and linear_buffer re-allocation logic

  • Use the correct base pointer after re-allocation to avoid buffer overflows.
  • Maintain correct snl_writer.size, which avoids redundant memory allocation, e.g. a need for ~1k bytes may end up with ~32k linear_buffer actually allocated.

This fixes a pfctl regression at least for armv7 after the addrule logic
migration to netlink:

ffbf25951e7b ("pf: convert rule addition to netlink")

The add rule command creates a bigger than default size netlink requests
which triggers the re-allocation logic.

Reviewed by: kp
MFC after: 2 weeks
Differnetial Revision: https://reviews.freebsd.org/D43003

(cherry picked from commit 0c511bafdd5b309505c13c8dc7c6816686d1e103)

Details

Provenance
igor.ostapenko_pm.meAuthored on Dec 12 2023, 6:26 PM
kpCommitted on Dec 27 2023, 9:01 PM
Parents
rG0a6b61a89a68: ocs_fc: Use xpt_path_sbuf() to copy the path to sbuf.
Branches
Unknown
Tags
Unknown