Page MenuHomeFreeBSD

arp(8): use getifaddrs(3) instead of ioctl(SIOCGIFCONF) etc.
ClosedPublic

Authored by takahiro.kurosawa_gmail.com on Jun 21 2022, 12:31 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 12 2024, 7:00 AM
Unknown Object (File)
Mar 8 2024, 10:44 PM
Unknown Object (File)
Mar 8 2024, 5:16 AM
Unknown Object (File)
Jan 15 2024, 3:13 PM
Unknown Object (File)
Jan 4 2024, 3:01 PM
Unknown Object (File)
Jan 4 2024, 4:01 AM
Unknown Object (File)
Dec 20 2023, 5:43 AM
Unknown Object (File)
Dec 12 2023, 5:35 PM

Details

Summary

The original code had used a fixed-size buffer for ioctl(SIOCGIFCONF),
that might cause the target ifreq spilled from the buffer.

Use the handy getifaddrs(3) to fix the problem.

Test Plan

Run the following script and check the output of ${arp} -s 198.51.100.200 auto pub

#!/bin/sh

naddrs=32
arp=/usr/sbin/arp

ifconfig epair0 create
ifconfig epair0a up
ifconfig epair0b up

i=1
while [ $i -le $naddrs ]
do
        ifconfig epair0a inet 198.51.100.${i}/25 alias
        i=$((i+1))
done

ifconfig epair0b ether
ifconfig epair0b inet 198.51.100.129/25
${arp} -s 198.51.100.200 auto pub
${arp} -n 198.51.100.200

ifconfig epair0a destroy

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable