57 lines
2.4 KiB
Diff
57 lines
2.4 KiB
Diff
From 416267baaa37a7ada0b9fc0f78c7d9be3df3c52e Mon Sep 17 00:00:00 2001
|
|
From: Laine Stump <laine@redhat.com>
|
|
Date: Tue, 20 Oct 2020 22:31:27 -0400
|
|
Subject: [PATCH 073/108] util: fix very old bug/typo in virNetDevParseVfInfo()
|
|
|
|
When this function was recently changed to add in parsing of
|
|
IFLA_VF_STATS, I noticed that the checks for existence of IFLA_VF_MAC
|
|
and IFLA_VF_VLAN were looking in the *wrong array*. The array that
|
|
contains the results of parsing each IFLA_VFINFO in
|
|
tb[IFLA_VFINFO_LIST] is tb_vf, but we were checking for these in tb
|
|
(which is the array containing the results of the toplevel parsing of
|
|
the netlink message, *not* the results of parsing one of the nested
|
|
IFLA_VFINFO's.
|
|
|
|
This incorrect code has been here since the function was originally
|
|
written in 2012. It has only worked all these years due to coincidence
|
|
- the items at those indexes in tb are IFLA_ADDRESS and IFLA_BROADCAST
|
|
(of the *PF*, not of any of its VFs), and those happen to always be
|
|
present in the toplevel netlink message; since we are only looking in
|
|
the incorrect place to check for mere existence of the attribute (but
|
|
are doing the actual retrieval of the attribute from the correct
|
|
place), this bug has no real consequences other than confusing anyone
|
|
trying to understand the code.
|
|
|
|
Signed-off-by: Laine Stump <laine@redhat.com>
|
|
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
(cherry picked from commit 6bd4505dea60b66203d82b3636bc9c51a557629f)
|
|
---
|
|
src/util/virnetdev.c | 4 ++--
|
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
|
|
index ff86aa1fc9..950844b110 100644
|
|
--- a/src/util/virnetdev.c
|
|
+++ b/src/util/virnetdev.c
|
|
@@ -1713,7 +1713,7 @@ virNetDevParseVfConfig(struct nlattr **tb, int32_t vf, virMacAddrPtr mac,
|
|
return rc;
|
|
}
|
|
|
|
- if (mac && tb[IFLA_VF_MAC]) {
|
|
+ if (mac && tb_vf[IFLA_VF_MAC]) {
|
|
vf_mac = RTA_DATA(tb_vf[IFLA_VF_MAC]);
|
|
if (vf_mac && vf_mac->vf == vf) {
|
|
virMacAddrSetRaw(mac, vf_mac->mac);
|
|
@@ -1721,7 +1721,7 @@ virNetDevParseVfConfig(struct nlattr **tb, int32_t vf, virMacAddrPtr mac,
|
|
}
|
|
}
|
|
|
|
- if (vlanid && tb[IFLA_VF_VLAN]) {
|
|
+ if (vlanid && tb_vf[IFLA_VF_VLAN]) {
|
|
vf_vlan = RTA_DATA(tb_vf[IFLA_VF_VLAN]);
|
|
if (vf_vlan && vf_vlan->vf == vf) {
|
|
*vlanid = vf_vlan->vlan;
|
|
--
|
|
2.33.0
|
|
|