Page MenuHomeFreeBSD

arp: remove gethostby*() calls
Needs RevisionPublic

Authored by bses30074_gmail.com on Fri, Jun 14, 11:26 AM.
Tags
None
Referenced Files
F86979867: D45594.id139875.diff
Fri, Jun 28, 12:08 AM
Unknown Object (File)
Sun, Jun 16, 4:34 PM
Unknown Object (File)
Fri, Jun 14, 8:24 PM
Subscribers

Details

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

Diff Detail

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

Event Timeline

usr.sbin/arp/arp.c
262–263

Should I use memset to replace the bzero function?

bses30074_gmail.com retitled this revision from arp: remove "gethostby*" function to arp: remove gethostby*() calls.Sun, Jun 16, 3:03 AM
bses30074_gmail.com edited the summary of this revision. (Show Details)

Revise error code

We should use EAI_AGAIN instead of TRY_AGAIN error code while using getnameinfo.

hrs requested changes to this revision.Fri, Jun 28, 12:38 AM

The change basically looks good to me, but I added some comments.

usr.sbin/arp/arp.c
263
hints = (struct addrinfo){
    .ai_family = AF_INET
};

is enough for memset() + assignments.

619

sizeof() should be replaced with addr->sin_len.

I would recommend to change the type of addr to struct sockaddr, and define struct sockaddr_in *sin = (struct sockaddr_in *)addr at the top of this function to use it as sockaddr_in. This requires additional changes in search() and action_fn, though.

usr.sbin/arp/arp_netlink.c
187

The same as arp.c

This revision now requires changes to proceed.Fri, Jun 28, 12:38 AM