virNWFilterSnoopReqLock(req);
if (virNWFilterIPAddrMapAddIPAddr(req->binding->portdevname, ipaddr) < 0)
- goto exit_snooprequnlock;
+ goto cleanup;
if (!instantiate) {
rc = 0;
- goto exit_snooprequnlock;
+ goto cleanup;
}
/* instantiate the filters */
req->ifindex);
}
- exit_snooprequnlock:
+ cleanup:
virNWFilterSnoopReqUnlock(req);
VIR_FREE(ipaddr);
virNWFilterSnoopReqUnlock(req);
- goto exit;
+ goto cleanup;
}
virNWFilterSnoopReqUnlock(req);
g_atomic_int_add(&virNWFilterSnoopState.nLeases, 1);
- exit:
+ cleanup:
if (update_leasefile)
virNWFilterSnoopLeaseFileSave(pl);
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));
break;
case DHCPO_MTYPE:
if (olen - oind < 3)
- goto malformed;
+ goto error;
if (*pmtype)
return -1; /* duplicate message type */
*pmtype = pd->d_opts[oind + 2];
return 0;
default:
if (olen - oind < 2)
- goto malformed;
+ goto error;
}
oind += pd->d_opts[oind + 1] + 2;
}
return 0;
- malformed:
+ error:
VIR_WARN("got lost in the options!");
return -1;
}
virNWFilterSnoopReqUnlock(req);
if (req->threadStatus != THREAD_STATUS_OK)
- goto exit;
+ goto cleanup;
while (!error) {
if (virNWFilterSnoopAdjustPoll(pcapConf,
*/
if (!virNWFilterSnoopIsActive(threadkey) ||
req->jobCompletionStatus != 0)
- goto exit;
+ goto cleanup;
for (i = 0; n > 0 && i < G_N_ELEMENTS(fds); i++) {
if (!fds[i].revents)
virNWFilterSnoopReqUnlock(req);
virNWFilterSnoopUnlock();
- exit:
+ cleanup:
virThreadPoolFree(worker);
virNWFilterSnoopReqPut(req);
virNWFilterSnoopLeaseFileOpen();
if (virNWFilterSnoopLeaseFileWrite(virNWFilterSnoopState.leaseFD,
req->ifkey, ipl) < 0)
- goto err_exit;
+ goto error;
/* keep dead leases at < ~95% of file size */
if (g_atomic_int_add(&virNWFilterSnoopState.wLeases, 1) >=
g_atomic_int_get(&virNWFilterSnoopState.nLeases) * 20)
virNWFilterSnoopLeaseFileLoad(); /* load & refresh lease file */
- err_exit:
+ error:
virNWFilterSnoopUnlock();
}
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;
}
if (rename(TMPLEASEFILE, LEASEFILE) < 0) {
}
g_atomic_int_set(&virNWFilterSnoopState.wLeases, 0);
- skip_rename:
+ cleanup:
virNWFilterSnoopLeaseFileOpen();
}
if (!virNWFilterSnoopState.ifnameToKey ||
!virNWFilterSnoopState.snoopReqs ||
!virNWFilterSnoopState.active)
- goto err_exit;
+ goto error;
virNWFilterSnoopLeaseFileLoad();
virNWFilterSnoopLeaseFileOpen();
return 0;
- err_exit:
+ error:
virHashFree(virNWFilterSnoopState.ifnameToKey);
virNWFilterSnoopState.ifnameToKey = NULL;
ebtablesRenameTmpRootChainFW(fw, true, ifname);
if (virFirewallApply(fw) < 0)
- goto tear_down_tmpebchains;
+ goto error;
return 0;
- tear_down_tmpebchains:
+ error:
ebtablesCleanAll(ifname);
return -1;
}
}
if (virFirewallApply(fw) < 0)
- goto tear_down_tmpebchains;
+ goto error;
return 0;
- tear_down_tmpebchains:
+ error:
ebtablesCleanAll(ifname);
return -1;
}
ebtablesRenameTmpRootChainFW(fw, false, ifname);
if (virFirewallApply(fw) < 0)
- goto tear_down_tmpebchains;
+ goto error;
return 0;
- tear_down_tmpebchains:
+ error:
ebtablesCleanAll(ifname);
return -1;
}
return NULL;
if (virNWFilterHashTablePutAll(vars1, res) < 0)
- goto err_exit;
+ goto error;
if (virNWFilterHashTablePutAll(vars2, res) < 0)
- goto err_exit;
+ goto error;
return res;
- err_exit:
+ error:
virHashFree(res);
return NULL;
}
if (!missing_vars) {
rc = -1;
- goto err_exit;
+ goto error;
}
rc = virNWFilterDetermineMissingVarsRec(filter,
useNewFilter,
driver);
if (rc < 0)
- goto err_exit;
+ goto error;
lv = virHashLookup(binding->filterparams, NWFILTER_VARNAME_CTRL_IP_LEARNING);
if (lv)
rc = virNWFilterDHCPSnoopReq(techdriver,
binding,
driver);
- goto err_exit;
+ goto error;
} else if (STRCASEEQ(learning, "any")) {
if (!virNWFilterHasLearnReq(ifindex)) {
rc = virNWFilterLearnIPAddress(techdriver,
driver,
DETECT_DHCP|DETECT_STATIC);
}
- goto err_exit;
+ goto error;
} else {
rc = -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;
goto err_unresolvable_vars;
} else if (!forceWithPendingReq &&
virNWFilterHasLearnReq(ifindex)) {
- goto err_exit;
+ goto error;
}
rc = virNWFilterDefToInst(driver,
&inst);
if (rc < 0)
- goto err_exit;
+ goto error;
switch (useNewFilter) {
case INSTANTIATE_FOLLOW_NEWFILTER:
if (instantiate) {
if (virNWFilterLockIface(binding->portdevname) < 0)
- goto err_exit;
+ goto error;
rc = techdriver->applyNewRules(binding->portdevname, inst.rules, inst.nrules);
virNWFilterUnlockIface(binding->portdevname);
}
- err_exit:
+ error:
virNWFilterInstReset(&inst);
virHashFree(missing_vars);
}
rc = -1;
- goto err_exit;
+ goto error;
}
if (virNWFilterVarHashmapAddStdValue(binding->filterparams,
NWFILTER_STD_VAR_MAC,
vmmacaddr) < 0)
- goto err_exit;
+ goto error;
ipaddr = virNWFilterIPAddrMapGetIPAddr(binding->portdevname);
if (ipaddr &&
virNWFilterVarHashmapAddStdValue(binding->filterparams,
NWFILTER_STD_VAR_IP,
virNWFilterVarValueGetSimple(ipaddr)) < 0)
- goto err_exit;
+ goto error;
filter = virNWFilterObjGetDef(obj);
teardownOld, driver,
forceWithPendingReq);
- err_exit:
+ error:
virNWFilterObjUnlock(obj);
return rc;
ifaceLock = virHashLookup(ifaceLockMap, ifname);
if (!ifaceLock) {
if (VIR_ALLOC(ifaceLock) < 0)
- goto err_exit;
+ goto error;
if (virMutexInitRecursive(&ifaceLock->lock) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("mutex initialization failed"));
VIR_FREE(ifaceLock);
- goto err_exit;
+ goto error;
}
if (virStrcpyStatic(ifaceLock->ifname, ifname) < 0) {
"buffer "),
ifaceLock->ifname);
VIR_FREE(ifaceLock);
- goto err_exit;
+ goto error;
}
while (virHashAddEntry(ifaceLockMap, ifname, ifaceLock)) {
VIR_FREE(ifaceLock);
- goto err_exit;
+ goto error;
}
ifaceLock->refctr = 0;
return 0;
- err_exit:
+ error:
virMutexUnlock(&ifaceMapLock);
return -1;
if (virNetDevValidateConfig(req->binding->portdevname, NULL, req->ifindex) <= 0) {
virResetLastError();
req->status = ENODEV;
- goto done;
+ goto cleanup;
}
handle = pcap_open_live(listen_if, BUFSIZ, 0, PKT_TIMEOUT_MS, errbuf);
if (handle == NULL) {
VIR_DEBUG("Couldn't open device %s: %s", listen_if, errbuf);
req->status = ENODEV;
- goto done;
+ goto cleanup;
}
fds[0].fd = pcap_fileno(handle);
NULL, false) < 0) {
VIR_DEBUG("Unable to apply DHCP only rules");
req->status = EINVAL;
- goto done;
+ goto cleanup;
}
virBufferAddLit(&buf, "src port 67 and dst port 68");
} else {
&req->binding->mac) < 0) {
VIR_DEBUG("Unable to apply basic rules");
req->status = EINVAL;
- goto done;
+ goto cleanup;
}
virBufferAsprintf(&buf, "ether host %s or ether dst ff:ff:ff:ff:ff:ff",
macaddr);
if (pcap_compile(handle, &fp, filter, 1, 0) != 0) {
VIR_DEBUG("Couldn't compile filter '%s'", filter);
req->status = EINVAL;
- goto done;
+ goto cleanup;
}
if (pcap_setfilter(handle, &fp) != 0) {
VIR_DEBUG("Couldn't set filter '%s'", filter);
req->status = EINVAL;
pcap_freecode(&fp);
- goto done;
+ goto cleanup;
}
pcap_freecode(&fp);
}
} /* while */
- done:
+ cleanup:
VIR_FREE(filter);
if (handle)