static int
iptablesCreateTmpRootChain(virBufferPtr buf,
char prefix,
- int incoming, const char *ifname,
+ bool incoming, const char *ifname,
int stopOnError)
{
char chain[MAX_CHAINNAME_LENGTH];
iptablesCreateTmpRootChains(virBufferPtr buf,
const char *ifname)
{
- iptablesCreateTmpRootChain(buf, 'F', 0, ifname, 1);
- iptablesCreateTmpRootChain(buf, 'F', 1, ifname, 1);
- iptablesCreateTmpRootChain(buf, 'H', 1, ifname, 1);
+ iptablesCreateTmpRootChain(buf, 'F', false, ifname, 1);
+ iptablesCreateTmpRootChain(buf, 'F', true, ifname, 1);
+ iptablesCreateTmpRootChain(buf, 'H', true, ifname, 1);
return 0;
}
static int
_iptablesRemoveRootChain(virBufferPtr buf,
char prefix,
- int incoming, const char *ifname,
+ bool incoming, const char *ifname,
int isTempChain)
{
char chain[MAX_CHAINNAME_LENGTH];
static int
iptablesRemoveRootChain(virBufferPtr buf,
char prefix,
- int incoming,
+ bool incoming,
const char *ifname)
{
return _iptablesRemoveRootChain(buf, prefix, incoming, ifname, 0);
static int
iptablesRemoveTmpRootChain(virBufferPtr buf,
char prefix,
- int incoming,
+ bool incoming,
const char *ifname)
{
return _iptablesRemoveRootChain(buf, prefix,
iptablesRemoveTmpRootChains(virBufferPtr buf,
const char *ifname)
{
- iptablesRemoveTmpRootChain(buf, 'F', 0, ifname);
- iptablesRemoveTmpRootChain(buf, 'F', 1, ifname);
- iptablesRemoveTmpRootChain(buf, 'H', 1, ifname);
+ iptablesRemoveTmpRootChain(buf, 'F', false, ifname);
+ iptablesRemoveTmpRootChain(buf, 'F', true, ifname);
+ iptablesRemoveTmpRootChain(buf, 'H', true, ifname);
return 0;
}
iptablesRemoveRootChains(virBufferPtr buf,
const char *ifname)
{
- iptablesRemoveRootChain(buf, 'F', 0, ifname);
- iptablesRemoveRootChain(buf, 'F', 1, ifname);
- iptablesRemoveRootChain(buf, 'H', 1, ifname);
+ iptablesRemoveRootChain(buf, 'F', false, ifname);
+ iptablesRemoveRootChain(buf, 'F', true, ifname);
+ iptablesRemoveRootChain(buf, 'H', true, ifname);
return 0;
}
iptablesLinkTmpRootChain(virBufferPtr buf,
const char *basechain,
char prefix,
- int incoming, const char *ifname,
+ bool incoming, const char *ifname,
int stopOnError)
{
char chain[MAX_CHAINNAME_LENGTH];
iptablesLinkTmpRootChains(virBufferPtr buf,
const char *ifname)
{
- iptablesLinkTmpRootChain(buf, VIRT_OUT_CHAIN, 'F', 0, ifname, 1);
- iptablesLinkTmpRootChain(buf, VIRT_IN_CHAIN, 'F', 1, ifname, 1);
- iptablesLinkTmpRootChain(buf, HOST_IN_CHAIN, 'H', 1, ifname, 1);
+ iptablesLinkTmpRootChain(buf, VIRT_OUT_CHAIN, 'F', false, ifname, 1);
+ iptablesLinkTmpRootChain(buf, VIRT_IN_CHAIN, 'F', true, ifname, 1);
+ iptablesLinkTmpRootChain(buf, HOST_IN_CHAIN, 'H', true, ifname, 1);
return 0;
}
_iptablesUnlinkRootChain(virBufferPtr buf,
const char *basechain,
char prefix,
- int incoming, const char *ifname,
+ bool incoming, const char *ifname,
int isTempChain)
{
char chain[MAX_CHAINNAME_LENGTH];
iptablesUnlinkRootChain(virBufferPtr buf,
const char *basechain,
char prefix,
- int incoming, const char *ifname)
+ bool incoming, const char *ifname)
{
return _iptablesUnlinkRootChain(buf,
basechain, prefix, incoming, ifname, 0);
iptablesUnlinkTmpRootChain(virBufferPtr buf,
const char *basechain,
char prefix,
- int incoming, const char *ifname)
+ bool incoming, const char *ifname)
{
return _iptablesUnlinkRootChain(buf,
basechain, prefix, incoming, ifname, 1);
iptablesUnlinkRootChains(virBufferPtr buf,
const char *ifname)
{
- iptablesUnlinkRootChain(buf, VIRT_OUT_CHAIN, 'F', 0, ifname);
- iptablesUnlinkRootChain(buf, VIRT_IN_CHAIN, 'F', 1, ifname);
- iptablesUnlinkRootChain(buf, HOST_IN_CHAIN, 'H', 1, ifname);
+ iptablesUnlinkRootChain(buf, VIRT_OUT_CHAIN, 'F', false, ifname);
+ iptablesUnlinkRootChain(buf, VIRT_IN_CHAIN, 'F', true, ifname);
+ iptablesUnlinkRootChain(buf, HOST_IN_CHAIN, 'H', true, ifname);
return 0;
}
iptablesUnlinkTmpRootChains(virBufferPtr buf,
const char *ifname)
{
- iptablesUnlinkTmpRootChain(buf, VIRT_OUT_CHAIN, 'F', 0, ifname);
- iptablesUnlinkTmpRootChain(buf, VIRT_IN_CHAIN, 'F', 1, ifname);
- iptablesUnlinkTmpRootChain(buf, HOST_IN_CHAIN, 'H', 1, ifname);
+ iptablesUnlinkTmpRootChain(buf, VIRT_OUT_CHAIN, 'F', false, ifname);
+ iptablesUnlinkTmpRootChain(buf, VIRT_IN_CHAIN, 'F', true, ifname);
+ iptablesUnlinkTmpRootChain(buf, HOST_IN_CHAIN, 'H', true, ifname);
return 0;
}
static int
iptablesRenameTmpRootChain(virBufferPtr buf,
char prefix,
- int incoming,
+ bool incoming,
const char *ifname)
{
char tmpchain[MAX_CHAINNAME_LENGTH], chain[MAX_CHAINNAME_LENGTH];
iptablesRenameTmpRootChains(virBufferPtr buf,
const char *ifname)
{
- iptablesRenameTmpRootChain(buf, 'F', 0, ifname);
- iptablesRenameTmpRootChain(buf, 'F', 1, ifname);
- iptablesRenameTmpRootChain(buf, 'H', 1, ifname);
+ iptablesRenameTmpRootChain(buf, 'F', false, ifname);
+ iptablesRenameTmpRootChain(buf, 'F', true, ifname);
+ iptablesRenameTmpRootChain(buf, 'H', true, ifname);
return 0;
}
static int
ebtablesCreateTmpRootChain(virBufferPtr buf,
- int incoming, const char *ifname,
+ bool incoming, const char *ifname,
int stopOnError)
{
char chain[MAX_CHAINNAME_LENGTH];
static int
ebtablesLinkTmpRootChain(virBufferPtr buf,
- int incoming, const char *ifname,
+ bool incoming, const char *ifname,
int stopOnError)
{
char chain[MAX_CHAINNAME_LENGTH];
static int
_ebtablesRemoveRootChain(virBufferPtr buf,
- int incoming, const char *ifname,
+ bool incoming, const char *ifname,
int isTempChain)
{
char chain[MAX_CHAINNAME_LENGTH];
static int
ebtablesRemoveRootChain(virBufferPtr buf,
- int incoming, const char *ifname)
+ bool incoming, const char *ifname)
{
return _ebtablesRemoveRootChain(buf, incoming, ifname, 0);
}
static int
ebtablesRemoveTmpRootChain(virBufferPtr buf,
- int incoming, const char *ifname)
+ bool incoming, const char *ifname)
{
return _ebtablesRemoveRootChain(buf, incoming, ifname, 1);
}
static int
_ebtablesUnlinkRootChain(virBufferPtr buf,
- int incoming, const char *ifname,
+ bool incoming, const char *ifname,
int isTempChain)
{
char chain[MAX_CHAINNAME_LENGTH];
static int
ebtablesUnlinkRootChain(virBufferPtr buf,
- int incoming, const char *ifname)
+ bool incoming, const char *ifname)
{
return _ebtablesUnlinkRootChain(buf, incoming, ifname, 0);
}
static int
ebtablesUnlinkTmpRootChain(virBufferPtr buf,
- int incoming, const char *ifname)
+ bool incoming, const char *ifname)
{
return _ebtablesUnlinkRootChain(buf, incoming, ifname, 1);
}
static int
ebtablesCreateTmpSubChain(ebiptablesRuleInstPtr *inst,
int *nRuleInstances,
- int incoming,
+ bool incoming,
const char *ifname,
enum l3_proto_idx protoidx,
const char *filtername,
static int
ebtablesRenameTmpSubChain(virBufferPtr buf,
- int incoming,
+ bool incoming,
const char *ifname,
const char *protocol)
{
static int
ebtablesRenameTmpRootChain(virBufferPtr buf,
- int incoming,
+ bool incoming,
const char *ifname)
{
return ebtablesRenameTmpSubChain(buf, incoming, ifname, NULL);
virBufferAddLit(buf, "rename_chains $chains\n");
- ebtablesRenameTmpRootChain(buf, 1, ifname);
- ebtablesRenameTmpRootChain(buf, 0, ifname);
+ ebtablesRenameTmpRootChain(buf, true, ifname);
+ ebtablesRenameTmpRootChain(buf, false, ifname);
return 0;
}
NWFILTER_SET_EBTABLES_SHELLVAR(&buf);
- ebtablesCreateTmpRootChain(&buf, 1, ifname, 1);
+ ebtablesCreateTmpRootChain(&buf, true, ifname, 1);
PRINT_ROOT_CHAIN(chain, chainPrefix, ifname);
virBufferAsprintf(&buf,
chain,
CMD_STOPONERR(1));
- ebtablesLinkTmpRootChain(&buf, 1, ifname, 1);
- ebtablesRenameTmpRootChain(&buf, 1, ifname);
+ ebtablesLinkTmpRootChain(&buf, true, ifname, 1);
+ ebtablesRenameTmpRootChain(&buf, true, ifname);
if (ebiptablesExecCLI(&buf, false, NULL) < 0)
goto tear_down_tmpebchains;
NWFILTER_SET_EBTABLES_SHELLVAR(&buf);
- ebtablesCreateTmpRootChain(&buf, 1, ifname, 1);
- ebtablesCreateTmpRootChain(&buf, 0, ifname, 1);
+ ebtablesCreateTmpRootChain(&buf, true, ifname, 1);
+ ebtablesCreateTmpRootChain(&buf, false, ifname, 1);
PRINT_ROOT_CHAIN(chain_in, CHAINPREFIX_HOST_IN_TEMP, ifname);
PRINT_ROOT_CHAIN(chain_out, CHAINPREFIX_HOST_OUT_TEMP, ifname);
chain_out,
CMD_STOPONERR(1));
- ebtablesLinkTmpRootChain(&buf, 1, ifname, 1);
- ebtablesLinkTmpRootChain(&buf, 0, ifname, 1);
+ ebtablesLinkTmpRootChain(&buf, true, ifname, 1);
+ ebtablesLinkTmpRootChain(&buf, false, ifname, 1);
if (!leaveTemporary) {
- ebtablesRenameTmpRootChain(&buf, 1, ifname);
- ebtablesRenameTmpRootChain(&buf, 0, ifname);
+ ebtablesRenameTmpRootChain(&buf, true, ifname);
+ ebtablesRenameTmpRootChain(&buf, false, ifname);
}
if (ebiptablesExecCLI(&buf, false, NULL) < 0)
NWFILTER_SET_EBTABLES_SHELLVAR(&buf);
- ebtablesCreateTmpRootChain(&buf, 1, ifname, 1);
- ebtablesCreateTmpRootChain(&buf, 0, ifname, 1);
+ ebtablesCreateTmpRootChain(&buf, true, ifname, 1);
+ ebtablesCreateTmpRootChain(&buf, false, ifname, 1);
PRINT_ROOT_CHAIN(chain_in, CHAINPREFIX_HOST_IN_TEMP, ifname);
PRINT_ROOT_CHAIN(chain_out, CHAINPREFIX_HOST_OUT_TEMP, ifname);
chain_out,
CMD_STOPONERR(1));
- ebtablesLinkTmpRootChain(&buf, 1, ifname, 1);
- ebtablesLinkTmpRootChain(&buf, 0, ifname, 1);
- ebtablesRenameTmpRootChain(&buf, 1, ifname);
- ebtablesRenameTmpRootChain(&buf, 0, ifname);
+ ebtablesLinkTmpRootChain(&buf, true, ifname, 1);
+ ebtablesLinkTmpRootChain(&buf, false, ifname, 1);
+ ebtablesRenameTmpRootChain(&buf, true, ifname);
+ ebtablesRenameTmpRootChain(&buf, false, ifname);
if (ebiptablesExecCLI(&buf, false, NULL) < 0)
goto tear_down_tmpebchains;
NWFILTER_SET_EBTABLES_SHELLVAR(&buf);
- ebtablesUnlinkRootChain(&buf, 1, ifname);
- ebtablesUnlinkRootChain(&buf, 0, ifname);
+ ebtablesUnlinkRootChain(&buf, true, ifname);
+ ebtablesUnlinkRootChain(&buf, false, ifname);
ebtablesRemoveSubChains(&buf, ifname);
- ebtablesRemoveRootChain(&buf, 1, ifname);
- ebtablesRemoveRootChain(&buf, 0, ifname);
+ ebtablesRemoveRootChain(&buf, true, ifname);
+ ebtablesRemoveRootChain(&buf, false, ifname);
- ebtablesUnlinkTmpRootChain(&buf, 1, ifname);
- ebtablesUnlinkTmpRootChain(&buf, 0, ifname);
+ ebtablesUnlinkTmpRootChain(&buf, true, ifname);
+ ebtablesUnlinkTmpRootChain(&buf, false, ifname);
ebtablesRemoveTmpSubChains(&buf, ifname);
- ebtablesRemoveTmpRootChain(&buf, 1, ifname);
- ebtablesRemoveTmpRootChain(&buf, 0, ifname);
+ ebtablesRemoveTmpRootChain(&buf, true, ifname);
+ ebtablesRemoveTmpRootChain(&buf, false, ifname);
ebiptablesExecCLI(&buf, true, NULL);
return 0;
static int
ebtablesCreateTmpRootAndSubChains(virBufferPtr buf,
const char *ifname,
- virHashTablePtr chains, int direction,
+ virHashTablePtr chains,
+ bool incoming,
ebiptablesRuleInstPtr *inst,
int *nRuleInstances)
{
virHashKeyValuePairPtr filter_names;
const virNWFilterChainPriority *priority;
- if (ebtablesCreateTmpRootChain(buf, direction, ifname, 1) < 0)
+ if (ebtablesCreateTmpRootChain(buf, incoming, ifname, 1) < 0)
return -1;
filter_names = virHashGetItems(chains,
continue;
priority = (const virNWFilterChainPriority *)filter_names[i].value;
rc = ebtablesCreateTmpSubChain(inst, nRuleInstances,
- direction, ifname, idx,
+ incoming, ifname, idx,
filter_names[i].key, 1,
*priority);
if (rc < 0)
if (ebtables_cmd_path) {
NWFILTER_SET_EBTABLES_SHELLVAR(&buf);
- ebtablesUnlinkTmpRootChain(&buf, 1, ifname);
- ebtablesUnlinkTmpRootChain(&buf, 0, ifname);
+ ebtablesUnlinkTmpRootChain(&buf, true, ifname);
+ ebtablesUnlinkTmpRootChain(&buf, false, ifname);
ebtablesRemoveTmpSubChains(&buf, ifname);
- ebtablesRemoveTmpRootChain(&buf, 1, ifname);
- ebtablesRemoveTmpRootChain(&buf, 0, ifname);
+ ebtablesRemoveTmpRootChain(&buf, true, ifname);
+ ebtablesRemoveTmpRootChain(&buf, false, ifname);
ebiptablesExecCLI(&buf, true, NULL);
}
/* create needed chains */
if ((virHashSize(chains_in_set) > 0 &&
- ebtablesCreateTmpRootAndSubChains(&buf, ifname, chains_in_set, 1,
+ ebtablesCreateTmpRootAndSubChains(&buf, ifname, chains_in_set, true,
&ebtChains, &nEbtChains) < 0) ||
(virHashSize(chains_out_set) > 0 &&
- ebtablesCreateTmpRootAndSubChains(&buf, ifname, chains_out_set, 0,
+ ebtablesCreateTmpRootAndSubChains(&buf, ifname, chains_out_set, false,
&ebtChains, &nEbtChains) < 0)) {
goto tear_down_tmpebchains;
}
NWFILTER_SET_EBTABLES_SHELLVAR(&buf);
if (virHashSize(chains_in_set) != 0)
- ebtablesLinkTmpRootChain(&buf, 1, ifname, 1);
+ ebtablesLinkTmpRootChain(&buf, true, ifname, 1);
if (virHashSize(chains_out_set) != 0)
- ebtablesLinkTmpRootChain(&buf, 0, ifname, 1);
+ ebtablesLinkTmpRootChain(&buf, false, ifname, 1);
if (ebiptablesExecCLI(&buf, false, &errmsg) < 0)
goto tear_down_ebsubchains_and_unlink;
if (ebtables_cmd_path) {
NWFILTER_SET_EBTABLES_SHELLVAR(&buf);
- ebtablesUnlinkTmpRootChain(&buf, 1, ifname);
- ebtablesUnlinkTmpRootChain(&buf, 0, ifname);
+ ebtablesUnlinkTmpRootChain(&buf, true, ifname);
+ ebtablesUnlinkTmpRootChain(&buf, false, ifname);
}
tear_down_tmpip6tchains:
NWFILTER_SET_EBTABLES_SHELLVAR(&buf);
ebtablesRemoveTmpSubChains(&buf, ifname);
- ebtablesRemoveTmpRootChain(&buf, 1, ifname);
- ebtablesRemoveTmpRootChain(&buf, 0, ifname);
+ ebtablesRemoveTmpRootChain(&buf, true, ifname);
+ ebtablesRemoveTmpRootChain(&buf, false, ifname);
}
ebiptablesExecCLI(&buf, true, NULL);
if (ebtables_cmd_path) {
NWFILTER_SET_EBTABLES_SHELLVAR(&buf);
- ebtablesUnlinkTmpRootChain(&buf, 1, ifname);
- ebtablesUnlinkTmpRootChain(&buf, 0, ifname);
+ ebtablesUnlinkTmpRootChain(&buf, true, ifname);
+ ebtablesUnlinkTmpRootChain(&buf, false, ifname);
ebtablesRemoveTmpSubChains(&buf, ifname);
- ebtablesRemoveTmpRootChain(&buf, 1, ifname);
- ebtablesRemoveTmpRootChain(&buf, 0, ifname);
+ ebtablesRemoveTmpRootChain(&buf, true, ifname);
+ ebtablesRemoveTmpRootChain(&buf, false, ifname);
}
ebiptablesExecCLI(&buf, true, NULL);
if (ebtables_cmd_path) {
NWFILTER_SET_EBTABLES_SHELLVAR(&buf);
- ebtablesUnlinkRootChain(&buf, 1, ifname);
- ebtablesUnlinkRootChain(&buf, 0, ifname);
+ ebtablesUnlinkRootChain(&buf, true, ifname);
+ ebtablesUnlinkRootChain(&buf, false, ifname);
ebtablesRemoveSubChains(&buf, ifname);
- ebtablesRemoveRootChain(&buf, 1, ifname);
- ebtablesRemoveRootChain(&buf, 0, ifname);
+ ebtablesRemoveRootChain(&buf, true, ifname);
+ ebtablesRemoveRootChain(&buf, false, ifname);
ebtablesRenameTmpSubAndRootChains(&buf, ifname);
if (ebtables_cmd_path) {
NWFILTER_SET_EBTABLES_SHELLVAR(&buf);
- ebtablesUnlinkRootChain(&buf, 1, ifname);
- ebtablesUnlinkRootChain(&buf, 0, ifname);
+ ebtablesUnlinkRootChain(&buf, true, ifname);
+ ebtablesUnlinkRootChain(&buf, false, ifname);
ebtablesRemoveSubChains(&buf, ifname);
- ebtablesRemoveRootChain(&buf, 1, ifname);
- ebtablesRemoveRootChain(&buf, 0, ifname);
+ ebtablesRemoveRootChain(&buf, true, ifname);
+ ebtablesRemoveRootChain(&buf, false, ifname);
}
ebiptablesExecCLI(&buf, true, NULL);