]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
iplink: filter stats using RTEXT_FILTER_SKIP_STATS
authorEdwin Peer <edwin.peer@broadcom.com>
Sun, 11 Jun 2023 10:57:38 +0000 (13:57 +0300)
committerDavid Ahern <dsahern@kernel.org>
Wed, 21 Jun 2023 16:14:01 +0000 (09:14 -0700)
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 <edwin.peer@broadcom.com>
Cc: Edwin Peer <espeer@gmail.com>
Signed-off-by: Gal Pressman <gal@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
ip/ipaddress.c
ip/iplink.c

index 361e6875b6714a0f374d0eaa0445bd9836e6c6e1..8197709d172eff0bd509de51522872f042ecd2bf 100644 (file)
@@ -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;
 
index 690636b65190daa7f9c8d8ebf9337aa48f1dd1c7..6c5d13d53a843a975bc30c6b95e754a18a7bd7d2 100644 (file)
@@ -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)