From nobody Wed May 15 14:49:14 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=1608304196; cv=none; d=zohomail.com; s=zohoarc; b=dcl0hQcaA4mCr7fwgf+FsbcJB7bu0BoQyB84fpiblE3NZP1AUpGiczJ9in8JT0R8RiNI4OFE0IgSJLB+hBcqjMMNNiP/15c7cJsPhOOS36/sUBatg+F7Too97y3ftdGI6L3lZdhRmIOPaL3WCikYYgtsqv3jXBv8IDLgvGGM974= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608304196; 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=C9MzROE8Z0qWbJ+YbMlvhuOpWbOlGMdlnjyx/9v1Z28=; b=CzQodJLkx1O4fyJrNRAN8Ok5IjF0ypPbYbHZS3Gd2sXEudvv1lUJqC6u+zldKfaPkl3f2jLlRkgL0w98GYmRhQiMvtE9D48gDdnW5a0Rq1bJ73OPKjL2LO5SKfsx3VCSrx7nOff19VXn7lZ3Ncs0qMQwvklzRXaATV4pMlERErs= 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 1608304196576664.8117508575663; Fri, 18 Dec 2020 07:09:56 -0800 (PST) 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-373-GOv0FQwrNnS17OKjAmVaJg-1; Fri, 18 Dec 2020 10:09:51 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 42C29190B2A8; Fri, 18 Dec 2020 15:09:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1DF7F2C8FF; Fri, 18 Dec 2020 15:09:45 +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 D5FE81809CA6; Fri, 18 Dec 2020 15:09:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0BIF9Nhj014025 for ; Fri, 18 Dec 2020 10:09:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id B7086100AE31; Fri, 18 Dec 2020 15:09:23 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.214]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A04F100AE2C for ; Fri, 18 Dec 2020 15:09:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304193; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=C9MzROE8Z0qWbJ+YbMlvhuOpWbOlGMdlnjyx/9v1Z28=; b=gmIBak+5Oi1ZPGg7pZd7l2SXscdZ9S42yWkSKTxBKnugOzKUA7EzZ/gFGGNVaM3y/FWGqH 8+NbWiAniaRzj63urPIaaT110TIk4rdzm5npgx8qsMAdtSShOaLPEvOc+JIwxMZh+jdhoR ApS2rcoCGZ72oRN9scidryu2Rl+wxVE= X-MC-Unique: GOv0FQwrNnS17OKjAmVaJg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 01/10] docs: Document ability to configure lease time Date: Fri, 18 Dec 2020 16:09:07 +0100 Message-Id: <8c795199a5a5075bf711cd5e28c5f9cc17f40a23.1608303776.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.15 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" In v6.3.0-rc1~64 we've introduced ability to configure lease time, but forgot to document the feature. Let's fix that. Fixes: 97a0aa246799c97d0a9ca9ecd6b4fd932ae4756c Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1908631 Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/formatnetwork.html.in | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/docs/formatnetwork.html.in b/docs/formatnetwork.html.in index f26909bec8..f5a48d9b92 100644 --- a/docs/formatnetwork.html.in +++ b/docs/formatnetwork.html.in @@ -930,8 +930,12 @@ </dns> <ip address=3D"192.168.122.1" netmask=3D"255.255.255.0" localPtr=3D"yes= "> <dhcp> - <range start=3D"192.168.122.100" end=3D"192.168.122.254"/> - <host mac=3D"00:16:3e:77:e2:ed" name=3D"foo.example.com" ip=3D"192.= 168.122.10"/> + <range start=3D"192.168.122.100" end=3D"192.168.122.254"> + <lease expiry=3D'1' unit=3D'hours'/> + </range> + <host mac=3D"00:16:3e:77:e2:ed" name=3D"foo.example.com" ip=3D"192.= 168.122.10"> + <lease expiry=3D'30' unit=3D'minutes'/> + </host> <host mac=3D"00:16:3e:3e:a9:1a" name=3D"bar.example.com" ip=3D"192.= 168.122.11"/> </dhcp> </ip> @@ -1130,6 +1134,19 @@ since 0.7.3) + +

+ Optionally, range and host element= s can + have lease child element which specifies the le= ase + time through it's attributes expiry and + unit (which accepts seconds, + minutes and hours and defaults to + minutes if omitted). The minimal lease time is 2 + minutes, except when setting an infinite lease time + (expiry=3D'0'). + Since 6.3.0 +

