Skip to contentSkip to conversation

iplink: filter stats using RTEXT_FILTER_SKIP_STATS

PATCH Applied Gal Pressman 2 participants 3 messages Jun 11, 2023 – Jun 21, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iplink: filter stats using RTEXT_FILTER_SKIP_STATS

From: Edwin Peer <[email protected]>

Don't request statistics we do not intend to render. This avoids the possibility of a truncated IFLA_VFINFO_LIST when statistics are not requested as well as the fetching of unnecessary data.

---
Userspace side for kernel submission:
https://lore.kernel.org/all/[email protected]/

It is only a partial "fix", but increases the number of VFs presented before the truncation occurs.

---
 ip/ipaddress.c | 6 +++++-
 ip/iplink.c    | 3 +++
 2 files changed, 8 insertions(+), 1 deletion(-)
ip/ipaddress.c +5 -1
index 361e6875b671..8197709d172e 100644
@@ -2031,9 +2031,13 @@ static int ipaddr_flush(void)
 
 static int iplink_filter_req(struct nlmsghdr *nlh, int reqlen)
 {
+	__u32 filt_mask;
 	int err;
 
-	err = addattr32(nlh, reqlen, IFLA_EXT_MASK, RTEXT_FILTER_VF);
+	filt_mask = RTEXT_FILTER_VF;
+	if (!show_stats)
+		filt_mask |= RTEXT_FILTER_SKIP_STATS;
+	err = addattr32(nlh, reqlen, IFLA_EXT_MASK, filt_mask);
 	if (err)
 		return err;
 
ip/iplink.c +3 -0
index 690636b65190..6c5d13d53a84 100644
@@ -1166,6 +1166,9 @@ int iplink_get(char *name, __u32 filt_mask)
 			  !check_ifname(name) ? IFLA_IFNAME : IFLA_ALT_IFNAME,
 			  name, strlen(name) + 1);
 	}
+
+	if (!show_stats)
+		filt_mask |= RTEXT_FILTER_SKIP_STATS;
 	addattr32(&req.n, sizeof(req), IFLA_EXT_MASK, filt_mask);
 
 	if (rtnl_talk(&rth, &req.n, &answer) < 0)
Signature · 1 line
2.39.1
#1 lore raw
Quoted 9 lines · Gal Pressman

From: Edwin Peer <[email protected]>

Don't request statistics we do not intend to render. This avoids the possibility of a truncated IFLA_VFINFO_LIST when statistics are not requested as well as the fetching of unnecessary data.

Quoted 6 lines

---
Userspace side for kernel submission:
https://lore.kernel.org/all/[email protected]/

It is only a partial "fix", but increases the number of VFs presented before the truncation occurs.

Kernel side was applied.

#2 lore raw
In reply to Gal Pressman
This patch was applied to iproute2/iproute2-next.git (main) by David Ahern <[email protected]>:

Hello:

This patch was applied to iproute2/iproute2-next.git (main) by David Ahern <[email protected]>:

Quoted 11 lines · On Sun, 11 Jun 2023 13:57:38 +0300 you wrote:

From: Edwin Peer <[email protected]>

Don't request statistics we do not intend to render. This avoids the possibility of a truncated IFLA_VFINFO_LIST when statistics are not requested as well as the fetching of unnecessary data.

[...]

Here is the summary with links:
- [iproute2-next] iplink: filter stats using RTEXT_FILTER_SKIP_STATS

    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=bbb1238123a8

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html