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 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 <[email protected]>
---
sysdep/linux/netlink.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/sysdep/linux/netlink.c b/sysdep/linux/netlink.c
index 844aefa16..a5493feed 100644
--- a/sysdep/linux/netlink.c
+++ b/sysdep/linux/netlink.c
@@ -172,12 +172,19 @@ nl_request_dump_link(void)
struct {
struct nlmsghdr nh;
struct ifinfomsg ifi;
+ struct {
+ struct rtattr hdr;
+ u32 val;
+ } attr;
} req = {
.nh.nlmsg_type = RTM_GETLINK,
- .nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)),
+ .nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.ifi) + sizeof(req.attr)),
.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP,
.nh.nlmsg_seq = ++(nl_scan.seq),
.ifi.ifi_family = AF_UNSPEC,
+ .attr.hdr.rta_len = sizeof(req.attr),
+ .attr.hdr.rta_type = IFLA_EXT_MASK,
+ .attr.val = RTEXT_FILTER_SKIP_STATS,
};
send(nl_scan.fd, &req, sizeof(req), 0);
--
2.51.0