MDEV-39169: Replace deprecated network functions with modern POSIX equivalents#4856
MDEV-39169: Replace deprecated network functions with modern POSIX equivalents#4856FaramosCZ wants to merge 1 commit intoMariaDB:mainfrom
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).
mysql-test/main/resolveip.test
Outdated
| --echo # MDEV-39169: resolveip IPv6 support | ||
| --echo # | ||
|
|
||
| --source include/not_windows.inc |
There was a problem hiding this comment.
please move the --source include.. to the top of the test file.
we write our mtr test in this format -
--source include/....inc
--echo #
--echo # MDEV-39169: resolveip IPv6 support
--echo #
... <tests> ...
--echo # End of 13.x tests
you have the header with MDEV, but footer is missing. please add the footer in your test with correct server version.
mysql-test/main/resolveip.test
Outdated
| --echo # | ||
| --echo # IPv6 reverse lookup | ||
| --echo # | ||
| --exec $MYSQL_RESOLVEIP ::1 | sed 's/Host name of ::1 is .*/Host name of ::1 is HOSTNAME/' |
There was a problem hiding this comment.
these are some of the cases that were not resolved in my machine (Ubuntu 24) with resolveip, I believe these are valid IPv6 addresses
$ resolveip :: ::1 ::ffff:127.0.0.1 0000:0000:0000:0000:0000:0000:0000:0001
resolveip: Unable to find hostid for '::': host not found
resolveip: Unable to find hostid for '::1': host not found
resolveip: Unable to find hostid for '::ffff:127.0.0.1': host not found
resolveip: Unable to find hostid for '0000:0000:0000:0000:0000:0000:0000:0001': host not found
getent ahosts works but resolveip couldn't resolve them
$ getent ahosts :: ::1 ::ffff:127.0.0.1 0000:0000:0000:0000:0000:0000:0000:0001
:: STREAM ::
:: DGRAM
:: RAW
::1 STREAM ::1
::1 DGRAM
::1 RAW
::ffff:127.0.0.1 STREAM ::ffff:127.0.0.1
::ffff:127.0.0.1 DGRAM
::ffff:127.0.0.1 RAW
::1 STREAM 0000:0000:0000:0000:0000:0000:0000:0001
::1 DGRAM
::1 RAW
mysql-test/main/resolveip.test
Outdated
| --exec $MYSQL_RESOLVEIP -s ::1 | sed 's/.*/HOSTNAME/' | ||
|
|
||
| --echo # | ||
| --echo # Error: invalid hostname |
There was a problem hiding this comment.
for completeness, may be you can add few more tests- trying to resolve multiple addresses, invalid addresses, resolving multiple mixed args ( resolveip ipv4 ipv6, resolveip ipv4 hostname)
096dd52 to
e64c305
Compare
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>
e64c305 to
dbd5f00
Compare
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.