Bug#740509: ifconfig: ioctl(SIOCGIFINFO_IN6): No such device or address
I think I've found a *different* bug while looking for this.
A sysctl { CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, 0 } from
kfreebsd-i386 userland on kfreebsd-amd64 9.0 or 10.0 kernel, never
seems to fail with ENOMEM! Regardless of given buffer size:
Calling sysctl with buffer of size 1024
sysctl() returned 672 bytes
Got message of length 152
Got message of length 152
Got message of length 152
Got message of length 152
Got message of length 64
which correctly describes four network interfaces (followed by a
shorter NEWADDR message).
It goes wrong when the buffer is too small:
Calling sysctl with buffer of size 512
sysctl() returned 512 bytes
Got message of length 152
Got message of length 152
Got message of length 152
Message of length 152 overflows the buffer!
Calling sysctl with buffer of size 128
sysctl() returned 128 bytes
Message of length 152 overflows the buffer!
The same compiled on kfreebsd-amd64 userland however, also with
four network interfaces:
Calling sysctl with buffer of size 512
sysctl() failed with errno 12
which is correct behaviour.
GNU libc uses an initial buffer size of 512, re-trying with the buffer
doubling in size in case of ENOMEM. My own test case is attached.
(Note that the sysctl shrinks bufsize to a smaller value if the
response fits in the buffer; leaves it unchanged otherwise).
Regards,
--
Steven Chamberlain
steven@pyro.eu.org
Reply to: