mirror of
https://github.com/python/cpython.git
synced 2025-08-09 11:29:45 +00:00
[3.12] gh-128916: Do not set SO_REUSEPORT
on non-AF_INET*
sockets (GH-128933) (#128970)
gh-128916: Do not set `SO_REUSEPORT` on non-`AF_INET*` sockets (GH-128933)
* gh-128916: Do not set `SO_REUSEPORT` on non-`AF_INET*` sockets
Do not attempt to set ``SO_REUSEPORT`` on sockets of address familifies other
than ``AF_INET`` and ``AF_INET6``, as it is meaningless with these address
families, and the call with fail with Linux kernel 6.12.9 and newer.
* Apply suggestions from code review
---------
(cherry picked from commit 3829104ab4
)
Co-authored-by: Michał Górny <mgorny@gentoo.org>
Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
This commit is contained in:
parent
8ee250bdd9
commit
8a8f5d636d
4 changed files with 15 additions and 3 deletions
|
@ -932,7 +932,9 @@ def create_server(address, *, family=AF_INET, backlog=None, reuse_port=False,
|
|||
# Fail later on bind(), for platforms which may not
|
||||
# support this option.
|
||||
pass
|
||||
if reuse_port:
|
||||
# Since Linux 6.12.9, SO_REUSEPORT is not allowed
|
||||
# on other address families than AF_INET/AF_INET6.
|
||||
if reuse_port and family in (AF_INET, AF_INET6):
|
||||
sock.setsockopt(SOL_SOCKET, SO_REUSEPORT, 1)
|
||||
if has_ipv6 and family == AF_INET6:
|
||||
if dualstack_ipv6:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue