From nobody Sun May 5 12:00:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603247971; cv=none; d=zohomail.com; s=zohoarc; b=Qoz0LO0zYaivrE+LPUsvCAAy8Sf7+3jmwLBpilOfR/k8oKJSvSjR8owYxfbewlEsETi5PsEb91M5hZPVlQ8d9kDI7/TFoXsnWZcWkULh6dx31VgoaQXDJW/55FHFpZ2WdjoI71/NTy0EKnTnuYxGN01Cot7uQgRLVziEDHLaKa4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603247971; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=8GEyqY1qRu/93/RbiVQVKwmTw7xe3vlail2LNDx/LLU=; b=c7tK9dGI1eUlK96MKMGytBbAihPZLOobDBFoyx4huIpAVkJ6nyAKa2v6jBj3dopfo5hArCIGuDJeWcDwM8ySH07TkYrv4wvm9MoVWZ2GdhUxdrvdI6J+0YWPx1fMlcL83+7/hnG+GrTZkPEYN4dZlNjxxoRkzDxdq8YpzNQJbls= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1603247971394759.6123191264425; Tue, 20 Oct 2020 19:39:31 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-379-c1evRWAaO4ecA5BVHzUJCA-1; Tue, 20 Oct 2020 22:39:28 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8969A18A0734; Wed, 21 Oct 2020 02:39:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 222D75D9F1; Wed, 21 Oct 2020 02:39:21 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 50F588C7C4; Wed, 21 Oct 2020 02:39:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09L2cXDW005497 for ; Tue, 20 Oct 2020 22:38:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id C1F995B4A1; Wed, 21 Oct 2020 02:38:33 +0000 (UTC) Received: from vhost2.laine.org (ovpn-112-130.phx2.redhat.com [10.3.112.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7960276642 for ; Wed, 21 Oct 2020 02:38:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603247970; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=8GEyqY1qRu/93/RbiVQVKwmTw7xe3vlail2LNDx/LLU=; b=I8y4V04QSY77muDRKcvrimJfgwU4uRhQsAz5FV0S5KI8SaX8y5jlYfxfNACAvfbPEdW/YL xd3YlJ4bNy5LTIPBBIinGGtyKVVL6gk26kV+D1QtAC+xTAiSs4bAu95EaqvGLhPxRgxtKs PyBcLEDexs5tNH9Dch2dC9bRW/G6Jhg= X-MC-Unique: c1evRWAaO4ecA5BVHzUJCA-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH] util: fix very old bug/typo in virNetDevParseVfInfo() Date: Tue, 20 Oct 2020 22:38:25 -0400 Message-Id: <20201021023825.2353833-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Michal Privoznik --- 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 e284d62233..591a73cb45 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -1691,7 +1691,7 @@ virNetDevParseVfInfo(struct nlattr **tb, int32_t vf, = virMacAddrPtr mac, return rc; } =20 - if (mac && tb[IFLA_VF_MAC]) { + if (mac && tb_vf[IFLA_VF_MAC]) { vf_mac =3D RTA_DATA(tb_vf[IFLA_VF_MAC]); if (vf_mac && vf_mac->vf =3D=3D vf) { virMacAddrSetRaw(mac, vf_mac->mac); @@ -1699,7 +1699,7 @@ virNetDevParseVfInfo(struct nlattr **tb, int32_t vf, = virMacAddrPtr mac, } } =20 - if (vlanid && tb[IFLA_VF_VLAN]) { + if (vlanid && tb_vf[IFLA_VF_VLAN]) { vf_vlan =3D RTA_DATA(tb_vf[IFLA_VF_VLAN]); if (vf_vlan && vf_vlan->vf =3D=3D vf) { *vlanid =3D vf_vlan->vlan; --=20 2.26.2