Page MenuHomeFreeBSD

systat: remove gethostby*() calls
Needs ReviewPublic

Authored by yanhaowang on Jun 25 2024, 2:21 AM.
Tags
None
Referenced Files
F106186378: D45723.diff
Thu, Dec 26, 7:58 PM
Unknown Object (File)
Wed, Dec 25, 7:58 PM
Unknown Object (File)
Wed, Dec 25, 8:13 AM
Unknown Object (File)
Fri, Dec 20, 12:18 AM
Unknown Object (File)
Fri, Dec 13, 8:50 AM
Unknown Object (File)
Wed, Dec 4, 11:00 AM
Unknown Object (File)
Nov 26 2024, 7:42 AM
Unknown Object (File)
Nov 22 2024, 8:30 AM
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 58559
Build 55447: 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