mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Replace use of virNWFilterReportError with virReportError
Update the network filter driver to use virReportError instead of the virNWFilterReportError custom macro Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
1
cfg.mk
1
cfg.mk
@@ -541,7 +541,6 @@ msg_gen_function += virLibNWFilterError
|
|||||||
msg_gen_function += virLibSecretError
|
msg_gen_function += virLibSecretError
|
||||||
msg_gen_function += virLibStoragePoolError
|
msg_gen_function += virLibStoragePoolError
|
||||||
msg_gen_function += virLibStorageVolError
|
msg_gen_function += virLibStorageVolError
|
||||||
msg_gen_function += virNWFilterReportError
|
|
||||||
msg_gen_function += virRaiseError
|
msg_gen_function += virRaiseError
|
||||||
msg_gen_function += virReportError
|
msg_gen_function += virReportError
|
||||||
msg_gen_function += virReportErrorHelper
|
msg_gen_function += virReportErrorHelper
|
||||||
|
|||||||
@@ -69,10 +69,6 @@
|
|||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_NWFILTER
|
#define VIR_FROM_THIS VIR_FROM_NWFILTER
|
||||||
|
|
||||||
#define virNWFilterReportError(code, fmt...) \
|
|
||||||
virReportErrorHelper(VIR_FROM_NWFILTER, code, __FILE__, \
|
|
||||||
__FUNCTION__, __LINE__, fmt)
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBPCAP
|
#ifdef HAVE_LIBPCAP
|
||||||
|
|
||||||
# define LEASEFILE LOCALSTATEDIR "/run/libvirt/network/nwfilter.leases"
|
# define LEASEFILE LOCALSTATEDIR "/run/libvirt/network/nwfilter.leases"
|
||||||
@@ -576,7 +572,7 @@ virNWFilterSnoopReqNew(const char *ifkey)
|
|||||||
virNWFilterSnoopReqPtr req;
|
virNWFilterSnoopReqPtr req;
|
||||||
|
|
||||||
if (ifkey == NULL || strlen(ifkey) != VIR_IFKEY_LEN - 1) {
|
if (ifkey == NULL || strlen(ifkey) != VIR_IFKEY_LEN - 1) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("virNWFilterSnoopReqNew called with invalid "
|
_("virNWFilterSnoopReqNew called with invalid "
|
||||||
"key \"%s\" (%zu)"),
|
"key \"%s\" (%zu)"),
|
||||||
ifkey ? ifkey : "",
|
ifkey ? ifkey : "",
|
||||||
@@ -890,7 +886,7 @@ virNWFilterSnoopReqLeaseDel(virNWFilterSnoopReqPtr req,
|
|||||||
if (req->techdriver &&
|
if (req->techdriver &&
|
||||||
req->techdriver->applyDHCPOnlyRules(req->ifname, &req->macaddr,
|
req->techdriver->applyDHCPOnlyRules(req->ifname, &req->macaddr,
|
||||||
dhcpsrvrs, false) < 0) {
|
dhcpsrvrs, false) < 0) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("virNWFilterSnoopListDel failed"));
|
_("virNWFilterSnoopListDel failed"));
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
@@ -1097,7 +1093,7 @@ virNWFilterSnoopDHCPOpen(const char *ifname, virMacAddr *mac,
|
|||||||
handle = pcap_create(ifname, pcap_errbuf);
|
handle = pcap_create(ifname, pcap_errbuf);
|
||||||
|
|
||||||
if (handle == NULL) {
|
if (handle == NULL) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("pcap_create failed"));
|
_("pcap_create failed"));
|
||||||
goto cleanup_nohandle;
|
goto cleanup_nohandle;
|
||||||
}
|
}
|
||||||
@@ -1105,25 +1101,25 @@ virNWFilterSnoopDHCPOpen(const char *ifname, virMacAddr *mac,
|
|||||||
if (pcap_set_snaplen(handle, PCAP_PBUFSIZE) < 0 ||
|
if (pcap_set_snaplen(handle, PCAP_PBUFSIZE) < 0 ||
|
||||||
pcap_set_buffer_size(handle, PCAP_BUFFERSIZE) < 0 ||
|
pcap_set_buffer_size(handle, PCAP_BUFFERSIZE) < 0 ||
|
||||||
pcap_activate(handle) < 0) {
|
pcap_activate(handle) < 0) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("setup of pcap handle failed"));
|
_("setup of pcap handle failed"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pcap_compile(handle, &fp, ext_filter, 1, PCAP_NETMASK_UNKNOWN) != 0) {
|
if (pcap_compile(handle, &fp, ext_filter, 1, PCAP_NETMASK_UNKNOWN) != 0) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("pcap_compile: %s"), pcap_geterr(handle));
|
_("pcap_compile: %s"), pcap_geterr(handle));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pcap_setfilter(handle, &fp) != 0) {
|
if (pcap_setfilter(handle, &fp) != 0) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("pcap_setfilter: %s"), pcap_geterr(handle));
|
_("pcap_setfilter: %s"), pcap_geterr(handle));
|
||||||
goto cleanup_freecode;
|
goto cleanup_freecode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pcap_setdirection(handle, dir) < 0) {
|
if (pcap_setdirection(handle, dir) < 0) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("pcap_setdirection: %s"),
|
_("pcap_setdirection: %s"),
|
||||||
pcap_geterr(handle));
|
pcap_geterr(handle));
|
||||||
goto cleanup_freecode;
|
goto cleanup_freecode;
|
||||||
@@ -1158,7 +1154,7 @@ static void virNWFilterDHCPDecodeWorker(void *jobdata, void *opaque)
|
|||||||
job->caplen, job->fromVM) == -1) {
|
job->caplen, job->fromVM) == -1) {
|
||||||
req->jobCompletionStatus = -1;
|
req->jobCompletionStatus = -1;
|
||||||
|
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Instantiation of rules failed on "
|
_("Instantiation of rules failed on "
|
||||||
"interface '%s'"), req->ifname);
|
"interface '%s'"), req->ifname);
|
||||||
}
|
}
|
||||||
@@ -1465,7 +1461,7 @@ virNWFilterDHCPSnoopThread(void *req0)
|
|||||||
/* protect req->ifname */
|
/* protect req->ifname */
|
||||||
virNWFilterSnoopReqLock(req);
|
virNWFilterSnoopReqLock(req);
|
||||||
|
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("interface '%s' failing; "
|
_("interface '%s' failing; "
|
||||||
"reopening"),
|
"reopening"),
|
||||||
req->ifname);
|
req->ifname);
|
||||||
@@ -1519,7 +1515,7 @@ virNWFilterDHCPSnoopThread(void *req0)
|
|||||||
hdr->caplen,
|
hdr->caplen,
|
||||||
pcapConf[i].dir,
|
pcapConf[i].dir,
|
||||||
&pcapConf[i].qCtr) < 0) {
|
&pcapConf[i].qCtr) < 0) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Job submission failed on "
|
_("Job submission failed on "
|
||||||
"interface '%s'"), req->ifname);
|
"interface '%s'"), req->ifname);
|
||||||
error = true;
|
error = true;
|
||||||
@@ -1625,7 +1621,7 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver,
|
|||||||
|
|
||||||
/* check that all tools are available for applying the filters (late) */
|
/* check that all tools are available for applying the filters (late) */
|
||||||
if ( !techdriver->canApplyBasicRules()) {
|
if ( !techdriver->canApplyBasicRules()) {
|
||||||
virNWFilterReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("IP parameter must be provided since "
|
_("IP parameter must be provided since "
|
||||||
"snooping the IP address does not work "
|
"snooping the IP address does not work "
|
||||||
"possibly due to missing tools"));
|
"possibly due to missing tools"));
|
||||||
@@ -1637,13 +1633,14 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver,
|
|||||||
|
|
||||||
if (techdriver->applyDHCPOnlyRules(req->ifname, &req->macaddr,
|
if (techdriver->applyDHCPOnlyRules(req->ifname, &req->macaddr,
|
||||||
dhcpsrvrs, false) < 0) {
|
dhcpsrvrs, false) < 0) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, _("applyDHCPOnlyRules "
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("applyDHCPOnlyRules "
|
||||||
"failed - spoofing not protected!"));
|
"failed - spoofing not protected!"));
|
||||||
goto exit_snoopreqput;
|
goto exit_snoopreqput;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virNWFilterHashTablePutAll(filterparams, req->vars) < 0) {
|
if (virNWFilterHashTablePutAll(filterparams, req->vars) < 0) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("virNWFilterDHCPSnoopReq: can't copy variables"
|
_("virNWFilterDHCPSnoopReq: can't copy variables"
|
||||||
" on if %s"), ifkey);
|
" on if %s"), ifkey);
|
||||||
goto exit_snoopreqput;
|
goto exit_snoopreqput;
|
||||||
@@ -1653,7 +1650,7 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver,
|
|||||||
|
|
||||||
if (virHashAddEntry(virNWFilterSnoopState.ifnameToKey, ifname,
|
if (virHashAddEntry(virNWFilterSnoopState.ifnameToKey, ifname,
|
||||||
req->ifkey) < 0) {
|
req->ifkey) < 0) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("virNWFilterDHCPSnoopReq ifname map failed"
|
_("virNWFilterDHCPSnoopReq ifname map failed"
|
||||||
" on interface \"%s\" key \"%s\""), ifname,
|
" on interface \"%s\" key \"%s\""), ifname,
|
||||||
ifkey);
|
ifkey);
|
||||||
@@ -1662,7 +1659,7 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver,
|
|||||||
|
|
||||||
if (isnewreq &&
|
if (isnewreq &&
|
||||||
virHashAddEntry(virNWFilterSnoopState.snoopReqs, ifkey, req) < 0) {
|
virHashAddEntry(virNWFilterSnoopState.snoopReqs, ifkey, req) < 0) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("virNWFilterDHCPSnoopReq req add failed on"
|
_("virNWFilterDHCPSnoopReq req add failed on"
|
||||||
" interface \"%s\" ifkey \"%s\""), ifname,
|
" interface \"%s\" ifkey \"%s\""), ifname,
|
||||||
ifkey);
|
ifkey);
|
||||||
@@ -1674,7 +1671,7 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver,
|
|||||||
|
|
||||||
if (virThreadCreate(&thread, false, virNWFilterDHCPSnoopThread,
|
if (virThreadCreate(&thread, false, virNWFilterDHCPSnoopThread,
|
||||||
req) != 0) {
|
req) != 0) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("virNWFilterDHCPSnoopReq virThreadCreate "
|
_("virNWFilterDHCPSnoopReq virThreadCreate "
|
||||||
"failed on interface '%s'"), ifname);
|
"failed on interface '%s'"), ifname);
|
||||||
goto exit_snoopreq_unlock;
|
goto exit_snoopreq_unlock;
|
||||||
@@ -1684,14 +1681,14 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver,
|
|||||||
|
|
||||||
req->threadkey = virNWFilterSnoopActivate(req);
|
req->threadkey = virNWFilterSnoopActivate(req);
|
||||||
if (!req->threadkey) {
|
if (!req->threadkey) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Activation of snoop request failed on "
|
_("Activation of snoop request failed on "
|
||||||
"interface '%s'"), req->ifname);
|
"interface '%s'"), req->ifname);
|
||||||
goto exit_snoopreq_unlock;
|
goto exit_snoopreq_unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virNWFilterSnoopReqRestore(req) < 0) {
|
if (virNWFilterSnoopReqRestore(req) < 0) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Restoring of leases failed on "
|
_("Restoring of leases failed on "
|
||||||
"interface '%s'"), req->ifname);
|
"interface '%s'"), req->ifname);
|
||||||
goto exit_snoop_cancel;
|
goto exit_snoop_cancel;
|
||||||
@@ -1932,7 +1929,7 @@ virNWFilterSnoopLeaseFileLoad(void)
|
|||||||
time(&now);
|
time(&now);
|
||||||
while (fp && fgets(line, sizeof(line), fp)) {
|
while (fp && fgets(line, sizeof(line), fp)) {
|
||||||
if (line[strlen(line)-1] != '\n') {
|
if (line[strlen(line)-1] != '\n') {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("virNWFilterSnoopLeaseFileLoad lease file "
|
_("virNWFilterSnoopLeaseFileLoad lease file "
|
||||||
"line %d corrupt"), ln);
|
"line %d corrupt"), ln);
|
||||||
break;
|
break;
|
||||||
@@ -1941,7 +1938,7 @@ virNWFilterSnoopLeaseFileLoad(void)
|
|||||||
/* key len 55 = "VMUUID"+'-'+"MAC" */
|
/* key len 55 = "VMUUID"+'-'+"MAC" */
|
||||||
if (sscanf(line, "%u %55s %16s %16s", &ipl.timeout,
|
if (sscanf(line, "%u %55s %16s %16s", &ipl.timeout,
|
||||||
ifkey, ipstr, srvstr) < 4) {
|
ifkey, ipstr, srvstr) < 4) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("virNWFilterSnoopLeaseFileLoad lease file "
|
_("virNWFilterSnoopLeaseFileLoad lease file "
|
||||||
"line %d corrupt"), ln);
|
"line %d corrupt"), ln);
|
||||||
break;
|
break;
|
||||||
@@ -1958,7 +1955,7 @@ virNWFilterSnoopLeaseFileLoad(void)
|
|||||||
|
|
||||||
if (tmp < 0) {
|
if (tmp < 0) {
|
||||||
virNWFilterSnoopReqPut(req);
|
virNWFilterSnoopReqPut(req);
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("virNWFilterSnoopLeaseFileLoad req add"
|
_("virNWFilterSnoopLeaseFileLoad req add"
|
||||||
" failed on interface \"%s\""), ifkey);
|
" failed on interface \"%s\""), ifkey);
|
||||||
continue;
|
continue;
|
||||||
@@ -1966,7 +1963,7 @@ virNWFilterSnoopLeaseFileLoad(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (virSocketAddrParseIPv4(&ipl.ipAddress, ipstr) < 0) {
|
if (virSocketAddrParseIPv4(&ipl.ipAddress, ipstr) < 0) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("line %d corrupt ipaddr \"%s\""),
|
_("line %d corrupt ipaddr \"%s\""),
|
||||||
ln, ipstr);
|
ln, ipstr);
|
||||||
virNWFilterSnoopReqPut(req);
|
virNWFilterSnoopReqPut(req);
|
||||||
@@ -2113,7 +2110,7 @@ virNWFilterDHCPSnoopEnd(const char *ifname)
|
|||||||
ifkey = (char *)virHashLookup(virNWFilterSnoopState.ifnameToKey,
|
ifkey = (char *)virHashLookup(virNWFilterSnoopState.ifnameToKey,
|
||||||
ifname);
|
ifname);
|
||||||
if (!ifkey) {
|
if (!ifkey) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("ifname \"%s\" not in key map"), ifname);
|
_("ifname \"%s\" not in key map"), ifname);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@@ -2127,7 +2124,7 @@ virNWFilterDHCPSnoopEnd(const char *ifname)
|
|||||||
|
|
||||||
req = virNWFilterSnoopReqGetByIFKey(ifkey);
|
req = virNWFilterSnoopReqGetByIFKey(ifkey);
|
||||||
if (!req) {
|
if (!req) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("ifkey \"%s\" has no req"), ifkey);
|
_("ifkey \"%s\" has no req"), ifkey);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@@ -2209,7 +2206,7 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver ATTRIBUTE_UNUSED,
|
|||||||
virNWFilterHashTablePtr filterparams ATTRIBUTE_UNUSED,
|
virNWFilterHashTablePtr filterparams ATTRIBUTE_UNUSED,
|
||||||
virNWFilterDriverStatePtr driver ATTRIBUTE_UNUSED)
|
virNWFilterDriverStatePtr driver ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("libvirt was not compiled with libpcap and \""
|
_("libvirt was not compiled with libpcap and \""
|
||||||
NWFILTER_VARNAME_CTRL_IP_LEARNING
|
NWFILTER_VARNAME_CTRL_IP_LEARNING
|
||||||
"='dhcp'\" requires it."));
|
"='dhcp'\" requires it."));
|
||||||
|
|||||||
@@ -44,9 +44,6 @@
|
|||||||
#include "nwfilter_learnipaddr.h"
|
#include "nwfilter_learnipaddr.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_NWFILTER
|
#define VIR_FROM_THIS VIR_FROM_NWFILTER
|
||||||
#define virNWFilterReportError(code, fmt...) \
|
|
||||||
virReportErrorHelper(VIR_FROM_NWFILTER, code, __FILE__, \
|
|
||||||
__FUNCTION__, __LINE__, fmt)
|
|
||||||
|
|
||||||
static virNWFilterDriverStatePtr driverState;
|
static virNWFilterDriverStatePtr driverState;
|
||||||
|
|
||||||
@@ -239,7 +236,7 @@ nwfilterLookupByUUID(virConnectPtr conn,
|
|||||||
nwfilterDriverUnlock(driver);
|
nwfilterDriverUnlock(driver);
|
||||||
|
|
||||||
if (!nwfilter) {
|
if (!nwfilter) {
|
||||||
virNWFilterReportError(VIR_ERR_NO_NWFILTER,
|
virReportError(VIR_ERR_NO_NWFILTER,
|
||||||
"%s", _("no nwfilter with matching uuid"));
|
"%s", _("no nwfilter with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@@ -265,7 +262,7 @@ nwfilterLookupByName(virConnectPtr conn,
|
|||||||
nwfilterDriverUnlock(driver);
|
nwfilterDriverUnlock(driver);
|
||||||
|
|
||||||
if (!nwfilter) {
|
if (!nwfilter) {
|
||||||
virNWFilterReportError(VIR_ERR_NO_NWFILTER,
|
virReportError(VIR_ERR_NO_NWFILTER,
|
||||||
_("no nwfilter with matching name '%s'"), name);
|
_("no nwfilter with matching name '%s'"), name);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@@ -389,13 +386,13 @@ nwfilterUndefine(virNWFilterPtr obj) {
|
|||||||
|
|
||||||
nwfilter = virNWFilterObjFindByUUID(&driver->nwfilters, obj->uuid);
|
nwfilter = virNWFilterObjFindByUUID(&driver->nwfilters, obj->uuid);
|
||||||
if (!nwfilter) {
|
if (!nwfilter) {
|
||||||
virNWFilterReportError(VIR_ERR_NO_NWFILTER,
|
virReportError(VIR_ERR_NO_NWFILTER,
|
||||||
"%s", _("no nwfilter with matching uuid"));
|
"%s", _("no nwfilter with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virNWFilterTestUnassignDef(obj->conn, nwfilter) < 0) {
|
if (virNWFilterTestUnassignDef(obj->conn, nwfilter) < 0) {
|
||||||
virNWFilterReportError(VIR_ERR_OPERATION_INVALID,
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
"%s",
|
"%s",
|
||||||
_("nwfilter is in use"));
|
_("nwfilter is in use"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@@ -437,7 +434,7 @@ nwfilterGetXMLDesc(virNWFilterPtr obj,
|
|||||||
nwfilterDriverUnlock(driver);
|
nwfilterDriverUnlock(driver);
|
||||||
|
|
||||||
if (!nwfilter) {
|
if (!nwfilter) {
|
||||||
virNWFilterReportError(VIR_ERR_NO_NWFILTER,
|
virReportError(VIR_ERR_NO_NWFILTER,
|
||||||
"%s", _("no nwfilter with matching uuid"));
|
"%s", _("no nwfilter with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,9 +45,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_NWFILTER
|
#define VIR_FROM_THIS VIR_FROM_NWFILTER
|
||||||
#define virNWFilterReportError(code, fmt...) \
|
|
||||||
virReportErrorHelper(VIR_FROM_NWFILTER, code, __FILE__, \
|
|
||||||
__FUNCTION__, __LINE__, fmt)
|
|
||||||
|
|
||||||
#define EBTABLES_CHAIN_INCOMING "PREROUTING"
|
#define EBTABLES_CHAIN_INCOMING "PREROUTING"
|
||||||
#define EBTABLES_CHAIN_OUTGOING "POSTROUTING"
|
#define EBTABLES_CHAIN_OUTGOING "POSTROUTING"
|
||||||
@@ -242,7 +239,7 @@ printVar(virNWFilterVarCombIterPtr vars,
|
|||||||
const char *varName;
|
const char *varName;
|
||||||
|
|
||||||
varName = virNWFilterVarAccessGetVarName(item->varAccess);
|
varName = virNWFilterVarAccessGetVarName(item->varAccess);
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Buffer too small to print variable "
|
_("Buffer too small to print variable "
|
||||||
"'%s' into"), varName);
|
"'%s' into"), varName);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -278,7 +275,7 @@ _printDataType(virNWFilterVarCombIterPtr vars,
|
|||||||
if (!data)
|
if (!data)
|
||||||
return -1;
|
return -1;
|
||||||
if (snprintf(buf, bufsize, "%s", data) >= bufsize) {
|
if (snprintf(buf, bufsize, "%s", data) >= bufsize) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("buffer too small for IP address"));
|
_("buffer too small for IP address"));
|
||||||
VIR_FREE(data);
|
VIR_FREE(data);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -292,7 +289,7 @@ _printDataType(virNWFilterVarCombIterPtr vars,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (snprintf(buf, bufsize, "%s", data) >= bufsize) {
|
if (snprintf(buf, bufsize, "%s", data) >= bufsize) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("buffer too small for IPv6 address"));
|
_("buffer too small for IPv6 address"));
|
||||||
VIR_FREE(data);
|
VIR_FREE(data);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -303,7 +300,7 @@ _printDataType(virNWFilterVarCombIterPtr vars,
|
|||||||
case DATATYPE_MACADDR:
|
case DATATYPE_MACADDR:
|
||||||
case DATATYPE_MACMASK:
|
case DATATYPE_MACMASK:
|
||||||
if (bufsize < VIR_MAC_STRING_BUFLEN) {
|
if (bufsize < VIR_MAC_STRING_BUFLEN) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Buffer too small for MAC address"));
|
_("Buffer too small for MAC address"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -315,7 +312,7 @@ _printDataType(virNWFilterVarCombIterPtr vars,
|
|||||||
case DATATYPE_IPMASK:
|
case DATATYPE_IPMASK:
|
||||||
if (snprintf(buf, bufsize, "%d",
|
if (snprintf(buf, bufsize, "%d",
|
||||||
item->u.u8) >= bufsize) {
|
item->u.u8) >= bufsize) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Buffer too small for uint8 type"));
|
_("Buffer too small for uint8 type"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -325,7 +322,7 @@ _printDataType(virNWFilterVarCombIterPtr vars,
|
|||||||
case DATATYPE_UINT32_HEX:
|
case DATATYPE_UINT32_HEX:
|
||||||
if (snprintf(buf, bufsize, asHex ? "0x%x" : "%u",
|
if (snprintf(buf, bufsize, asHex ? "0x%x" : "%u",
|
||||||
item->u.u32) >= bufsize) {
|
item->u.u32) >= bufsize) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Buffer too small for uint32 type"));
|
_("Buffer too small for uint32 type"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -335,7 +332,7 @@ _printDataType(virNWFilterVarCombIterPtr vars,
|
|||||||
case DATATYPE_UINT16_HEX:
|
case DATATYPE_UINT16_HEX:
|
||||||
if (snprintf(buf, bufsize, asHex ? "0x%x" : "%d",
|
if (snprintf(buf, bufsize, asHex ? "0x%x" : "%d",
|
||||||
item->u.u16) >= bufsize) {
|
item->u.u16) >= bufsize) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Buffer too small for uint16 type"));
|
_("Buffer too small for uint16 type"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -345,7 +342,7 @@ _printDataType(virNWFilterVarCombIterPtr vars,
|
|||||||
case DATATYPE_UINT8_HEX:
|
case DATATYPE_UINT8_HEX:
|
||||||
if (snprintf(buf, bufsize, asHex ? "0x%x" : "%d",
|
if (snprintf(buf, bufsize, asHex ? "0x%x" : "%d",
|
||||||
item->u.u8) >= bufsize) {
|
item->u.u8) >= bufsize) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Buffer too small for uint8 type"));
|
_("Buffer too small for uint8 type"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -353,7 +350,7 @@ _printDataType(virNWFilterVarCombIterPtr vars,
|
|||||||
|
|
||||||
case DATATYPE_IPSETNAME:
|
case DATATYPE_IPSETNAME:
|
||||||
if (virStrcpy(buf, item->u.ipset.setname, bufsize) == NULL) {
|
if (virStrcpy(buf, item->u.ipset.setname, bufsize) == NULL) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Buffer to small for ipset name"));
|
_("Buffer to small for ipset name"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -385,7 +382,7 @@ _printDataType(virNWFilterVarCombIterPtr vars,
|
|||||||
flags = virBufferContentAndReset(&vb);
|
flags = virBufferContentAndReset(&vb);
|
||||||
|
|
||||||
if (virStrcpy(buf, flags, bufsize) == NULL) {
|
if (virStrcpy(buf, flags, bufsize) == NULL) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Buffer too small for IPSETFLAGS type"));
|
_("Buffer too small for IPSETFLAGS type"));
|
||||||
VIR_FREE(flags);
|
VIR_FREE(flags);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -394,7 +391,7 @@ _printDataType(virNWFilterVarCombIterPtr vars,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Unhandled datatype %x"), item->datatype);
|
_("Unhandled datatype %x"), item->datatype);
|
||||||
return -1;
|
return -1;
|
||||||
break;
|
break;
|
||||||
@@ -1297,7 +1294,7 @@ _iptablesCreateRuleInstance(int directionIn,
|
|||||||
bool hasICMPType = false;
|
bool hasICMPType = false;
|
||||||
|
|
||||||
if (!iptables_cmd) {
|
if (!iptables_cmd) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("cannot create rule since %s tool is "
|
_("cannot create rule since %s tool is "
|
||||||
"missing."),
|
"missing."),
|
||||||
isIPv6 ? "ip6tables" : "iptables");
|
isIPv6 ? "ip6tables" : "iptables");
|
||||||
@@ -2015,7 +2012,7 @@ ebtablesCreateRuleInstance(char chainPrefix,
|
|||||||
const char *target;
|
const char *target;
|
||||||
|
|
||||||
if (!ebtables_cmd_path) {
|
if (!ebtables_cmd_path) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("cannot create rule since ebtables tool is "
|
_("cannot create rule since ebtables tool is "
|
||||||
"missing."));
|
"missing."));
|
||||||
goto err_exit;
|
goto err_exit;
|
||||||
@@ -2116,7 +2113,7 @@ ebtablesCreateRuleInstance(char chainPrefix,
|
|||||||
since this clashes with -d below... */
|
since this clashes with -d below... */
|
||||||
if (reverse &&
|
if (reverse &&
|
||||||
HAS_ENTRY_ITEM(&rule->p.stpHdrFilter.ethHdr.dataSrcMACAddr)) {
|
HAS_ENTRY_ITEM(&rule->p.stpHdrFilter.ethHdr.dataSrcMACAddr)) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("STP filtering in %s direction with "
|
_("STP filtering in %s direction with "
|
||||||
"source MAC address set is not supported"),
|
"source MAC address set is not supported"),
|
||||||
virNWFilterRuleDirectionTypeToString(
|
virNWFilterRuleDirectionTypeToString(
|
||||||
@@ -2683,7 +2680,7 @@ ebiptablesCreateRuleInstance(enum virDomainNetType nettype ATTRIBUTE_UNUSED,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_NWFILTER_RULE_PROTOCOL_LAST:
|
case VIR_NWFILTER_RULE_PROTOCOL_LAST:
|
||||||
virNWFilterReportError(VIR_ERR_OPERATION_FAILED,
|
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||||
"%s", _("illegal protocol type"));
|
"%s", _("illegal protocol type"));
|
||||||
rc = -1;
|
rc = -1;
|
||||||
break;
|
break;
|
||||||
@@ -3199,7 +3196,7 @@ ebtablesApplyBasicRules(const char *ifname,
|
|||||||
char macaddr_str[VIR_MAC_STRING_BUFLEN];
|
char macaddr_str[VIR_MAC_STRING_BUFLEN];
|
||||||
|
|
||||||
if (!ebtables_cmd_path) {
|
if (!ebtables_cmd_path) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("cannot create rules since ebtables tool is "
|
_("cannot create rules since ebtables tool is "
|
||||||
"missing."));
|
"missing."));
|
||||||
return -1;
|
return -1;
|
||||||
@@ -3257,7 +3254,7 @@ ebtablesApplyBasicRules(const char *ifname,
|
|||||||
tear_down_tmpebchains:
|
tear_down_tmpebchains:
|
||||||
ebtablesCleanAll(ifname);
|
ebtablesCleanAll(ifname);
|
||||||
|
|
||||||
virNWFilterReportError(VIR_ERR_BUILD_FIREWALL,
|
virReportError(VIR_ERR_BUILD_FIREWALL,
|
||||||
"%s",
|
"%s",
|
||||||
_("Some rules could not be created."));
|
_("Some rules could not be created."));
|
||||||
|
|
||||||
@@ -3296,7 +3293,7 @@ ebtablesApplyDHCPOnlyRules(const char *ifname,
|
|||||||
unsigned int num_dhcpsrvrs;
|
unsigned int num_dhcpsrvrs;
|
||||||
|
|
||||||
if (!ebtables_cmd_path) {
|
if (!ebtables_cmd_path) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("cannot create rules since ebtables tool is "
|
_("cannot create rules since ebtables tool is "
|
||||||
"missing."));
|
"missing."));
|
||||||
return -1;
|
return -1;
|
||||||
@@ -3400,7 +3397,7 @@ ebtablesApplyDHCPOnlyRules(const char *ifname,
|
|||||||
tear_down_tmpebchains:
|
tear_down_tmpebchains:
|
||||||
ebtablesCleanAll(ifname);
|
ebtablesCleanAll(ifname);
|
||||||
|
|
||||||
virNWFilterReportError(VIR_ERR_BUILD_FIREWALL,
|
virReportError(VIR_ERR_BUILD_FIREWALL,
|
||||||
"%s",
|
"%s",
|
||||||
_("Some rules could not be created."));
|
_("Some rules could not be created."));
|
||||||
|
|
||||||
@@ -3425,7 +3422,7 @@ ebtablesApplyDropAllRules(const char *ifname)
|
|||||||
chain_out[MAX_CHAINNAME_LENGTH];
|
chain_out[MAX_CHAINNAME_LENGTH];
|
||||||
|
|
||||||
if (!ebtables_cmd_path) {
|
if (!ebtables_cmd_path) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("cannot create rules since ebtables tool is "
|
_("cannot create rules since ebtables tool is "
|
||||||
"missing."));
|
"missing."));
|
||||||
return -1;
|
return -1;
|
||||||
@@ -3470,7 +3467,7 @@ ebtablesApplyDropAllRules(const char *ifname)
|
|||||||
tear_down_tmpebchains:
|
tear_down_tmpebchains:
|
||||||
ebtablesCleanAll(ifname);
|
ebtablesCleanAll(ifname);
|
||||||
|
|
||||||
virNWFilterReportError(VIR_ERR_BUILD_FIREWALL,
|
virReportError(VIR_ERR_BUILD_FIREWALL,
|
||||||
"%s",
|
"%s",
|
||||||
_("Some rules could not be created."));
|
_("Some rules could not be created."));
|
||||||
|
|
||||||
@@ -3903,7 +3900,7 @@ tear_down_tmpebchains:
|
|||||||
|
|
||||||
ebiptablesExecCLI(&buf, &cli_status, NULL);
|
ebiptablesExecCLI(&buf, &cli_status, NULL);
|
||||||
|
|
||||||
virNWFilterReportError(VIR_ERR_BUILD_FIREWALL,
|
virReportError(VIR_ERR_BUILD_FIREWALL,
|
||||||
_("Some rules could not be created for "
|
_("Some rules could not be created for "
|
||||||
"interface %s%s%s"),
|
"interface %s%s%s"),
|
||||||
ifname,
|
ifname,
|
||||||
@@ -4042,7 +4039,7 @@ ebiptablesRemoveRules(const char *ifname ATTRIBUTE_UNUSED,
|
|||||||
goto err_exit;
|
goto err_exit;
|
||||||
|
|
||||||
if (cli_status) {
|
if (cli_status) {
|
||||||
virNWFilterReportError(VIR_ERR_BUILD_FIREWALL,
|
virReportError(VIR_ERR_BUILD_FIREWALL,
|
||||||
"%s",
|
"%s",
|
||||||
_("error while executing CLI commands"));
|
_("error while executing CLI commands"));
|
||||||
rc = -1;
|
rc = -1;
|
||||||
|
|||||||
@@ -39,9 +39,6 @@
|
|||||||
#include "datatypes.h"
|
#include "datatypes.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_NWFILTER
|
#define VIR_FROM_THIS VIR_FROM_NWFILTER
|
||||||
#define virNWFilterReportError(code, fmt...) \
|
|
||||||
virReportErrorHelper(VIR_FROM_NWFILTER, code, __FILE__, \
|
|
||||||
__FUNCTION__, __LINE__, fmt)
|
|
||||||
|
|
||||||
|
|
||||||
#define NWFILTER_STD_VAR_MAC NWFILTER_VARNAME_MAC
|
#define NWFILTER_STD_VAR_MAC NWFILTER_VARNAME_MAC
|
||||||
@@ -164,7 +161,7 @@ virNWFilterVarHashmapAddStdValues(virNWFilterHashTablePtr table,
|
|||||||
if (virHashAddEntry(table->hashTable,
|
if (virHashAddEntry(table->hashTable,
|
||||||
NWFILTER_STD_VAR_MAC,
|
NWFILTER_STD_VAR_MAC,
|
||||||
val) < 0) {
|
val) < 0) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("Could not add variable 'MAC' to hashmap"));
|
"%s", _("Could not add variable 'MAC' to hashmap"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -178,7 +175,7 @@ virNWFilterVarHashmapAddStdValues(virNWFilterHashTablePtr table,
|
|||||||
if (virHashAddEntry(table->hashTable,
|
if (virHashAddEntry(table->hashTable,
|
||||||
NWFILTER_STD_VAR_IP,
|
NWFILTER_STD_VAR_IP,
|
||||||
val) < 0) {
|
val) < 0) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("Could not add variable 'IP' to hashmap"));
|
"%s", _("Could not add variable 'IP' to hashmap"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -430,7 +427,7 @@ _virNWFilterInstantiateRec(virNWFilterTechDriverPtr techdriver,
|
|||||||
if (obj) {
|
if (obj) {
|
||||||
|
|
||||||
if (obj->wantRemoved) {
|
if (obj->wantRemoved) {
|
||||||
virNWFilterReportError(VIR_ERR_NO_NWFILTER,
|
virReportError(VIR_ERR_NO_NWFILTER,
|
||||||
_("Filter '%s' is in use."),
|
_("Filter '%s' is in use."),
|
||||||
inc->filterref);
|
inc->filterref);
|
||||||
rc = -1;
|
rc = -1;
|
||||||
@@ -478,7 +475,7 @@ _virNWFilterInstantiateRec(virNWFilterTechDriverPtr techdriver,
|
|||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("referenced filter '%s' is missing"),
|
_("referenced filter '%s' is missing"),
|
||||||
inc->filterref);
|
inc->filterref);
|
||||||
rc = -1;
|
rc = -1;
|
||||||
@@ -542,7 +539,7 @@ virNWFilterDetermineMissingVarsRec(virNWFilterDefPtr filter,
|
|||||||
if (obj) {
|
if (obj) {
|
||||||
|
|
||||||
if (obj->wantRemoved) {
|
if (obj->wantRemoved) {
|
||||||
virNWFilterReportError(VIR_ERR_NO_NWFILTER,
|
virReportError(VIR_ERR_NO_NWFILTER,
|
||||||
_("Filter '%s' is in use."),
|
_("Filter '%s' is in use."),
|
||||||
inc->filterref);
|
inc->filterref);
|
||||||
rc = -1;
|
rc = -1;
|
||||||
@@ -585,7 +582,7 @@ virNWFilterDetermineMissingVarsRec(virNWFilterDefPtr filter,
|
|||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("referenced filter '%s' is missing"),
|
_("referenced filter '%s' is missing"),
|
||||||
inc->filterref);
|
inc->filterref);
|
||||||
rc = -1;
|
rc = -1;
|
||||||
@@ -724,7 +721,8 @@ virNWFilterInstantiate(const unsigned char *vmuuid ATTRIBUTE_UNUSED,
|
|||||||
goto err_exit;
|
goto err_exit;
|
||||||
} else {
|
} else {
|
||||||
rc = -1;
|
rc = -1;
|
||||||
virNWFilterReportError(VIR_ERR_PARSE_FAILED, _("filter '%s' "
|
virReportError(VIR_ERR_PARSE_FAILED,
|
||||||
|
_("filter '%s' "
|
||||||
"learning value '%s' invalid."),
|
"learning value '%s' invalid."),
|
||||||
filter->name, learning);
|
filter->name, learning);
|
||||||
}
|
}
|
||||||
@@ -799,7 +797,7 @@ err_unresolvable_vars:
|
|||||||
|
|
||||||
buf = virNWFilterPrintVars(missing_vars->hashTable, ", ", false, reportIP);
|
buf = virNWFilterPrintVars(missing_vars->hashTable, ", ", false, reportIP);
|
||||||
if (buf) {
|
if (buf) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Cannot instantiate filter due to unresolvable "
|
_("Cannot instantiate filter due to unresolvable "
|
||||||
"variables or unavailable list elements: %s"), buf);
|
"variables or unavailable list elements: %s"), buf);
|
||||||
VIR_FREE(buf);
|
VIR_FREE(buf);
|
||||||
@@ -842,7 +840,7 @@ __virNWFilterInstantiateFilter(const unsigned char *vmuuid,
|
|||||||
techdriver = virNWFilterTechDriverForName(drvname);
|
techdriver = virNWFilterTechDriverForName(drvname);
|
||||||
|
|
||||||
if (!techdriver) {
|
if (!techdriver) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not get access to ACL tech "
|
_("Could not get access to ACL tech "
|
||||||
"driver '%s'"),
|
"driver '%s'"),
|
||||||
drvname);
|
drvname);
|
||||||
@@ -853,14 +851,14 @@ __virNWFilterInstantiateFilter(const unsigned char *vmuuid,
|
|||||||
|
|
||||||
obj = virNWFilterObjFindByName(&driver->nwfilters, filtername);
|
obj = virNWFilterObjFindByName(&driver->nwfilters, filtername);
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
virNWFilterReportError(VIR_ERR_NO_NWFILTER,
|
virReportError(VIR_ERR_NO_NWFILTER,
|
||||||
_("Could not find filter '%s'"),
|
_("Could not find filter '%s'"),
|
||||||
filtername);
|
filtername);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj->wantRemoved) {
|
if (obj->wantRemoved) {
|
||||||
virNWFilterReportError(VIR_ERR_NO_NWFILTER,
|
virReportError(VIR_ERR_NO_NWFILTER,
|
||||||
_("Filter '%s' is in use."),
|
_("Filter '%s' is in use."),
|
||||||
filtername);
|
filtername);
|
||||||
rc = -1;
|
rc = -1;
|
||||||
@@ -1070,7 +1068,7 @@ virNWFilterRollbackUpdateFilter(const virDomainNetDefPtr net)
|
|||||||
|
|
||||||
techdriver = virNWFilterTechDriverForName(drvname);
|
techdriver = virNWFilterTechDriverForName(drvname);
|
||||||
if (!techdriver) {
|
if (!techdriver) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not get access to ACL tech "
|
_("Could not get access to ACL tech "
|
||||||
"driver '%s'"),
|
"driver '%s'"),
|
||||||
drvname);
|
drvname);
|
||||||
@@ -1096,7 +1094,7 @@ virNWFilterTearOldFilter(virDomainNetDefPtr net)
|
|||||||
|
|
||||||
techdriver = virNWFilterTechDriverForName(drvname);
|
techdriver = virNWFilterTechDriverForName(drvname);
|
||||||
if (!techdriver) {
|
if (!techdriver) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not get access to ACL tech "
|
_("Could not get access to ACL tech "
|
||||||
"driver '%s'"),
|
"driver '%s'"),
|
||||||
drvname);
|
drvname);
|
||||||
@@ -1121,7 +1119,7 @@ _virNWFilterTeardownFilter(const char *ifname)
|
|||||||
techdriver = virNWFilterTechDriverForName(drvname);
|
techdriver = virNWFilterTechDriverForName(drvname);
|
||||||
|
|
||||||
if (!techdriver) {
|
if (!techdriver) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not get access to ACL tech "
|
_("Could not get access to ACL tech "
|
||||||
"driver '%s'"),
|
"driver '%s'"),
|
||||||
drvname);
|
drvname);
|
||||||
@@ -1200,7 +1198,7 @@ virNWFilterDomainFWUpdateCB(void *payload,
|
|||||||
vm->uuid,
|
vm->uuid,
|
||||||
net);
|
net);
|
||||||
if (err)
|
if (err)
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Failure while applying current filter on "
|
_("Failure while applying current filter on "
|
||||||
"VM %s"), vm->name);
|
"VM %s"), vm->name);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -56,9 +56,6 @@
|
|||||||
#include "nwfilter_learnipaddr.h"
|
#include "nwfilter_learnipaddr.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_NWFILTER
|
#define VIR_FROM_THIS VIR_FROM_NWFILTER
|
||||||
#define virNWFilterReportError(code, fmt...) \
|
|
||||||
virReportErrorHelper(VIR_FROM_NWFILTER, code, __FILE__, \
|
|
||||||
__FUNCTION__, __LINE__, fmt)
|
|
||||||
|
|
||||||
#define IFINDEX2STR(VARNAME, ifindex) \
|
#define IFINDEX2STR(VARNAME, ifindex) \
|
||||||
char VARNAME[INT_BUFSIZE_BOUND(ifindex)]; \
|
char VARNAME[INT_BUFSIZE_BOUND(ifindex)]; \
|
||||||
@@ -151,14 +148,14 @@ virNWFilterLockIface(const char *ifname) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (virMutexInitRecursive(&ifaceLock->lock) < 0) {
|
if (virMutexInitRecursive(&ifaceLock->lock) < 0) {
|
||||||
virNWFilterReportError(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 err_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virStrcpyStatic(ifaceLock->ifname, ifname) == NULL) {
|
if (virStrcpyStatic(ifaceLock->ifname, ifname) == NULL) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("interface name %s does not fit into "
|
_("interface name %s does not fit into "
|
||||||
"buffer "),
|
"buffer "),
|
||||||
ifaceLock->ifname);
|
ifaceLock->ifname);
|
||||||
@@ -675,7 +672,7 @@ virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if ( !techdriver->canApplyBasicRules()) {
|
if ( !techdriver->canApplyBasicRules()) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("IP parameter must be provided since "
|
_("IP parameter must be provided since "
|
||||||
"snooping the IP address does not work "
|
"snooping the IP address does not work "
|
||||||
"possibly due to missing tools"));
|
"possibly due to missing tools"));
|
||||||
@@ -703,7 +700,7 @@ virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (virStrcpyStatic(req->ifname, ifname) == NULL) {
|
if (virStrcpyStatic(req->ifname, ifname) == NULL) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Destination buffer for ifname ('%s') "
|
_("Destination buffer for ifname ('%s') "
|
||||||
"not large enough"), ifname);
|
"not large enough"), ifname);
|
||||||
goto err_free_ht;
|
goto err_free_ht;
|
||||||
@@ -711,7 +708,7 @@ virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver,
|
|||||||
|
|
||||||
if (linkdev) {
|
if (linkdev) {
|
||||||
if (virStrcpyStatic(req->linkdev, linkdev) == NULL) {
|
if (virStrcpyStatic(req->linkdev, linkdev) == NULL) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Destination buffer for linkdev ('%s') "
|
_("Destination buffer for linkdev ('%s') "
|
||||||
"not large enough"), linkdev);
|
"not large enough"), linkdev);
|
||||||
goto err_free_ht;
|
goto err_free_ht;
|
||||||
@@ -763,7 +760,7 @@ virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver ATTRIBUTE_UNUSED,
|
|||||||
virNWFilterHashTablePtr filterparams ATTRIBUTE_UNUSED,
|
virNWFilterHashTablePtr filterparams ATTRIBUTE_UNUSED,
|
||||||
virNWFilterDriverStatePtr driver ATTRIBUTE_UNUSED,
|
virNWFilterDriverStatePtr driver ATTRIBUTE_UNUSED,
|
||||||
enum howDetect howDetect ATTRIBUTE_UNUSED) {
|
enum howDetect howDetect ATTRIBUTE_UNUSED) {
|
||||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("IP parameter must be given since libvirt "
|
_("IP parameter must be given since libvirt "
|
||||||
"was not compiled with IP address learning "
|
"was not compiled with IP address learning "
|
||||||
"support"));
|
"support"));
|
||||||
|
|||||||
Reference in New Issue
Block a user