From nobody Tue Jul 1 13:24:03 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4bWkJM5wxjz60PBZ; Tue, 01 Jul 2025 13:24:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bWkJM3gKZz4Pl9; Tue, 01 Jul 2025 13:24:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1751376243; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yFrdAmwWUpvDRGD3C89otd8z/TMqzPuF6bGe99qpMoQ=; b=NolU7TV1F5PqYAJgYLeLsjlAdca3jjsIssSqGcUCbQlhiL2jZGAESYj9rcTXZppJhMDVgF CXHZgy0TLDH6LJ5CYv18JtW8DiPmP+pfwwL6q46F387lk0aZAxrZMm2R77gHzVaHXk7uUt eM0gVuAfMIdptNxP+GnQST/Z985n2ieHKE7aQhDygw2iQwKGxJOJxpMYcfo2FGZQxPRCQT oDLG9Jv49kfT7ob5Gcfhu9DJv3jwYejLrqZzQVdB0txwcMBtlstZyC6s41ztcp3GaA5RH1 8lBLuNkbRmrulwxePAO27gtDS4J+8nvGl768KhaurFWp4yKHhzmrvzYZKFOGkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1751376243; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yFrdAmwWUpvDRGD3C89otd8z/TMqzPuF6bGe99qpMoQ=; b=QVrt0qRV4ILSop8btN/QO6f3zMtWguR1bwjY0sZTxlIdTvyB1X5wIIa/kSaiNS7KsRHiWt 2m9LNrowspzhfoQXXplOGmMgYIl8eWqZoemYwPOetfC/9F3c/eJJAiJlH81b64+7Duq1L2 C1AHB4ynt9wjCa4/sA4JhVd/4OwLpuPIkkN4j5NFcYiMmW35QkeKWn5rbFZft/2DCp3Rm9 gI77sbUld4IkSnUyHV34HDz2BVixTdThm04l7N8oO/Tk1UDKE1IgKT7bde67WBK8dy25IU bC+NmZky95um/DnGRkH+T0Hx5m8UGnUk3i5IqRZWd05TgmUtx52BFJAIXoYpVw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1751376243; a=rsa-sha256; cv=none; b=aOMWF+P0GUq/SngfF4CP0giykIRkboZD64NS18sxbAR5C1PPyvTyx1AHhNVxFAz7gs/5J8 HFZaQQtRDaoPPU583fv0TwAPRtZHc+aEKSWbDDfmPyz2FLdNn1KiixZkJZoPuqHYp7UJOl +CyHt9R/imB8jKcNy5koJV/9A0eEECGIXugdUrEFtwUB09cwv/jWrbQOoUAuqokd0O/te3 Sk7oea0EVClNRXcTwqxL5UczPAbb2MfNxnToGR41jvF+qv/cb+KmTEfirfFCasAyVyFLp8 w0r54duOkbahQlCl0C1MR0ikyfzCuP6TgqU7sOZsLbQsQyHvNJYms5Pwtx1b3A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4bWkJM3D4gzcBT; Tue, 01 Jul 2025 13:24:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 561DO3LB080331; Tue, 1 Jul 2025 13:24:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 561DO30x080328; Tue, 1 Jul 2025 13:24:03 GMT (envelope-from git) Date: Tue, 1 Jul 2025 13:24:03 GMT Message-Id: <202507011324.561DO30x080328@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Eugene Grosbein Subject: git: b1b17432aa1b - main - ifconfig_netlink.c: optimise non-listing case List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: eugen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b1b17432aa1be670564161232d110461a5dde4ce Auto-Submitted: auto-generated The branch main has been updated by eugen: URL: https://cgit.FreeBSD.org/src/commit/?id=b1b17432aa1be670564161232d110461a5dde4ce commit b1b17432aa1be670564161232d110461a5dde4ce Author: Alexander V. Chernikov AuthorDate: 2025-07-01 13:16:57 +0000 Commit: Eugene Grosbein 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) {