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)
Wed, Nov 26, 4:14 AM
Unknown Object (File)
Nov 21 2025, 11:02 PM
Unknown Object (File)
Nov 19 2025, 9:11 AM
Unknown Object (File)
Nov 12 2025, 5:35 AM
Unknown Object (File)
Nov 10 2025, 11:03 AM
Unknown Object (File)
Nov 4 2025, 4:36 PM
Unknown Object (File)
Nov 4 2025, 1:20 PM
Unknown Object (File)
Nov 2 2025, 8:39 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