The branch main has been updated by eugen: URL: https://cgit.FreeBSD.org/src/commit/?id=b1b17432aa1be670564161232d110461a5dde4ce
commit b1b17432aa1be670564161232d110461a5dde4ce Author: Alexander V. Chernikov <melif...@freebsd.org> AuthorDate: 2025-07-01 13:16:57 +0000 Commit: Eugene Grosbein <eu...@freebsd.org> CommitDate: 2025-07-01 13:16:57 +0000 ifconfig_netlink.c: optimise non-listing case This change produced by melifaro and the commit is concerted with him as he is pretty busy IRL these days. The change restores performance of /sbin/ifconfig utility for non-listing case after it switched from rtsock to netlink(4) API in FreeBSD 14+. PR: 287872 MFC-after: 2 weeks --- sbin/ifconfig/ifconfig_netlink.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sbin/ifconfig/ifconfig_netlink.c b/sbin/ifconfig/ifconfig_netlink.c index c1e6b7be587f..b5badfd585b8 100644 --- a/sbin/ifconfig/ifconfig_netlink.c +++ b/sbin/ifconfig/ifconfig_netlink.c @@ -141,7 +141,7 @@ struct ifmap { * Memory is allocated using snl temporary buffers */ static struct ifmap * -prepare_ifmap(struct snl_state *ss) +prepare_ifmap(struct snl_state *ss, const char *ifname) { struct snl_writer nw = {}; @@ -149,6 +149,8 @@ prepare_ifmap(struct snl_state *ss) struct nlmsghdr *hdr = snl_create_msg_request(&nw, RTM_GETLINK); hdr->nlmsg_flags |= NLM_F_DUMP; snl_reserve_msg_object(&nw, struct ifinfomsg); + if (ifname != NULL) + snl_add_msg_attr_string(&nw, IFLA_IFNAME, ifname); if (! (hdr = snl_finalize_msg(&nw)) || !snl_send_message(ss, hdr)) return (NULL); @@ -455,7 +457,7 @@ list_interfaces_nl(struct ifconfig_args *args) nl_init_socket(&ss); - struct ifmap *ifmap = prepare_ifmap(&ss); + struct ifmap *ifmap = prepare_ifmap(&ss, args->ifname); struct iface **sorted_ifaces = snl_allocz(&ss, ifmap->count * sizeof(void *)); for (uint32_t i = 0, num = 0; i < ifmap->size; i++) { if (ifmap->ifaces[i] != NULL) {