]> rtime.felk.cvut.cz Git - lisovros/iproute2_canprio.git/commitdiff
iptables library fix
authorStephen Hemminger <shemminger@linux-foundation.org>
Tue, 6 Mar 2007 21:03:19 +0000 (13:03 -0800)
committerStephen Hemminger <shemminger@linux-foundation.org>
Tue, 6 Mar 2007 21:03:19 +0000 (13:03 -0800)
Don't hard code iptables library path. Allow use of environment variable.

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
include/iptables_common.h
tc/m_ipt.c

index 82b0febdc3f8e975d3fdb9299062585b4031e369..6f7e4295ea8c9820599a3564344ad2566baaf6f7 100644 (file)
@@ -5,34 +5,47 @@
 enum exittype {
        OTHER_PROBLEM = 1,
        PARAMETER_PROBLEM,
-       VERSION_PROBLEM
+       VERSION_PROBLEM,
+       RESOURCE_PROBLEM
 };
-extern void exit_printhelp(void) __attribute__((noreturn));
+
+/* this is a special 64bit data type that is 8-byte aligned */
+#define aligned_u64 unsigned long long __attribute__((aligned(8)))
+
+extern void exit_printhelp() __attribute__((noreturn));
 extern void exit_tryhelp(int) __attribute__((noreturn));
 int check_inverse(const char option[], int *invert, int *optind, int argc);
-extern int string_to_number(const char *,
-                           unsigned int,
+extern int string_to_number(const char *, 
+                           unsigned int, 
                            unsigned int,
                            unsigned int *);
-extern int string_to_number_l(const char *,
-                           unsigned long int,
+extern int string_to_number_l(const char *, 
+                           unsigned long int, 
                            unsigned long int,
                            unsigned long *);
-extern int string_to_number_ll(const char *,
-                           unsigned long long int,
+extern int string_to_number_ll(const char *, 
+                           unsigned long long int, 
                            unsigned long long int,
                            unsigned long long *);
 extern int iptables_insmod(const char *modname, const char *modprobe);
+extern int load_iptables_ko(const char *modprobe);
 void exit_error(enum exittype, char *, ...)__attribute__((noreturn,
                                                          format(printf,2,3)));
 extern const char *program_name, *program_version;
 extern char *lib_dir;
 
+#define _init __attribute__((constructor)) my_init
 #ifdef NO_SHARED_LIBS
 # ifdef _INIT
+#  undef _init
 #  define _init _INIT
 # endif
   extern void init_extensions(void);
 #endif
 
+#define __be32 u_int32_t
+#define __le32 u_int32_t
+#define __be16 u_int16_t
+#define __le16 u_int16_t
+
 #endif /*_IPTABLES_COMMON_H*/
index 3d6533916f6e3a108aca224200123e7a4eca7c81..01914dc636b3a61fb36c1335d3dfdeca4ac5cb16 100644 (file)
@@ -8,10 +8,7 @@
  *             2 of the License, or (at your option) any later version.
  *
  * Authors:  J Hadi Salim (hadi@cyberus.ca)
- *
- * TODO: bad bad hardcoding IPT_LIB_DIR and PROC_SYS_MODPROBE
- *
-*/
+ */
 
 #include <syslog.h>
 #include <sys/socket.h>
@@ -58,6 +55,7 @@ static struct option *opts = original_opts;
 static unsigned int global_option_offset = 0;
 #define OPTION_OFFSET 256
 
+char *lib_dir;
 
 void
 register_target(struct iptables_target *me)
@@ -212,14 +210,13 @@ find_t(char *name)
 }
 
 static struct iptables_target *
-get_target_name(char *name)
+get_target_name(const char *name)
 {
        void *handle;
        char *error;
        char *new_name, *lname;
        struct iptables_target *m;
-
-       char path[sizeof (IPT_LIB_DIR) + sizeof ("/libipt_.so") + strlen(name)];
+       char path[strlen(lib_dir) + sizeof ("/libipt_.so") + strlen(name)];
 
        new_name = malloc(strlen(name) + 1);
        lname = malloc(strlen(name) + 1);
@@ -250,10 +247,10 @@ get_target_name(char *name)
                }
        }
 
-       sprintf(path, IPT_LIB_DIR "/libipt_%s.so", new_name);
+       sprintf(path, lib_dir, "/libipt_%s.so", new_name);
        handle = dlopen(path, RTLD_LAZY);
        if (!handle) {
-               sprintf(path, IPT_LIB_DIR "/libipt_%s.so", lname);
+               sprintf(path, lib_dir, "/libipt_%s.so", lname);
                handle = dlopen(path, RTLD_LAZY);
                if (!handle) {
                        fputs(dlerror(), stderr);
@@ -374,6 +371,10 @@ static int parse_ipt(struct action_util *a,int *argc_p,
        __u32 hook = 0, index = 0;
        res = 0;
 
+       lib_dir = getenv("IPTABLES_LIB_DIR");
+       if (!lib_dir)
+               lib_dir = IPT_LIB_DIR;
+
        {
                int i;
                for (i = 0; i < rargc; i++) {