]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: permit querying a VF MAC address or VLAN tag by itself
authorLaine Stump <laine@laine.org>
Fri, 17 Feb 2017 19:28:55 +0000 (14:28 -0500)
committerLaine Stump <laine@laine.org>
Fri, 24 Mar 2017 04:34:08 +0000 (00:34 -0400)
virNetDevParseVfConfig() assumed that both the MAC address and VLAN
tag pointers were valid, so even if you only wanted one or the other,
you would need a variable to hold the returned value for both. This
patch checks each for a NULL pointer before filling it in.

src/util/virnetdev.c

index 455239ad9b3af738b0745932a18b6096df84354a..2a0dabce7fa345162e72d6a436133601a9dd9ba7 100644 (file)
@@ -1603,7 +1603,7 @@ virNetDevParseVfConfig(struct nlattr **tb, int32_t vf, virMacAddrPtr mac,
             goto cleanup;
         }
 
-        if (tb[IFLA_VF_MAC]) {
+        if (mac && tb[IFLA_VF_MAC]) {
             vf_mac = RTA_DATA(tb_vf[IFLA_VF_MAC]);
             if (vf_mac && vf_mac->vf == vf)  {
                 virMacAddrSetRaw(mac, vf_mac->mac);
@@ -1611,7 +1611,7 @@ virNetDevParseVfConfig(struct nlattr **tb, int32_t vf, virMacAddrPtr mac,
             }
         }
 
-        if (tb[IFLA_VF_VLAN]) {
+        if (vlanid && tb[IFLA_VF_VLAN]) {
             vf_vlan = RTA_DATA(tb_vf[IFLA_VF_VLAN]);
             if (vf_vlan && vf_vlan->vf == vf)  {
                 *vlanid = vf_vlan->vlan;