-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Converting ipv6 address to string representation using getnameinfo() is wrong. #76402
Comments
The problem is in the performance. For each In order to convert from tuple to string-based full address one may use
|
Please look at my PR |
What do you mean? Can you give results for a benchmark of your choice? How much does your PR speed it up? |
Original (not patched) python:
On patched version, times for both cases should be the same exactly (i.e. 532 ns) |
So it may affect applications, that work with UDP and .recvfrom() |
Wow. That's a heavy price to pay indeed. Unfortunately I'm not competent on IPv6. I'm cc-ing other core developers so that they may chime in. |
After my patch: $ python3.7 -m timeit --setup 'import socket; s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM); s.bind(("ff02::1de:c0db", 1234, 0, 2))' 's.getsockname()'
500000 loops, best of 5: 613 nsec per loop
$ python3.7 -m timeit --setup 'import socket; s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM); s.bind(("::", 1235, 0, 0))' 's.getsockname()'
500000 loops, best of 5: 420 nsec per loop |
I thought the improvements were way bigger than 200nsec, no? |
No, Improvement for typical case (not scoped IPv6 addresses) was not the target, but fortunatelly it also sped up. |
The PR looks good, but I don't have the capacity right now to merge it. Ill need some time for research to double check if it's ok to drop scope id. Will try to find it in the next few days. |
So, PR is ready. Please review. |
I understand, however I still don't have time for it at the moment. If another core dev wants to take initiative, please by all means do. I can/will take another look at this after January 15. |
Merged. Thanks, Mark! |
Mark, Two tests fail on MacOS X now (newly added tests). I'm reverting the change for now. If you figure this out, please re-submit a PR for a quick approval. ====================================================================== Traceback (most recent call last):
File "/Users/yury/dev/pydev/cpython/Lib/test/test_socket.py", line 1612, in test_getaddrinfo_ipv6_scopeid
ifindex = socket.if_nametoindex(test_interface)
OSError: no interface with this name ====================================================================== Traceback (most recent call last):
File "/Users/yury/dev/pydev/cpython/Lib/test/test_socket.py", line 1636, in test_getnameinfo_ipv6_scopeid
nameinfo = socket.getnameinfo(sockaddr, socket.NI_NUMERICHOST | socket.NI_NUMERICSERV)
socket.gaierror: [Errno 4] Non-recoverable failure in name resolution |
Mark, I think this still land in beta-2. Please try to figure out what's going on on Mac OS (I have no time to take care of this myself). |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: