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)
Fri, Jan 24, 5:29 PM
Unknown Object (File)
Tue, Jan 14, 5:10 PM
Unknown Object (File)
Dec 26 2024, 8:28 AM
Unknown Object (File)
Dec 24 2024, 8:16 PM
Unknown Object (File)
Nov 22 2024, 5:24 PM
Unknown Object (File)
Oct 23 2024, 1:31 PM
Unknown Object (File)
Oct 11 2024, 7:10 AM
Unknown Object (File)
Oct 11 2024, 7:10 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 Passed
Unit
No Test Coverage
Build Status
Buildable 58560
Build 55448: arc lint + arc unit