minor changes
authorBart De Schuymer <bdschuym@pandora.be>
Sat, 1 Oct 2005 20:12:50 +0000 (20:12 +0000)
committerBart De Schuymer <bdschuym@pandora.be>
Sat, 1 Oct 2005 20:12:50 +0000 (20:12 +0000)
ebtables-restore.c
ebtables.c
include/ebtables_u.h
libebtc.c

index 37f88f5..c0f9f6b 100644 (file)
@@ -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;
index 855b4fc..91f40f2 100644 (file)
@@ -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;
index b725625..7a47782 100644 (file)
@@ -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')          \
index af95694..b558c9c 100644 (file)
--- 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));