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)
Thu, Dec 26, 6:54 AM
Unknown Object (File)
Tue, Dec 24, 5:08 AM
Unknown Object (File)
Sat, Dec 14, 5:19 PM
Unknown Object (File)
Nov 25 2024, 7:12 AM
Unknown Object (File)
Nov 23 2024, 4:42 AM
Unknown Object (File)
Nov 22 2024, 2:12 PM
Unknown Object (File)
Nov 21 2024, 8:11 AM
Unknown Object (File)
Nov 15 2024, 10:21 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.