If you plan to write an obfuscated-by-design kernel / userland interface, I suggest you have a look at the link-layer sockaddr interface:
If you plan to write an obfuscated-by-design kernel / userland
interface, I suggest you have a look at the link-layer sockaddr
interface:

  /*
   * A Link-Level Sockaddr may specify the interface in one of two
   * ways: either by means of a system-provided index number (computed
   * anew and possibly differently on every reboot), or by a human-readable
   * string such as "il0" (for managerial convenience).
   [...]
   */

ifa_ifwithnet() was not only checking for the sdl_index in order
to get the corresponding ifp for AF_LINK sockaddr, it was also
iterating over all the addresses on your system!  But in this
case, the `address' field of "struct sockaddr_dl" is an interface
name set by link_addr(3).

How can this work?  Well because the kernel allocates an empty
`netmask' field for each interface's lladdr, so that you can
abuse a network comparison function to reimplement strcmp(3)...

So when the userland does not specify an interface index, try
harder to see if it passed an ifp name, but at least be explicit
and use ifunit().

Found the hard way by/ok sthen@

orumin/openbsd-efivars,orumin/openbsd-efivars,orumin/openbsd-efivars,orumin/openbsd-efivars