[PATCH v2 4/4] Netlink: Skip stats in device dumps
Asbjørn Sloth Tønnesen
ast at 2e8.dk
Mon May 18 10:59:23 CEST 2026
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 omit device statistics,
when scanning devices, as the statistics aren't used by BIRD.
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 device.
Signed-off-by: Asbjørn Sloth Tønnesen <ast at 2e8.dk>
---
sysdep/linux/netlink.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/sysdep/linux/netlink.c b/sysdep/linux/netlink.c
index 02efa0f6d..5b437b0e6 100644
--- a/sysdep/linux/netlink.c
+++ b/sysdep/linux/netlink.c
@@ -1412,7 +1412,7 @@ kif_do_scan(struct kif_proto *p UNUSED)
if_start_update();
- nl_request_dump_link(AF_UNSPEC, 0);
+ nl_request_dump_link(AF_UNSPEC, RTEXT_FILTER_SKIP_STATS);
while (h = nl_get_scan())
if (h->nlmsg_type == RTM_NEWLINK || h->nlmsg_type == RTM_DELLINK)
nl_parse_link(h, 1);
@@ -2557,7 +2557,8 @@ kbr_do_vlan_scan(struct kbr_proto *p)
struct nlmsghdr *h;
- nl_request_dump_link(AF_BRIDGE, RTEXT_FILTER_BRVLAN);
+ nl_request_dump_link(AF_BRIDGE, RTEXT_FILTER_BRVLAN |
+ RTEXT_FILTER_SKIP_STATS);
while (h = nl_get_scan())
{
if (h->nlmsg_type == RTM_NEWLINK || h->nlmsg_type == RTM_DELLINK)
--
2.53.0
More information about the Bird-users
mailing list