* [PATCH iproute2-next v2 1/2] iplink: print warning for missing VF data
@ 2021-01-26 17:40 Edwin Peer
2021-01-26 17:40 ` [PATCH iproute2-next v2 2/2] iplink: filter stats using RTEXT_FILTER_SKIP_STATS Edwin Peer
2021-01-28 3:51 ` [PATCH iproute2-next v2 1/2] iplink: print warning for missing VF data David Ahern
0 siblings, 2 replies; 3+ messages in thread
From: Edwin Peer @ 2021-01-26 17:40 UTC (permalink / raw)
To: netdev
Cc: Edwin Peer, Jakub Kicinski, Andrew Gospodarek, Michael Chan,
Stephen Hemminger, Michal Kubecek, David Ahern
[-- Attachment #1: Type: text/plain, Size: 1627 bytes --]
The kernel might truncate VF info in IFLA_VFINFO_LIST. Compare the
expected number of VFs in IFLA_NUM_VF to how many were found in the
list and warn accordingly.
Signed-off-by: Edwin Peer <edwin.peer@broadcom.com>
---
ip/ipaddress.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 571346b15cc3..0bbcee2b3bb2 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -922,6 +922,7 @@ int print_linkinfo(struct nlmsghdr *n, void *arg)
const char *name;
unsigned int m_flag = 0;
SPRINT_BUF(b1);
+ bool truncated_vfs = false;
if (n->nlmsg_type != RTM_NEWLINK && n->nlmsg_type != RTM_DELLINK)
return 0;
@@ -1199,15 +1200,18 @@ int print_linkinfo(struct nlmsghdr *n, void *arg)
if ((do_link || show_details) && tb[IFLA_VFINFO_LIST] && tb[IFLA_NUM_VF]) {
struct rtattr *i, *vflist = tb[IFLA_VFINFO_LIST];
- int rem = RTA_PAYLOAD(vflist);
+ int rem = RTA_PAYLOAD(vflist), count = 0;
open_json_array(PRINT_JSON, "vfinfo_list");
for (i = RTA_DATA(vflist); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
open_json_object(NULL);
print_vfinfo(fp, ifi, i);
close_json_object();
+ count++;
}
close_json_array(PRINT_JSON, NULL);
+ if (count != rta_getattr_u32(tb[IFLA_NUM_VF]))
+ truncated_vfs = true;
}
if (tb[IFLA_PROP_LIST]) {
@@ -1228,6 +1232,9 @@ int print_linkinfo(struct nlmsghdr *n, void *arg)
print_string(PRINT_FP, NULL, "%s", "\n");
fflush(fp);
+ /* prettier here if stderr and stdout go to the same place */
+ if (truncated_vfs)
+ fprintf(stderr, "Truncated VF list: %s\n", name);
return 1;
}
--
2.30.0
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4160 bytes --]
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH iproute2-next v2 2/2] iplink: filter stats using RTEXT_FILTER_SKIP_STATS
2021-01-26 17:40 [PATCH iproute2-next v2 1/2] iplink: print warning for missing VF data Edwin Peer
@ 2021-01-26 17:40 ` Edwin Peer
2021-01-28 3:51 ` [PATCH iproute2-next v2 1/2] iplink: print warning for missing VF data David Ahern
1 sibling, 0 replies; 3+ messages in thread
From: Edwin Peer @ 2021-01-26 17:40 UTC (permalink / raw)
To: netdev
Cc: Edwin Peer, Jakub Kicinski, Andrew Gospodarek, Michael Chan,
Stephen Hemminger, Michal Kubecek, David Ahern
[-- Attachment #1: Type: text/plain, Size: 1327 bytes --]
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>
---
ip/ipaddress.c | 6 +++++-
ip/iplink.c | 3 +++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 0bbcee2b3bb2..75511881050d 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -1882,9 +1882,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 27c9be442a7a..6a973213dc11 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -1116,6 +1116,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)
--
2.30.0
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4160 bytes --]
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH iproute2-next v2 1/2] iplink: print warning for missing VF data
2021-01-26 17:40 [PATCH iproute2-next v2 1/2] iplink: print warning for missing VF data Edwin Peer
2021-01-26 17:40 ` [PATCH iproute2-next v2 2/2] iplink: filter stats using RTEXT_FILTER_SKIP_STATS Edwin Peer
@ 2021-01-28 3:51 ` David Ahern
1 sibling, 0 replies; 3+ messages in thread
From: David Ahern @ 2021-01-28 3:51 UTC (permalink / raw)
To: Edwin Peer, netdev
Cc: Jakub Kicinski, Andrew Gospodarek, Michael Chan,
Stephen Hemminger, Michal Kubecek
On 1/26/21 10:40 AM, Edwin Peer wrote:
> The kernel might truncate VF info in IFLA_VFINFO_LIST. Compare the
> expected number of VFs in IFLA_NUM_VF to how many were found in the
> list and warn accordingly.
>
> Signed-off-by: Edwin Peer <edwin.peer@broadcom.com>
> ---
> ip/ipaddress.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/ip/ipaddress.c b/ip/ipaddress.c
> index 571346b15cc3..0bbcee2b3bb2 100644
> --- a/ip/ipaddress.c
> +++ b/ip/ipaddress.c
> @@ -922,6 +922,7 @@ int print_linkinfo(struct nlmsghdr *n, void *arg)
> const char *name;
> unsigned int m_flag = 0;
> SPRINT_BUF(b1);
> + bool truncated_vfs = false;
>
> if (n->nlmsg_type != RTM_NEWLINK && n->nlmsg_type != RTM_DELLINK)
> return 0;
> @@ -1199,15 +1200,18 @@ int print_linkinfo(struct nlmsghdr *n, void *arg)
>
> if ((do_link || show_details) && tb[IFLA_VFINFO_LIST] && tb[IFLA_NUM_VF]) {
> struct rtattr *i, *vflist = tb[IFLA_VFINFO_LIST];
> - int rem = RTA_PAYLOAD(vflist);
> + int rem = RTA_PAYLOAD(vflist), count = 0;
>
> open_json_array(PRINT_JSON, "vfinfo_list");
> for (i = RTA_DATA(vflist); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
> open_json_object(NULL);
> print_vfinfo(fp, ifi, i);
> close_json_object();
> + count++;
> }
> close_json_array(PRINT_JSON, NULL);
> + if (count != rta_getattr_u32(tb[IFLA_NUM_VF]))
> + truncated_vfs = true;
> }
>
> if (tb[IFLA_PROP_LIST]) {
> @@ -1228,6 +1232,9 @@ int print_linkinfo(struct nlmsghdr *n, void *arg)
>
> print_string(PRINT_FP, NULL, "%s", "\n");
> fflush(fp);
> + /* prettier here if stderr and stdout go to the same place */
> + if (truncated_vfs)
> + fprintf(stderr, "Truncated VF list: %s\n", name);
> return 1;
> }
>
>
LGTM. I think it should go to the main branch versus -next.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-01-28 4:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-26 17:40 [PATCH iproute2-next v2 1/2] iplink: print warning for missing VF data Edwin Peer
2021-01-26 17:40 ` [PATCH iproute2-next v2 2/2] iplink: filter stats using RTEXT_FILTER_SKIP_STATS Edwin Peer
2021-01-28 3:51 ` [PATCH iproute2-next v2 1/2] iplink: print warning for missing VF data David Ahern
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).