From owner-freebsd-bugs@freebsd.org Sun Jun 18 09:03:44 2017 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7F659D8C963 for ; Sun, 18 Jun 2017 09:03:44 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6CB9264F51 for ; Sun, 18 Jun 2017 09:03:44 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id v5I93iqN054955 for ; Sun, 18 Jun 2017 09:03:44 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 220101] [patch] LibAlias: allocate NAT ports using exhaustive search Date: Sun, 18 Jun 2017 09:03:44 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: patch X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: damjan.jov@gmail.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status keywords bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Jun 2017 09:03:44 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D220101 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@FreeBSD.org Reporter: damjan.jov@gmail.com Created attachment 183594 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D183594&action= =3Dedit 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 po= rt if any are available. The attached patch changes libalias to do the same. --=20 You are receiving this mail because: You are the assignee for the bug.=