From: Edwin Peer Date: Sun, 11 Jun 2023 10:57:38 +0000 (+0300) Subject: iplink: filter stats using RTEXT_FILTER_SKIP_STATS X-Git-Tag: v6.5.0~33^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bbb1238123a8cfe12766ad85f2c0a4aaa32d6610;p=thirdparty%2Fiproute2.git iplink: filter stats using RTEXT_FILTER_SKIP_STATS 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. Signed-off-by: Edwin Peer Cc: Edwin Peer Signed-off-by: Gal Pressman Signed-off-by: David Ahern --- diff --git a/ip/ipaddress.c b/ip/ipaddress.c index 361e6875b..8197709d1 100644 --- a/ip/ipaddress.c +++ b/ip/ipaddress.c @@ -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; diff --git a/ip/iplink.c b/ip/iplink.c index 690636b65..6c5d13d53 100644 --- a/ip/iplink.c +++ b/ip/iplink.c @@ -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)