[Bug 220101] [patch] LibAlias: allocate NAT ports using exhaustive search

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Sun Jun 18 09:03:44 UTC 2017


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=220101

            Bug ID: 220101
           Summary: [patch] LibAlias: allocate NAT ports using exhaustive
                    search
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Keywords: patch
          Severity: Affects Many People
          Priority: ---
         Component: kern
          Assignee: freebsd-bugs at FreeBSD.org
          Reporter: damjan.jov at gmail.com

Created attachment 183594
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=183594&action=edit
LibAlias: allocate NAT ports using exhaustive search

Currently libalias allocates NAT ports from a pool of 32768 ports (from
ALIAS_PORT_BASE to ALIAS_PORT_BASE + ALIAS_PORT_MASK), by randomly trying
GET_NEW_PORT_MAX_ATTEMPTS (20) ports and returning the first unused one,
otherwise failing.

On a heavily loaded setup, as the number of ports in use approaches 32768,
requests for ports will increasingly fail even though there are free ports.
With 30000 ports in use, 17.12% of requests fail, with 31000 ports in use,
32.98% of requests fail, with 32000 ports in use, 62.23% of requests fail.

This behavior is erratic, and both PF and IPFILTER allocate ports by
exhaustively searching the entire port range from a random starting point (eg.
pf_get_sport() in sys/netpfil/pf/pf_lb.c), which is guaranteed to find a port
if any are available. The attached patch changes libalias to do the same.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list