From nobody Tue Feb 10 05:10:17 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571363996; cv=none; d=zoho.com; s=zohoarc; b=mmxpUlaLWpLU0yfcuOOdnfNEe11VlCSAPECvEBG5RQ1TdCFxNI2+BkXFKKTThUAGK1zLwVJx3FRMjGh9Z9cOmGpuEWVooZK3l6mX+t6Gijwlp/gMmgwnqRisCThuRzM1yi+Rt7/lsqhFukaJmWDHZjqYCVIajR/oQgfLbyt5Rs4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571363996; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yDw2Sfq8e+nupVR+gpAfA428/vTnYb4Gg/qVsH5MZgo=; b=ZCjl/VNKPmvdAM1OKF0nxk4dY72ueKRo3Nmgh4CfmPLA4d/WtV4MQNRfnoAPzmPkkY01hgV6FzsJ6RswEtXFcYaST917kvPSuKuB8jG8t37ev2cxU01UQEH/kq6hr1EAiRtIUl5tptzebATkaPUBwY4TGDCPj3QSYoqxpQQZ0+g= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15713639965699.650862163330203; Thu, 17 Oct 2019 18:59:56 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C84B5300157A; Fri, 18 Oct 2019 01:59:54 +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 9AFCF60BE1; Fri, 18 Oct 2019 01:59:54 +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 50A234E58A; Fri, 18 Oct 2019 01:59:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9I1xrvI027696 for ; Thu, 17 Oct 2019 21:59:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4AF5160C63; Fri, 18 Oct 2019 01:59:53 +0000 (UTC) Received: from tilapia.redhat.com (ovpn-124-27.rdu2.redhat.com [10.10.124.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0769560C4E for ; Fri, 18 Oct 2019 01:59:52 +0000 (UTC) From: Laine Stump To: libvir-list@redhat.com Date: Thu, 17 Oct 2019 21:59:48 -0400 Message-Id: <20191018015949.457017-2-laine@laine.org> In-Reply-To: <20191018015949.457017-1-laine@laine.org> References: <20191018015949.457017-1-laine@laine.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCHv2 1/2] util: allow sending mac addr to virNetNewLink without ifindex 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 18 Oct 2019 01:59:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" From: Laine Stump Although until now, any use of the extra_args argument (a pointer to a struct containing extra attributes to add the the RTM_NEWLINK message) would always have the ifindex and mac set, so the code could assume it was safe to add both to the message if extra_args !=3D NULL. There is now a use for setting a MAC address in the RTM_NEWLINK without setting the ifindex, so we should check each of these separately. Signed-off-by: Laine Stump Reviewed-by: Jiri Denemark --- src/util/virnetlink.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c index ab41b57672..f18946061c 100644 --- a/src/util/virnetlink.c +++ b/src/util/virnetlink.c @@ -548,9 +548,14 @@ virNetlinkNewLink(const char *ifname, NETLINK_MSG_NEST_END(nl_msg, linkinfo); =20 if (extra_args) { - NETLINK_MSG_PUT(nl_msg, IFLA_LINK, + if (extra_args->ifindex) { + NETLINK_MSG_PUT(nl_msg, IFLA_LINK, sizeof(uint32_t), extra_args->ifindex); - NETLINK_MSG_PUT(nl_msg, IFLA_ADDRESS, VIR_MAC_BUFLEN, extra_args->= mac); + } + if (extra_args->mac) { + NETLINK_MSG_PUT(nl_msg, IFLA_ADDRESS, + VIR_MAC_BUFLEN, extra_args->mac); + } } =20 if (virNetlinkCommand(nl_msg, &resp, &buflen, 0, 0, NETLINK_ROUTE, 0) = < 0) --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list