Page MenuHomeFreeBSD

libc: Shortcut if_indextoname() if index == 0
ClosedPublic

Authored by kp on Apr 21 2020, 7:57 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 23 2023, 12:40 AM
Unknown Object (File)
Nov 12 2023, 4:37 AM
Unknown Object (File)
Jul 10 2023, 10:13 PM
Unknown Object (File)
Jul 10 2023, 10:11 PM
Unknown Object (File)
Jul 10 2023, 10:10 PM
Unknown Object (File)
Jul 8 2023, 11:24 AM
Unknown Object (File)
Jun 24 2023, 11:22 PM
Unknown Object (File)
Jun 21 2023, 11:19 AM
Subscribers

Details

Summary

If the index we're trying to convert is 0 we can avoid a potentially
expensive call to getifaddrs(). No interface has an ifindex of zero, so
we can handle this as an error: set the errno to ENXIO and return NULL.

Submitted by: Nick Rogers
Sponsed by: RG Nets
MFC after: 2 weeks

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Is there really a typical use case for this call?

Yeah, pfctl calls this, and there are flows where it gets called with an index of 0. There's no point in asking the kernel, that only takes time and doesn't change the answer.
We could take this shortcut in pfctl, but it makes more sense to do add the shortcut for everyone.

This revision is now accepted and ready to land.Apr 23 2020, 10:56 AM
This revision was automatically updated to reflect the committed changes.