HomeFreeBSD

pf: Use pf_map_addr() only once when choosing source port and address

Description

pf: Use pf_map_addr() only once when choosing source port and address

When choosing source port and address for NAT operations the proper order of
operations is:

  1. Try to get them from udp_mapping if rule has PF_POOL_ENDPI. This might be enough to return.
  2. Get IP address from pf_map_addr_sn()
  3. Look for free ports for the IP address
  4. Get another IP address from pf_map_addr() if no ports are free

Calling pf_map_addr_sn() before checking udp_mappings is not necessary,
remove the first call. Since now a rule can have multiple pools, don't
hardcode pools anymore, always use the pool given in pf_get_sport() call.

Reviewed by: kp
Approved by: kp (mentor)
Sponsored by: InnoGames GmbH
Differential Revision: https://reviews.freebsd.org/D48821

Details

Provenance
vegeta_tuxpowered.netAuthored on Mon, Feb 3, 4:41 PM
Reviewer
kp
Differential Revision
D48821: pf: Use pf_map_addr() only once when choosing source port and address
Parents
rG9ef38a01aea8: unix: remove always true check from uipc_attach
Branches
Unknown
Tags
Unknown