Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

py TSocket: Only disable socket.IPV6_V6ONLY when the family is AF_INET6 #2770

Merged
merged 1 commit into from
Mar 17, 2023
Merged

py TSocket: Only disable socket.IPV6_V6ONLY when the family is AF_INET6 #2770

merged 1 commit into from
Mar 17, 2023

Conversation

derkuci
Copy link
Contributor

@derkuci derkuci commented Mar 17, 2023

The changes introduced in 916ae8b causes OSError when the socket is of IPv4 family. This can be verified by the code snippet below (at least on RHEL 8 and RHEL 9 with Python 3.9):

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0)

This will raise an exception OSError: [Errno 92] Protocol not available.

My fix is pretty simple: only set that IPv6 option when the socket family is IPv6.

@Jens-G Jens-G added the python label Mar 17, 2023
@Jens-G Jens-G merged commit ae3e96b into apache:master Mar 17, 2023
@tisdall tisdall mentioned this pull request Aug 17, 2023
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants