---
src/conf/nwfilter_conf.c | 120 ++++++-------
src/conf/nwfilter_conf.h | 16 +-
src/conf/nwfilter_params.c | 2 +-
src/nwfilter/nwfilter_driver.c | 25 ++--
src/nwfilter/nwfilter_ebiptables_driver.c | 285 +++++++++++------------------
src/nwfilter/nwfilter_gentech_driver.c | 39 ++--
src/nwfilter/nwfilter_gentech_driver.h | 3 +-
tests/nwfilterxml2xmltest.c | 2 +-
8 files changed, 202 insertions(+), 290 deletions(-)
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index c8dda04..7759c18 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -1325,7 +1325,7 @@ virNWFilterRuleDetailsParse(virConnectPtr conn ATTRIBUTE_UNUSED,
}
if (!found || rc) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
_("%s has illegal value %s"),
att[idx].name, prop);
rc = -1;
@@ -1348,8 +1348,7 @@ virNWFilterRuleDetailsParse(virConnectPtr conn ATTRIBUTE_UNUSED,
static virNWFilterIncludeDefPtr
-virNWFilterIncludeParse(virConnectPtr conn,
- xmlNodePtr cur)
+virNWFilterIncludeParse(xmlNodePtr cur)
{
virNWFilterIncludeDefPtr ret;
@@ -1360,8 +1359,7 @@ virNWFilterIncludeParse(virConnectPtr conn,
ret->filterref = virXMLPropString(cur, "filter");
if (!ret->filterref) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
- "%s",
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("rule node requires action attribute"));
goto err_exit;
}
@@ -1571,29 +1569,25 @@ virNWFilterRuleParse(virConnectPtr conn,
prio = virXMLPropString(node, "priority");
if (!action) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
- "%s",
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("rule node requires action attribute"));
goto err_exit;
}
if ((ret->action = virNWFilterRuleActionTypeFromString(action)) < 0) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
- "%s",
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("unknown rule action attribute value"));
goto err_exit;
}
if (!direction) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
- "%s",
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("rule node requires direction attribute"));
goto err_exit;
}
if ((ret->tt = virNWFilterRuleDirectionTypeFromString(direction)) < 0) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
- "%s",
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("unknown rule direction attribute value"));
goto err_exit;
}
@@ -1678,8 +1672,8 @@ virNWFilterDefParseXML(virConnectPtr conn,
ret->name = virXPathString("string(./@name)", ctxt);
if (!ret->name) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
- "%s", _("filter has no name"));
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("filter has no name"));
goto cleanup;
}
@@ -1688,7 +1682,7 @@ virNWFilterDefParseXML(virConnectPtr conn,
if (chain) {
if ((ret->chainsuffix =
virNWFilterChainSuffixTypeFromString(chain)) < 0) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown chain suffix '%s'"),
chain);
goto cleanup;
}
@@ -1697,14 +1691,14 @@ virNWFilterDefParseXML(virConnectPtr conn,
uuid = virXPathString("string(./uuid)", ctxt);
if (uuid == NULL) {
if (virUUIDGenerate(ret->uuid) < 0) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
- "%s", _("unable to generate
uuid"));
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("unable to generate uuid"));
goto cleanup;
}
} else {
if (virUUIDParse(uuid, ret->uuid) < 0) {
- virNWFilterReportError(conn, VIR_ERR_XML_ERROR,
- "%s", _("malformed uuid
element"));
+ virNWFilterReportError(VIR_ERR_XML_ERROR, "%s",
+ _("malformed uuid element"));
goto cleanup;
}
VIR_FREE(uuid);
@@ -1723,7 +1717,7 @@ virNWFilterDefParseXML(virConnectPtr conn,
if (xmlStrEqual(curr->name, BAD_CAST "rule"))
entry->rule = virNWFilterRuleParse(conn, curr);
else if (xmlStrEqual(curr->name, BAD_CAST "filterref"))
- entry->include = virNWFilterIncludeParse(conn, curr);
+ entry->include = virNWFilterIncludeParse(curr);
if (entry->rule || entry->include) {
if (VIR_REALLOC_N(ret->filterEntries, ret->nentries+1) < 0) {
@@ -1762,7 +1756,7 @@ catchXMLError (void *ctx, const char *msg ATTRIBUTE_UNUSED, ...)
conn->err.code == VIR_ERR_NONE &&
ctxt->lastError.level == XML_ERR_FATAL &&
ctxt->lastError.message != NULL) {
- virNWFilterReportError(conn, VIR_ERR_XML_DETAIL,
+ virNWFilterReportError(VIR_ERR_XML_DETAIL,
_("at line %d: %s"),
ctxt->lastError.line,
ctxt->lastError.message);
@@ -1779,8 +1773,7 @@ virNWFilterDefParseNode(virConnectPtr conn,
virNWFilterDefPtr def = NULL;
if (STRNEQ((const char *)root->name, "filter")) {
- virNWFilterReportError(conn, VIR_ERR_XML_ERROR,
- "%s",
+ virNWFilterReportError(VIR_ERR_XML_ERROR, "%s",
_("unknown root element for nw filter pool"));
goto cleanup;
}
@@ -1830,15 +1823,15 @@ virNWFilterDefParse(virConnectPtr conn,
if (!xml) {
if (conn && conn->err.code == VIR_ERR_NONE)
- virNWFilterReportError(conn, VIR_ERR_XML_ERROR,
- "%s",_("failed to parse xml
document"));
+ virNWFilterReportError(VIR_ERR_XML_ERROR, "%s",
+ _("failed to parse xml document"));
goto cleanup;
}
node = xmlDocGetRootElement(xml);
if (node == NULL) {
- virNWFilterReportError(conn, VIR_ERR_XML_ERROR,
- "%s", _("missing root element"));
+ virNWFilterReportError(VIR_ERR_XML_ERROR, "%s",
+ _("missing root element"));
goto cleanup;
}
@@ -1969,7 +1962,7 @@ int virNWFilterSaveConfig(virConnectPtr conn,
int ret = -1;
char *xml;
- if (!(xml = virNWFilterDefFormat(conn, def)))
+ if (!(xml = virNWFilterDefFormat(def)))
goto cleanup;
if (virNWFilterSaveXML(conn, configDir, def, xml))
@@ -2125,8 +2118,8 @@ virNWFilterPoolObjAssignDef(virConnectPtr conn,
virNWFilterPoolObjPtr pool;
if (virNWFilterDefLoopDetect(conn, pools, def)) {
- virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER,
- "%s", _("filter would introduce a
loop"));
+ virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, "%s",
+ _("filter would introduce a loop"));
return NULL;
}
@@ -2154,8 +2147,8 @@ virNWFilterPoolObjAssignDef(virConnectPtr conn,
}
if (virMutexInitRecursive(&pool->lock) < 0) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
- "%s", _("cannot initialize mutex"));
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("cannot initialize mutex"));
VIR_FREE(pool);
return NULL;
}
@@ -2190,9 +2183,10 @@ virNWFilterPoolObjLoad(virConnectPtr conn,
}
if (!virFileMatchesNameSuffix(file, def->name, ".xml")) {
- virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER,
- _("network filter pool config filename '%s' does not match pool
name '%s'"),
- path, def->name);
+ virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
+ _("network filter pool config filename '%s'
"
+ "does not match pool name '%s'"),
+ path, def->name);
virNWFilterDefFree(def);
return NULL;
}
@@ -2242,7 +2236,7 @@ virNWFilterPoolLoadAllConfigs(virConnectPtr conn,
if (virFileBuildPath(configDir, entry->d_name,
NULL, path, PATH_MAX) < 0) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
_("config filename '%s/%s' is too
long"),
configDir, entry->d_name);
continue;
@@ -2260,10 +2254,9 @@ virNWFilterPoolLoadAllConfigs(virConnectPtr conn,
int
-virNWFilterPoolObjSaveDef(virConnectPtr conn,
- virNWFilterDriverStatePtr driver,
- virNWFilterPoolObjPtr pool,
- virNWFilterDefPtr def)
+virNWFilterPoolObjSaveDef(virNWFilterDriverStatePtr driver,
+ virNWFilterPoolObjPtr pool,
+ virNWFilterDefPtr def)
{
char *xml;
int fd = -1, ret = -1;
@@ -2282,8 +2275,8 @@ virNWFilterPoolObjSaveDef(virConnectPtr conn,
if (virFileBuildPath(driver->configDir, def->name, ".xml",
path, sizeof(path)) < 0) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
- "%s", _("cannot construct config file
path"));
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("cannot construct config file path"));
return -1;
}
if (!(pool->configFile = strdup(path))) {
@@ -2292,9 +2285,9 @@ virNWFilterPoolObjSaveDef(virConnectPtr conn,
}
}
- if (!(xml = virNWFilterDefFormat(conn, def))) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
- "%s", _("failed to generate XML"));
+ if (!(xml = virNWFilterDefFormat(def))) {
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("failed to generate XML"));
return -1;
}
@@ -2335,19 +2328,18 @@ virNWFilterPoolObjSaveDef(virConnectPtr conn,
int
-virNWFilterPoolObjDeleteDef(virConnectPtr conn,
- virNWFilterPoolObjPtr pool)
+virNWFilterPoolObjDeleteDef(virNWFilterPoolObjPtr pool)
{
if (!pool->configFile) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
_("no config file for %s"),
pool->def->name);
return -1;
}
if (unlink(pool->configFile) < 0) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("cannot remove config for %s"),
- pool->def->name);
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
+ _("cannot remove config for %s"),
+ pool->def->name);
return -1;
}
@@ -2369,8 +2361,7 @@ virNWIPAddressFormat(virBufferPtr buf, nwIPAddressPtr ipaddr)
static void
-virNWFilterRuleDefDetailsFormat(virConnectPtr conn,
- virBufferPtr buf,
+virNWFilterRuleDefDetailsFormat(virBufferPtr buf,
const char *type,
const virXMLAttr2Struct *att,
virNWFilterRuleDefPtr def)
@@ -2420,10 +2411,9 @@ virNWFilterRuleDefDetailsFormat(virConnectPtr conn,
att[i].name);
if (att[i].formatter) {
if (!att[i].formatter(buf, def)) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
_("formatter for %s %s reported
error"),
- type,
- att[i].name);
+ type, att[i].name);
goto err_exit;
}
} else if ((flags & NWFILTER_ENTRY_ITEM_FLAG_HAS_VAR)) {
@@ -2484,8 +2474,7 @@ err_exit:
static char *
-virNWFilterRuleDefFormat(virConnectPtr conn,
- virNWFilterRuleDefPtr def)
+virNWFilterRuleDefFormat(virNWFilterRuleDefPtr def)
{
int i;
virBuffer buf = VIR_BUFFER_INITIALIZER;
@@ -2500,8 +2489,7 @@ virNWFilterRuleDefFormat(virConnectPtr conn,
i = 0;
while (virAttr[i].id) {
if (virAttr[i].prtclType == def->prtclType) {
- virNWFilterRuleDefDetailsFormat(conn,
- &buf2,
+ virNWFilterRuleDefDetailsFormat(&buf2,
virAttr[i].id,
virAttr[i].att,
def);
@@ -2563,18 +2551,16 @@ virNWFilterIncludeDefFormat(virNWFilterIncludeDefPtr inc)
static char *
-virNWFilterEntryFormat(virConnectPtr conn,
- virNWFilterEntryPtr entry)
+virNWFilterEntryFormat(virNWFilterEntryPtr entry)
{
if (entry->rule)
- return virNWFilterRuleDefFormat(conn, entry->rule);
+ return virNWFilterRuleDefFormat(entry->rule);
return virNWFilterIncludeDefFormat(entry->include);
}
char *
-virNWFilterDefFormat(virConnectPtr conn,
- virNWFilterDefPtr def)
+virNWFilterDefFormat(virNWFilterDefPtr def)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
char uuid[VIR_UUID_STRING_BUFLEN];
@@ -2590,7 +2576,7 @@ virNWFilterDefFormat(virConnectPtr conn,
virBufferVSprintf(&buf," <uuid>%s</uuid>\n", uuid);
for (i = 0; i < def->nentries; i++) {
- xml = virNWFilterEntryFormat(conn, def->filterEntries[i]);
+ xml = virNWFilterEntryFormat(def->filterEntries[i]);
if (!xml)
goto err_exit;
virBufferVSprintf(&buf, "%s", xml);
diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h
index 8ab0b89..6c9dd4e 100644
--- a/src/conf/nwfilter_conf.h
+++ b/src/conf/nwfilter_conf.h
@@ -518,13 +518,11 @@ virNWFilterPoolObjPtr
const char *name);
-int virNWFilterPoolObjSaveDef(virConnectPtr conn,
- virNWFilterDriverStatePtr driver,
+int virNWFilterPoolObjSaveDef(virNWFilterDriverStatePtr driver,
virNWFilterPoolObjPtr pool,
virNWFilterDefPtr def);
-int virNWFilterPoolObjDeleteDef(virConnectPtr conn,
- virNWFilterPoolObjPtr pool);
+int virNWFilterPoolObjDeleteDef(virNWFilterPoolObjPtr pool);
virNWFilterPoolObjPtr virNWFilterPoolObjAssignDef(virConnectPtr conn,
virNWFilterPoolObjListPtr pools,
@@ -537,8 +535,7 @@ virNWFilterDefPtr virNWFilterDefParseNode(virConnectPtr conn,
xmlDocPtr xml,
xmlNodePtr root);
-char *virNWFilterDefFormat(virConnectPtr conn,
- virNWFilterDefPtr def);
+char *virNWFilterDefFormat(virNWFilterDefPtr def);
int virNWFilterSaveXML(virConnectPtr conn,
const char *configDir,
@@ -568,10 +565,9 @@ void virNWFilterPoolObjUnlock(virNWFilterPoolObjPtr obj);
int virNWFilterConfLayerInit(virHashIterator domUpdateCB);
void virNWFilterConfLayerShutdown(void);
-# define virNWFilterReportError(conn, code, fmt...) \
- (void)conn; \
- virReportErrorHelper(NULL, VIR_FROM_NWFILTER, code, __FILE__, \
- __FUNCTION__, __LINE__, fmt)
+# define virNWFilterReportError(code, fmt...) \
+ virReportErrorHelper(NULL, VIR_FROM_NWFILTER, code, __FILE__, \
+ __FUNCTION__, __LINE__, fmt)
typedef int (*virNWFilterRebuild)(virConnectPtr conn,
diff --git a/src/conf/nwfilter_params.c b/src/conf/nwfilter_params.c
index a1c30bb..93f97d7 100644
--- a/src/conf/nwfilter_params.c
+++ b/src/conf/nwfilter_params.c
@@ -174,7 +174,7 @@ addToTable(void *payload, const char *name, void *data)
}
if (virNWFilterHashTablePut(atts->target, name, val, 1) != 0) {
- virNWFilterReportError(atts->conn, VIR_ERR_INTERNAL_ERROR,
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not put variable '%s' into
hashmap"),
name);
atts->errOccurred = 1;
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index c659793..0f3e9aa 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -194,8 +194,8 @@ nwfilterLookupByUUID(virConnectPtr conn,
nwfilterDriverUnlock(driver);
if (!pool) {
- virNWFilterReportError(conn, VIR_ERR_NO_NWFILTER,
- "%s", _("no pool with matching
uuid"));
+ virNWFilterReportError(VIR_ERR_NO_NWFILTER, "%s",
+ _("no pool with matching uuid"));
goto cleanup;
}
@@ -220,8 +220,8 @@ nwfilterLookupByName(virConnectPtr conn,
nwfilterDriverUnlock(driver);
if (!pool) {
- virNWFilterReportError(conn, VIR_ERR_NO_NWFILTER,
- _("no pool with matching name '%s'"),
name);
+ virNWFilterReportError(VIR_ERR_NO_NWFILTER,
+ _("no pool with matching name '%s'"),
name);
goto cleanup;
}
@@ -306,7 +306,7 @@ nwfilterDefine(virConnectPtr conn,
if (!(pool = virNWFilterPoolObjAssignDef(conn, &driver->pools, def)))
goto cleanup;
- if (virNWFilterPoolObjSaveDef(conn, driver, pool, def) < 0) {
+ if (virNWFilterPoolObjSaveDef(driver, pool, def) < 0) {
virNWFilterPoolObjRemove(&driver->pools, pool);
def = NULL;
goto cleanup;
@@ -333,19 +333,18 @@ nwfilterUndefine(virNWFilterPtr obj) {
nwfilterDriverLock(driver);
pool = virNWFilterPoolObjFindByUUID(&driver->pools, obj->uuid);
if (!pool) {
- virNWFilterReportError(obj->conn, VIR_ERR_INVALID_NWFILTER,
- "%s", _("no nwfilter pool with matching
uuid"));
+ virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, "%s",
+ _("no nwfilter pool with matching uuid"));
goto cleanup;
}
if (virNWFilterTestUnassignDef(obj->conn, pool)) {
- virNWFilterReportError(obj->conn, VIR_ERR_INVALID_NWFILTER,
- "%s",
+ virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, "%s",
_("nwfilter is in use"));
goto cleanup;
}
- if (virNWFilterPoolObjDeleteDef(obj->conn, pool) < 0)
+ if (virNWFilterPoolObjDeleteDef(pool) < 0)
goto cleanup;
VIR_FREE(pool->configFile);
@@ -374,12 +373,12 @@ nwfilterDumpXML(virNWFilterPtr obj,
nwfilterDriverUnlock(driver);
if (!pool) {
- virNWFilterReportError(obj->conn, VIR_ERR_INVALID_NWFILTER,
- "%s", _("no nwfilter pool with matching
uuid"));
+ virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, "%s",
+ _("no nwfilter pool with matching uuid"));
goto cleanup;
}
- ret = virNWFilterDefFormat(obj->conn, pool->def);
+ ret = virNWFilterDefFormat(pool->def);
cleanup:
if (pool)
diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c
b/src/nwfilter/nwfilter_ebiptables_driver.c
index fdf1c10..963588a 100644
--- a/src/nwfilter/nwfilter_ebiptables_driver.c
+++ b/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -106,8 +106,7 @@ static const char *supported_protocols[] = {
static int
-printVar(virConnectPtr conn,
- virNWFilterHashTablePtr vars,
+printVar(virNWFilterHashTablePtr vars,
char *buf, int bufsize,
nwItemDescPtr item,
int *done)
@@ -117,16 +116,16 @@ printVar(virConnectPtr conn,
if ((item->flags & NWFILTER_ENTRY_ITEM_FLAG_HAS_VAR)) {
char *val = (char *)virHashLookup(vars->hashTable, item->var);
if (!val) {
- virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER,
+ virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
_("cannot find value for '%s'"),
item->var);
return 1;
}
if (!virStrcpy(buf, val, bufsize)) {
- virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER,
+ virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
_("Buffer to small to print MAC address "
- "'%s' into"),
+ "'%s' into"),
item->var);
return 1;
}
@@ -138,8 +137,7 @@ printVar(virConnectPtr conn,
static int
-_printDataType(virConnectPtr conn,
- virNWFilterHashTablePtr vars,
+_printDataType(virNWFilterHashTablePtr vars,
char *buf, int bufsize,
nwItemDescPtr item,
bool asHex)
@@ -147,7 +145,7 @@ _printDataType(virConnectPtr conn,
int done;
char *data;
- if (printVar(conn, vars, buf, bufsize, item, &done))
+ if (printVar(vars, buf, bufsize, item, &done))
return 1;
if (done)
@@ -157,13 +155,13 @@ _printDataType(virConnectPtr conn,
case DATATYPE_IPADDR:
data = virSocketFormatAddr(&item->u.ipaddr.addr);
if (!data) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s",
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("internal IPv4 address representation "
"is bad"));
return 1;
}
if (snprintf(buf, bufsize, "%s", data) >= bufsize) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s",
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("buffer too small for IP address"));
VIR_FREE(data);
return 1;
@@ -174,14 +172,14 @@ _printDataType(virConnectPtr conn,
case DATATYPE_IPV6ADDR:
data = virSocketFormatAddr(&item->u.ipaddr.addr);
if (!data) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s",
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("internal IPv6 address representation "
"is bad"));
return 1;
}
if (snprintf(buf, bufsize, "%s", data) >= bufsize) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s",
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("buffer too small for IPv6 address"));
VIR_FREE(data);
return 1;
@@ -192,7 +190,7 @@ _printDataType(virConnectPtr conn,
case DATATYPE_MACADDR:
case DATATYPE_MACMASK:
if (bufsize < VIR_MAC_STRING_BUFLEN) {
- virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER, "%s",
+ virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, "%s",
_("Buffer too small for MAC address"));
return 1;
}
@@ -204,7 +202,7 @@ _printDataType(virConnectPtr conn,
case DATATYPE_IPMASK:
if (snprintf(buf, bufsize, "%d",
item->u.u8) >= bufsize) {
- virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER, "%s",
+ virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, "%s",
_("Buffer too small for uint8 type"));
return 1;
}
@@ -213,7 +211,7 @@ _printDataType(virConnectPtr conn,
case DATATYPE_UINT16:
if (snprintf(buf, bufsize, asHex ? "0x%x" : "%d",
item->u.u16) >= bufsize) {
- virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER, "%s",
+ virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, "%s",
_("Buffer too small for uint16 type"));
return 1;
}
@@ -222,14 +220,14 @@ _printDataType(virConnectPtr conn,
case DATATYPE_UINT8:
if (snprintf(buf, bufsize, asHex ? "0x%x" : "%d",
item->u.u8) >= bufsize) {
- virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER, "%s",
+ virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, "%s",
_("Buffer too small for uint8 type"));
return 1;
}
break;
default:
- virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER,
+ virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
_("Unhandled datatype %x"), item->datatype);
return 1;
break;
@@ -240,22 +238,20 @@ _printDataType(virConnectPtr conn,
static int
-printDataType(virConnectPtr conn,
- virNWFilterHashTablePtr vars,
+printDataType(virNWFilterHashTablePtr vars,
char *buf, int bufsize,
nwItemDescPtr item)
{
- return _printDataType(conn, vars, buf, bufsize, item, 0);
+ return _printDataType(vars, buf, bufsize, item, 0);
}
static int
-printDataTypeAsHex(virConnectPtr conn,
- virNWFilterHashTablePtr vars,
+printDataTypeAsHex(virNWFilterHashTablePtr vars,
char *buf, int bufsize,
nwItemDescPtr item)
{
- return _printDataType(conn, vars, buf, bufsize, item, 1);
+ return _printDataType(vars, buf, bufsize, item, 1);
}
@@ -297,16 +293,14 @@ ebiptablesAddRuleInst(virConnectPtr conn,
static int
-ebtablesHandleEthHdr(virConnectPtr conn,
- virBufferPtr buf,
+ebtablesHandleEthHdr(virBufferPtr buf,
virNWFilterHashTablePtr vars,
ethHdrDataDefPtr ethHdr)
{
char macaddr[VIR_MAC_STRING_BUFLEN];
if (HAS_ENTRY_ITEM(ðHdr->dataSrcMACAddr)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
macaddr, sizeof(macaddr),
ðHdr->dataSrcMACAddr))
goto err_exit;
@@ -317,8 +311,7 @@ ebtablesHandleEthHdr(virConnectPtr conn,
macaddr);
if (HAS_ENTRY_ITEM(ðHdr->dataSrcMACMask)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
macaddr, sizeof(macaddr),
ðHdr->dataSrcMACMask))
goto err_exit;
@@ -330,8 +323,7 @@ ebtablesHandleEthHdr(virConnectPtr conn,
}
if (HAS_ENTRY_ITEM(ðHdr->dataDstMACAddr)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
macaddr, sizeof(macaddr),
ðHdr->dataDstMACAddr))
goto err_exit;
@@ -342,8 +334,7 @@ ebtablesHandleEthHdr(virConnectPtr conn,
macaddr);
if (HAS_ENTRY_ITEM(ðHdr->dataDstMACMask)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
macaddr, sizeof(macaddr),
ðHdr->dataDstMACMask))
goto err_exit;
@@ -806,8 +797,7 @@ iptablesHandleSrcMacAddr(virConnectPtr conn ATTRIBUTE_UNUSED,
char macaddr[VIR_MAC_STRING_BUFLEN];
if (HAS_ENTRY_ITEM(srcMacAddr)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
macaddr, sizeof(macaddr),
srcMacAddr))
goto err_exit;
@@ -849,8 +839,7 @@ iptablesHandleIpHdr(virConnectPtr conn ATTRIBUTE_UNUSED,
if (HAS_ENTRY_ITEM(&ipHdr->dataSrcIPAddr)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
ipaddr, sizeof(ipaddr),
&ipHdr->dataSrcIPAddr))
goto err_exit;
@@ -863,8 +852,7 @@ iptablesHandleIpHdr(virConnectPtr conn ATTRIBUTE_UNUSED,
if (HAS_ENTRY_ITEM(&ipHdr->dataSrcIPMask)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
number, sizeof(number),
&ipHdr->dataSrcIPMask))
goto err_exit;
@@ -875,8 +863,7 @@ iptablesHandleIpHdr(virConnectPtr conn ATTRIBUTE_UNUSED,
}
} else if (HAS_ENTRY_ITEM(&ipHdr->dataSrcIPFrom)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
ipaddr, sizeof(ipaddr),
&ipHdr->dataSrcIPFrom))
goto err_exit;
@@ -889,8 +876,7 @@ iptablesHandleIpHdr(virConnectPtr conn ATTRIBUTE_UNUSED,
if (HAS_ENTRY_ITEM(&ipHdr->dataSrcIPTo)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
ipaddr, sizeof(ipaddr),
&ipHdr->dataSrcIPTo))
goto err_exit;
@@ -903,8 +889,7 @@ iptablesHandleIpHdr(virConnectPtr conn ATTRIBUTE_UNUSED,
if (HAS_ENTRY_ITEM(&ipHdr->dataDstIPAddr)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
ipaddr, sizeof(ipaddr),
&ipHdr->dataDstIPAddr))
goto err_exit;
@@ -917,8 +902,7 @@ iptablesHandleIpHdr(virConnectPtr conn ATTRIBUTE_UNUSED,
if (HAS_ENTRY_ITEM(&ipHdr->dataDstIPMask)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
number, sizeof(number),
&ipHdr->dataDstIPMask))
goto err_exit;
@@ -930,8 +914,7 @@ iptablesHandleIpHdr(virConnectPtr conn ATTRIBUTE_UNUSED,
}
} else if (HAS_ENTRY_ITEM(&ipHdr->dataDstIPFrom)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
ipaddr, sizeof(ipaddr),
&ipHdr->dataDstIPFrom))
goto err_exit;
@@ -944,8 +927,7 @@ iptablesHandleIpHdr(virConnectPtr conn ATTRIBUTE_UNUSED,
if (HAS_ENTRY_ITEM(&ipHdr->dataDstIPTo)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
ipaddr, sizeof(ipaddr),
&ipHdr->dataDstIPTo))
goto err_exit;
@@ -958,8 +940,7 @@ iptablesHandleIpHdr(virConnectPtr conn ATTRIBUTE_UNUSED,
if (HAS_ENTRY_ITEM(&ipHdr->dataDSCP)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
number, sizeof(number),
&ipHdr->dataDSCP))
goto err_exit;
@@ -995,8 +976,7 @@ iptablesHandlePortData(virConnectPtr conn ATTRIBUTE_UNUSED,
}
if (HAS_ENTRY_ITEM(&portData->dataSrcPortStart)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
portstr, sizeof(portstr),
&portData->dataSrcPortStart))
goto err_exit;
@@ -1008,8 +988,7 @@ iptablesHandlePortData(virConnectPtr conn ATTRIBUTE_UNUSED,
portstr);
if (HAS_ENTRY_ITEM(&portData->dataSrcPortEnd)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
portstr, sizeof(portstr),
&portData->dataSrcPortEnd))
goto err_exit;
@@ -1021,8 +1000,7 @@ iptablesHandlePortData(virConnectPtr conn ATTRIBUTE_UNUSED,
}
if (HAS_ENTRY_ITEM(&portData->dataDstPortStart)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
portstr, sizeof(portstr),
&portData->dataDstPortStart))
goto err_exit;
@@ -1034,8 +1012,7 @@ iptablesHandlePortData(virConnectPtr conn ATTRIBUTE_UNUSED,
portstr);
if (HAS_ENTRY_ITEM(&portData->dataDstPortEnd)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
portstr, sizeof(portstr),
&portData->dataDstPortEnd))
goto err_exit;
@@ -1121,8 +1098,7 @@ _iptablesCreateRuleInstance(virConnectPtr conn,
goto err_exit;
if (HAS_ENTRY_ITEM(&rule->p.tcpHdrFilter.dataTCPOption)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
number, sizeof(number),
&rule->p.tcpHdrFilter.dataTCPOption))
goto err_exit;
@@ -1305,8 +1281,7 @@ _iptablesCreateRuleInstance(virConnectPtr conn,
else
parm = "--icmpv6-type";
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
number, sizeof(number),
&rule->p.icmpHdrFilter.dataICMPType))
goto err_exit;
@@ -1318,8 +1293,7 @@ _iptablesCreateRuleInstance(virConnectPtr conn,
number);
if (HAS_ENTRY_ITEM(&rule->p.icmpHdrFilter.dataICMPCode)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
number, sizeof(number),
&rule->p.icmpHdrFilter.dataICMPCode))
goto err_exit;
@@ -1543,15 +1517,13 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
EBTABLES_DEFAULT_TABLE, chain);
- if (ebtablesHandleEthHdr(conn,
- &buf,
+ if (ebtablesHandleEthHdr(&buf,
vars,
&rule->p.ethHdrFilter.ethHdr))
goto err_exit;
if (HAS_ENTRY_ITEM(&rule->p.ethHdrFilter.dataProtocolID)) {
- if (printDataTypeAsHex(conn,
- vars,
+ if (printDataTypeAsHex(vars,
number, sizeof(number),
&rule->p.ethHdrFilter.dataProtocolID))
goto err_exit;
@@ -1568,8 +1540,7 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
CMD_DEF_PRE EBTABLES_CMD " -t %s -%%c %s %%s",
EBTABLES_DEFAULT_TABLE, chain);
- if (ebtablesHandleEthHdr(conn,
- &buf,
+ if (ebtablesHandleEthHdr(&buf,
vars,
&rule->p.arpHdrFilter.ethHdr))
goto err_exit;
@@ -1577,10 +1548,9 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
virBufferAddLit(&buf, " -p arp");
if (HAS_ENTRY_ITEM(&rule->p.arpHdrFilter.dataHWType)) {
- if (printDataType(conn,
- vars,
- number, sizeof(number),
- &rule->p.arpHdrFilter.dataHWType))
+ if (printDataType(vars,
+ number, sizeof(number),
+ &rule->p.arpHdrFilter.dataHWType))
goto err_exit;
virBufferVSprintf(&buf,
" --arp-htype %s %s",
@@ -1589,8 +1559,7 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
}
if (HAS_ENTRY_ITEM(&rule->p.arpHdrFilter.dataOpcode)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
number, sizeof(number),
&rule->p.arpHdrFilter.dataOpcode))
goto err_exit;
@@ -1601,8 +1570,7 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
}
if (HAS_ENTRY_ITEM(&rule->p.arpHdrFilter.dataProtocolType)) {
- if (printDataTypeAsHex(conn,
- vars,
+ if (printDataTypeAsHex(vars,
number, sizeof(number),
&rule->p.arpHdrFilter.dataProtocolType))
goto err_exit;
@@ -1613,8 +1581,7 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
}
if (HAS_ENTRY_ITEM(&rule->p.arpHdrFilter.dataARPSrcIPAddr)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
ipaddr, sizeof(ipaddr),
&rule->p.arpHdrFilter.dataARPSrcIPAddr))
goto err_exit;
@@ -1626,8 +1593,7 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
}
if (HAS_ENTRY_ITEM(&rule->p.arpHdrFilter.dataARPDstIPAddr)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
ipaddr, sizeof(ipaddr),
&rule->p.arpHdrFilter.dataARPDstIPAddr))
goto err_exit;
@@ -1639,8 +1605,7 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
}
if (HAS_ENTRY_ITEM(&rule->p.arpHdrFilter.dataARPSrcMACAddr)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
macaddr, sizeof(macaddr),
&rule->p.arpHdrFilter.dataARPSrcMACAddr))
goto err_exit;
@@ -1652,8 +1617,7 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
}
if (HAS_ENTRY_ITEM(&rule->p.arpHdrFilter.dataARPDstMACAddr)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
macaddr, sizeof(macaddr),
&rule->p.arpHdrFilter.dataARPDstMACAddr))
goto err_exit;
@@ -1670,8 +1634,7 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
CMD_DEF_PRE EBTABLES_CMD " -t %s -%%c %s %%s",
EBTABLES_DEFAULT_TABLE, chain);
- if (ebtablesHandleEthHdr(conn,
- &buf,
+ if (ebtablesHandleEthHdr(&buf,
vars,
&rule->p.ipHdrFilter.ethHdr))
goto err_exit;
@@ -1680,8 +1643,7 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
" -p ipv4");
if (HAS_ENTRY_ITEM(&rule->p.ipHdrFilter.ipHdr.dataSrcIPAddr)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
ipaddr, sizeof(ipaddr),
&rule->p.ipHdrFilter.ipHdr.dataSrcIPAddr))
goto err_exit;
@@ -1692,8 +1654,7 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
ipaddr);
if (HAS_ENTRY_ITEM(&rule->p.ipHdrFilter.ipHdr.dataSrcIPMask)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
number, sizeof(number),
&rule->p.ipHdrFilter.ipHdr.dataSrcIPMask))
goto err_exit;
@@ -1705,8 +1666,7 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
if (HAS_ENTRY_ITEM(&rule->p.ipHdrFilter.ipHdr.dataDstIPAddr)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
ipaddr, sizeof(ipaddr),
&rule->p.ipHdrFilter.ipHdr.dataDstIPAddr))
goto err_exit;
@@ -1717,8 +1677,7 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
ipaddr);
if (HAS_ENTRY_ITEM(&rule->p.ipHdrFilter.ipHdr.dataDstIPMask)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
number, sizeof(number),
&rule->p.ipHdrFilter.ipHdr.dataDstIPMask))
goto err_exit;
@@ -1729,8 +1688,7 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
}
if (HAS_ENTRY_ITEM(&rule->p.ipHdrFilter.ipHdr.dataProtocolID)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
number, sizeof(number),
&rule->p.ipHdrFilter.ipHdr.dataProtocolID))
goto err_exit;
@@ -1743,8 +1701,7 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
if (HAS_ENTRY_ITEM(&rule->p.ipHdrFilter.portData.dataSrcPortStart)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
number, sizeof(number),
&rule->p.ipHdrFilter.portData.dataSrcPortStart))
goto err_exit;
@@ -1755,8 +1712,7 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
number);
if (HAS_ENTRY_ITEM(&rule->p.ipHdrFilter.portData.dataSrcPortEnd)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
number, sizeof(number),
&rule->p.ipHdrFilter.portData.dataSrcPortEnd))
goto err_exit;
@@ -1769,8 +1725,7 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
if (HAS_ENTRY_ITEM(&rule->p.ipHdrFilter.portData.dataDstPortStart)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
number, sizeof(number),
&rule->p.ipHdrFilter.portData.dataDstPortStart))
goto err_exit;
@@ -1781,10 +1736,9 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
number);
if (HAS_ENTRY_ITEM(&rule->p.ipHdrFilter.portData.dataDstPortEnd)) {
- if (printDataType(conn,
- vars,
- number, sizeof(number),
- &rule->p.ipHdrFilter.portData.dataDstPortEnd))
+ if (printDataType(vars,
+ number, sizeof(number),
+ &rule->p.ipHdrFilter.portData.dataDstPortEnd))
goto err_exit;
virBufferVSprintf(&buf,
@@ -1794,8 +1748,7 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
}
if (HAS_ENTRY_ITEM(&rule->p.ipHdrFilter.ipHdr.dataDSCP)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
number, sizeof(number),
&rule->p.ipHdrFilter.ipHdr.dataDSCP))
goto err_exit;
@@ -1812,8 +1765,7 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
CMD_DEF_PRE EBTABLES_CMD " -t %s -%%c %s %%s",
EBTABLES_DEFAULT_TABLE, chain);
- if (ebtablesHandleEthHdr(conn,
- &buf,
+ if (ebtablesHandleEthHdr(&buf,
vars,
&rule->p.ipv6HdrFilter.ethHdr))
goto err_exit;
@@ -1822,8 +1774,7 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
" -p ipv6");
if (HAS_ENTRY_ITEM(&rule->p.ipv6HdrFilter.ipHdr.dataSrcIPAddr)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
ipv6addr, sizeof(ipv6addr),
&rule->p.ipv6HdrFilter.ipHdr.dataSrcIPAddr))
goto err_exit;
@@ -1834,8 +1785,7 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
ipv6addr);
if (HAS_ENTRY_ITEM(&rule->p.ipv6HdrFilter.ipHdr.dataSrcIPMask)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
number, sizeof(number),
&rule->p.ipv6HdrFilter.ipHdr.dataSrcIPMask))
goto err_exit;
@@ -1847,8 +1797,7 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
if (HAS_ENTRY_ITEM(&rule->p.ipv6HdrFilter.ipHdr.dataDstIPAddr)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
ipv6addr, sizeof(ipv6addr),
&rule->p.ipv6HdrFilter.ipHdr.dataDstIPAddr))
goto err_exit;
@@ -1859,8 +1808,7 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
ipv6addr);
if (HAS_ENTRY_ITEM(&rule->p.ipv6HdrFilter.ipHdr.dataDstIPMask)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
number, sizeof(number),
&rule->p.ipv6HdrFilter.ipHdr.dataDstIPMask))
goto err_exit;
@@ -1871,8 +1819,7 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
}
if (HAS_ENTRY_ITEM(&rule->p.ipv6HdrFilter.ipHdr.dataProtocolID)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
number, sizeof(number),
&rule->p.ipv6HdrFilter.ipHdr.dataProtocolID))
goto err_exit;
@@ -1885,8 +1832,7 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
if (HAS_ENTRY_ITEM(&rule->p.ipv6HdrFilter.portData.dataSrcPortStart)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
number, sizeof(number),
&rule->p.ipv6HdrFilter.portData.dataSrcPortStart))
goto err_exit;
@@ -1897,8 +1843,7 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
number);
if (HAS_ENTRY_ITEM(&rule->p.ipv6HdrFilter.portData.dataSrcPortEnd)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
number, sizeof(number),
&rule->p.ipv6HdrFilter.portData.dataSrcPortEnd))
goto err_exit;
@@ -1911,8 +1856,7 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
if (HAS_ENTRY_ITEM(&rule->p.ipv6HdrFilter.portData.dataDstPortStart)) {
- if (printDataType(conn,
- vars,
+ if (printDataType(vars,
number, sizeof(number),
&rule->p.ipv6HdrFilter.portData.dataDstPortStart))
goto err_exit;
@@ -1923,10 +1867,9 @@ ebtablesCreateRuleInstance(virConnectPtr conn,
number);
if (HAS_ENTRY_ITEM(&rule->p.ipv6HdrFilter.portData.dataDstPortEnd)) {
- if (printDataType(conn,
- vars,
- number, sizeof(number),
- &rule->p.ipv6HdrFilter.portData.dataDstPortEnd))
+ if (printDataType(vars,
+ number, sizeof(number),
+
&rule->p.ipv6HdrFilter.portData.dataDstPortEnd))
goto err_exit;
virBufferVSprintf(&buf,
@@ -2041,7 +1984,7 @@ ebiptablesCreateRuleInstance(virConnectPtr conn,
case VIR_NWFILTER_RULE_PROTOCOL_IGMP:
case VIR_NWFILTER_RULE_PROTOCOL_ALL:
if (nettype == VIR_DOMAIN_NET_TYPE_DIRECT) {
- virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER,
+ virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
_("'%s' protocol not support for net type
'%s'"),
virNWFilterRuleProtocolTypeToString(rule->prtclType),
virDomainNetTypeToString(nettype));
@@ -2066,7 +2009,7 @@ ebiptablesCreateRuleInstance(virConnectPtr conn,
case VIR_NWFILTER_RULE_PROTOCOL_ICMPV6:
case VIR_NWFILTER_RULE_PROTOCOL_ALLoIPV6:
if (nettype == VIR_DOMAIN_NET_TYPE_DIRECT) {
- virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER,
+ virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
_("'%s' protocol not support for net type
'%s'"),
virNWFilterRuleProtocolTypeToString(rule->prtclType),
virDomainNetTypeToString(nettype));
@@ -2083,8 +2026,8 @@ ebiptablesCreateRuleInstance(virConnectPtr conn,
break;
case VIR_NWFILTER_RULE_PROTOCOL_LAST:
- virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER,
- "%s", _("illegal protocol type"));
+ virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, "%s",
+ _("illegal protocol type"));
rc = 1;
break;
}
@@ -2128,8 +2071,7 @@ ebiptablesDisplayRuleInstance(virConnectPtr conn ATTRIBUTE_UNUSED,
* set so that the file can be run as an executable script.
*/
static char *
-ebiptablesWriteToTempFile(virConnectPtr conn,
- const char *string) {
+ebiptablesWriteToTempFile(const char *string) {
char filename[] = "/tmp/virtdXXXXXX";
int len;
char *filnam;
@@ -2139,15 +2081,13 @@ ebiptablesWriteToTempFile(virConnectPtr conn,
int fd = mkstemp(filename);
if (fd < 0) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
- "%s",
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot create temporary file"));
return NULL;
}
if (fchmod(fd, S_IXUSR| S_IRUSR | S_IWUSR) < 0) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
- "%s",
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot change permissions on temp. file"));
goto err_exit;
}
@@ -2155,8 +2095,7 @@ ebiptablesWriteToTempFile(virConnectPtr conn,
len = strlen(header);
written = safewrite(fd, header, len);
if (written != len) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
- "%s",
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot write string to file"));
goto err_exit;
}
@@ -2164,8 +2103,7 @@ ebiptablesWriteToTempFile(virConnectPtr conn,
len = strlen(string);
written = safewrite(fd, string, len);
if (written != len) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
- "%s",
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot write string to file"));
goto err_exit;
}
@@ -2202,8 +2140,7 @@ err_exit:
* script and return the status of the execution.
*/
static int
-ebiptablesExecCLI(virConnectPtr conn,
- virBufferPtr buf,
+ebiptablesExecCLI(virBufferPtr buf,
int *status)
{
char *cmds;
@@ -2226,7 +2163,7 @@ ebiptablesExecCLI(virConnectPtr conn,
if (!cmds)
return 0;
- filename = ebiptablesWriteToTempFile(conn, cmds);
+ filename = ebiptablesWriteToTempFile(cmds);
VIR_FREE(cmds);
if (!filename)
@@ -2635,7 +2572,7 @@ ebiptablesApplyNewRules(virConnectPtr conn,
ebtablesRemoveTmpSubChains(conn, &buf, ifname);
ebtablesRemoveTmpRootChain(conn, &buf, 1, ifname);
ebtablesRemoveTmpRootChain(conn, &buf, 0, ifname);
- ebiptablesExecCLI(conn, &buf, &cli_status);
+ ebiptablesExecCLI(&buf, &cli_status);
if (chains_in != 0)
ebtablesCreateTmpRootChain(conn, &buf, 1, ifname, 1);
@@ -2658,7 +2595,7 @@ ebiptablesApplyNewRules(virConnectPtr conn,
if (chains_out & (1 << VIR_NWFILTER_CHAINSUFFIX_ARP))
ebtablesCreateTmpSubChain(conn, &buf, 0, ifname, "arp", 1);
- if (ebiptablesExecCLI(conn, &buf, &cli_status) || cli_status != 0)
+ if (ebiptablesExecCLI(&buf, &cli_status) || cli_status != 0)
goto tear_down_tmpebchains;
for (i = 0; i < nruleInstances; i++)
@@ -2676,7 +2613,7 @@ ebiptablesApplyNewRules(virConnectPtr conn,
break;
}
- if (ebiptablesExecCLI(conn, &buf, &cli_status) || cli_status != 0)
+ if (ebiptablesExecCLI(&buf, &cli_status) || cli_status != 0)
goto tear_down_tmpebchains;
// FIXME: establishment of iptables user define table tree goes here
@@ -2687,17 +2624,17 @@ ebiptablesApplyNewRules(virConnectPtr conn,
iptablesCreateBaseChains(conn, IPTABLES_CMD, &buf);
- if (ebiptablesExecCLI(conn, &buf, &cli_status) || cli_status != 0)
+ if (ebiptablesExecCLI(&buf, &cli_status) || cli_status != 0)
goto tear_down_tmpebchains;
iptablesCreateTmpRootChains(conn, IPTABLES_CMD, &buf, ifname);
- if (ebiptablesExecCLI(conn, &buf, &cli_status) || cli_status != 0)
+ if (ebiptablesExecCLI(&buf, &cli_status) || cli_status != 0)
goto tear_down_tmpiptchains;
iptablesLinkTmpRootChains(conn, IPTABLES_CMD, &buf, ifname);
iptablesSetupVirtInPost(conn, IPTABLES_CMD, &buf, ifname);
- if (ebiptablesExecCLI(conn, &buf, &cli_status) || cli_status != 0)
+ if (ebiptablesExecCLI(&buf, &cli_status) || cli_status != 0)
goto tear_down_tmpiptchains;
for (i = 0; i < nruleInstances; i++) {
@@ -2707,7 +2644,7 @@ ebiptablesApplyNewRules(virConnectPtr conn,
'A', -1, 1);
}
- if (ebiptablesExecCLI(conn, &buf, &cli_status) || cli_status != 0)
+ if (ebiptablesExecCLI(&buf, &cli_status) || cli_status != 0)
goto tear_down_tmpiptchains;
}
@@ -2717,17 +2654,17 @@ ebiptablesApplyNewRules(virConnectPtr conn,
iptablesCreateBaseChains(conn, IP6TABLES_CMD, &buf);
- if (ebiptablesExecCLI(conn, &buf, &cli_status) || cli_status != 0)
+ if (ebiptablesExecCLI(&buf, &cli_status) || cli_status != 0)
goto tear_down_tmpiptchains;
iptablesCreateTmpRootChains(conn, IP6TABLES_CMD, &buf, ifname);
- if (ebiptablesExecCLI(conn, &buf, &cli_status) || cli_status != 0)
+ if (ebiptablesExecCLI(&buf, &cli_status) || cli_status != 0)
goto tear_down_tmpip6tchains;
iptablesLinkTmpRootChains(conn, IP6TABLES_CMD, &buf, ifname);
iptablesSetupVirtInPost(conn, IP6TABLES_CMD, &buf, ifname);
- if (ebiptablesExecCLI(conn, &buf, &cli_status) || cli_status != 0)
+ if (ebiptablesExecCLI(&buf, &cli_status) || cli_status != 0)
goto tear_down_tmpip6tchains;
for (i = 0; i < nruleInstances; i++) {
@@ -2737,7 +2674,7 @@ ebiptablesApplyNewRules(virConnectPtr conn,
'A', -1, 1);
}
- if (ebiptablesExecCLI(conn, &buf, &cli_status) || cli_status != 0)
+ if (ebiptablesExecCLI(&buf, &cli_status) || cli_status != 0)
goto tear_down_tmpip6tchains;
}
@@ -2749,7 +2686,7 @@ ebiptablesApplyNewRules(virConnectPtr conn,
if (chains_out != 0)
ebtablesLinkTmpRootChain(conn, &buf, 0, ifname, 1);
- if (ebiptablesExecCLI(conn, &buf, &cli_status) || cli_status != 0)
+ if (ebiptablesExecCLI(&buf, &cli_status) || cli_status != 0)
goto tear_down_ebsubchains_and_unlink;
return 0;
@@ -2775,10 +2712,9 @@ tear_down_tmpebchains:
ebtablesRemoveTmpRootChain(conn, &buf, 1, ifname);
ebtablesRemoveTmpRootChain(conn, &buf, 0, ifname);
- ebiptablesExecCLI(conn, &buf, &cli_status);
+ ebiptablesExecCLI(&buf, &cli_status);
- virNWFilterReportError(conn, VIR_ERR_BUILD_FIREWALL,
- "%s",
+ virNWFilterReportError(VIR_ERR_BUILD_FIREWALL, "%s",
_("Some rules could not be created."));
return 1;
@@ -2805,7 +2741,7 @@ ebiptablesTearNewRules(virConnectPtr conn,
ebtablesRemoveTmpRootChain(conn, &buf, 1, ifname);
ebtablesRemoveTmpRootChain(conn, &buf, 0, ifname);
- ebiptablesExecCLI(conn, &buf, &cli_status);
+ ebiptablesExecCLI(&buf, &cli_status);
return 0;
}
@@ -2823,13 +2759,13 @@ ebiptablesTearOldRules(virConnectPtr conn,
iptablesRemoveRootChains(conn, IPTABLES_CMD, &buf, ifname);
iptablesRenameTmpRootChains(conn, IPTABLES_CMD, &buf, ifname);
- ebiptablesExecCLI(conn, &buf, &cli_status);
+ ebiptablesExecCLI(&buf, &cli_status);
iptablesUnlinkRootChains(conn, IP6TABLES_CMD, &buf, ifname);
iptablesRemoveRootChains(conn, IP6TABLES_CMD, &buf, ifname);
iptablesRenameTmpRootChains(conn, IP6TABLES_CMD, &buf, ifname);
- ebiptablesExecCLI(conn, &buf, &cli_status);
+ ebiptablesExecCLI(&buf, &cli_status);
ebtablesUnlinkRootChain(conn, &buf, 1, ifname);
ebtablesUnlinkRootChain(conn, &buf, 0, ifname);
@@ -2843,7 +2779,7 @@ ebiptablesTearOldRules(virConnectPtr conn,
ebtablesRenameTmpRootChain(conn, &buf, 1, ifname);
ebtablesRenameTmpRootChain(conn, &buf, 0, ifname);
- ebiptablesExecCLI(conn, &buf, &cli_status);
+ ebiptablesExecCLI(&buf, &cli_status);
return 0;
}
@@ -2879,12 +2815,11 @@ ebiptablesRemoveRules(virConnectPtr conn,
'D', -1,
0);
- if (ebiptablesExecCLI(conn, &buf, &cli_status))
+ if (ebiptablesExecCLI(&buf, &cli_status))
goto err_exit;
if (cli_status) {
- virNWFilterReportError(conn, VIR_ERR_BUILD_FIREWALL,
- "%s",
+ virNWFilterReportError(VIR_ERR_BUILD_FIREWALL, "%s",
_("error while executing CLI commands"));
rc = 1;
}
@@ -2926,7 +2861,7 @@ ebiptablesAllTeardown(const char *ifname)
ebtablesRemoveSubChains(conn, &buf, ifname);
- ebiptablesExecCLI(conn, &buf, &cli_status);
+ ebiptablesExecCLI(&buf, &cli_status);
return 0;
}
diff --git a/src/nwfilter/nwfilter_gentech_driver.c
b/src/nwfilter/nwfilter_gentech_driver.c
index e1a0986..0ece679 100644
--- a/src/nwfilter/nwfilter_gentech_driver.c
+++ b/src/nwfilter/nwfilter_gentech_driver.c
@@ -118,16 +118,15 @@ virNWFilterRuleInstFree(virNWFilterRuleInstPtr inst)
* Adds a couple of standard keys (MAC, IP) to the hash table.
*/
static int
-virNWFilterVarHashmapAddStdValues(virConnectPtr conn,
- virNWFilterHashTablePtr table,
+virNWFilterVarHashmapAddStdValues(virNWFilterHashTablePtr table,
char *macaddr)
{
if (macaddr) {
if (virHashAddEntry(table->hashTable,
NWFILTER_STD_VAR_MAC,
macaddr) < 0) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
- "%s", _("Could not add variable
'MAC' to hashmap"));
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Could not add variable 'MAC' to
hashmap"));
return 1;
}
}
@@ -148,15 +147,14 @@ virNWFilterVarHashmapAddStdValues(virConnectPtr conn,
* is attached to the virConnect object.
*/
virNWFilterHashTablePtr
-virNWFilterCreateVarHashmap(virConnectPtr conn,
- char *macaddr) {
+virNWFilterCreateVarHashmap(char *macaddr) {
virNWFilterHashTablePtr table = virNWFilterHashTableCreate(0);
if (!table) {
virReportOOMError();
return NULL;
}
- if (virNWFilterVarHashmapAddStdValues(conn, table, macaddr)) {
+ if (virNWFilterVarHashmapAddStdValues(table, macaddr)) {
virNWFilterHashTableFree(table);
return NULL;
}
@@ -324,7 +322,7 @@ _virNWFilterInstantiateRec(virConnectPtr conn,
if (obj) {
if (obj->wantRemoved) {
- virNWFilterReportError(conn, VIR_ERR_NO_NWFILTER,
+ virNWFilterReportError(VIR_ERR_NO_NWFILTER,
_("Filter '%s' is in
use."),
inc->filterref);
rc = 1;
@@ -373,7 +371,7 @@ _virNWFilterInstantiateRec(virConnectPtr conn,
if (rc)
break;
} else {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
_("referenced filter '%s' is
missing"),
inc->filterref);
rc = 1;
@@ -516,9 +514,9 @@ _virNWFilterInstantiateFilter(virConnectPtr conn,
techdriver = virNWFilterTechDriverForName(drvname);
if (!techdriver) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not get access to ACL tech "
- "driver '%s'"),
+ "driver '%s'"),
drvname);
return 1;
}
@@ -527,14 +525,14 @@ _virNWFilterInstantiateFilter(virConnectPtr conn,
obj = virNWFilterPoolObjFindByName(&driver->pools, net->filter);
if (!obj) {
- virNWFilterReportError(conn, VIR_ERR_NO_NWFILTER,
+ virNWFilterReportError(VIR_ERR_NO_NWFILTER,
_("Could not find filter '%s'"),
net->filter);
return 1;
}
if (obj->wantRemoved) {
- virNWFilterReportError(conn, VIR_ERR_NO_NWFILTER,
+ virNWFilterReportError(VIR_ERR_NO_NWFILTER,
_("Filter '%s' is in use."),
net->filter);
rc = 1;
@@ -549,8 +547,7 @@ _virNWFilterInstantiateFilter(virConnectPtr conn,
goto err_exit;
}
- vars1 = virNWFilterCreateVarHashmap(conn,
- str_macaddr);
+ vars1 = virNWFilterCreateVarHashmap(str_macaddr);
if (!vars1) {
rc = 1;
goto err_exit;
@@ -630,9 +627,9 @@ int virNWFilterRollbackUpdateFilter(virConnectPtr conn,
virNWFilterTechDriverPtr techdriver;
techdriver = virNWFilterTechDriverForName(drvname);
if (!techdriver) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not get access to ACL tech "
- "driver '%s'"),
+ "driver '%s'"),
drvname);
return 1;
}
@@ -649,9 +646,9 @@ virNWFilterTearOldFilter(virConnectPtr conn,
virNWFilterTechDriverPtr techdriver;
techdriver = virNWFilterTechDriverForName(drvname);
if (!techdriver) {
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not get access to ACL tech "
- "driver '%s'"),
+ "driver '%s'"),
drvname);
return 1;
}
@@ -669,9 +666,9 @@ virNWFilterTeardownFilter(const virDomainNetDefPtr net)
if (!techdriver) {
#if 0
- virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not get access to ACL tech "
- "driver '%s'"),
+ "driver '%s'"),
drvname);
#endif
return 1;
diff --git a/src/nwfilter/nwfilter_gentech_driver.h
b/src/nwfilter/nwfilter_gentech_driver.h
index b10480f..a68c455 100644
--- a/src/nwfilter/nwfilter_gentech_driver.h
+++ b/src/nwfilter/nwfilter_gentech_driver.h
@@ -48,8 +48,7 @@ int virNWFilterTearOldFilter(virConnectPtr conn,
int virNWFilterTeardownFilter(const virDomainNetDefPtr net);
-virNWFilterHashTablePtr virNWFilterCreateVarHashmap(virConnectPtr conn,
- char *macaddr);
+virNWFilterHashTablePtr virNWFilterCreateVarHashmap(char *macaddr);
void virNWFilterDomainFWUpdateCB(void *payload,
const char *name ATTRIBUTE_UNUSED,
diff --git a/tests/nwfilterxml2xmltest.c b/tests/nwfilterxml2xmltest.c
index a7e6126..8a8c15a 100644
--- a/tests/nwfilterxml2xmltest.c
+++ b/tests/nwfilterxml2xmltest.c
@@ -39,7 +39,7 @@ static int testCompareXMLToXMLFiles(const char *inxml, const char
*outxml) {
if (!(dev = virNWFilterDefParseString(NULL, inXmlData)))
goto fail;
- if (!(actual = virNWFilterDefFormat(NULL, dev)))
+ if (!(actual = virNWFilterDefFormat(dev)))
goto fail;
if (STRNEQ(outXmlData, actual)) {
--
1.6.3.3