summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart De Schuymer <bdschuym@pandora.be>2005-10-01 20:12:50 +0000
committerBart De Schuymer <bdschuym@pandora.be>2005-10-01 20:12:50 +0000
commitcdc2cd0195ffac0996772d0dcec0d1535f16a2d8 (patch)
tree4c974920aa73e449c79f649a7c1713d5fe5b4400
parent9d680cc0033cd96bfd31c933e808a79ebea32f2f (diff)
minor changes
-rw-r--r--ebtables-restore.c3
-rw-r--r--ebtables.c13
-rw-r--r--include/ebtables_u.h6
-rw-r--r--libebtc.c11
4 files changed, 14 insertions, 19 deletions
diff --git a/ebtables-restore.c b/ebtables-restore.c
index 37f88f5..c0f9f6b 100644
--- a/ebtables-restore.c
+++ b/ebtables-restore.c
@@ -90,9 +90,8 @@ int main(int argc_, char *argv_[])
}
if (i == NUM_STANDARD_TARGETS)
ebtrest_print_error("invalid policy specified");
- if (ebt_get_chainnr(&replace[table_nr], cmdline+1) == -1) {
+ if (ebt_get_chainnr(&replace[table_nr], cmdline+1) == -1)
ebt_new_chain(&replace[table_nr], cmdline+1, policy);
- }
continue;
}
argv[1] = cmdline;
diff --git a/ebtables.c b/ebtables.c
index 855b4fc..91f40f2 100644
--- a/ebtables.c
+++ b/ebtables.c
@@ -605,6 +605,13 @@ int do_command(int argc, char *argv[], int exec_style,
if (optarg && (optarg[0] == '-' || !strcmp(optarg, "!")))
ebt_print_error2("No chain name specified");
if (c == 'N') {
+ if (ebt_get_chainnr(replace, optarg) != -1)
+ ebt_print_error2("Chain %s already exists", optarg);
+ else if (ebt_find_target(optarg))
+ ebt_print_error2("Target with name %s exists", optarg);
+ else if (strlen(optarg) >= EBT_CHAIN_MAXNAMELEN)
+ ebt_print_error2("Chain name length can't exceed %d",
+ EBT_CHAIN_MAXNAMELEN - 1);
ebt_new_chain(replace, optarg, EBT_ACCEPT);
/* This is needed to get -N x -P y working */
replace->selected_chain = ebt_get_chainnr(replace, optarg);
@@ -895,10 +902,10 @@ big_iface_length:
new_entry->cnt.pcnt = strtoull(optarg, &buffer, 10);
if (*buffer != '\0')
- ebt_print_error2("Packet counter '%s' invalid", optarg)
+ ebt_print_error2("Packet counter '%s' invalid", optarg);
new_entry->cnt.bcnt = strtoull(argv[optind], &buffer, 10);
if (*buffer != '\0')
- ebt_print_error2("Packet counter '%s' invalid", argv[optind])
+ ebt_print_error2("Packet counter '%s' invalid", argv[optind]);
optind++;
break;
}
@@ -919,7 +926,7 @@ big_iface_length:
}
ent = getethertypebyname(optarg);
if (!ent)
- ebt_print_error2("Problem with the specified Ethernet protocol '%s', perhaps "_PATH_ETHERTYPES " is missing", optarg)
+ ebt_print_error2("Problem with the specified Ethernet protocol '%s', perhaps "_PATH_ETHERTYPES " is missing", optarg);
new_entry->ethproto = ent->e_ethertype;
} else
new_entry->ethproto = i;
diff --git a/include/ebtables_u.h b/include/ebtables_u.h
index b725625..7a47782 100644
--- a/include/ebtables_u.h
+++ b/include/ebtables_u.h
@@ -298,14 +298,14 @@ struct ethertypeent *parseethertypebynumber(int type);
#define ebt_to_chain(repl) \
({struct ebt_u_entries *_ch = NULL; \
-if (repl->selected_chain != -1) \
+if (repl->selected_chain != -1) \
_ch = repl->chains[repl->selected_chain]; \
_ch;})
#define ebt_print_bug(format, args...) \
__ebt_print_bug(__FILE__, __LINE__, format, ##args)
#define ebt_print_error(format,args...) __ebt_print_error(format, ##args);
-#define ebt_print_error2(format, args...) {__ebt_print_error(format, ##args); \
- return -1;}
+#define ebt_print_error2(format, args...) do {__ebt_print_error(format, ##args); \
+ return -1;} while (0)
#define ebt_check_option2(flags,mask) \
({ebt_check_option(flags,mask); \
if (ebt_errormsg[0] != '\0') \
diff --git a/libebtc.c b/libebtc.c
index af95694..b558c9c 100644
--- a/libebtc.c
+++ b/libebtc.c
@@ -817,17 +817,6 @@ void ebt_new_chain(struct ebt_u_replace *replace, const char *name, int policy)
{
struct ebt_u_entries *new;
- if (ebt_get_chainnr(replace, name) != -1) {
- ebt_print_error("Chain %s already exists", optarg);
- return;
- } else if (ebt_find_target(name)) {
- ebt_print_error("Target with name %s exists", optarg);
- return;
- } else if (strlen(optarg) >= EBT_CHAIN_MAXNAMELEN) {
- ebt_print_error("Chain name length can't exceed %d",
- EBT_CHAIN_MAXNAMELEN - 1);
- return;
- }
if (replace->num_chains == replace->max_chains)
ebt_double_chains(replace);
new = (struct ebt_u_entries *)malloc(sizeof(struct ebt_u_entries));