git: 8f43b39b1c38 - stable/14 - ifconfig_netlink.c: MFC: optimise non-listing case
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 13 Jul 2025 15:40:22 UTC
The branch stable/14 has been updated by eugen:
URL: https://cgit.FreeBSD.org/src/commit/?id=8f43b39b1c38bde166314d4682daae7bf15a5445
commit 8f43b39b1c38bde166314d4682daae7bf15a5445
Author: Alexander V. Chernikov <melifaro@FreeBSD.org>
AuthorDate: 2025-07-01 13:16:57 +0000
Commit: Eugene Grosbein <eugen@FreeBSD.org>
CommitDate: 2025-07-13 15:38:58 +0000
ifconfig_netlink.c: MFC: 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
(cherry picked from commit b1b17432aa1be670564161232d110461a5dde4ce)
---
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 03fe1e418082..11b3595dafe6 100644
--- a/sbin/ifconfig/ifconfig_netlink.c
+++ b/sbin/ifconfig/ifconfig_netlink.c
@@ -162,7 +162,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 = {};
@@ -170,6 +170,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);
@@ -457,7 +459,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) {