From nobody Thu Dec 18 23:01:04 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1639509047; cv=none; d=zohomail.com; s=zohoarc; b=MlcmZiqvBCBbgqHeOGEdQuZvYCUy8/HU39ZbQqknhA1ay81czTY4jJ2vLuQOTwop1s5TrvzbHfouSMfXxxHImNXM5MRZwJbkYNkxrnzZ7xwLK4HIu4myMVuGROVyX7x3qO4mLpHNmbarK/9FVOYzA9wvNxSjMgStOvX5SOdZhOU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639509047; 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=SQ5/VDZXERXewWkDsXUFuy897P1eY+6LeeHarjdWxVk=; b=YeTuiLQDZ0rP4KNYgQX3PYt3bGlKPt1CJGEp9+Eye4mg+MgRhCPus23OywVga0IyqwrJndhHlbYF0mJa8ewm0x7xFuVQDFKoTIWSbASliXooy0nbKAAxUVm3s6/YCnONYGvyThVTQuP3nCjE9u5fYOpHEtuJ1mHVDT7Ab5zvs0M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1639509047499330.2642374960071; Tue, 14 Dec 2021 11:10:47 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-433-fRqDDIj_OJGtWCrb2IjumA-1; Tue, 14 Dec 2021 14:10:42 -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 CEF143E741; Tue, 14 Dec 2021 19:10:36 +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 928965E275; Tue, 14 Dec 2021 19:10:36 +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 441F518033F6; Tue, 14 Dec 2021 19:10:36 +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 1BEJAZ9x001171 for ; Tue, 14 Dec 2021 14:10:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0E18960CC9; Tue, 14 Dec 2021 19:10:35 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8926461095 for ; Tue, 14 Dec 2021 19:09:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639509046; 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=SQ5/VDZXERXewWkDsXUFuy897P1eY+6LeeHarjdWxVk=; b=gl4g6oL9gpsfq2u17IWSk6PipKRAxcl+msogfGAbeRZ67JRXNeMhokrtFhr9Po7qnF+S20 wn38sG+W64OH2NDlxGhWyJ69Q+jF2m5m8BPw69uda7UponJfdl09lIRNMHaezWq59K0z9F HrO4oHXhbZQNXFeNXzmYrDJI4ANXS8w= X-MC-Unique: fRqDDIj_OJGtWCrb2IjumA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 05/17] network: assume DNSMASQ_RA_SUPPORT Date: Tue, 14 Dec 2021 20:09:21 +0100 Message-Id: <8ff47bc3fa97f5ad7e60382c3633cb76888f6e48.1639508754.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639509048762100001 Delete the code that is only run without the capability. Signed-off-by: J=C3=A1n Tomko --- src/network/bridge_driver.c | 134 +++++------------------------------- 1 file changed, 19 insertions(+), 115 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 526485e3f9..e57731742b 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -1486,21 +1486,18 @@ networkDnsmasqConfContents(virNetworkObj *obj, if (def->mtu > 0) virBufferAsprintf(&configbuf, "dhcp-option=3Doption:mtu,%d\n", def= ->mtu); =20 - /* Are we doing RA instead of radvd? */ - if (DNSMASQ_RA_SUPPORT(caps)) { - if (ipv6def) { - virBufferAddLit(&configbuf, "enable-ra\n"); - } else { - for (i =3D 0; - (ipdef =3D virNetworkDefGetIPByIndex(def, AF_INET6, i)); - i++) { - if (!(ipdef->nranges || ipdef->nhosts)) { - g_autofree char *bridgeaddr =3D virSocketAddrFormat(&i= pdef->address); - if (!bridgeaddr) - return -1; - virBufferAsprintf(&configbuf, - "dhcp-range=3D%s,ra-only\n", bridgea= ddr); - } + if (ipv6def) { + virBufferAddLit(&configbuf, "enable-ra\n"); + } else { + for (i =3D 0; + (ipdef =3D virNetworkDefGetIPByIndex(def, AF_INET6, i)); + i++) { + if (!(ipdef->nranges || ipdef->nhosts)) { + g_autofree char *bridgeaddr =3D virSocketAddrFormat(&ipdef= ->address); + if (!bridgeaddr) + return -1; + virBufferAsprintf(&configbuf, + "dhcp-range=3D%s,ra-only\n", bridgeaddr); } } } @@ -1860,84 +1857,11 @@ networkRadvdConfWrite(virNetworkDriverState *driver, =20 =20 static int -networkStartRadvd(virNetworkDriverState *driver, +networkStartRadvd(virNetworkDriverState *driver G_GNUC_UNUSED, virNetworkObj *obj) { - virNetworkDef *def =3D virNetworkObjGetDef(obj); - g_autoptr(dnsmasqCaps) dnsmasq_caps =3D networkGetDnsmasqCaps(driver); - pid_t radvdPid; - g_autofree char *pidfile =3D NULL; - g_autofree char *radvdpidbase =3D NULL; - g_autofree char *configfile =3D NULL; - g_autoptr(virCommand) cmd =3D NULL; - virNetworkObjSetRadvdPid(obj, -1); =20 - /* Is dnsmasq handling RA? */ - if (DNSMASQ_RA_SUPPORT(dnsmasq_caps)) - return 0; - - if (!virNetworkDefGetIPByIndex(def, AF_INET6, 0)) { - /* no IPv6 addresses, so we don't need to run radvd */ - return 0; - } - - if (!virFileIsExecutable(RADVD)) { - virReportSystemError(errno, - _("Cannot find %s - " - "Possibly the package isn't installed"), - RADVD); - return -1; - } - - if (g_mkdir_with_parents(driver->pidDir, 0777) < 0) { - virReportSystemError(errno, - _("cannot create directory %s"), - driver->pidDir); - return -1; - } - - if (g_mkdir_with_parents(driver->radvdStateDir, 0777) < 0) { - virReportSystemError(errno, - _("cannot create directory %s"), - driver->radvdStateDir); - return -1; - } - - /* construct pidfile name */ - if (!(radvdpidbase =3D networkRadvdPidfileBasename(def->name))) - return -1; - - if (!(pidfile =3D virPidFileBuildPath(driver->pidDir, radvdpidbase))) - return -1; - - if (networkRadvdConfWrite(driver, obj, &configfile) < 0) - return -1; - - /* prevent radvd from daemonizing itself with "--debug 1", and use - * a dummy pidfile name - virCommand will create the pidfile we - * want to use (this is necessary because radvd's internal - * daemonization and pidfile creation causes a race, and the - * virPidFileRead() below will fail if we use them). - * Unfortunately, it isn't possible to tell radvd to not create - * its own pidfile, so we just let it do so, with a slightly - * different name. Unused, but harmless. - */ - cmd =3D virCommandNewArgList(RADVD, "--debug", "1", - "--config", configfile, - "--pidfile", NULL); - virCommandAddArgFormat(cmd, "%s-bin", pidfile); - - virCommandSetPidFile(cmd, pidfile); - virCommandDaemonize(cmd); - - if (virCommandRun(cmd, NULL) < 0) - return -1; - - if (virPidFileRead(driver->pidDir, radvdpidbase, &radvdPid) < 0) - return -1; - - virNetworkObjSetRadvdPid(obj, radvdPid); return 0; } =20 @@ -1947,36 +1871,16 @@ networkRefreshRadvd(virNetworkDriverState *driver, virNetworkObj *obj) { virNetworkDef *def =3D virNetworkObjGetDef(obj); - g_autoptr(dnsmasqCaps) dnsmasq_caps =3D networkGetDnsmasqCaps(driver); g_autofree char *radvdpidbase =3D NULL; g_autofree char *pidfile =3D NULL; - pid_t radvdPid; =20 - /* Is dnsmasq handling RA? */ - if (DNSMASQ_RA_SUPPORT(dnsmasq_caps)) { - if ((radvdpidbase =3D networkRadvdPidfileBasename(def->name)) && - (pidfile =3D virPidFileBuildPath(driver->pidDir, radvdpidbase)= )) { - /* radvd should not be running but in case it is */ - virPidFileForceCleanupPath(pidfile); - virNetworkObjSetRadvdPid(obj, -1); - } - return 0; + if ((radvdpidbase =3D networkRadvdPidfileBasename(def->name)) && + (pidfile =3D virPidFileBuildPath(driver->pidDir, radvdpidbase))) { + /* radvd should not be running but in case it is */ + virPidFileForceCleanupPath(pidfile); + virNetworkObjSetRadvdPid(obj, -1); } - - /* if there's no running radvd, just start it */ - radvdPid =3D virNetworkObjGetRadvdPid(obj); - if (radvdPid <=3D 0 || (kill(radvdPid, 0) < 0)) - return networkStartRadvd(driver, obj); - - if (!virNetworkDefGetIPByIndex(def, AF_INET6, 0)) { - /* no IPv6 addresses, so we don't need to run radvd */ - return 0; - } - - if (networkRadvdConfWrite(driver, obj, NULL) < 0) - return -1; - - return kill(radvdPid, SIGHUP); + return 0; } =20 =20 --=20 2.31.1