llvm-project
9c39cd9a - [libc] Read multiple interfaces per netlink message in if_nameindex (#213952)

Commit
1 day ago
[libc] Read multiple interfaces per netlink message in if_nameindex (#213952) This patch changes it to collect all interfaces in the buffer using BlockStore<InterfaceEntry, 16>. I'm storing interface names as a fixed char array (IF_NAMESIZE) in InterfaceEntry so that we're ready for the next step when we reuse the recvfrom buffer across multiple messages. Once all messages in the buffer are parsed, I allocate a single contiguous buffer containing all struct if_nameindex entries and strings. To keep if_nameindex() readable, I've split the implementation into two helper functions: parse_netlink_messages() and build_if_nameindex_list().
Author
Parents
Loading