MDEV-39169: Replace deprecated network functions with modern POSIX equivalents#4856
Conversation
gkodinov
left a comment
There was a problem hiding this comment.
Thank you for your contribution! This is a preliminary review.
LGTM. I've taken the liberty of filing a jira for the task.
Please stand by for the final review.
I'd also be nice to have some sort of testing for this. Maybe resolve some IPv6 IP or something?
70e52fc to
6333f1a
Compare
raghunandanbhat
left a comment
There was a problem hiding this comment.
@FaramosCZ , thanks for the contribution.
I have a few suggestion-
- please squash two commits into a single commit
- ensure that commit message starts with the MDEV number, something like
MDEV-39169:... - plus, issues I found in test (comments below).
e64c305 to
dbd5f00
Compare
|
I fixed all concerns you listed. |
There was a problem hiding this comment.
@FaramosCZ, looks good overall.
cases like ::, ::1, IPv4-mapped IPv6 addresses, etc seem to work fine. however, some test cases are "sneaky". please fix them.
b1399e9 to
af57ebc
Compare
raghunandanbhat
left a comment
There was a problem hiding this comment.
looks good to me. thank you @FaramosCZ for the contribution.
@gkodinov, I believe this needs go through QA/testing before we merge this.
test failure found in build bot - amd64-ubuntu-2204 & s390x-ubuntu-2204-debug
Rebase failed
Replace inet_aton/inet_addr/gethostbyname/gethostbyaddr with their modern POSIX equivalents inet_pton/getaddrinfo/getnameinfo. This adds IPv6 support to resolveip and removes dependency on the deprecated h_errno global. Handle IPv6 unspecified address (::) as Null-IP-Addr, consistent with existing IPv4 INADDR_ANY handling for 0.0.0.0. Add MTR test covering IPv4/IPv6 reverse lookups, special addresses, multiple arguments, mixed address types, and invalid hostname handling. Co-Authored-By: Claude AI <noreply@anthropic.com>
resolveip: replace inet_aton/inet_addr, gethostbyname, gethostbyaddr, inet_ntoa with inet_pton, getaddrinfo, getnameinfo, inet_ntop.
These deprecated functions are IPv4-only and some are not thread-safe (gethostbyname, gethostbyaddr, and inet_ntoa use static internal buffers). The modernized code:
Bump version from 2.3 to 2.4 to reflect the API change.
Update Solaris library search in CMakeLists.txt from inet_aton to getaddrinfo since the old function is no longer referenced.