From nobody Mon Feb 9 21:20:53 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1593056173; cv=none; d=zohomail.com; s=zohoarc; b=UK/BBwfo+vfbpviYk3bX/m2ZvvcOsDLGxUGv+ihJK5qJcmlkyvqTNEfDv5QlwZKFw5IuKjcgd9rEYEAdLx3LbdTOCd65gBhLqPYhKmx6SakcxtATQJIOrOA2B7qTetP/jPB4bqhc1CIEIV+IDbjyV03eemHvfe/25OXGyk2mXNI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593056173; 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=hyXRAxfSaPXiATlNc9S9fnFjl5gr2Jfm6hepy15b+LU=; b=jFTWK2To1ia0uiJCQmS4+2EXQQExZpznCYjAQIwRO6Qdrt8haAD7dj5RyKBmoCSWVg543s9V+byFxSYahIXpr4ScG4V+qPUBEOB4Ui6FkGFVyKReo/StF5luSlc9hR2fURedYKsQxr2D3FP9jwf8tWYi6Wl9VRVPe26O4adoYqo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1593056173158133.25586166342032; Wed, 24 Jun 2020 20:36:13 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-475-HRYM7mqMO_mq0Cu5-ihMqg-1; Wed, 24 Jun 2020 23:34:51 -0400 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 B11BF10059AA; Thu, 25 Jun 2020 03:34:45 +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 9336D5C578; Thu, 25 Jun 2020 03:34: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 6159D875B5; Thu, 25 Jun 2020 03:34:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05P3YZww007954 for ; Wed, 24 Jun 2020 23:34:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id BB98F5BAC9; Thu, 25 Jun 2020 03:34:35 +0000 (UTC) Received: from vhost2.laine.org (ovpn-114-28.phx2.redhat.com [10.3.114.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 779235BACC for ; Thu, 25 Jun 2020 03:34:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593056171; 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=hyXRAxfSaPXiATlNc9S9fnFjl5gr2Jfm6hepy15b+LU=; b=EChchh4ckvWP8QXPoSYA+I+xxDYsCQjCeSqruOhgu+6tFzkcfSP//BGugxV2z7jRFEQ4WG omNzRLtuRETBLl8cgTedCTgnHijPEUW9i7/u7kDpPHyYySUA0kCwK0hkzqMcJEqm31QDqb aNS50SbxKFL55K8LRqwYOrqQOS6m4r4= X-MC-Unique: HRYM7mqMO_mq0Cu5-ihMqg-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 24/25] nwfilter: use standard label names when reasonable Date: Wed, 24 Jun 2020 23:34:13 -0400 Message-Id: <20200625033414.1819594-25-laine@redhat.com> In-Reply-To: <20200625033414.1819594-1-laine@redhat.com> References: <20200625033414.1819594-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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 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" Rather than having labels named exit, done, exit_snooprequnlock, skip_rename, etc, use the standard "cleanup" label. And instead of err_exit, malformed, tear_down_tmpebchains, use "error". Signed-off-by: Laine Stump --- src/nwfilter/nwfilter_dhcpsnoop.c | 36 +++++++++++------------ src/nwfilter/nwfilter_ebiptables_driver.c | 12 ++++---- src/nwfilter/nwfilter_gentech_driver.c | 32 ++++++++++---------- src/nwfilter/nwfilter_learnipaddr.c | 22 +++++++------- 4 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcp= snoop.c index e41062feca..efb3257e92 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -454,11 +454,11 @@ virNWFilterSnoopIPLeaseInstallRule(virNWFilterSnoopIP= LeasePtr ipl, virNWFilterSnoopReqLock(req); =20 if (virNWFilterIPAddrMapAddIPAddr(req->binding->portdevname, ipaddr) <= 0) - goto exit_snooprequnlock; + goto cleanup; =20 if (!instantiate) { rc =3D 0; - goto exit_snooprequnlock; + goto cleanup; } =20 /* instantiate the filters */ @@ -469,7 +469,7 @@ virNWFilterSnoopIPLeaseInstallRule(virNWFilterSnoopIPLe= asePtr ipl, req->ifindex); } =20 - exit_snooprequnlock: + cleanup: virNWFilterSnoopReqUnlock(req); return rc; } @@ -718,7 +718,7 @@ virNWFilterSnoopReqLeaseAdd(virNWFilterSnoopReqPtr req, =20 virNWFilterSnoopReqUnlock(req); =20 - goto exit; + goto cleanup; } =20 virNWFilterSnoopReqUnlock(req); @@ -742,7 +742,7 @@ virNWFilterSnoopReqLeaseAdd(virNWFilterSnoopReqPtr req, =20 g_atomic_int_add(&virNWFilterSnoopState.nLeases, 1); =20 - exit: + cleanup: if (update_leasefile) virNWFilterSnoopLeaseFileSave(pl); =20 @@ -885,7 +885,7 @@ virNWFilterSnoopDHCPGetOpt(virNWFilterSnoopDHCPHdrPtr p= d, int len, switch (pd->d_opts[oind]) { case DHCPO_LEASE: if (olen - oind < 6) - goto malformed; + goto error; if (*pleasetime) return -1; /* duplicate lease time */ memcpy(&nwint, (char *)pd->d_opts + oind + 2, sizeof(nwint)); @@ -893,7 +893,7 @@ virNWFilterSnoopDHCPGetOpt(virNWFilterSnoopDHCPHdrPtr p= d, int len, break; case DHCPO_MTYPE: if (olen - oind < 3) - goto malformed; + goto error; if (*pmtype) return -1; /* duplicate message type */ *pmtype =3D pd->d_opts[oind + 2]; @@ -905,12 +905,12 @@ virNWFilterSnoopDHCPGetOpt(virNWFilterSnoopDHCPHdrPtr= pd, int len, return 0; default: if (olen - oind < 2) - goto malformed; + goto error; } oind +=3D pd->d_opts[oind + 1] + 2; } return 0; - malformed: + error: VIR_WARN("got lost in the options!"); return -1; } @@ -1362,7 +1362,7 @@ virNWFilterDHCPSnoopThread(void *req0) virNWFilterSnoopReqUnlock(req); =20 if (req->threadStatus !=3D THREAD_STATUS_OK) - goto exit; + goto cleanup; =20 while (!error) { if (virNWFilterSnoopAdjustPoll(pcapConf, @@ -1390,7 +1390,7 @@ virNWFilterDHCPSnoopThread(void *req0) */ if (!virNWFilterSnoopIsActive(threadkey) || req->jobCompletionStatus !=3D 0) - goto exit; + goto cleanup; =20 for (i =3D 0; n > 0 && i < G_N_ELEMENTS(fds); i++) { if (!fds[i].revents) @@ -1507,7 +1507,7 @@ virNWFilterDHCPSnoopThread(void *req0) virNWFilterSnoopReqUnlock(req); virNWFilterSnoopUnlock(); =20 - exit: + cleanup: virThreadPoolFree(worker); =20 virNWFilterSnoopReqPut(req); @@ -1736,14 +1736,14 @@ virNWFilterSnoopLeaseFileSave(virNWFilterSnoopIPLea= sePtr ipl) virNWFilterSnoopLeaseFileOpen(); if (virNWFilterSnoopLeaseFileWrite(virNWFilterSnoopState.leaseFD, req->ifkey, ipl) < 0) - goto err_exit; + goto error; =20 /* keep dead leases at < ~95% of file size */ if (g_atomic_int_add(&virNWFilterSnoopState.wLeases, 1) >=3D g_atomic_int_get(&virNWFilterSnoopState.nLeases) * 20) virNWFilterSnoopLeaseFileLoad(); /* load & refresh lease file */ =20 - err_exit: + error: virNWFilterSnoopUnlock(); } =20 @@ -1838,7 +1838,7 @@ virNWFilterSnoopLeaseFileRefresh(void) if (VIR_CLOSE(tfd) < 0) { virReportSystemError(errno, _("unable to close %s"), TMPLEASEFILE); /* assuming the old lease file is still better, skip the renaming = */ - goto skip_rename; + goto cleanup; } =20 if (rename(TMPLEASEFILE, LEASEFILE) < 0) { @@ -1848,7 +1848,7 @@ virNWFilterSnoopLeaseFileRefresh(void) } g_atomic_int_set(&virNWFilterSnoopState.wLeases, 0); =20 - skip_rename: + cleanup: virNWFilterSnoopLeaseFileOpen(); } =20 @@ -2013,14 +2013,14 @@ virNWFilterDHCPSnoopInit(void) if (!virNWFilterSnoopState.ifnameToKey || !virNWFilterSnoopState.snoopReqs || !virNWFilterSnoopState.active) - goto err_exit; + goto error; =20 virNWFilterSnoopLeaseFileLoad(); virNWFilterSnoopLeaseFileOpen(); =20 return 0; =20 - err_exit: + error: virHashFree(virNWFilterSnoopState.ifnameToKey); virNWFilterSnoopState.ifnameToKey =3D NULL; =20 diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfil= ter_ebiptables_driver.c index 90afbe21f1..6aefbe226b 100644 --- a/src/nwfilter/nwfilter_ebiptables_driver.c +++ b/src/nwfilter/nwfilter_ebiptables_driver.c @@ -2881,11 +2881,11 @@ ebtablesApplyBasicRules(const char *ifname, ebtablesRenameTmpRootChainFW(fw, true, ifname); =20 if (virFirewallApply(fw) < 0) - goto tear_down_tmpebchains; + goto error; =20 return 0; =20 - tear_down_tmpebchains: + error: ebtablesCleanAll(ifname); return -1; } @@ -2997,11 +2997,11 @@ ebtablesApplyDHCPOnlyRules(const char *ifname, } =20 if (virFirewallApply(fw) < 0) - goto tear_down_tmpebchains; + goto error; =20 return 0; =20 - tear_down_tmpebchains: + error: ebtablesCleanAll(ifname); return -1; } @@ -3048,11 +3048,11 @@ ebtablesApplyDropAllRules(const char *ifname) ebtablesRenameTmpRootChainFW(fw, false, ifname); =20 if (virFirewallApply(fw) < 0) - goto tear_down_tmpebchains; + goto error; =20 return 0; =20 - tear_down_tmpebchains: + error: ebtablesCleanAll(ifname); return -1; } diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter= _gentech_driver.c index 183e2f0a91..5433761548 100644 --- a/src/nwfilter/nwfilter_gentech_driver.c +++ b/src/nwfilter/nwfilter_gentech_driver.c @@ -204,14 +204,14 @@ virNWFilterCreateVarsFrom(virHashTablePtr vars1, return NULL; =20 if (virNWFilterHashTablePutAll(vars1, res) < 0) - goto err_exit; + goto error; =20 if (virNWFilterHashTablePutAll(vars2, res) < 0) - goto err_exit; + goto error; =20 return res; =20 - err_exit: + error: virHashFree(res); return NULL; } @@ -521,7 +521,7 @@ virNWFilterDoInstantiate(virNWFilterTechDriverPtr techd= river, =20 if (!missing_vars) { rc =3D -1; - goto err_exit; + goto error; } =20 rc =3D virNWFilterDetermineMissingVarsRec(filter, @@ -530,7 +530,7 @@ virNWFilterDoInstantiate(virNWFilterTechDriverPtr techd= river, useNewFilter, driver); if (rc < 0) - goto err_exit; + goto error; =20 lv =3D virHashLookup(binding->filterparams, NWFILTER_VARNAME_CTRL_IP_L= EARNING); if (lv) @@ -552,7 +552,7 @@ virNWFilterDoInstantiate(virNWFilterTechDriverPtr techd= river, rc =3D virNWFilterDHCPSnoopReq(techdriver, binding, driver); - goto err_exit; + goto error; } else if (STRCASEEQ(learning, "any")) { if (!virNWFilterHasLearnReq(ifindex)) { rc =3D virNWFilterLearnIPAddress(techdriver, @@ -561,14 +561,14 @@ virNWFilterDoInstantiate(virNWFilterTechDriverPtr tec= hdriver, driver, DETECT_DHCP|DETECT_STAT= IC); } - goto err_exit; + goto error; } else { rc =3D -1; virReportError(VIR_ERR_PARSE_FAILED, _("filter '%s' " "learning value '%s' invalid."), filter->name, learning); - goto err_exit; + goto error; } } else { goto err_unresolvable_vars; @@ -577,7 +577,7 @@ virNWFilterDoInstantiate(virNWFilterTechDriverPtr techd= river, goto err_unresolvable_vars; } else if (!forceWithPendingReq && virNWFilterHasLearnReq(ifindex)) { - goto err_exit; + goto error; } =20 rc =3D virNWFilterDefToInst(driver, @@ -587,7 +587,7 @@ virNWFilterDoInstantiate(virNWFilterTechDriverPtr techd= river, &inst); =20 if (rc < 0) - goto err_exit; + goto error; =20 switch (useNewFilter) { case INSTANTIATE_FOLLOW_NEWFILTER: @@ -600,7 +600,7 @@ virNWFilterDoInstantiate(virNWFilterTechDriverPtr techd= river, =20 if (instantiate) { if (virNWFilterLockIface(binding->portdevname) < 0) - goto err_exit; + goto error; =20 rc =3D techdriver->applyNewRules(binding->portdevname, inst.rules,= inst.nrules); =20 @@ -617,7 +617,7 @@ virNWFilterDoInstantiate(virNWFilterTechDriverPtr techd= river, virNWFilterUnlockIface(binding->portdevname); } =20 - err_exit: + error: virNWFilterInstReset(&inst); virHashFree(missing_vars); =20 @@ -633,7 +633,7 @@ virNWFilterDoInstantiate(virNWFilterTechDriverPtr techd= river, } =20 rc =3D -1; - goto err_exit; + goto error; } =20 =20 @@ -700,14 +700,14 @@ virNWFilterInstantiateFilterUpdate(virNWFilterDriverS= tatePtr driver, if (virNWFilterVarHashmapAddStdValue(binding->filterparams, NWFILTER_STD_VAR_MAC, vmmacaddr) < 0) - goto err_exit; + goto error; =20 ipaddr =3D virNWFilterIPAddrMapGetIPAddr(binding->portdevname); if (ipaddr && virNWFilterVarHashmapAddStdValue(binding->filterparams, NWFILTER_STD_VAR_IP, virNWFilterVarValueGetSimple(ipad= dr)) < 0) - goto err_exit; + goto error; =20 =20 filter =3D virNWFilterObjGetDef(obj); @@ -730,7 +730,7 @@ virNWFilterInstantiateFilterUpdate(virNWFilterDriverSta= tePtr driver, teardownOld, driver, forceWithPendingReq); =20 - err_exit: + error: virNWFilterObjUnlock(obj); =20 return rc; diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_le= arnipaddr.c index c72ae23e4c..c6497450eb 100644 --- a/src/nwfilter/nwfilter_learnipaddr.c +++ b/src/nwfilter/nwfilter_learnipaddr.c @@ -157,7 +157,7 @@ virNWFilterLockIface(const char *ifname) virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("mutex initialization failed")); g_free(ifaceLock); - goto err_exit; + goto error; } =20 if (virStrcpyStatic(ifaceLock->ifname, ifname) < 0) { @@ -166,12 +166,12 @@ virNWFilterLockIface(const char *ifname) "buffer "), ifaceLock->ifname); g_free(ifaceLock); - goto err_exit; + goto error; } =20 while (virHashAddEntry(ifaceLockMap, ifname, ifaceLock)) { g_free(ifaceLock); - goto err_exit; + goto error; } =20 ifaceLock->refctr =3D 0; @@ -185,7 +185,7 @@ virNWFilterLockIface(const char *ifname) =20 return 0; =20 - err_exit: + error: virMutexUnlock(&ifaceMapLock); =20 return -1; @@ -413,7 +413,7 @@ learnIPAddressThread(void *arg) if (virNetDevValidateConfig(req->binding->portdevname, NULL, req->ifin= dex) <=3D 0) { virResetLastError(); req->status =3D ENODEV; - goto done; + goto cleanup; } =20 handle =3D pcap_open_live(listen_if, BUFSIZ, 0, PKT_TIMEOUT_MS, errbuf= ); @@ -421,7 +421,7 @@ learnIPAddressThread(void *arg) if (handle =3D=3D NULL) { VIR_DEBUG("Couldn't open device %s: %s", listen_if, errbuf); req->status =3D ENODEV; - goto done; + goto cleanup; } =20 fds[0].fd =3D pcap_fileno(handle); @@ -435,7 +435,7 @@ learnIPAddressThread(void *arg) NULL, false) < 0) { VIR_DEBUG("Unable to apply DHCP only rules"); req->status =3D EINVAL; - goto done; + goto cleanup; } virBufferAddLit(&buf, "src port 67 and dst port 68"); } else { @@ -443,7 +443,7 @@ learnIPAddressThread(void *arg) &req->binding->mac) < 0) { VIR_DEBUG("Unable to apply basic rules"); req->status =3D EINVAL; - goto done; + goto cleanup; } virBufferAsprintf(&buf, "ether host %s or ether dst ff:ff:ff:ff:ff= :ff", macaddr); @@ -454,14 +454,14 @@ learnIPAddressThread(void *arg) if (pcap_compile(handle, &fp, filter, 1, 0) !=3D 0) { VIR_DEBUG("Couldn't compile filter '%s'", filter); req->status =3D EINVAL; - goto done; + goto cleanup; } =20 if (pcap_setfilter(handle, &fp) !=3D 0) { VIR_DEBUG("Couldn't set filter '%s'", filter); req->status =3D EINVAL; pcap_freecode(&fp); - goto done; + goto cleanup; } =20 pcap_freecode(&fp); @@ -621,7 +621,7 @@ learnIPAddressThread(void *arg) } } /* while */ =20 - done: + cleanup: if (handle) pcap_close(handle); =20 --=20 2.25.4