From: "Asbjørn Sloth Tønnesen" <ast@fiberby.net>
To: "Jason A . Donenfeld" <Jason@zx2c4.com>
Cc: "Asbjørn Sloth Tønnesen" <ast@fiberby.net>, wireguard@lists.zx2c4.com
Subject: [PATCH wireguard-tools v4 3/3] ipc: linux: skip statistics on netdevice listing
Date: Thu, 12 Mar 2026 21:44:01 +0000 [thread overview]
Message-ID: <20260312214405.589127-4-ast@fiberby.net> (raw)
In-Reply-To: <20260312214405.589127-1-ast@fiberby.net>
Gathering interface statistics can be a relatively expensive operation
on certain systems as it requires iterating over all the cpus.
This patch instructs the kernel to not include netdevice statistics,
in the netdevice listing.
Kernel-side support for this was added in Linux v4.4 in commit
d5566fd72ec1 ("rtnetlink: RTEXT_FILTER_SKIP_STATS support to avoid
dumping inet/inet6 stats"), this saves 368 bytes of statistics.
In the Linux v6.19 commit 105bae321862 ("rtnetlink: honor
RTEXT_FILTER_SKIP_STATS in IFLA_STATS"), it is expanded to skip more
statistics bringing the savings to 800 bytes per netdevice.
Despite the subject prefix, this patch also applies to the
embeddable C library, so the two implementations stay in sync.
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
---
contrib/embeddable-wg-library/wireguard.c | 1 +
src/ipc-linux.h | 1 +
2 files changed, 2 insertions(+)
diff --git a/contrib/embeddable-wg-library/wireguard.c b/contrib/embeddable-wg-library/wireguard.c
index eff441b..686cd3a 100644
--- a/contrib/embeddable-wg-library/wireguard.c
+++ b/contrib/embeddable-wg-library/wireguard.c
@@ -957,6 +957,7 @@ static int fetch_device_names(struct string_list *list)
nlh->nlmsg_seq = seq;
ifm = mnl_nlmsg_put_extra_header(nlh, sizeof(*ifm));
ifm->ifi_family = AF_UNSPEC;
+ mnl_attr_put_u32(nlh, IFLA_EXT_MASK, RTEXT_FILTER_SKIP_STATS);
linkinfo_nest = mnl_attr_nest_start(nlh, IFLA_LINKINFO);
mnl_attr_put_strz(nlh, IFLA_INFO_KIND, WG_GENL_NAME);
diff --git a/src/ipc-linux.h b/src/ipc-linux.h
index 45bb55c..791eb84 100644
--- a/src/ipc-linux.h
+++ b/src/ipc-linux.h
@@ -94,6 +94,7 @@ static int kernel_get_wireguard_interfaces(struct string_list *list)
nlh->nlmsg_seq = seq;
ifm = mnl_nlmsg_put_extra_header(nlh, sizeof(*ifm));
ifm->ifi_family = AF_UNSPEC;
+ mnl_attr_put_u32(nlh, IFLA_EXT_MASK, RTEXT_FILTER_SKIP_STATS);
linkinfo_nest = mnl_attr_nest_start(nlh, IFLA_LINKINFO);
mnl_attr_put_strz(nlh, IFLA_INFO_KIND, WG_GENL_NAME);
--
2.53.0
prev parent reply other threads:[~2026-03-12 21:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-12 21:43 [PATCH wireguard-tools v4 0/3] ipc: linux: kernel-side netdevice filtering Asbjørn Sloth Tønnesen
2026-03-12 21:43 ` [PATCH wireguard-tools v4 1/3] ipc: linux: filter netdevices kernel-side Asbjørn Sloth Tønnesen
2026-03-12 21:44 ` [PATCH wireguard-tools v4 2/3] ipc: linux: remove user-space netdevice filtering Asbjørn Sloth Tønnesen
2026-03-12 21:44 ` Asbjørn Sloth Tønnesen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260312214405.589127-4-ast@fiberby.net \
--to=ast@fiberby.net \
--cc=Jason@zx2c4.com \
--cc=wireguard@lists.zx2c4.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox