[server] minor return value handling update for create_chain() and add_jump_rule()

This commit is contained in:
Michael Rash 2015-04-08 18:30:03 -07:00
parent 1e33119b04
commit 547dbb66b3

View File

@ -346,7 +346,7 @@ comment_match_exists(const fko_srv_options_t * const opts)
static int static int
add_jump_rule(const fko_srv_options_t * const opts, const int chain_num) add_jump_rule(const fko_srv_options_t * const opts, const int chain_num)
{ {
int res = 0; int res = 0, rv = 0;
zero_cmd_buffers(); zero_cmd_buffers();
@ -365,13 +365,16 @@ add_jump_rule(const fko_srv_options_t * const opts, const int chain_num)
cmd_buf, res, err_buf); cmd_buf, res, err_buf);
if(EXTCMD_IS_SUCCESS(res)) if(EXTCMD_IS_SUCCESS(res))
{
log_msg(LOG_INFO, "Added jump rule from chain: %s to chain: %s", log_msg(LOG_INFO, "Added jump rule from chain: %s to chain: %s",
fwc.chain[chain_num].from_chain, fwc.chain[chain_num].from_chain,
fwc.chain[chain_num].to_chain); fwc.chain[chain_num].to_chain);
rv = 1;
}
else else
log_msg(LOG_ERR, "Error %i from cmd:'%s': %s", res, cmd_buf, err_buf); log_msg(LOG_ERR, "Error %i from cmd:'%s': %s", res, cmd_buf, err_buf);
return res; return rv;
} }
static int static int
@ -642,7 +645,7 @@ delete_all_chains(const fko_srv_options_t * const opts)
static int static int
create_chain(const fko_srv_options_t * const opts, const int chain_num) create_chain(const fko_srv_options_t * const opts, const int chain_num)
{ {
int res = 0; int res = 0, rv = 0;
zero_cmd_buffers(); zero_cmd_buffers();
@ -662,10 +665,12 @@ create_chain(const fko_srv_options_t * const opts, const int chain_num)
cmd_buf, res, err_buf); cmd_buf, res, err_buf);
/* Expect full success on this */ /* Expect full success on this */
if(! EXTCMD_IS_SUCCESS(res)) if(EXTCMD_IS_SUCCESS(res))
rv = 1;
else
log_msg(LOG_ERR, "Error %i from cmd:'%s': %s", res, cmd_buf, err_buf); log_msg(LOG_ERR, "Error %i from cmd:'%s': %s", res, cmd_buf, err_buf);
return res; return rv;
} }
static void static void
@ -699,14 +704,14 @@ create_fw_chains(const fko_srv_options_t * const opts)
/* Create the chain /* Create the chain
*/ */
if(! EXTCMD_IS_SUCCESS(create_chain(opts, i))) if(! create_chain(opts, i))
got_err++; got_err++;
/* Then create the jump rule to that chain if it /* Then create the jump rule to that chain if it
* doesn't already exist (which is possible) * doesn't already exist (which is possible)
*/ */
if(jump_rule_exists(opts, i) == 0) if(jump_rule_exists(opts, i) == 0)
if(! EXTCMD_IS_SUCCESS(add_jump_rule(opts, i))) if(! add_jump_rule(opts, i))
got_err++; got_err++;
} }
} }