Page MenuHomeFreeBSD

systat: remove gethostby*() calls
Needs ReviewPublic

Authored by yanhaowang on Jun 25 2024, 2:21 AM.
Tags
None
Referenced Files
F116746392: D45723.id140201.diff
Fri, May 9, 5:33 PM
Unknown Object (File)
Wed, May 7, 10:47 PM
Unknown Object (File)
Tue, May 6, 2:58 AM
Unknown Object (File)
Sat, Apr 19, 5:13 PM
Unknown Object (File)
Mar 21 2025, 9:00 AM
Unknown Object (File)
Mar 11 2025, 9:36 AM
Unknown Object (File)
Jan 18 2025, 9:38 PM
Unknown Object (File)
Jan 11 2025, 10:18 PM
Subscribers

Details

Reviewers
hrs
lwhsu
Summary
  1. Use getaddrinfo to replace gethostbyname.
  2. Use getnameinfo with NI_NAMEREQD flag to replace gethostbyaddr.
Test Plan

showhosts function will be used when type show [ports|hosts] option and changeitems function will be used when use ignore [items] option. inetname function are always use. So I compare the command output before revised and after and it seem process normally.

$ systat -netstat
:ignore 8.8.8.8
:show hosts
!dns.google
!8.8.8.8 // Second output

I ignore DNS server of google and can see it ignore successfully. In second output, it also show the ignore IP successfully, but it sometimes show the above output 8.8.8.8 which due to the fail of resolve IP (This happened on both revise and not revised code). I don't know why.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 58546
Build 55434: arc lint + arc unit

Event Timeline

Update according Hiroki advise in D45594

  1. Use "result" instead of "status" name to store the value of getaddrinfo() function. I don't use "error" because it has already error() function in the code.
  2. Use compound literals instead of "hints" variable.

Revise showhosts() for improved efficiency