mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-06 17:17:56 +03:00
nwfilter: use standard label names when reasonable
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 <laine@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
9c5cd04545
commit
a082c3d1a1
@ -456,11 +456,11 @@ virNWFilterSnoopIPLeaseInstallRule(virNWFilterSnoopIPLeasePtr ipl,
|
|||||||
virNWFilterSnoopReqLock(req);
|
virNWFilterSnoopReqLock(req);
|
||||||
|
|
||||||
if (virNWFilterIPAddrMapAddIPAddr(req->binding->portdevname, ipaddr) < 0)
|
if (virNWFilterIPAddrMapAddIPAddr(req->binding->portdevname, ipaddr) < 0)
|
||||||
goto exit_snooprequnlock;
|
goto cleanup;
|
||||||
|
|
||||||
if (!instantiate) {
|
if (!instantiate) {
|
||||||
rc = 0;
|
rc = 0;
|
||||||
goto exit_snooprequnlock;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* instantiate the filters */
|
/* instantiate the filters */
|
||||||
@ -471,7 +471,7 @@ virNWFilterSnoopIPLeaseInstallRule(virNWFilterSnoopIPLeasePtr ipl,
|
|||||||
req->ifindex);
|
req->ifindex);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit_snooprequnlock:
|
cleanup:
|
||||||
virNWFilterSnoopReqUnlock(req);
|
virNWFilterSnoopReqUnlock(req);
|
||||||
|
|
||||||
VIR_FREE(ipaddr);
|
VIR_FREE(ipaddr);
|
||||||
@ -732,7 +732,7 @@ virNWFilterSnoopReqLeaseAdd(virNWFilterSnoopReqPtr req,
|
|||||||
|
|
||||||
virNWFilterSnoopReqUnlock(req);
|
virNWFilterSnoopReqUnlock(req);
|
||||||
|
|
||||||
goto exit;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
virNWFilterSnoopReqUnlock(req);
|
virNWFilterSnoopReqUnlock(req);
|
||||||
@ -757,7 +757,7 @@ virNWFilterSnoopReqLeaseAdd(virNWFilterSnoopReqPtr req,
|
|||||||
|
|
||||||
g_atomic_int_add(&virNWFilterSnoopState.nLeases, 1);
|
g_atomic_int_add(&virNWFilterSnoopState.nLeases, 1);
|
||||||
|
|
||||||
exit:
|
cleanup:
|
||||||
if (update_leasefile)
|
if (update_leasefile)
|
||||||
virNWFilterSnoopLeaseFileSave(pl);
|
virNWFilterSnoopLeaseFileSave(pl);
|
||||||
|
|
||||||
@ -902,7 +902,7 @@ virNWFilterSnoopDHCPGetOpt(virNWFilterSnoopDHCPHdrPtr pd, int len,
|
|||||||
switch (pd->d_opts[oind]) {
|
switch (pd->d_opts[oind]) {
|
||||||
case DHCPO_LEASE:
|
case DHCPO_LEASE:
|
||||||
if (olen - oind < 6)
|
if (olen - oind < 6)
|
||||||
goto malformed;
|
goto error;
|
||||||
if (*pleasetime)
|
if (*pleasetime)
|
||||||
return -1; /* duplicate lease time */
|
return -1; /* duplicate lease time */
|
||||||
memcpy(&nwint, (char *)pd->d_opts + oind + 2, sizeof(nwint));
|
memcpy(&nwint, (char *)pd->d_opts + oind + 2, sizeof(nwint));
|
||||||
@ -910,7 +910,7 @@ virNWFilterSnoopDHCPGetOpt(virNWFilterSnoopDHCPHdrPtr pd, int len,
|
|||||||
break;
|
break;
|
||||||
case DHCPO_MTYPE:
|
case DHCPO_MTYPE:
|
||||||
if (olen - oind < 3)
|
if (olen - oind < 3)
|
||||||
goto malformed;
|
goto error;
|
||||||
if (*pmtype)
|
if (*pmtype)
|
||||||
return -1; /* duplicate message type */
|
return -1; /* duplicate message type */
|
||||||
*pmtype = pd->d_opts[oind + 2];
|
*pmtype = pd->d_opts[oind + 2];
|
||||||
@ -922,12 +922,12 @@ virNWFilterSnoopDHCPGetOpt(virNWFilterSnoopDHCPHdrPtr pd, int len,
|
|||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
if (olen - oind < 2)
|
if (olen - oind < 2)
|
||||||
goto malformed;
|
goto error;
|
||||||
}
|
}
|
||||||
oind += pd->d_opts[oind + 1] + 2;
|
oind += pd->d_opts[oind + 1] + 2;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
malformed:
|
error:
|
||||||
VIR_WARN("got lost in the options!");
|
VIR_WARN("got lost in the options!");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1386,7 +1386,7 @@ virNWFilterDHCPSnoopThread(void *req0)
|
|||||||
virNWFilterSnoopReqUnlock(req);
|
virNWFilterSnoopReqUnlock(req);
|
||||||
|
|
||||||
if (req->threadStatus != THREAD_STATUS_OK)
|
if (req->threadStatus != THREAD_STATUS_OK)
|
||||||
goto exit;
|
goto cleanup;
|
||||||
|
|
||||||
while (!error) {
|
while (!error) {
|
||||||
if (virNWFilterSnoopAdjustPoll(pcapConf,
|
if (virNWFilterSnoopAdjustPoll(pcapConf,
|
||||||
@ -1414,7 +1414,7 @@ virNWFilterDHCPSnoopThread(void *req0)
|
|||||||
*/
|
*/
|
||||||
if (!virNWFilterSnoopIsActive(threadkey) ||
|
if (!virNWFilterSnoopIsActive(threadkey) ||
|
||||||
req->jobCompletionStatus != 0)
|
req->jobCompletionStatus != 0)
|
||||||
goto exit;
|
goto cleanup;
|
||||||
|
|
||||||
for (i = 0; n > 0 && i < G_N_ELEMENTS(fds); i++) {
|
for (i = 0; n > 0 && i < G_N_ELEMENTS(fds); i++) {
|
||||||
if (!fds[i].revents)
|
if (!fds[i].revents)
|
||||||
@ -1531,7 +1531,7 @@ virNWFilterDHCPSnoopThread(void *req0)
|
|||||||
virNWFilterSnoopReqUnlock(req);
|
virNWFilterSnoopReqUnlock(req);
|
||||||
virNWFilterSnoopUnlock();
|
virNWFilterSnoopUnlock();
|
||||||
|
|
||||||
exit:
|
cleanup:
|
||||||
virThreadPoolFree(worker);
|
virThreadPoolFree(worker);
|
||||||
|
|
||||||
virNWFilterSnoopReqPut(req);
|
virNWFilterSnoopReqPut(req);
|
||||||
@ -1774,14 +1774,14 @@ virNWFilterSnoopLeaseFileSave(virNWFilterSnoopIPLeasePtr ipl)
|
|||||||
virNWFilterSnoopLeaseFileOpen();
|
virNWFilterSnoopLeaseFileOpen();
|
||||||
if (virNWFilterSnoopLeaseFileWrite(virNWFilterSnoopState.leaseFD,
|
if (virNWFilterSnoopLeaseFileWrite(virNWFilterSnoopState.leaseFD,
|
||||||
req->ifkey, ipl) < 0)
|
req->ifkey, ipl) < 0)
|
||||||
goto err_exit;
|
goto error;
|
||||||
|
|
||||||
/* keep dead leases at < ~95% of file size */
|
/* keep dead leases at < ~95% of file size */
|
||||||
if (g_atomic_int_add(&virNWFilterSnoopState.wLeases, 1) >=
|
if (g_atomic_int_add(&virNWFilterSnoopState.wLeases, 1) >=
|
||||||
g_atomic_int_get(&virNWFilterSnoopState.nLeases) * 20)
|
g_atomic_int_get(&virNWFilterSnoopState.nLeases) * 20)
|
||||||
virNWFilterSnoopLeaseFileLoad(); /* load & refresh lease file */
|
virNWFilterSnoopLeaseFileLoad(); /* load & refresh lease file */
|
||||||
|
|
||||||
err_exit:
|
error:
|
||||||
virNWFilterSnoopUnlock();
|
virNWFilterSnoopUnlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1876,7 +1876,7 @@ virNWFilterSnoopLeaseFileRefresh(void)
|
|||||||
if (VIR_CLOSE(tfd) < 0) {
|
if (VIR_CLOSE(tfd) < 0) {
|
||||||
virReportSystemError(errno, _("unable to close %s"), TMPLEASEFILE);
|
virReportSystemError(errno, _("unable to close %s"), TMPLEASEFILE);
|
||||||
/* assuming the old lease file is still better, skip the renaming */
|
/* assuming the old lease file is still better, skip the renaming */
|
||||||
goto skip_rename;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rename(TMPLEASEFILE, LEASEFILE) < 0) {
|
if (rename(TMPLEASEFILE, LEASEFILE) < 0) {
|
||||||
@ -1886,7 +1886,7 @@ virNWFilterSnoopLeaseFileRefresh(void)
|
|||||||
}
|
}
|
||||||
g_atomic_int_set(&virNWFilterSnoopState.wLeases, 0);
|
g_atomic_int_set(&virNWFilterSnoopState.wLeases, 0);
|
||||||
|
|
||||||
skip_rename:
|
cleanup:
|
||||||
virNWFilterSnoopLeaseFileOpen();
|
virNWFilterSnoopLeaseFileOpen();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2051,14 +2051,14 @@ virNWFilterDHCPSnoopInit(void)
|
|||||||
if (!virNWFilterSnoopState.ifnameToKey ||
|
if (!virNWFilterSnoopState.ifnameToKey ||
|
||||||
!virNWFilterSnoopState.snoopReqs ||
|
!virNWFilterSnoopState.snoopReqs ||
|
||||||
!virNWFilterSnoopState.active)
|
!virNWFilterSnoopState.active)
|
||||||
goto err_exit;
|
goto error;
|
||||||
|
|
||||||
virNWFilterSnoopLeaseFileLoad();
|
virNWFilterSnoopLeaseFileLoad();
|
||||||
virNWFilterSnoopLeaseFileOpen();
|
virNWFilterSnoopLeaseFileOpen();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_exit:
|
error:
|
||||||
virHashFree(virNWFilterSnoopState.ifnameToKey);
|
virHashFree(virNWFilterSnoopState.ifnameToKey);
|
||||||
virNWFilterSnoopState.ifnameToKey = NULL;
|
virNWFilterSnoopState.ifnameToKey = NULL;
|
||||||
|
|
||||||
|
@ -2893,11 +2893,11 @@ ebtablesApplyBasicRules(const char *ifname,
|
|||||||
ebtablesRenameTmpRootChainFW(fw, true, ifname);
|
ebtablesRenameTmpRootChainFW(fw, true, ifname);
|
||||||
|
|
||||||
if (virFirewallApply(fw) < 0)
|
if (virFirewallApply(fw) < 0)
|
||||||
goto tear_down_tmpebchains;
|
goto error;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
tear_down_tmpebchains:
|
error:
|
||||||
ebtablesCleanAll(ifname);
|
ebtablesCleanAll(ifname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -3009,11 +3009,11 @@ ebtablesApplyDHCPOnlyRules(const char *ifname,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (virFirewallApply(fw) < 0)
|
if (virFirewallApply(fw) < 0)
|
||||||
goto tear_down_tmpebchains;
|
goto error;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
tear_down_tmpebchains:
|
error:
|
||||||
ebtablesCleanAll(ifname);
|
ebtablesCleanAll(ifname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -3060,11 +3060,11 @@ ebtablesApplyDropAllRules(const char *ifname)
|
|||||||
ebtablesRenameTmpRootChainFW(fw, false, ifname);
|
ebtablesRenameTmpRootChainFW(fw, false, ifname);
|
||||||
|
|
||||||
if (virFirewallApply(fw) < 0)
|
if (virFirewallApply(fw) < 0)
|
||||||
goto tear_down_tmpebchains;
|
goto error;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
tear_down_tmpebchains:
|
error:
|
||||||
ebtablesCleanAll(ifname);
|
ebtablesCleanAll(ifname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -204,14 +204,14 @@ virNWFilterCreateVarsFrom(virHashTablePtr vars1,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (virNWFilterHashTablePutAll(vars1, res) < 0)
|
if (virNWFilterHashTablePutAll(vars1, res) < 0)
|
||||||
goto err_exit;
|
goto error;
|
||||||
|
|
||||||
if (virNWFilterHashTablePutAll(vars2, res) < 0)
|
if (virNWFilterHashTablePutAll(vars2, res) < 0)
|
||||||
goto err_exit;
|
goto error;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
err_exit:
|
error:
|
||||||
virHashFree(res);
|
virHashFree(res);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -527,7 +527,7 @@ virNWFilterDoInstantiate(virNWFilterTechDriverPtr techdriver,
|
|||||||
|
|
||||||
if (!missing_vars) {
|
if (!missing_vars) {
|
||||||
rc = -1;
|
rc = -1;
|
||||||
goto err_exit;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = virNWFilterDetermineMissingVarsRec(filter,
|
rc = virNWFilterDetermineMissingVarsRec(filter,
|
||||||
@ -536,7 +536,7 @@ virNWFilterDoInstantiate(virNWFilterTechDriverPtr techdriver,
|
|||||||
useNewFilter,
|
useNewFilter,
|
||||||
driver);
|
driver);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
goto err_exit;
|
goto error;
|
||||||
|
|
||||||
lv = virHashLookup(binding->filterparams, NWFILTER_VARNAME_CTRL_IP_LEARNING);
|
lv = virHashLookup(binding->filterparams, NWFILTER_VARNAME_CTRL_IP_LEARNING);
|
||||||
if (lv)
|
if (lv)
|
||||||
@ -558,7 +558,7 @@ virNWFilterDoInstantiate(virNWFilterTechDriverPtr techdriver,
|
|||||||
rc = virNWFilterDHCPSnoopReq(techdriver,
|
rc = virNWFilterDHCPSnoopReq(techdriver,
|
||||||
binding,
|
binding,
|
||||||
driver);
|
driver);
|
||||||
goto err_exit;
|
goto error;
|
||||||
} else if (STRCASEEQ(learning, "any")) {
|
} else if (STRCASEEQ(learning, "any")) {
|
||||||
if (!virNWFilterHasLearnReq(ifindex)) {
|
if (!virNWFilterHasLearnReq(ifindex)) {
|
||||||
rc = virNWFilterLearnIPAddress(techdriver,
|
rc = virNWFilterLearnIPAddress(techdriver,
|
||||||
@ -567,14 +567,14 @@ virNWFilterDoInstantiate(virNWFilterTechDriverPtr techdriver,
|
|||||||
driver,
|
driver,
|
||||||
DETECT_DHCP|DETECT_STATIC);
|
DETECT_DHCP|DETECT_STATIC);
|
||||||
}
|
}
|
||||||
goto err_exit;
|
goto error;
|
||||||
} else {
|
} else {
|
||||||
rc = -1;
|
rc = -1;
|
||||||
virReportError(VIR_ERR_PARSE_FAILED,
|
virReportError(VIR_ERR_PARSE_FAILED,
|
||||||
_("filter '%s' "
|
_("filter '%s' "
|
||||||
"learning value '%s' invalid."),
|
"learning value '%s' invalid."),
|
||||||
filter->name, learning);
|
filter->name, learning);
|
||||||
goto err_exit;
|
goto error;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
goto err_unresolvable_vars;
|
goto err_unresolvable_vars;
|
||||||
@ -583,7 +583,7 @@ virNWFilterDoInstantiate(virNWFilterTechDriverPtr techdriver,
|
|||||||
goto err_unresolvable_vars;
|
goto err_unresolvable_vars;
|
||||||
} else if (!forceWithPendingReq &&
|
} else if (!forceWithPendingReq &&
|
||||||
virNWFilterHasLearnReq(ifindex)) {
|
virNWFilterHasLearnReq(ifindex)) {
|
||||||
goto err_exit;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = virNWFilterDefToInst(driver,
|
rc = virNWFilterDefToInst(driver,
|
||||||
@ -593,7 +593,7 @@ virNWFilterDoInstantiate(virNWFilterTechDriverPtr techdriver,
|
|||||||
&inst);
|
&inst);
|
||||||
|
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
goto err_exit;
|
goto error;
|
||||||
|
|
||||||
switch (useNewFilter) {
|
switch (useNewFilter) {
|
||||||
case INSTANTIATE_FOLLOW_NEWFILTER:
|
case INSTANTIATE_FOLLOW_NEWFILTER:
|
||||||
@ -606,7 +606,7 @@ virNWFilterDoInstantiate(virNWFilterTechDriverPtr techdriver,
|
|||||||
|
|
||||||
if (instantiate) {
|
if (instantiate) {
|
||||||
if (virNWFilterLockIface(binding->portdevname) < 0)
|
if (virNWFilterLockIface(binding->portdevname) < 0)
|
||||||
goto err_exit;
|
goto error;
|
||||||
|
|
||||||
rc = techdriver->applyNewRules(binding->portdevname, inst.rules, inst.nrules);
|
rc = techdriver->applyNewRules(binding->portdevname, inst.rules, inst.nrules);
|
||||||
|
|
||||||
@ -623,7 +623,7 @@ virNWFilterDoInstantiate(virNWFilterTechDriverPtr techdriver,
|
|||||||
virNWFilterUnlockIface(binding->portdevname);
|
virNWFilterUnlockIface(binding->portdevname);
|
||||||
}
|
}
|
||||||
|
|
||||||
err_exit:
|
error:
|
||||||
virNWFilterInstReset(&inst);
|
virNWFilterInstReset(&inst);
|
||||||
virHashFree(missing_vars);
|
virHashFree(missing_vars);
|
||||||
|
|
||||||
@ -640,7 +640,7 @@ virNWFilterDoInstantiate(virNWFilterTechDriverPtr techdriver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
rc = -1;
|
rc = -1;
|
||||||
goto err_exit;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -707,14 +707,14 @@ virNWFilterInstantiateFilterUpdate(virNWFilterDriverStatePtr driver,
|
|||||||
if (virNWFilterVarHashmapAddStdValue(binding->filterparams,
|
if (virNWFilterVarHashmapAddStdValue(binding->filterparams,
|
||||||
NWFILTER_STD_VAR_MAC,
|
NWFILTER_STD_VAR_MAC,
|
||||||
vmmacaddr) < 0)
|
vmmacaddr) < 0)
|
||||||
goto err_exit;
|
goto error;
|
||||||
|
|
||||||
ipaddr = virNWFilterIPAddrMapGetIPAddr(binding->portdevname);
|
ipaddr = virNWFilterIPAddrMapGetIPAddr(binding->portdevname);
|
||||||
if (ipaddr &&
|
if (ipaddr &&
|
||||||
virNWFilterVarHashmapAddStdValue(binding->filterparams,
|
virNWFilterVarHashmapAddStdValue(binding->filterparams,
|
||||||
NWFILTER_STD_VAR_IP,
|
NWFILTER_STD_VAR_IP,
|
||||||
virNWFilterVarValueGetSimple(ipaddr)) < 0)
|
virNWFilterVarValueGetSimple(ipaddr)) < 0)
|
||||||
goto err_exit;
|
goto error;
|
||||||
|
|
||||||
|
|
||||||
filter = virNWFilterObjGetDef(obj);
|
filter = virNWFilterObjGetDef(obj);
|
||||||
@ -737,7 +737,7 @@ virNWFilterInstantiateFilterUpdate(virNWFilterDriverStatePtr driver,
|
|||||||
teardownOld, driver,
|
teardownOld, driver,
|
||||||
forceWithPendingReq);
|
forceWithPendingReq);
|
||||||
|
|
||||||
err_exit:
|
error:
|
||||||
virNWFilterObjUnlock(obj);
|
virNWFilterObjUnlock(obj);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -152,13 +152,13 @@ virNWFilterLockIface(const char *ifname)
|
|||||||
ifaceLock = virHashLookup(ifaceLockMap, ifname);
|
ifaceLock = virHashLookup(ifaceLockMap, ifname);
|
||||||
if (!ifaceLock) {
|
if (!ifaceLock) {
|
||||||
if (VIR_ALLOC(ifaceLock) < 0)
|
if (VIR_ALLOC(ifaceLock) < 0)
|
||||||
goto err_exit;
|
goto error;
|
||||||
|
|
||||||
if (virMutexInitRecursive(&ifaceLock->lock) < 0) {
|
if (virMutexInitRecursive(&ifaceLock->lock) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("mutex initialization failed"));
|
_("mutex initialization failed"));
|
||||||
VIR_FREE(ifaceLock);
|
VIR_FREE(ifaceLock);
|
||||||
goto err_exit;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virStrcpyStatic(ifaceLock->ifname, ifname) < 0) {
|
if (virStrcpyStatic(ifaceLock->ifname, ifname) < 0) {
|
||||||
@ -167,12 +167,12 @@ virNWFilterLockIface(const char *ifname)
|
|||||||
"buffer "),
|
"buffer "),
|
||||||
ifaceLock->ifname);
|
ifaceLock->ifname);
|
||||||
VIR_FREE(ifaceLock);
|
VIR_FREE(ifaceLock);
|
||||||
goto err_exit;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (virHashAddEntry(ifaceLockMap, ifname, ifaceLock)) {
|
while (virHashAddEntry(ifaceLockMap, ifname, ifaceLock)) {
|
||||||
VIR_FREE(ifaceLock);
|
VIR_FREE(ifaceLock);
|
||||||
goto err_exit;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
ifaceLock->refctr = 0;
|
ifaceLock->refctr = 0;
|
||||||
@ -186,7 +186,7 @@ virNWFilterLockIface(const char *ifname)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_exit:
|
error:
|
||||||
virMutexUnlock(&ifaceMapLock);
|
virMutexUnlock(&ifaceMapLock);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
@ -414,7 +414,7 @@ learnIPAddressThread(void *arg)
|
|||||||
if (virNetDevValidateConfig(req->binding->portdevname, NULL, req->ifindex) <= 0) {
|
if (virNetDevValidateConfig(req->binding->portdevname, NULL, req->ifindex) <= 0) {
|
||||||
virResetLastError();
|
virResetLastError();
|
||||||
req->status = ENODEV;
|
req->status = ENODEV;
|
||||||
goto done;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle = pcap_open_live(listen_if, BUFSIZ, 0, PKT_TIMEOUT_MS, errbuf);
|
handle = pcap_open_live(listen_if, BUFSIZ, 0, PKT_TIMEOUT_MS, errbuf);
|
||||||
@ -422,7 +422,7 @@ learnIPAddressThread(void *arg)
|
|||||||
if (handle == NULL) {
|
if (handle == NULL) {
|
||||||
VIR_DEBUG("Couldn't open device %s: %s", listen_if, errbuf);
|
VIR_DEBUG("Couldn't open device %s: %s", listen_if, errbuf);
|
||||||
req->status = ENODEV;
|
req->status = ENODEV;
|
||||||
goto done;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
fds[0].fd = pcap_fileno(handle);
|
fds[0].fd = pcap_fileno(handle);
|
||||||
@ -436,7 +436,7 @@ learnIPAddressThread(void *arg)
|
|||||||
NULL, false) < 0) {
|
NULL, false) < 0) {
|
||||||
VIR_DEBUG("Unable to apply DHCP only rules");
|
VIR_DEBUG("Unable to apply DHCP only rules");
|
||||||
req->status = EINVAL;
|
req->status = EINVAL;
|
||||||
goto done;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
virBufferAddLit(&buf, "src port 67 and dst port 68");
|
virBufferAddLit(&buf, "src port 67 and dst port 68");
|
||||||
} else {
|
} else {
|
||||||
@ -444,7 +444,7 @@ learnIPAddressThread(void *arg)
|
|||||||
&req->binding->mac) < 0) {
|
&req->binding->mac) < 0) {
|
||||||
VIR_DEBUG("Unable to apply basic rules");
|
VIR_DEBUG("Unable to apply basic rules");
|
||||||
req->status = EINVAL;
|
req->status = EINVAL;
|
||||||
goto done;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
virBufferAsprintf(&buf, "ether host %s or ether dst ff:ff:ff:ff:ff:ff",
|
virBufferAsprintf(&buf, "ether host %s or ether dst ff:ff:ff:ff:ff:ff",
|
||||||
macaddr);
|
macaddr);
|
||||||
@ -455,14 +455,14 @@ learnIPAddressThread(void *arg)
|
|||||||
if (pcap_compile(handle, &fp, filter, 1, 0) != 0) {
|
if (pcap_compile(handle, &fp, filter, 1, 0) != 0) {
|
||||||
VIR_DEBUG("Couldn't compile filter '%s'", filter);
|
VIR_DEBUG("Couldn't compile filter '%s'", filter);
|
||||||
req->status = EINVAL;
|
req->status = EINVAL;
|
||||||
goto done;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pcap_setfilter(handle, &fp) != 0) {
|
if (pcap_setfilter(handle, &fp) != 0) {
|
||||||
VIR_DEBUG("Couldn't set filter '%s'", filter);
|
VIR_DEBUG("Couldn't set filter '%s'", filter);
|
||||||
req->status = EINVAL;
|
req->status = EINVAL;
|
||||||
pcap_freecode(&fp);
|
pcap_freecode(&fp);
|
||||||
goto done;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
pcap_freecode(&fp);
|
pcap_freecode(&fp);
|
||||||
@ -622,7 +622,7 @@ learnIPAddressThread(void *arg)
|
|||||||
}
|
}
|
||||||
} /* while */
|
} /* while */
|
||||||
|
|
||||||
done:
|
cleanup:
|
||||||
VIR_FREE(filter);
|
VIR_FREE(filter);
|
||||||
|
|
||||||
if (handle)
|
if (handle)
|
||||||
|
Loading…
Reference in New Issue
Block a user