From nobody Fri Dec 19 02:51:17 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1639509066; cv=none; d=zohomail.com; s=zohoarc; b=CtNfk7w1MEG/yx4jYt4keymCckvps8a3RlodqBVE5T/CeOc3aIygPFDOUpiU9OVp0mGatYlxGip9Riu8thPOCPcgbL9KIWC3RygEgblFVb2HURhvy9fLcd8AfRLDtXkeshlQK49AgK2TVbgBm2ZZL8fCMFMr8Uo3AmwhLRqjgaU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639509066; 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=7Yzytfhcd/oOQZLTX4yuZjioh+L+rCXN5dcekrxzDVc=; b=fApHKDf3nEZAWDHSB6rIXBzXB289Wgb6lmohxb4q3NiOiWBhjnz+niVga23O3NzixrlDwoxPrhIMh8tTJzmZyUMfEME3t4LvOtvx0i0TzOGMP6XsM9gzQlHpDqtCvv+x3H9s94iCQ1VP3pmc4JRXEPUOxNb4vB74Y4UrmjLp51k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1639509066272279.76285530311156; Tue, 14 Dec 2021 11:11:06 -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-530-HYEORWo-MeyIGJHgEXcq1w-1; Tue, 14 Dec 2021 14:11:03 -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 BB202192FDCE; Tue, 14 Dec 2021 19:10: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 96883610A7; Tue, 14 Dec 2021 19:10: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 654074A700; Tue, 14 Dec 2021 19:10: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 1BEJAnvi001234 for ; Tue, 14 Dec 2021 14:10:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id 03B98610AE; Tue, 14 Dec 2021 19:10:49 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E4E0610A7 for ; Tue, 14 Dec 2021 19:10:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639509065; 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=7Yzytfhcd/oOQZLTX4yuZjioh+L+rCXN5dcekrxzDVc=; b=LQ8ReGqGzC1/OHOSYizzUKcH8dA854vEJ6dHNsaSgVDjIofIgoaaf2hFB4P4ZSAV5QxFPU pbhkQdJatH5KX4Of8D32lzV3LyPV8irtXnWtMyc7/YVbYPx31vT8c4otvkN5OEeq42BaMe uBKiNinTWZiWfvs9vEaooqZAC0kLUeo= X-MC-Unique: HYEORWo-MeyIGJHgEXcq1w-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 10/17] network: remove any code dealing with radvd Date: Tue, 14 Dec 2021 20:09:26 +0100 Message-Id: <697d2d9332d6997ef008b368aa75fd70f6d6e1ff.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.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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639509068102100001 Since dnsmasq supports --ra-param for a long time, this code is now unused. Signed-off-by: J=C3=A1n Tomko --- src/network/bridge_driver.c | 248 +----------------------------------- 1 file changed, 6 insertions(+), 242 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index a4535b1b49..39f6ed14e1 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -371,20 +371,6 @@ networkDnsmasqConfigFileName(virNetworkDriverState *dr= iver, } =20 =20 -static char * -networkRadvdPidfileBasename(const char *netname) -{return g_strdup_printf("%s-radvd", netname); -} - - -static char * -networkRadvdConfigFileName(virNetworkDriverState *driver, - const char *netname) -{ - return g_strdup_printf("%s/%s-radvd.conf", driver->radvdStateDir, netn= ame); -} - - /* do needed cleanup steps and remove the network from the list */ static int networkRemoveInactive(virNetworkDriverState *driver, @@ -392,15 +378,13 @@ networkRemoveInactive(virNetworkDriverState *driver, { g_autofree char *leasefile =3D NULL; g_autofree char *customleasefile =3D NULL; - g_autofree char *radvdconfigfile =3D NULL; g_autofree char *configfile =3D NULL; - g_autofree char *radvdpidbase =3D NULL; g_autofree char *statusfile =3D NULL; g_autofree char *macMapFile =3D NULL; g_autoptr(dnsmasqContext) dctx =3D NULL; virNetworkDef *def =3D virNetworkObjGetPersistentDef(obj); =20 - /* remove the (possibly) existing dnsmasq and radvd files */ + /* remove the (possibly) existing dnsmasq files */ if (!(dctx =3D dnsmasqContextNew(def->name, driver->dnsmasqStateDir))) { return -1; @@ -412,12 +396,6 @@ networkRemoveInactive(virNetworkDriverState *driver, if (!(customleasefile =3D networkDnsmasqLeaseFileNameCustom(driver, de= f->bridge))) return -1; =20 - if (!(radvdconfigfile =3D networkRadvdConfigFileName(driver, def->name= ))) - return -1; - - if (!(radvdpidbase =3D networkRadvdPidfileBasename(def->name))) - return -1; - if (!(configfile =3D networkDnsmasqConfigFileName(driver, def->name))) return -1; =20 @@ -436,10 +414,6 @@ networkRemoveInactive(virNetworkDriverState *driver, /* MAC map manager */ unlink(macMapFile); =20 - /* radvd */ - unlink(radvdconfigfile); - virPidFileDelete(driver->pidDir, radvdpidbase); - /* remove status file */ unlink(statusfile); =20 @@ -556,26 +530,15 @@ networkUpdateState(virNetworkObj *obj, =20 virNetworkObjPortForEach(obj, networkUpdatePort, obj); =20 - /* Try and read dnsmasq/radvd pids of active networks */ + /* Try and read dnsmasq pids of active networks */ if (virNetworkObjIsActive(obj) && def->ips && (def->nips > 0)) { - pid_t radvdPid; pid_t dnsmasqPid; - g_autofree char *radvdpidbase =3D NULL; =20 ignore_value(virPidFileReadIfAlive(driver->pidDir, def->name, &dnsmasqPid, dnsmasqCapsGetBinaryPath(dnsmas= q_caps))); virNetworkObjSetDnsmasqPid(obj, dnsmasqPid); - - radvdpidbase =3D networkRadvdPidfileBasename(def->name); - if (!radvdpidbase) - goto cleanup; - - ignore_value(virPidFileReadIfAlive(driver->pidDir, - radvdpidbase, - &radvdPid, RADVD)); - virNetworkObjSetRadvdPid(obj, radvdPid); } =20 ret =3D 0; @@ -690,7 +653,6 @@ networkStateInitialize(bool privileged, network_driver->stateDir =3D g_strdup(RUNSTATEDIR "/libvirt/networ= k"); network_driver->pidDir =3D g_strdup(RUNSTATEDIR "/libvirt/network"= ); network_driver->dnsmasqStateDir =3D g_strdup(LOCALSTATEDIR "/lib/l= ibvirt/dnsmasq"); - network_driver->radvdStateDir =3D g_strdup(LOCALSTATEDIR "/lib/lib= virt/radvd"); } else { configdir =3D virGetUserConfigDirectory(); rundir =3D virGetUserRuntimeDirectory(); @@ -700,7 +662,6 @@ networkStateInitialize(bool privileged, network_driver->stateDir =3D g_strdup_printf("%s/network/lib", run= dir); network_driver->pidDir =3D g_strdup_printf("%s/network/run", rundi= r); network_driver->dnsmasqStateDir =3D g_strdup_printf("%s/dnsmasq/li= b", rundir); - network_driver->radvdStateDir =3D g_strdup_printf("%s/radvd/lib", = rundir); } =20 if (g_mkdir_with_parents(network_driver->stateDir, 0777) < 0) { @@ -847,7 +808,6 @@ networkStateCleanup(void) g_free(network_driver->stateDir); g_free(network_driver->pidDir); g_free(network_driver->dnsmasqStateDir); - g_free(network_driver->radvdStateDir); =20 virObjectUnref(network_driver->dnsmasqCaps); =20 @@ -1697,170 +1657,6 @@ networkRestartDhcpDaemon(virNetworkDriverState *dri= ver, } =20 =20 -static char radvd1[] =3D " AdvOtherConfigFlag off;\n\n"; -static char radvd2[] =3D " AdvAutonomous off;\n"; -static char radvd3[] =3D " AdvOnLink on;\n" - " AdvAutonomous on;\n" - " AdvRouterAddr off;\n"; - -static int -networkRadvdConfContents(virNetworkObj *obj, - char **configstr) -{ - virNetworkDef *def =3D virNetworkObjGetDef(obj); - g_auto(virBuffer) configbuf =3D VIR_BUFFER_INITIALIZER; - size_t i; - virNetworkIPDef *ipdef; - bool v6present =3D false, dhcp6 =3D false; - - *configstr =3D NULL; - - /* Check if DHCPv6 is needed */ - for (i =3D 0; (ipdef =3D virNetworkDefGetIPByIndex(def, AF_INET6, i));= i++) { - v6present =3D true; - if (ipdef->nranges || ipdef->nhosts) { - dhcp6 =3D true; - break; - } - } - - /* If there are no IPv6 addresses, then we are done */ - if (!v6present) - return 0; - - /* create radvd config file appropriate for this network; - * IgnoreIfMissing allows radvd to start even when the bridge is down - */ - virBufferAsprintf(&configbuf, "interface %s\n" - "{\n" - " AdvSendAdvert on;\n" - " IgnoreIfMissing on;\n" - " AdvManagedFlag %s;\n" - "%s", - def->bridge, - dhcp6 ? "on" : "off", - dhcp6 ? "\n" : radvd1); - - /* add a section for each IPv6 address in the config */ - for (i =3D 0; (ipdef =3D virNetworkDefGetIPByIndex(def, AF_INET6, i));= i++) { - int prefix; - g_autofree char *netaddr =3D NULL; - - prefix =3D virNetworkIPDefPrefix(ipdef); - if (prefix < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("bridge '%s' has an invalid prefix"), - def->bridge); - return -1; - } - if (!(netaddr =3D virSocketAddrFormat(&ipdef->address))) - return -1; - - virBufferAsprintf(&configbuf, - " prefix %s/%d\n" - " {\n%s };\n", - netaddr, prefix, - dhcp6 ? radvd2 : radvd3); - } - - virBufferAddLit(&configbuf, "};\n"); - - *configstr =3D virBufferContentAndReset(&configbuf); - - return 0; -} - - -/* write file and return its name (which must be freed by caller) */ -static int -networkRadvdConfWrite(virNetworkDriverState *driver, - virNetworkObj *obj, - char **configFile) -{ - virNetworkDef *def =3D virNetworkObjGetDef(obj); - g_autofree char *configStr =3D NULL; - g_autofree char *myConfigFile =3D NULL; - - if (!configFile) - configFile =3D &myConfigFile; - - *configFile =3D NULL; - - if (networkRadvdConfContents(obj, &configStr) < 0) - return -1; - - if (!configStr) - return 0; - - /* construct the filename */ - if (!(*configFile =3D networkRadvdConfigFileName(driver, def->name))) - return -1; - - /* write the file */ - if (virFileWriteStr(*configFile, configStr, 0600) < 0) { - virReportSystemError(errno, - _("couldn't write radvd config file '%s'"), - *configFile); - return -1; - } - - return 0; -} - - -static int -networkStartRadvd(virNetworkDriverState *driver G_GNUC_UNUSED, - virNetworkObj *obj) -{ - virNetworkObjSetRadvdPid(obj, -1); - - return 0; -} - - -static int -networkRefreshRadvd(virNetworkDriverState *driver, - virNetworkObj *obj) -{ - virNetworkDef *def =3D virNetworkObjGetDef(obj); - g_autofree char *radvdpidbase =3D NULL; - g_autofree char *pidfile =3D NULL; - - 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 0 -/* currently unused, so it causes a build error unless we #if it out */ -static int -networkRestartRadvd(virNetworkObj *obj) -{ - virNetworkDef *def =3D virNetworkObjGetDef(obj); - g_autofree char *radvdpidbase =3D NULL; - g_autofree char *pidfile =3D NULL; - - /* If there is a running radvd, kill it. Essentially ignore errors fro= m the - * following two functions, since there's really no better recovery to= be - * done than to just push ahead (and that may be exactly what's needed= ). - */ - if ((radvdpidbase =3D networkRadvdPidfileBasename(def->name)) && - (pidfile =3D virPidFileBuildPath(driver->pidDir, radvdpidbase))) { - virPidFileForceCleanupPath(pidfile); - virNetworkObjSetRadvdPid(obj, -1); - } - - /* now start radvd if it should be started */ - return networkStartRadvd(obj); -} -#endif /* #if 0 */ - - static int networkRefreshDaemonsHelper(virNetworkObj *obj, void *opaque) @@ -1877,13 +1673,11 @@ networkRefreshDaemonsHelper(virNetworkObj *obj, case VIR_NETWORK_FORWARD_ROUTE: case VIR_NETWORK_FORWARD_OPEN: /* Only the three L3 network types that are configured by - * libvirt will have a dnsmasq or radvd daemon associated + * libvirt will have a dnsmasq daemon associated * with them. Here we send a SIGHUP to an existing - * dnsmasq and/or radvd, or restart them if they've - * disappeared. + * dnsmasq, or restart it if it has disappeared. */ networkRefreshDhcpDaemon(driver, obj); - networkRefreshRadvd(driver, obj); break; =20 case VIR_NETWORK_FORWARD_BRIDGE: @@ -1906,7 +1700,7 @@ networkRefreshDaemonsHelper(virNetworkObj *obj, } =20 =20 -/* SIGHUP/restart any dnsmasq or radvd daemons. +/* SIGHUP/restart any dnsmasq * This should be called when libvirtd is restarted. */ static void @@ -2263,10 +2057,6 @@ networkStartNetworkVirtual(virNetworkDriverState *dr= iver, =20 dnsmasqStarted =3D true; =20 - /* start radvd if there are any ipv6 addresses */ - if (v6present && networkStartRadvd(driver, obj) < 0) - goto error; - if (virNetDevBandwidthSet(def->bridge, def->bandwidth, true, true) < 0) goto error; =20 @@ -2300,28 +2090,16 @@ networkStartNetworkVirtual(virNetworkDriverState *d= river, =20 =20 static int -networkShutdownNetworkVirtual(virNetworkDriverState *driver, +networkShutdownNetworkVirtual(virNetworkDriverState *driver G_GNUC_UNUSED, virNetworkObj *obj) { virNetworkDef *def =3D virNetworkObjGetDef(obj); - pid_t radvdPid; pid_t dnsmasqPid; =20 if (def->bandwidth) virNetDevBandwidthClear(def->bridge); =20 virNetworkObjUnrefMacMap(obj); - - radvdPid =3D virNetworkObjGetRadvdPid(obj); - if (radvdPid > 0) { - g_autofree char *radvdpidbase =3D NULL; - - kill(radvdPid, SIGTERM); - /* attempt to delete the pidfile we created */ - if ((radvdpidbase =3D networkRadvdPidfileBasename(def->name))) - virPidFileDelete(driver->pidDir, radvdpidbase); - } - dnsmasqPid =3D virNetworkObjGetDnsmasqPid(obj); if (dnsmasqPid > 0) kill(dnsmasqPid, SIGTERM); @@ -2350,12 +2128,6 @@ networkShutdownNetworkVirtual(virNetworkDriverState = *driver, kill(dnsmasqPid, SIGKILL); virNetworkObjSetDnsmasqPid(obj, -1); =20 - radvdPid =3D virNetworkObjGetRadvdPid(obj); - if (radvdPid > 0 && - (kill(radvdPid, 0) =3D=3D 0)) - kill(radvdPid, SIGKILL); - virNetworkObjSetRadvdPid(obj, -1); - return 0; } =20 @@ -3634,14 +3406,6 @@ networkUpdate(virNetworkPtr net, =20 } =20 - if (section =3D=3D VIR_NETWORK_SECTION_IP) { - /* only a change in IP addresses will affect radvd, and all of= radvd's - * config is stored in the conf file which will be re-read wit= h a SIGHUP. - */ - if (networkRefreshRadvd(driver, obj) < 0) - goto cleanup; - } - /* save current network state to disk */ if ((ret =3D virNetworkObjSaveStatus(driver->stateDir, obj, network_driver->xmlopt)) <= 0) --=20 2.31.1