+ --=20 2.26.2 From nobody Wed May 15 14:49:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1608304202; cv=none; d=zohomail.com; s=zohoarc; b=ArG4satmKPiCNlUfZwUZOEeYnnFf3PWMZkhm4mK+0pzqRN7lmHn5xs1t11ctn3I1eSqJF8H6seXW1SxPOKWQxwEi3QmMHDqLuZVCaaY2Vv1FkaSxsqJkKpfkX23FKUQpmPiuH1jYLcnW01PLHV/TmLQcyIL5bjGqR2KkBNZgmUE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608304202; 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=XsOQuBNYn8xEBbVfaOMuiBMquBEhUc7HD90tAW7bM2s=; b=EJE5LT3SS/Q/fkeyQ/tpRdTjWixm3QuMgXkeOCYlFyXk9orP3veMzv5jsLC+mIWxJxD+17wgk8doP7Rtx1be4NCLBr1Phe6q0vxSlJr8JJ4JSX9F0JhiXwUwo2LYsfowqkUjNeNboTPzy4ZS8YCJ+T8tolZLTFpCtI3f1dX38gY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1608304202638621.4978248326635; Fri, 18 Dec 2020 07:10:02 -0800 (PST) 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-168-AfMV0vgmOOajCIeDXGRc9w-1; Fri, 18 Dec 2020 10:09:55 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 12512800D55; Fri, 18 Dec 2020 15:09:49 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E2E9560C15; Fri, 18 Dec 2020 15:09:48 +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 AFE7E1809CA7; Fri, 18 Dec 2020 15:09:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0BIF9OoQ014032 for ; Fri, 18 Dec 2020 10:09:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id BF11E100AE2D; Fri, 18 Dec 2020 15:09:24 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.214]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1FD53100AE2C for ; Fri, 18 Dec 2020 15:09:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304198; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=XsOQuBNYn8xEBbVfaOMuiBMquBEhUc7HD90tAW7bM2s=; b=dmNB4vXDBuya8NvU3RIA+sqQgg5teLteZqXyCwYIfEvlHTmvOloRLA/mkQxHohUyIO8Hnf EIHDKSvFXu3gk4d2mTfK5whgYxB5z5Lzqq+yanyznF04I/cxOhK9+/kgebXq9xPXQi36nj o7SyAWtCgCH6JWij3h4kMikcQleaE9g= X-MC-Unique: AfMV0vgmOOajCIeDXGRc9w-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 02/10] leaseshelper: Report errors on failure Date: Fri, 18 Dec 2020 16:09:08 +0100 Message-Id: <7a24f9a194f69b6815eaa7c06385aab62ed23d05.1608303776.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.12 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" If leasehelper fails all that we are left with is a simple error message produced by dnsmasq: lease-init script returned exit code 1 This is because the leasehelper did not write any message to stderr. According to dnsmasq's manpage, whenever it's invoking leasehelper the stderr is kept open: All file descriptors are closed except stdin, which is open to /dev/null, and stdout and stderr which capture output for logging by dnsmasq. As debugging leasehelper is not trivial (because dnsmasq invokes it with plenty of env vars set - that's how data is passed onto helper), let's print an error into stderr if exiting with an error. And since we are not calling public APIs, we have to call virDispatchError() explicitly and since we don't have any connection open, we have to pass NULL. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/network/leaseshelper.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/network/leaseshelper.c b/src/network/leaseshelper.c index 732dd09610..c20e63efa9 100644 --- a/src/network/leaseshelper.c +++ b/src/network/leaseshelper.c @@ -253,6 +253,8 @@ main(int argc, char **argv) rv =3D EXIT_SUCCESS; =20 cleanup: + if (rv !=3D EXIT_SUCCESS) + virDispatchError(NULL); if (pid_file_fd !=3D -1) virPidFileReleasePath(pid_file, pid_file_fd); =20 --=20 2.26.2 From nobody Wed May 15 14:49:14 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=1608304569; cv=none; d=zohomail.com; s=zohoarc; b=lgANkvqFC9icrCv07hGT+p31JmwdLMHewvteZIuFdBDYisVUUwd3WtjNi3RJcdFSX67nTuJJmRtmgLBt+F7ODUNFBRIumJ/FVHAjCiOyXv5BlzJNVlMu4aBelqfyrqah8SJ1OXm8Itzfnasy5zlnVhrA0Q1UnvgBml2yZLsozGI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608304569; 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=JZzWHQ6QjLxFCw0eU9CJfA4ht2nikYK2TJdfpYdKGwo=; b=J4E6ZdSNs9JTUPRh2Pvav4vT9skvDn5DLQu1vFV39i+a+1YQIcwIlXRIuJV7oceXTM+pIqSLmG5OS+xMRaFLamyKffUE4E50H+42SMXmV8/F8Md7McMiwVv4dp/gkT9shVv46o3y/2tov1hA0eun/VrWRNAwNTYRvgy80h283v4= 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 1608304569672424.4183516451353; Fri, 18 Dec 2020 07:16:09 -0800 (PST) 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-462-nKJItK-1MtK6fJw1IqhFsw-1; Fri, 18 Dec 2020 10:10:00 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2E220190B2B3; Fri, 18 Dec 2020 15:09:52 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F3C5310023AB; Fri, 18 Dec 2020 15:09:51 +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 BBF031809CAA; Fri, 18 Dec 2020 15:09:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0BIF9POK014043 for ; Fri, 18 Dec 2020 10:09:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id B6431100AE2D; Fri, 18 Dec 2020 15:09:25 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.214]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2743F100AE2C for ; Fri, 18 Dec 2020 15:09:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304326; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=JZzWHQ6QjLxFCw0eU9CJfA4ht2nikYK2TJdfpYdKGwo=; b=VkNlmCOpZYq0k3ZUM1Z+HV8d2t0cEOjOVZZBhHcaDb4COxWMsoDXqeNSGkZ/lT6rJmcIMl u/VgqLletkXpdsDXq5gO9jOxw4zd0JED/mbCE8QTEt6jfRIZp+LHRAxCy8ieHe70eNWsrs w0LDzJesZslQSk8Sbjwq+TfO4FqrG5c= X-MC-Unique: nKJItK-1MtK6fJw1IqhFsw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 03/10] virlease: Rework virLeaseReadCustomLeaseFile() Date: Fri, 18 Dec 2020 16:09:09 +0100 Message-Id: <80940e76094b9fb77930d5e40da7a2f87e209a16.1608303776.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.84 on 10.5.11.22 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" There are some variables which are used only inside the single loop the function has. Let's declare them inside the loop body to make that obvious. Also, fix indendation. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/util/virlease.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/util/virlease.c b/src/util/virlease.c index aeb605862f..f01cf5b9bd 100644 --- a/src/util/virlease.c +++ b/src/util/virlease.c @@ -50,11 +50,7 @@ virLeaseReadCustomLeaseFile(virJSONValuePtr leases_array= _new, { g_autofree char *lease_entries =3D NULL; g_autoptr(virJSONValue) leases_array =3D NULL; - long long expirytime; int custom_lease_file_len =3D 0; - virJSONValuePtr lease_tmp =3D NULL; - const char *ip_tmp =3D NULL; - const char *server_duid_tmp =3D NULL; size_t i; =20 /* Read entire contents */ @@ -83,7 +79,11 @@ virLeaseReadCustomLeaseFile(virJSONValuePtr leases_array= _new, =20 i =3D 0; while (i < virJSONValueArraySize(leases_array)) { - if (!(lease_tmp =3D virJSONValueArrayGet(leases_array, i))) { + virJSONValuePtr lease_tmp =3D virJSONValueArrayGet(leases_array, i= ); + long long expirytime; + const char *ip_tmp =3D NULL; + + if (!lease_tmp) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to parse json")); return -1; @@ -103,9 +103,10 @@ virLeaseReadCustomLeaseFile(virJSONValuePtr leases_arr= ay_new, } =20 if (server_duid && strchr(ip_tmp, ':')) { + const char *server_duid_tmp =3D NULL; + /* This is an ipv6 lease */ - if ((server_duid_tmp - =3D virJSONValueObjectGetString(lease_tmp, "server-duid")= )) { + if ((server_duid_tmp =3D virJSONValueObjectGetString(lease_tmp= , "server-duid"))) { if (!*server_duid) *server_duid =3D g_strdup(server_duid_tmp); } else { --=20 2.26.2 From nobody Wed May 15 14:49:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1608304180; cv=none; d=zohomail.com; s=zohoarc; b=nc+phtOlvSZinfdDuIZgcgGbpIPOJbwOL7jdHyhlnNEM+PdQd1WQZ0xI5FURbV6CM7UpNtkEQRV53LsJiIj6b9Ago0swjRZ9/XMeeIKmy2dMM048DHdwiDcNjBRMpyHB7yspeFVl+My5hIMjfUQWFx6X1QJ1Qfop8luSPS/XKmA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608304180; 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=d/CnQd95PADU6QEvgzeVXmPiTrpjNiRu4XPL659gq38=; b=ixWCjRGfyakrKL8zf1hAXjGF0rsIiZNLMwvvRHWEVOOwle2jm3Uoxteoxr+s6dAm7+rABSQf0BBAUjMh1jLsNi5mnOHH6S0mT9ag1taNfz06xJ0Oij50YkLBORWrSNg7dd+ooImTClzZ/1isn/QAWBw5XMJGID41/SQ6B/dckk0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1608304180138875.2025558312325; Fri, 18 Dec 2020 07:09:40 -0800 (PST) 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-500-bAuD1nxiP-6M9NVWdFgwoA-1; Fri, 18 Dec 2020 10:09:36 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2C119800D53; Fri, 18 Dec 2020 15:09:30 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E44C947; Fri, 18 Dec 2020 15:09:29 +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 4599D1809C9F; Fri, 18 Dec 2020 15:09:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0BIF9QB2014049 for ; Fri, 18 Dec 2020 10:09:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id AB2F8100238C; Fri, 18 Dec 2020 15:09:26 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.214]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E7AE10016FF for ; Fri, 18 Dec 2020 15:09:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304178; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=d/CnQd95PADU6QEvgzeVXmPiTrpjNiRu4XPL659gq38=; b=Gsn4arhnt09BrmBA7H89/Kb9fbZhNd/D4l3EvzJSJ4mDBGZbiLtTVkELKToNA9K5qjJVR3 P0MNZXRP20PO3F4pcxwGx//z1HqfCTdTwkyFR0h4JQZCh0KxqH0LYLBHbhS5B9b1M73Stn nUuqnZ102D8KCtO6cqIAy7ylWlM1TYg= X-MC-Unique: bAuD1nxiP-6M9NVWdFgwoA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 04/10] virlease: Use virTrimSpaces() instead of open coded alternative Date: Fri, 18 Dec 2020 16:09:10 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.84 on 10.5.11.23 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" In virLeaseNew() we are trying to remove trailing space (per comment it may happen that older versions of dnsmasq put it into an env variable). Well, instead of open coding it, we can use virTrimSpaces(). Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/util/virlease.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/util/virlease.c b/src/util/virlease.c index f01cf5b9bd..edfdc6477a 100644 --- a/src/util/virlease.c +++ b/src/util/virlease.c @@ -226,8 +226,7 @@ virLeaseNew(virJSONValuePtr *lease_ret, =20 /* Removed extraneous trailing space in DNSMASQ_LEASE_EXPIRES * (dnsmasq < 2.52) */ - if (exptime[strlen(exptime) - 1] =3D=3D ' ') - exptime[strlen(exptime) - 1] =3D '\0'; + virTrimSpaces(exptime, NULL); } =20 if (!exptime || --=20 2.26.2 From nobody Wed May 15 14:49:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1608304197; cv=none; d=zohomail.com; s=zohoarc; b=GIZaxu81FDDOzb1Ox+opXXnEwUmDTeCgSHxWp5y1zqUo6HfB1AtnBdM/xPl0UVY2htvRwlaVmjJslL6ZgVWgGGO0gwFM3dBQFUPNhpMCetfOP7paMG7EArQX1kn6n9NoO2/5nsA5GKTtyt77rN1iOYSZKTEutk8T4J0tD7AugOE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608304197; 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=qBVIvRT/PJiT6gJh725NI+Y5L/rHPjJ7wYaAE8VoC9g=; b=FDnYk0CRou6293VZcmOCRXWsw11iubCfSKdpxQCwPy0esyqE6hfOQI5soh1i//GmT+nd2iP5S+0hEl8OiD1pTzqFW9XuY24BPTbjDfr5vosh3tJwz2PiWs/Cg8ZYFWgF8OAvlSXsjPQcgw6cfhwa6gpA9dVQlHqcNbWp56cYxFk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 16083041973431023.9725472821702; Fri, 18 Dec 2020 07:09:57 -0800 (PST) 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-228-F7aJXjS9OneyMbK1YnZtLQ-1; Fri, 18 Dec 2020 10:09:50 -0500 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 3E7C2B8107; Fri, 18 Dec 2020 15:09:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1DE745D9E8; Fri, 18 Dec 2020 15:09:45 +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 D494F1809CA5; Fri, 18 Dec 2020 15:09:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0BIF9RxX014061 for ; Fri, 18 Dec 2020 10:09:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id A2BE8100238C; Fri, 18 Dec 2020 15:09:27 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.214]) by smtp.corp.redhat.com (Postfix) with ESMTP id 149BC1002382 for ; Fri, 18 Dec 2020 15:09:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304193; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=qBVIvRT/PJiT6gJh725NI+Y5L/rHPjJ7wYaAE8VoC9g=; b=ART8NFf98PT2uDPCEGlvUQqmKZ3w8EO5H9YmEROiIAUszwhCBkp3of1GNQyJS8z1BQ4yu5 YHu4oSCNLTFF9ac5UPoD8tRhr9v9+Jx+NY4BMZB/b6DgGDCeuYOP0FvCvVALsArfQ6DEW1 gQ/tpwfxTOjtpad3K2uczFFyTc8ZYqk= X-MC-Unique: F7aJXjS9OneyMbK1YnZtLQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 05/10] virlease: Allow infinite lease expiry time Date: Fri, 18 Dec 2020 16:09:11 +0100 Message-Id: <4728b5dd7eb69caf2cc2864b1e0d318308b094d6.1608303776.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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 adding a new lease by our leaseshelper then virLeaseNew() is called. Here, we check for DNSMASQ_LEASE_EXPIRES environment variable which is the expiration time for the lease. For infinite lease time the value is zero. However, our code is not prepared for that and adds "expiry-time" into the JSON file only if lease expiry time is non-zero. This breaks the assumption that the "expiry-time" attribute is always present (as can be seen in virLeaseReadCustomLeaseFile() and virLeasePrintLeases()). Store "expiry-time" always. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/util/virlease.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/util/virlease.c b/src/util/virlease.c index edfdc6477a..3d68bb660c 100644 --- a/src/util/virlease.c +++ b/src/util/virlease.c @@ -227,14 +227,13 @@ virLeaseNew(virJSONValuePtr *lease_ret, /* Removed extraneous trailing space in DNSMASQ_LEASE_EXPIRES * (dnsmasq < 2.52) */ virTrimSpaces(exptime, NULL); - } =20 - if (!exptime || - virStrToLong_ll(exptime, NULL, 10, &expirytime) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to convert lease expiry time to long long= : %s"), - NULLSTR(exptime)); - return -1; + if (virStrToLong_ll(exptime, NULL, 10, &expirytime) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to convert lease expiry time to long = long: %s"), + NULLSTR(exptime)); + return -1; + } } =20 /* Create new lease */ @@ -252,7 +251,7 @@ virLeaseNew(virJSONValuePtr *lease_ret, return -1; if (server_duid && virJSONValueObjectAppendString(lease_new, "server-d= uid", server_duid) < 0) return -1; - if (expirytime && virJSONValueObjectAppendNumberLong(lease_new, "expir= y-time", expirytime) < 0) + if (virJSONValueObjectAppendNumberLong(lease_new, "expiry-time", expir= ytime) < 0) return -1; =20 *lease_ret =3D lease_new; --=20 2.26.2 From nobody Wed May 15 14:49:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1608304182; cv=none; d=zohomail.com; s=zohoarc; b=YaoRiy+vSWSZakP0T3IMHjyV0hwlBSer6i2JcSmnk4ftfTcLsKxJXYk2EvJzZ/PhhI30bUX7/U2HzMZE1QjpGpQ9yr9Bp2wWbCWif+QMaQjiFvcX7Ve1XuYyjBS3N1KMl732/qdtV7C+j4fSUPyE6jISYfyo2nJnK4//dyuglaE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608304182; 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=g59D2PHeXnbphqqPbaizyHxdqJW07SLIvDLNIjDX5cI=; b=DyDs+5U975AfCOxg6yPypZCqL7DQXD9KZ7Gw6enSsVPrpzs6h+0tvOie8sB/fuFlDC6ZygYHHzmlkeuOt2dcFiKlWk1WgubHUhyeagcmfcMB7/5HsIOkxAC+jwN3a383lEw/ANMxqsUP2SSIvSm2UxPwVm/mQ91YYtkc/i+t1RM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1608304181926409.5150763560657; Fri, 18 Dec 2020 07:09:41 -0800 (PST) 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-316-hh-d09elMEOWUgQ6q0QNgQ-1; Fri, 18 Dec 2020 10:09:37 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0BB68107ACF5; Fri, 18 Dec 2020 15:09:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DA39A2998C; Fri, 18 Dec 2020 15:09:31 +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 A15B81809CA1; Fri, 18 Dec 2020 15:09:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0BIF9S38014072 for ; Fri, 18 Dec 2020 10:09:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9A04A106D5A2; Fri, 18 Dec 2020 15:09:28 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.214]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0BAEC10016FF for ; Fri, 18 Dec 2020 15:09:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304179; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=g59D2PHeXnbphqqPbaizyHxdqJW07SLIvDLNIjDX5cI=; b=BJKKKwHtNFml1RpOiEpJnCvWsGi5JSUZSJ+H9KDGkO4fsdQMf2Yel0N/z+hctuaXSZ2N1J tT5rAYofh4oRgrmzg7JjS4SIE4WXF0bZ2qHvuBX7Nvagw0I/qXAvMbNiFz0Wpix+81jain Nvr3/mYZGJvxcfHawyeiOiSI/NIc+I8= X-MC-Unique: hh-d09elMEOWUgQ6q0QNgQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 06/10] network: Drop @custom_lease_file_len variable from networkGetDHCPLeases() Date: Fri, 18 Dec 2020 16:09:12 +0100 Message-Id: <8eefbb9a355b06ade7430742e80bfa79b02816a2.1608303776.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.84 on 10.5.11.23 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" We don't need to track the lease file size. Instead, we can simply check if the file was empty by comparing the buffer the file was read into with an empty string. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/network/bridge_driver.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index fdad2191e6..191e429ea2 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -4035,7 +4035,6 @@ networkGetDHCPLeases(virNetworkPtr net, size_t nleases =3D 0; int rv =3D -1; size_t size =3D 0; - int custom_lease_file_len =3D 0; bool need_results =3D !!leases; long long currtime =3D 0; long long expirytime_tmp =3D -1; @@ -4071,9 +4070,9 @@ networkGetDHCPLeases(virNetworkPtr net, custom_lease_file =3D networkDnsmasqLeaseFileNameCustom(driver, def->b= ridge); =20 /* Read entire contents */ - if ((custom_lease_file_len =3D virFileReadAllQuiet(custom_lease_file, - VIR_NETWORK_DHCP_LEAS= E_FILE_SIZE_MAX, - &lease_entries)) < 0)= { + if (virFileReadAllQuiet(custom_lease_file, + VIR_NETWORK_DHCP_LEASE_FILE_SIZE_MAX, + &lease_entries) < 0) { /* Not all networks are guaranteed to have leases file. * Only those which run dnsmasq. Therefore, if we failed * to read the leases file, don't report error. Return 0 @@ -4088,20 +4087,23 @@ networkGetDHCPLeases(virNetworkPtr net, goto error; } =20 - if (custom_lease_file_len) { - if (!(leases_array =3D virJSONValueFromString(lease_entries))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("invalid json in file: %s"), custom_lease_fil= e); - goto error; - } + if (STREQ(lease_entries, "")) { + rv =3D 0; + goto error; + } + + if (!(leases_array =3D virJSONValueFromString(lease_entries))) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("invalid json in file: %s"), custom_lease_file); + goto error; + } =20 - if (!virJSONValueIsArray(leases_array)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Malformed lease_entries array")); - goto error; - } - size =3D virJSONValueArraySize(leases_array); + if (!virJSONValueIsArray(leases_array)) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Malformed lease_entries array")); + goto error; } + size =3D virJSONValueArraySize(leases_array); =20 currtime =3D (long long)time(NULL); =20 --=20 2.26.2 From nobody Wed May 15 14:49:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1608304195; cv=none; d=zohomail.com; s=zohoarc; b=EvJqgUwYw04XkTnvoDNXkifkDh9NOOd+QjPOSX5AiNaySlzWS8cZTY1m3d1JHhLXUsFlUtMmq61psHvyBSJdvrMb8Fzqs+X72O2Jv7J57hu/LEzBtS+m2DR0q82R19Onl/lkP//dczRM7mxuZMPoQLiesQnQayAuTRMmV/X3VN8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608304195; 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=rAYnQCDpqGdpUN2QVHzfxoid81Q07EivgK35uNG8m1Y=; b=EmGV6jd6Z/56E+5WPHAG+9+pu9i6nz7+LkEku7G3SU7Icw0T6jdhZ8Ifo9nw1uBfLvhC1nJPa8y9z9WcNpYetoK9STas+MKBSLHSH3m4VALHhwcQOJ3T5D362ohiGBzPitFI4MLzNVyGhrHsKUSrYOgadhCzuP8cLq5Uasxk2uI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1608304195400924.2138359901144; Fri, 18 Dec 2020 07:09:55 -0800 (PST) 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-164-m63YC1-dNteFyIx2_WZEKQ-1; Fri, 18 Dec 2020 10:09:50 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4A2DA1005D53; Fri, 18 Dec 2020 15:09:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2516E648A8; Fri, 18 Dec 2020 15:09:45 +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 DC4FD1809CA7; Fri, 18 Dec 2020 15:09:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0BIF9T76014080 for ; Fri, 18 Dec 2020 10:09:29 -0500 Received: by smtp.corp.redhat.com (Postfix) id 91B01106D5A2; Fri, 18 Dec 2020 15:09:29 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.214]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0374010016FF for ; Fri, 18 Dec 2020 15:09:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304193; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=rAYnQCDpqGdpUN2QVHzfxoid81Q07EivgK35uNG8m1Y=; b=LL3nweVS6QirTcvf+B8ERRBM25XqVMQXF51iYU+5erU3cZfJhZ05tmHp1oKpA2NHg7FAPM YOdQCV5EayMD6qM0+aimohXH58sMr/vHTO7Xmzgp+iZjfZ7PDCQ5hEzNqR/S+X2NO0sViW zb43AtdkeGsAJD8UL1l9RS8reaM1YpY= X-MC-Unique: m63YC1-dNteFyIx2_WZEKQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 07/10] networkGetDHCPLeases: Use VIR_APPEND_ELEMENT() instead of VIR_INSERT_ELEMENT() Date: Fri, 18 Dec 2020 16:09:13 +0100 Message-Id: <9f3ee3b0834fb73588bf9fb610cd5f65e599def3.1608303776.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.13 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" This function is misusing VIR_INSERT_ELEMENT() to behave like VIR_APPEND_ELEMENT(). Use the latter to make it explicit what we are trying to achieve. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/network/bridge_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 191e429ea2..43102a02c1 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -4179,7 +4179,7 @@ networkGetDHCPLeases(virNetworkPtr net, lease->clientid =3D g_strdup(virJSONValueObjectGetString(lease= _tmp, "client-id")); lease->hostname =3D g_strdup(virJSONValueObjectGetString(lease= _tmp, "hostname")); =20 - if (VIR_INSERT_ELEMENT(leases_ret, nleases, nleases, lease) < = 0) + if (VIR_APPEND_ELEMENT(leases_ret, nleases, lease) < 0) goto error; =20 } else { --=20 2.26.2 From nobody Wed May 15 14:49:14 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=1608304331; cv=none; d=zohomail.com; s=zohoarc; b=CA0kojnVnlV6O3q2Tq5cik+bT+gtLw0u58BkvGnSa7D3RZS48AhzvNkQjUWAXibSqfJcKTwDP6rgMX+gXio9IAoeDkVQUBXQadJycqxz7slWgomMbbo3bkR6sTj7bZ12aaoNdzsfmfMPDPFmOM7YrjlzOyc0Ra67+d6jBrysgK4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608304331; 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=nXtQJqsdgRppIAASC/NcoaDRPonMcj1LQk5ednuu+RY=; b=iAkERX+7+3v9UC9svawTyymhpUcAcaJGPTI0IZSm2h0FdYrKXLzWgVBrqxb1lvGZKeSMhZPZrj4jcQPAFfhqwLkchVdPfBopkedkQ2Oy5rB2Kf7jpF+xYMJpvrLW1R+gyKObIL/yqTMpZqXsY8YiL8AFWkVnpMpJsSqhB0WvM4Y= 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 1608304331443286.296873322877; Fri, 18 Dec 2020 07:12:11 -0800 (PST) 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-324-sqEoNxoSOFy5CdxdqKtWog-1; Fri, 18 Dec 2020 10:10:00 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B1CAB107ACF9; Fri, 18 Dec 2020 15:09:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8AF9310013C0; Fri, 18 Dec 2020 15:09: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 55EAC1809CAC; Fri, 18 Dec 2020 15:09:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0BIF9Uxu014094 for ; Fri, 18 Dec 2020 10:09:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id 88879100238C; Fri, 18 Dec 2020 15:09:30 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.214]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE8FE1002382 for ; Fri, 18 Dec 2020 15:09:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304328; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=nXtQJqsdgRppIAASC/NcoaDRPonMcj1LQk5ednuu+RY=; b=AeYEhoNgIuBoKhco54xOc/8km4Z+uUjJ9hlczPO5/5xs2ezZT2zx95J62cPzb4sWRlbODz LqOefWmh9enm/sFNznJSTrRo7aWb695vZvzZBNbisR3X17I2QL/qNO3YLFa0CbsJrFMSsM YFZfq6hMsiHKdnBGa1u31hEl63AdoPM= X-MC-Unique: sqEoNxoSOFy5CdxdqKtWog-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 08/10] network: Rework networkGetDHCPLeases() Date: Fri, 18 Dec 2020 16:09:14 +0100 Message-Id: <538b10683c7c91eb80e2fe91db2e28a8ecf837b7.1608303776.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.84 on 10.5.11.22 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" Firstly, bring variables that are used only within loops into their respective loops. Secondly, drop 'error' label which is redundant since we have @rv which holds the return value. Thirdly, fix indendation in one case, the rest is indented properly. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/network/bridge_driver.c | 47 +++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 43102a02c1..fcc7e05ad8 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -4031,22 +4031,16 @@ networkGetDHCPLeases(virNetworkPtr net, unsigned int flags) { virNetworkDriverStatePtr driver =3D networkGetDriver(); - size_t i, j; + size_t i; size_t nleases =3D 0; int rv =3D -1; size_t size =3D 0; bool need_results =3D !!leases; long long currtime =3D 0; - long long expirytime_tmp =3D -1; - bool ipv6 =3D false; g_autofree char *lease_entries =3D NULL; g_autofree char *custom_lease_file =3D NULL; - const char *ip_tmp =3D NULL; - const char *mac_tmp =3D NULL; - virJSONValuePtr lease_tmp =3D NULL; g_autoptr(virJSONValue) leases_array =3D NULL; - virNetworkIPDefPtr ipdef_tmp =3D NULL; - virNetworkDHCPLeasePtr *leases_ret =3D NULL; + g_autofree virNetworkDHCPLeasePtr *leases_ret =3D NULL; virNetworkObjPtr obj; virNetworkDefPtr def; virMacAddr mac_addr; @@ -4084,34 +4078,38 @@ networkGetDHCPLeases(virNetworkPtr net, _("Unable to read leases file: %s"), custom_lease_file); } - goto error; + goto cleanup; } =20 if (STREQ(lease_entries, "")) { rv =3D 0; - goto error; + goto cleanup; } =20 if (!(leases_array =3D virJSONValueFromString(lease_entries))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid json in file: %s"), custom_lease_file); - goto error; + goto cleanup; } =20 if (!virJSONValueIsArray(leases_array)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Malformed lease_entries array")); - goto error; + goto cleanup; } size =3D virJSONValueArraySize(leases_array); =20 currtime =3D (long long)time(NULL); =20 for (i =3D 0; i < size; i++) { - if (!(lease_tmp =3D virJSONValueArrayGet(leases_array, i))) { + virJSONValuePtr lease_tmp =3D virJSONValueArrayGet(leases_array, i= ); + long long expirytime_tmp =3D -1; + const char *mac_tmp =3D NULL; + + if (!lease_tmp) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to parse json")); - goto error; + goto cleanup; } =20 if (!(mac_tmp =3D virJSONValueObjectGetString(lease_tmp, "mac-addr= ess"))) { @@ -4119,7 +4117,7 @@ networkGetDHCPLeases(virNetworkPtr net, * mac-address is known otherwise not */ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("found lease without mac-address")); - goto error; + goto cleanup; } =20 if (mac && virMacAddrCompare(mac, mac_tmp)) @@ -4129,7 +4127,7 @@ networkGetDHCPLeases(virNetworkPtr net, /* A lease cannot be present without expiry-time */ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("found lease without expiry-time")); - goto error; + goto cleanup; } =20 /* Do not report expired lease */ @@ -4138,6 +4136,9 @@ networkGetDHCPLeases(virNetworkPtr net, =20 if (need_results) { g_autoptr(virNetworkDHCPLease) lease =3D g_new0(virNetworkDHCP= Lease, 1); + const char *ip_tmp =3D NULL; + bool ipv6 =3D false; + size_t j; =20 lease->expirytime =3D expirytime_tmp; =20 @@ -4145,7 +4146,7 @@ networkGetDHCPLeases(virNetworkPtr net, /* A lease without ip-address makes no sense */ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("found lease without ip-address")); - goto error; + goto cleanup; } =20 /* Unlike IPv4, IPv6 uses ':' instead of '.' as separator */ @@ -4154,7 +4155,7 @@ networkGetDHCPLeases(virNetworkPtr net, =20 /* Obtain prefix */ for (j =3D 0; j < def->nips; j++) { - ipdef_tmp =3D &def->ips[j]; + virNetworkIPDefPtr ipdef_tmp =3D ipdef_tmp =3D &def->ips[j= ]; =20 if (ipv6 && VIR_SOCKET_ADDR_IS_FAMILY(&ipdef_tmp->address, AF_INET6)) { @@ -4162,7 +4163,7 @@ networkGetDHCPLeases(virNetworkPtr net, break; } if (!ipv6 && VIR_SOCKET_ADDR_IS_FAMILY(&ipdef_tmp->address, - AF_INET)) { + AF_INET)) { lease->prefix =3D virSocketAddrGetIPPrefix(&ipdef_tmp-= >address, &ipdef_tmp->n= etmask, ipdef_tmp->pr= efix); @@ -4180,7 +4181,7 @@ networkGetDHCPLeases(virNetworkPtr net, lease->hostname =3D g_strdup(virJSONValueObjectGetString(lease= _tmp, "hostname")); =20 if (VIR_APPEND_ELEMENT(leases_ret, nleases, lease) < 0) - goto error; + goto cleanup; =20 } else { nleases++; @@ -4197,15 +4198,11 @@ networkGetDHCPLeases(virNetworkPtr net, =20 cleanup: virNetworkObjEndAPI(&obj); - return rv; - - error: if (leases_ret) { for (i =3D 0; i < nleases; i++) virNetworkDHCPLeaseFree(leases_ret[i]); - g_free(leases_ret); } - goto cleanup; + return rv; } =20 =20 --=20 2.26.2 From nobody Wed May 15 14:49:14 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=1608304199; cv=none; d=zohomail.com; s=zohoarc; b=oB7pWfNLDnPF6uzYIBS6af6G1kFXu1hNxh+T2JhLOfx0hcaISLwsF9lvS2sk9VKIFUt/MJK6XxxVxYJXKL0GddOTjcZk09mLpRkCjH4wlUxVNcsw8xaXz9TuyXSIhv6dWomv7+5z+bFBmpuqW3nwiaI6BAOtizwpJpkPNLQ1baU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608304199; 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=M5PPTAtkQCyvI5vlljAdfId4e8OD+gSKq6zzSUxm0YU=; b=ALDfsV2i3nnKr/2zd3K6GqwlNxXe/Fo8eyl4MMlBE4DXlgdMHSQz0OrDkOyljVphC5QCzht3Gzhf/kGKs4b9iBCGyabwxz/zX7J8IApYLThnRJI07mB3IaY+E92RcKFcIlX+KtuROqi2jqFHp9QcioDWUyjslgYDhecCQvdMdf4= 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 1608304199062165.8412565937375; Fri, 18 Dec 2020 07:09:59 -0800 (PST) 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-113-YZF7D8zMN8-ARDHszcgZDw-1; Fri, 18 Dec 2020 10:09:54 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1E818B810B; Fri, 18 Dec 2020 15:09:48 +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 ED5C22CFB2; Fri, 18 Dec 2020 15:09:47 +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 B3A7F5002E; Fri, 18 Dec 2020 15:09:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0BIF9V61014102 for ; Fri, 18 Dec 2020 10:09:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id 80734100238C; Fri, 18 Dec 2020 15:09:31 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.214]) by smtp.corp.redhat.com (Postfix) with ESMTP id E504F1002382 for ; Fri, 18 Dec 2020 15:09:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304197; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=M5PPTAtkQCyvI5vlljAdfId4e8OD+gSKq6zzSUxm0YU=; b=dDnIJ1w4iNljK1hkJmYelS28w75BehHoh5a/3Gx1ysVWOe2LbvjYltb/SXQKKNhOEvJNbx OJDbSQwL6NMLbQ3lFGRGD84/F9eFTEbtyqzYtuR3H+KKIQ1NLcCXcAcALtC65EBqeCKaTQ XfOUG4HZ1SieptL7Cer5yHgj84E41uA= X-MC-Unique: YZF7D8zMN8-ARDHszcgZDw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 09/10] networkGetDHCPLeases: Handle leases with infinite expiry time Date: Fri, 18 Dec 2020 16:09:15 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.16 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" After v6.3.0-rc1~64 a lease can have infinite expiry time. This means that the expiration time will appear as a value of zero. Do the expiration check only if the expiration time is not zero. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1908053 Fixes: 97a0aa246799c97d0a9ca9ecd6b4fd932ae4756c Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/network/bridge_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index fcc7e05ad8..22d7d330a3 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -4131,7 +4131,7 @@ networkGetDHCPLeases(virNetworkPtr net, } =20 /* Do not report expired lease */ - if (expirytime_tmp < currtime) + if (expirytime_tmp > 0 && expirytime_tmp < currtime) continue; =20 if (need_results) { --=20 2.26.2 From nobody Wed May 15 14:49:14 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=1608304455; cv=none; d=zohomail.com; s=zohoarc; b=SRGd0EP7eNNbKexzc3InvjyPN7cOOqyPoVubHwP8nPP9S6tlqhIojQ4lZvIx8E0H5ex84xCJR3FRKaSQ1a1fSyLKdn13pUtHTzPez3Sks98Tl0gWhEUM9PcOAssdwb4SRCh4yg5Vfl/f3Rm0LL17vgLBQnG2cR2w2IAH8+II488= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608304455; 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=ne4J9u7VfDsYOEB3C4+JBmY89sUq6qcbDoLjuZcgugg=; b=OvAKkdH5ixM/MR+vh/8qT5di132IwL4k4wdymWsFYIwCuDLaepndWg1NX5QtRblQbFAcgA3S1xLpQyZlyzQ+UzBji5R7ilJ6OcNqH1vijU4oPjuqmPcZr85pqWF/YjGeOqiekUCXhqZ2QsXxTnvpCviVY7g9NTJA50G+MM+nqUs= 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 1608304455236769.2733692694491; Fri, 18 Dec 2020 07:14:15 -0800 (PST) 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-11-KFYVmolVMh-mVqvc5IwiVA-1; Fri, 18 Dec 2020 10:10:08 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B117C1005D4C; Fri, 18 Dec 2020 15:09:59 +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 8B7F86B8DF; Fri, 18 Dec 2020 15:09:59 +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 2E65450031; Fri, 18 Dec 2020 15:09:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0BIF9WW3014113 for ; Fri, 18 Dec 2020 10:09:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id 76E6C100238C; Fri, 18 Dec 2020 15:09:32 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.214]) by smtp.corp.redhat.com (Postfix) with ESMTP id DCFF11002382 for ; Fri, 18 Dec 2020 15:09:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304211; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ne4J9u7VfDsYOEB3C4+JBmY89sUq6qcbDoLjuZcgugg=; b=fpOa4kDC5Yxyvwu6i99TgpJHVGrekWRYmb4xCiyKp4uStWEsb/NtUI4qfN9/p3tX/dBizP eOp2EoFpE2TpaLO+5W9LwLGVBLR9ECkFddVoOQJcA35CcFl3JqPeBQAWFAa1+S6z+j3EZx XALCz3AnNWC8JIt/dLo2mr7o04KXah4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608304452; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ne4J9u7VfDsYOEB3C4+JBmY89sUq6qcbDoLjuZcgugg=; b=BOAVi8TX5Hbi9AKpLFQV5kfYBXYZJisc4D6sgsUfO2L6EK03pDH+ALV1B56lox0hyeNS5g KKe2dcRbB5uPzNQh74dLLYYEYoYllEkWkqcjBCx93KVvu8MbtufKDyPk1+y00TaoxYZIIv jiLr96EY2W9kIqN+nf1ZDvIqTLmpWDg= X-MC-Unique: KFYVmolVMh-mVqvc5IwiVA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 10/10] nss: handle leases with infinite expiry time Date: Fri, 18 Dec 2020 16:09:16 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.13 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) (identity @redhat.com) Content-Type: text/plain; charset="utf-8" After v6.3.0-rc1~64 a lease can have infinite expiry time. This means that the expiration time will appear as a value of zero. Do the expiration check only if the expiration time is not zero. Fixes: 97a0aa246799c97d0a9ca9ecd6b4fd932ae4756c Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/nssdata/virbr0.status | 7 +++++++ tests/nsstest.c | 2 +- tools/nss/libvirt_nss_leases.c | 4 +++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/nssdata/virbr0.status b/tests/nssdata/virbr0.status index 78afaf6200..354715bb1c 100644 --- a/tests/nssdata/virbr0.status +++ b/tests/nssdata/virbr0.status @@ -21,5 +21,12 @@ "ip-address": "192.168.122.2", "mac-address": "52:54:00:11:22:33", "expiry-time": 2000000000 + }, + { + "ip-address": "192.168.122.3", + "mac-address": "52:54:00:a4:6f:91", + "hostname": "fedora", + "client-id": "01:52:54:00:a4:6f:91", + "expiry-time": 0 } ] diff --git a/tests/nsstest.c b/tests/nsstest.c index 135f6b6c93..a4e8a4a37f 100644 --- a/tests/nsstest.c +++ b/tests/nsstest.c @@ -173,7 +173,7 @@ mymain(void) } while (0) =20 # if !defined(LIBVIRT_NSS_GUEST) - DO_TEST("fedora", AF_INET, "192.168.122.197", "192.168.122.198", "192.= 168.122.199"); + DO_TEST("fedora", AF_INET, "192.168.122.197", "192.168.122.198", "192.= 168.122.199", "192.168.122.3"); DO_TEST("gentoo", AF_INET, "192.168.122.254"); DO_TEST("gentoo", AF_INET6, "2001:1234:dead:beef::2"); DO_TEST("gentoo", AF_UNSPEC, "192.168.122.254"); diff --git a/tools/nss/libvirt_nss_leases.c b/tools/nss/libvirt_nss_leases.c index 015bbc4ab6..536fcf8608 100644 --- a/tools/nss/libvirt_nss_leases.c +++ b/tools/nss/libvirt_nss_leases.c @@ -276,7 +276,8 @@ findLeasesParserEndMap(void *ctx) found =3D true; } DEBUG("Found %d", found); - if (parser->entry.expiry < parser->now) { + if (parser->entry.expiry !=3D 0 && + parser->entry.expiry < parser->now) { DEBUG("Entry expired at %llu vs now %llu", parser->entry.expiry, parser->now); found =3D false; @@ -298,6 +299,7 @@ findLeasesParserEndMap(void *ctx) free(parser->entry.macaddr); free(parser->entry.ipaddr); free(parser->entry.hostname); + parser->entry.expiry =3D 0; parser->entry.macaddr =3D NULL; parser->entry.ipaddr =3D NULL; parser->entry.hostname =3D NULL; --=20 2.26.2