diff options
| author | 2026-03-12 21:44:01 +0000 | |
|---|---|---|
| committer | 2026-11-10 17:31:20 +0100 | |
| commit | ba8556ce45c230906041a1a04450b7b638057917 (patch) | |
| tree | 456b76fbdd60887ecbfa93b2c6e6e4da7049a9a4 | |
| parent | ipc: linux: clean up interface struct (diff) | |
| download | wireguard-tools-master.tar.xz wireguard-tools-master.zip | |
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.
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
| -rw-r--r-- | contrib/embeddable-wg-library/wireguard.c | 1 | ||||
| -rw-r--r-- | src/ipc-linux.h | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/contrib/embeddable-wg-library/wireguard.c b/contrib/embeddable-wg-library/wireguard.c index 5abed1a..a45ade2 100644 --- a/contrib/embeddable-wg-library/wireguard.c +++ b/contrib/embeddable-wg-library/wireguard.c @@ -952,6 +952,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 cbaf104..911b3dc 100644 --- a/src/ipc-linux.h +++ b/src/ipc-linux.h @@ -89,6 +89,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); |
