提交 2b42e17c 编写于 作者: D Daniel P. Berrange

Remove 'int stopOnError' parameters in nwfilter methods

Many nwfilter methods have an 'int stopOnError' parameter but
with 1 exception, the callers always pass '1'. The parameter
can therefore be removed from all except one method. That method
will be changed to 'bool stopOnError'
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 6c582bb9
...@@ -587,8 +587,7 @@ ebtablesHandleEthHdr(virBufferPtr buf, ...@@ -587,8 +587,7 @@ ebtablesHandleEthHdr(virBufferPtr buf,
static int iptablesLinkIPTablesBaseChain(virBufferPtr buf, static int iptablesLinkIPTablesBaseChain(virBufferPtr buf,
const char *udchain, const char *udchain,
const char *syschain, const char *syschain,
unsigned int pos, unsigned int pos)
int stopOnError)
{ {
virBufferAsprintf(buf, virBufferAsprintf(buf,
"res=$($IPT -L %s -n --line-number | %s '%s')\n" "res=$($IPT -L %s -n --line-number | %s '%s')\n"
...@@ -614,10 +613,10 @@ static int iptablesLinkIPTablesBaseChain(virBufferPtr buf, ...@@ -614,10 +613,10 @@ static int iptablesLinkIPTablesBaseChain(virBufferPtr buf,
pos, pos,
syschain, pos, udchain, syschain, pos, udchain,
CMD_STOPONERR(stopOnError), CMD_STOPONERR(true),
syschain, syschain,
CMD_STOPONERR(stopOnError)); CMD_STOPONERR(true));
return 0; return 0;
} }
...@@ -629,13 +628,13 @@ static int iptablesCreateBaseChains(virBufferPtr buf) ...@@ -629,13 +628,13 @@ static int iptablesCreateBaseChains(virBufferPtr buf)
"$IPT -N " VIRT_IN_POST_CHAIN CMD_SEPARATOR "$IPT -N " VIRT_IN_POST_CHAIN CMD_SEPARATOR
"$IPT -N " HOST_IN_CHAIN CMD_SEPARATOR); "$IPT -N " HOST_IN_CHAIN CMD_SEPARATOR);
iptablesLinkIPTablesBaseChain(buf, iptablesLinkIPTablesBaseChain(buf,
VIRT_IN_CHAIN, "FORWARD", 1, 1); VIRT_IN_CHAIN, "FORWARD", 1);
iptablesLinkIPTablesBaseChain(buf, iptablesLinkIPTablesBaseChain(buf,
VIRT_OUT_CHAIN, "FORWARD", 2, 1); VIRT_OUT_CHAIN, "FORWARD", 2);
iptablesLinkIPTablesBaseChain(buf, iptablesLinkIPTablesBaseChain(buf,
VIRT_IN_POST_CHAIN, "FORWARD", 3, 1); VIRT_IN_POST_CHAIN, "FORWARD", 3);
iptablesLinkIPTablesBaseChain(buf, iptablesLinkIPTablesBaseChain(buf,
HOST_IN_CHAIN, "INPUT", 1, 1); HOST_IN_CHAIN, "INPUT", 1);
return 0; return 0;
} }
...@@ -644,8 +643,7 @@ static int iptablesCreateBaseChains(virBufferPtr buf) ...@@ -644,8 +643,7 @@ static int iptablesCreateBaseChains(virBufferPtr buf)
static int static int
iptablesCreateTmpRootChain(virBufferPtr buf, iptablesCreateTmpRootChain(virBufferPtr buf,
char prefix, char prefix,
bool incoming, const char *ifname, bool incoming, const char *ifname)
int stopOnError)
{ {
char chain[MAX_CHAINNAME_LENGTH]; char chain[MAX_CHAINNAME_LENGTH];
char chainPrefix[2] = { char chainPrefix[2] = {
...@@ -661,7 +659,7 @@ iptablesCreateTmpRootChain(virBufferPtr buf, ...@@ -661,7 +659,7 @@ iptablesCreateTmpRootChain(virBufferPtr buf,
CMD_EXEC CMD_EXEC
"%s", "%s",
chain, chain,
CMD_STOPONERR(stopOnError)); CMD_STOPONERR(true));
return 0; return 0;
} }
...@@ -671,9 +669,9 @@ static int ...@@ -671,9 +669,9 @@ static int
iptablesCreateTmpRootChains(virBufferPtr buf, iptablesCreateTmpRootChains(virBufferPtr buf,
const char *ifname) const char *ifname)
{ {
iptablesCreateTmpRootChain(buf, 'F', false, ifname, 1); iptablesCreateTmpRootChain(buf, 'F', false, ifname);
iptablesCreateTmpRootChain(buf, 'F', true, ifname, 1); iptablesCreateTmpRootChain(buf, 'F', true, ifname);
iptablesCreateTmpRootChain(buf, 'H', true, ifname, 1); iptablesCreateTmpRootChain(buf, 'H', true, ifname);
return 0; return 0;
} }
...@@ -755,8 +753,7 @@ static int ...@@ -755,8 +753,7 @@ static int
iptablesLinkTmpRootChain(virBufferPtr buf, iptablesLinkTmpRootChain(virBufferPtr buf,
const char *basechain, const char *basechain,
char prefix, char prefix,
bool incoming, const char *ifname, bool incoming, const char *ifname)
int stopOnError)
{ {
char chain[MAX_CHAINNAME_LENGTH]; char chain[MAX_CHAINNAME_LENGTH];
char chainPrefix[2] = { char chainPrefix[2] = {
...@@ -777,7 +774,7 @@ iptablesLinkTmpRootChain(virBufferPtr buf, ...@@ -777,7 +774,7 @@ iptablesLinkTmpRootChain(virBufferPtr buf,
basechain, basechain,
match, ifname, chain, match, ifname, chain,
CMD_STOPONERR(stopOnError)); CMD_STOPONERR(true));
return 0; return 0;
} }
...@@ -787,9 +784,9 @@ static int ...@@ -787,9 +784,9 @@ static int
iptablesLinkTmpRootChains(virBufferPtr buf, iptablesLinkTmpRootChains(virBufferPtr buf,
const char *ifname) const char *ifname)
{ {
iptablesLinkTmpRootChain(buf, VIRT_OUT_CHAIN, 'F', false, ifname, 1); iptablesLinkTmpRootChain(buf, VIRT_OUT_CHAIN, 'F', false, ifname);
iptablesLinkTmpRootChain(buf, VIRT_IN_CHAIN, 'F', true, ifname, 1); iptablesLinkTmpRootChain(buf, VIRT_IN_CHAIN, 'F', true, ifname);
iptablesLinkTmpRootChain(buf, HOST_IN_CHAIN, 'H', true, ifname, 1); iptablesLinkTmpRootChain(buf, HOST_IN_CHAIN, 'H', true, ifname);
return 0; return 0;
} }
...@@ -962,15 +959,14 @@ iptablesRenameTmpRootChains(virBufferPtr buf, ...@@ -962,15 +959,14 @@ iptablesRenameTmpRootChains(virBufferPtr buf,
static void static void
iptablesInstCommand(virBufferPtr buf, iptablesInstCommand(virBufferPtr buf,
const char *templ, char cmd, int pos, const char *templ, char cmd, int pos)
int stopOnError)
{ {
char position[10] = { 0 }; char position[10] = { 0 };
if (pos >= 0) if (pos >= 0)
snprintf(position, sizeof(position), "%d", pos); snprintf(position, sizeof(position), "%d", pos);
virBufferAsprintf(buf, templ, cmd, position); virBufferAsprintf(buf, templ, cmd, position);
virBufferAsprintf(buf, CMD_SEPARATOR "%s", virBufferAsprintf(buf, CMD_SEPARATOR "%s",
CMD_STOPONERR(stopOnError)); CMD_STOPONERR(true));
} }
...@@ -2871,8 +2867,7 @@ ebiptablesExecCLI(virBufferPtr buf, bool ignoreNonzero, char **outbuf) ...@@ -2871,8 +2867,7 @@ ebiptablesExecCLI(virBufferPtr buf, bool ignoreNonzero, char **outbuf)
static int static int
ebtablesCreateTmpRootChain(virBufferPtr buf, ebtablesCreateTmpRootChain(virBufferPtr buf,
bool incoming, const char *ifname, bool incoming, const char *ifname)
int stopOnError)
{ {
char chain[MAX_CHAINNAME_LENGTH]; char chain[MAX_CHAINNAME_LENGTH];
char chainPrefix = incoming ? CHAINPREFIX_HOST_IN_TEMP char chainPrefix = incoming ? CHAINPREFIX_HOST_IN_TEMP
...@@ -2885,7 +2880,7 @@ ebtablesCreateTmpRootChain(virBufferPtr buf, ...@@ -2885,7 +2880,7 @@ ebtablesCreateTmpRootChain(virBufferPtr buf,
CMD_EXEC CMD_EXEC
"%s", "%s",
chain, chain,
CMD_STOPONERR(stopOnError)); CMD_STOPONERR(true));
return 0; return 0;
} }
...@@ -2893,8 +2888,7 @@ ebtablesCreateTmpRootChain(virBufferPtr buf, ...@@ -2893,8 +2888,7 @@ ebtablesCreateTmpRootChain(virBufferPtr buf,
static int static int
ebtablesLinkTmpRootChain(virBufferPtr buf, ebtablesLinkTmpRootChain(virBufferPtr buf,
bool incoming, const char *ifname, bool incoming, const char *ifname)
int stopOnError)
{ {
char chain[MAX_CHAINNAME_LENGTH]; char chain[MAX_CHAINNAME_LENGTH];
char chainPrefix = incoming ? CHAINPREFIX_HOST_IN_TEMP char chainPrefix = incoming ? CHAINPREFIX_HOST_IN_TEMP
...@@ -2911,7 +2905,7 @@ ebtablesLinkTmpRootChain(virBufferPtr buf, ...@@ -2911,7 +2905,7 @@ ebtablesLinkTmpRootChain(virBufferPtr buf,
: EBTABLES_CHAIN_OUTGOING, : EBTABLES_CHAIN_OUTGOING,
iodev, ifname, chain, iodev, ifname, chain,
CMD_STOPONERR(stopOnError)); CMD_STOPONERR(true));
return 0; return 0;
} }
...@@ -3011,7 +3005,6 @@ ebtablesCreateTmpSubChain(ebiptablesRuleInstPtr *inst, ...@@ -3011,7 +3005,6 @@ ebtablesCreateTmpSubChain(ebiptablesRuleInstPtr *inst,
const char *ifname, const char *ifname,
enum l3_proto_idx protoidx, enum l3_proto_idx protoidx,
const char *filtername, const char *filtername,
int stopOnError,
virNWFilterChainPriority priority) virNWFilterChainPriority priority)
{ {
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
...@@ -3059,11 +3052,11 @@ ebtablesCreateTmpSubChain(ebiptablesRuleInstPtr *inst, ...@@ -3059,11 +3052,11 @@ ebtablesCreateTmpSubChain(ebiptablesRuleInstPtr *inst,
chain, chain,
chain, chain,
CMD_STOPONERR(stopOnError), CMD_STOPONERR(true),
rootchain, protostr, chain, rootchain, protostr, chain,
CMD_STOPONERR(stopOnError)); CMD_STOPONERR(true));
VIR_FREE(protostr); VIR_FREE(protostr);
...@@ -3219,7 +3212,7 @@ ebtablesRenameTmpSubAndRootChains(virBufferPtr buf, ...@@ -3219,7 +3212,7 @@ ebtablesRenameTmpSubAndRootChains(virBufferPtr buf,
static void static void
ebiptablesInstCommand(virBufferPtr buf, ebiptablesInstCommand(virBufferPtr buf,
const char *templ, char cmd, int pos, const char *templ, char cmd, int pos,
int stopOnError) bool stopOnError)
{ {
char position[10] = { 0 }; char position[10] = { 0 };
if (pos >= 0) if (pos >= 0)
...@@ -3277,7 +3270,7 @@ ebtablesApplyBasicRules(const char *ifname, ...@@ -3277,7 +3270,7 @@ ebtablesApplyBasicRules(const char *ifname,
NWFILTER_SET_EBTABLES_SHELLVAR(&buf); NWFILTER_SET_EBTABLES_SHELLVAR(&buf);
ebtablesCreateTmpRootChain(&buf, true, ifname, 1); ebtablesCreateTmpRootChain(&buf, true, ifname);
PRINT_ROOT_CHAIN(chain, chainPrefix, ifname); PRINT_ROOT_CHAIN(chain, chainPrefix, ifname);
virBufferAsprintf(&buf, virBufferAsprintf(&buf,
...@@ -3312,7 +3305,7 @@ ebtablesApplyBasicRules(const char *ifname, ...@@ -3312,7 +3305,7 @@ ebtablesApplyBasicRules(const char *ifname,
chain, chain,
CMD_STOPONERR(1)); CMD_STOPONERR(1));
ebtablesLinkTmpRootChain(&buf, true, ifname, 1); ebtablesLinkTmpRootChain(&buf, true, ifname);
ebtablesRenameTmpRootChain(&buf, true, ifname); ebtablesRenameTmpRootChain(&buf, true, ifname);
if (ebiptablesExecCLI(&buf, false, NULL) < 0) if (ebiptablesExecCLI(&buf, false, NULL) < 0)
...@@ -3374,8 +3367,8 @@ ebtablesApplyDHCPOnlyRules(const char *ifname, ...@@ -3374,8 +3367,8 @@ ebtablesApplyDHCPOnlyRules(const char *ifname,
NWFILTER_SET_EBTABLES_SHELLVAR(&buf); NWFILTER_SET_EBTABLES_SHELLVAR(&buf);
ebtablesCreateTmpRootChain(&buf, true, ifname, 1); ebtablesCreateTmpRootChain(&buf, true, ifname);
ebtablesCreateTmpRootChain(&buf, false, ifname, 1); ebtablesCreateTmpRootChain(&buf, false, ifname);
PRINT_ROOT_CHAIN(chain_in, CHAINPREFIX_HOST_IN_TEMP, ifname); PRINT_ROOT_CHAIN(chain_in, CHAINPREFIX_HOST_IN_TEMP, ifname);
PRINT_ROOT_CHAIN(chain_out, CHAINPREFIX_HOST_OUT_TEMP, ifname); PRINT_ROOT_CHAIN(chain_out, CHAINPREFIX_HOST_OUT_TEMP, ifname);
...@@ -3455,8 +3448,8 @@ ebtablesApplyDHCPOnlyRules(const char *ifname, ...@@ -3455,8 +3448,8 @@ ebtablesApplyDHCPOnlyRules(const char *ifname,
chain_out, chain_out,
CMD_STOPONERR(1)); CMD_STOPONERR(1));
ebtablesLinkTmpRootChain(&buf, true, ifname, 1); ebtablesLinkTmpRootChain(&buf, true, ifname);
ebtablesLinkTmpRootChain(&buf, false, ifname, 1); ebtablesLinkTmpRootChain(&buf, false, ifname);
if (!leaveTemporary) { if (!leaveTemporary) {
ebtablesRenameTmpRootChain(&buf, true, ifname); ebtablesRenameTmpRootChain(&buf, true, ifname);
...@@ -3506,8 +3499,8 @@ ebtablesApplyDropAllRules(const char *ifname) ...@@ -3506,8 +3499,8 @@ ebtablesApplyDropAllRules(const char *ifname)
NWFILTER_SET_EBTABLES_SHELLVAR(&buf); NWFILTER_SET_EBTABLES_SHELLVAR(&buf);
ebtablesCreateTmpRootChain(&buf, true, ifname, 1); ebtablesCreateTmpRootChain(&buf, true, ifname);
ebtablesCreateTmpRootChain(&buf, false, ifname, 1); ebtablesCreateTmpRootChain(&buf, false, ifname);
PRINT_ROOT_CHAIN(chain_in, CHAINPREFIX_HOST_IN_TEMP, ifname); PRINT_ROOT_CHAIN(chain_in, CHAINPREFIX_HOST_IN_TEMP, ifname);
PRINT_ROOT_CHAIN(chain_out, CHAINPREFIX_HOST_OUT_TEMP, ifname); PRINT_ROOT_CHAIN(chain_out, CHAINPREFIX_HOST_OUT_TEMP, ifname);
...@@ -3528,8 +3521,8 @@ ebtablesApplyDropAllRules(const char *ifname) ...@@ -3528,8 +3521,8 @@ ebtablesApplyDropAllRules(const char *ifname)
chain_out, chain_out,
CMD_STOPONERR(1)); CMD_STOPONERR(1));
ebtablesLinkTmpRootChain(&buf, true, ifname, 1); ebtablesLinkTmpRootChain(&buf, true, ifname);
ebtablesLinkTmpRootChain(&buf, false, ifname, 1); ebtablesLinkTmpRootChain(&buf, false, ifname);
ebtablesRenameTmpRootChain(&buf, true, ifname); ebtablesRenameTmpRootChain(&buf, true, ifname);
ebtablesRenameTmpRootChain(&buf, false, ifname); ebtablesRenameTmpRootChain(&buf, false, ifname);
...@@ -3694,7 +3687,7 @@ ebtablesCreateTmpRootAndSubChains(virBufferPtr buf, ...@@ -3694,7 +3687,7 @@ ebtablesCreateTmpRootAndSubChains(virBufferPtr buf,
virHashKeyValuePairPtr filter_names; virHashKeyValuePairPtr filter_names;
const virNWFilterChainPriority *priority; const virNWFilterChainPriority *priority;
if (ebtablesCreateTmpRootChain(buf, incoming, ifname, 1) < 0) if (ebtablesCreateTmpRootChain(buf, incoming, ifname) < 0)
return -1; return -1;
filter_names = virHashGetItems(chains, filter_names = virHashGetItems(chains,
...@@ -3710,7 +3703,7 @@ ebtablesCreateTmpRootAndSubChains(virBufferPtr buf, ...@@ -3710,7 +3703,7 @@ ebtablesCreateTmpRootAndSubChains(virBufferPtr buf,
priority = (const virNWFilterChainPriority *)filter_names[i].value; priority = (const virNWFilterChainPriority *)filter_names[i].value;
rc = ebtablesCreateTmpSubChain(inst, nRuleInstances, rc = ebtablesCreateTmpSubChain(inst, nRuleInstances,
incoming, ifname, idx, incoming, ifname, idx,
filter_names[i].key, 1, filter_names[i].key,
*priority); *priority);
if (rc < 0) if (rc < 0)
break; break;
...@@ -3825,11 +3818,11 @@ ebiptablesApplyNewRules(const char *ifname, ...@@ -3825,11 +3818,11 @@ ebiptablesApplyNewRules(const char *ifname,
ebtChains[j].priority <= inst[i]->priority) { ebtChains[j].priority <= inst[i]->priority) {
ebiptablesInstCommand(&buf, ebiptablesInstCommand(&buf,
ebtChains[j++].commandTemplate, ebtChains[j++].commandTemplate,
'A', -1, 1); 'A', -1, true);
} }
ebiptablesInstCommand(&buf, ebiptablesInstCommand(&buf,
inst[i]->commandTemplate, inst[i]->commandTemplate,
'A', -1, 1); 'A', -1, true);
break; break;
case RT_IPTABLES: case RT_IPTABLES:
haveIptables = true; haveIptables = true;
...@@ -3843,7 +3836,7 @@ ebiptablesApplyNewRules(const char *ifname, ...@@ -3843,7 +3836,7 @@ ebiptablesApplyNewRules(const char *ifname,
while (j < nEbtChains) while (j < nEbtChains)
ebiptablesInstCommand(&buf, ebiptablesInstCommand(&buf,
ebtChains[j++].commandTemplate, ebtChains[j++].commandTemplate,
'A', -1, 1); 'A', -1, true);
if (ebiptablesExecCLI(&buf, false, &errmsg) < 0) if (ebiptablesExecCLI(&buf, false, &errmsg) < 0)
goto tear_down_tmpebchains; goto tear_down_tmpebchains;
...@@ -3880,7 +3873,7 @@ ebiptablesApplyNewRules(const char *ifname, ...@@ -3880,7 +3873,7 @@ ebiptablesApplyNewRules(const char *ifname,
if (inst[i]->ruleType == RT_IPTABLES) if (inst[i]->ruleType == RT_IPTABLES)
iptablesInstCommand(&buf, iptablesInstCommand(&buf,
inst[i]->commandTemplate, inst[i]->commandTemplate,
'A', -1, 1); 'A', -1);
} }
if (ebiptablesExecCLI(&buf, false, &errmsg) < 0) if (ebiptablesExecCLI(&buf, false, &errmsg) < 0)
...@@ -3920,7 +3913,7 @@ ebiptablesApplyNewRules(const char *ifname, ...@@ -3920,7 +3913,7 @@ ebiptablesApplyNewRules(const char *ifname,
if (inst[i]->ruleType == RT_IP6TABLES) if (inst[i]->ruleType == RT_IP6TABLES)
iptablesInstCommand(&buf, iptablesInstCommand(&buf,
inst[i]->commandTemplate, inst[i]->commandTemplate,
'A', -1, 1); 'A', -1);
} }
if (ebiptablesExecCLI(&buf, false, &errmsg) < 0) if (ebiptablesExecCLI(&buf, false, &errmsg) < 0)
...@@ -3932,9 +3925,9 @@ ebiptablesApplyNewRules(const char *ifname, ...@@ -3932,9 +3925,9 @@ ebiptablesApplyNewRules(const char *ifname,
NWFILTER_SET_EBTABLES_SHELLVAR(&buf); NWFILTER_SET_EBTABLES_SHELLVAR(&buf);
if (virHashSize(chains_in_set) != 0) if (virHashSize(chains_in_set) != 0)
ebtablesLinkTmpRootChain(&buf, true, ifname, 1); ebtablesLinkTmpRootChain(&buf, true, ifname);
if (virHashSize(chains_out_set) != 0) if (virHashSize(chains_out_set) != 0)
ebtablesLinkTmpRootChain(&buf, false, ifname, 1); ebtablesLinkTmpRootChain(&buf, false, ifname);
if (ebiptablesExecCLI(&buf, false, &errmsg) < 0) if (ebiptablesExecCLI(&buf, false, &errmsg) < 0)
goto tear_down_ebsubchains_and_unlink; goto tear_down_ebsubchains_and_unlink;
...@@ -4115,7 +4108,7 @@ ebiptablesRemoveRules(const char *ifname ATTRIBUTE_UNUSED, ...@@ -4115,7 +4108,7 @@ ebiptablesRemoveRules(const char *ifname ATTRIBUTE_UNUSED,
ebiptablesInstCommand(&buf, ebiptablesInstCommand(&buf,
inst[i]->commandTemplate, inst[i]->commandTemplate,
'D', -1, 'D', -1,
0); false);
if (ebiptablesExecCLI(&buf, true, NULL) < 0) if (ebiptablesExecCLI(&buf, true, NULL) < 0)
goto cleanup; goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册