Page MenuHomeFreeBSD

systat: remove gethostby*() calls
Needs ReviewPublic

Authored by bses30074_gmail.com on Jun 25 2024, 2:21 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Oct 1, 7:28 PM
Unknown Object (File)
Tue, Oct 1, 5:51 PM
Unknown Object (File)
Fri, Sep 27, 2:46 AM
Unknown Object (File)
Tue, Sep 24, 9:01 AM
Unknown Object (File)
Mon, Sep 23, 2:39 AM
Unknown Object (File)
Sat, Sep 21, 6:19 PM
Unknown Object (File)
Tue, Sep 10, 12:23 PM
Unknown Object (File)
Sun, Sep 8, 10:47 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 58339
Build 55227: 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