Page MenuHomeFreeBSD

rarpd: remove gethostby*() calls
Needs ReviewPublic

Authored by yanhaowang on Jul 7 2024, 10:35 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Feb 15, 6:43 AM
Unknown Object (File)
Jan 30 2026, 6:09 AM
Unknown Object (File)
Jan 27 2026, 5:29 AM
Unknown Object (File)
Jan 24 2026, 1:35 PM
Unknown Object (File)
Jan 22 2026, 12:04 PM
Unknown Object (File)
Jan 19 2026, 8:26 PM
Unknown Object (File)
Jan 17 2026, 2:10 PM
Unknown Object (File)
Jan 15 2026, 4:23 AM
Subscribers

Details

Reviewers
hrs
lwhsu
Summary
  1. Use getaddrinfo to replace gethostbyname.
  2. Update choose_ipaddr() function to take a more general parameter. Use struct addrinfo pointer as address list.
Test Plan

I use "nemesis" pkg to simulate rarp packet and use "tcpdump" to capture the send and response rarp packet and it seem work fine.

  1. Add a simulate MAC on "/etc/ethers" and add hosts.
$ cat /etc/ethers 
00:0c:29:02:ba:a1 mytesthost

$ cat /etc/hosts
192.168.42.128 mytesthost
  1. Then simulate with "nemesis" like below output. I also add some output about choose_ipaddr function to see if it output same as before.
// Same output on both revsied and not revised code
$ sudo rarpd -a -f -s
IP address: 192.168.42.128

$ sudo nemesis arp -d le0 -S 192.168.42.128 -D 192.168.42.255 -h 00:0c:29:02:ba:a1 -m 00:0c:29:02:ba:a1 -R

$ sudo tcpdump -i le0 ether proto 0x8035 -vvv
tcpdump: listening on le0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
11:25:58.921947 ARP, Ethernet (len 6), IPv4 (len 4), Reverse Request who-is mytesthost tell mytesthost, length 28
11:25:58.922065 ARP, Ethernet (len 6), IPv4 (len 4), Reverse Reply mytesthost at mytesthost, length 28

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Warnings
SeverityLocationCodeMessage
Warningusr.sbin/rarpd/rarpd.c:CHMOD1Invalid Executable
Unit
No Test Coverage
Build Status
Buildable 58544
Build 55432: arc lint + arc unit