]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
Don't need ipt_entry_target()/ip6t_entry_target() now kernel uses static inline inste...
authorRusty Russell <rusty@rustcorp.com.au>
Wed, 22 Dec 2004 00:37:10 +0000 (00:37 +0000)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 22 Dec 2004 00:37:10 +0000 (00:37 +0000)
Don't re-initialize libiptc/libip6t unless modprobe attempt actually succeeds.  This makes nfsim run about 20 times faster, as it doesn't have to explore failures in the first iptc_init().

ip6tables.c
iptables.c

index ced26a558c5412effdefe363fe0e6409e5c42374..aac953167cba17f4c0a3f02fd3ce1d38086d1eaa 100644 (file)
@@ -148,14 +148,6 @@ static struct option original_opts[] = {
  * magic number of -1 */
 int line = -1;
 
-#ifndef __OPTIMIZE__
-struct ip6t_entry_target *
-ip6t_get_target(struct ip6t_entry *e)
-{
-       return (void *)e + e->target_offset;
-}
-#endif
-
 static struct option *opts = original_opts;
 static unsigned int global_option_offset = 0;
 
@@ -1624,6 +1616,7 @@ int ip6tables_insmod(const char *modname, const char *modprobe)
 {
        char *buf = NULL;
        char *argv[3];
+       int status;
 
        /* If they don't explicitly set it, read out of kernel */
        if (!modprobe) {
@@ -1641,16 +1634,18 @@ int ip6tables_insmod(const char *modname, const char *modprobe)
                execv(argv[0], argv);
 
                /* not usually reached */
-               exit(0);
+               exit(1);
        case -1:
                return -1;
 
        default: /* parent */
-               wait(NULL);
+               wait(&status);
        }
 
        free(buf);
-       return 0;
+       if (WIFEXITED(status) && WEXITSTATUS(status) == 0)
+               return 0;
+       return -1;
 }
 
 static struct ip6t_entry *
@@ -2193,11 +2188,9 @@ int do_command6(int argc, char *argv[], char **table, ip6tc_handle_t *handle)
        if (!*handle)
                *handle = ip6tc_init(*table);
 
-       if (!*handle) {
-               /* try to insmod the module if iptc_init failed */
-               ip6tables_insmod("ip6_tables", modprobe);
+       /* try to insmod the module if iptc_init failed */
+       if (!*handle && ip6tables_insmod("ip6_tables", modprobe) != -1)
                *handle = ip6tc_init(*table);
-       }
 
        if (!*handle)
                exit_error(VERSION_PROBLEM,
index c6f19c229a4f58a640e2c2a3f64a5686f48b4ef3..7c003ad19bbab424682cde2c6776737c1aca2fe9 100644 (file)
@@ -147,14 +147,6 @@ static struct option original_opts[] = {
  * magic number of -1 */
 int line = -1;
 
-#ifndef __OPTIMIZE__
-struct ipt_entry_target *
-ipt_get_target(struct ipt_entry *e)
-{
-       return (void *)e + e->target_offset;
-}
-#endif
-
 static struct option *opts = original_opts;
 static unsigned int global_option_offset = 0;
 
@@ -1622,6 +1614,7 @@ int iptables_insmod(const char *modname, const char *modprobe)
 {
        char *buf = NULL;
        char *argv[3];
+       int status;
 
        /* If they don't explicitly set it, read out of kernel */
        if (!modprobe) {
@@ -1639,16 +1632,18 @@ int iptables_insmod(const char *modname, const char *modprobe)
                execv(argv[0], argv);
 
                /* not usually reached */
-               exit(0);
+               exit(1);
        case -1:
                return -1;
 
        default: /* parent */
-               wait(NULL);
+               wait(&status);
        }
 
        free(buf);
-       return 0;
+       if (WIFEXITED(status) && WEXITSTATUS(status) == 0)
+               return 0;
+       return -1;
 }
 
 static struct ipt_entry *
@@ -2193,11 +2188,9 @@ int do_command(int argc, char *argv[], char **table, iptc_handle_t *handle)
        if (!*handle)
                *handle = iptc_init(*table);
 
-       if (!*handle) {
-               /* try to insmod the module if iptc_init failed */
-               iptables_insmod("ip_tables", modprobe);
+       /* try to insmod the module if iptc_init failed */
+       if (!*handle && iptables_insmod("ip_tables", modprobe) != -1)
                *handle = iptc_init(*table);
-       }
 
        if (!*handle)
                exit_error(VERSION_PROBLEM,