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
F115644172: D35536.diff
Sat, Apr 26, 11:39 AM
Unknown Object (File)
Wed, Apr 16, 3:00 PM
Unknown Object (File)
Mar 20 2025, 10:10 AM
Unknown Object (File)
Mar 19 2025, 8:27 PM
Unknown Object (File)
Mar 2 2025, 5:21 AM
Unknown Object (File)
Dec 8 2024, 2:25 AM
Unknown Object (File)
Nov 17 2024, 5:16 AM
Unknown Object (File)
Nov 6 2024, 6:04 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
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 46048
Build 42937: arc lint + arc unit