Rework match initialization
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 26 May 2015 10:29:52 +0000 (12:29 +0200)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 26 May 2015 11:05:00 +0000 (13:05 +0200)
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
CMakeLists.txt
iptables.c
iptables.h

index bfaa3eb95b1a21ccf03fcc844ead95345bae21c3..22e890dff9c61eb679153a5f5e998615bf9e8370 100644 (file)
@@ -5,14 +5,7 @@ ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -Wmissing-declarations)
 
 SET(iptc_libs   ip4tc)
 
-SET(sed_match   "^[[:space:]]*__ipt_module(\\(.*\\)).*")
-SET(sed_replace "-Wl,--undefined=libxt_\\1_init -Wl,--undefined=libipt_\\1_init -Wl,--undefined=libip6t_\\1_init")
-
-EXECUTE_PROCESS(COMMAND sed -n -e "s/${sed_match}/${sed_replace}/; T n; H; :n; \${ x; s/^\\n//; s/\\n/ /gp }" ${CMAKE_SOURCE_DIR}/iptables.h
-                OUTPUT_VARIABLE ext_syms OUTPUT_STRIP_TRAILING_WHITESPACE)
-
 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
-SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--unresolved-symbols=ignore-all ${ext_syms}")
 
 LIST(APPEND ext_libs iptext)
 LIST(APPEND ext_libs iptext4)
index ca847617a3e897ae856b899637ed2ff4e6ca89b3..0f41fb04fccebabc010ad378420b331ac901b203 100644 (file)
@@ -53,22 +53,14 @@ get_kernel_version(void)
        kernel_version = 0x10000 * x + 0x100 * y + z;
 }
 
-#ifdef DISABLE_IPV6
-#undef __ipt_module
-#define __ipt_module(x) libxt_##x##_init, libipt_##x##_init,
-#else
-#undef __ipt_module
-#define __ipt_module(x) libxt_##x##_init, libipt_##x##_init, libip6t_##x##_init,
-#endif
-
 static void fw3_init_extensions(void)
 {
-       int i;
-       void (*initfuncs[])(void) = { FW3_IPT_MODULES };
+       init_extensions();
+       init_extensions4();
 
-       for (i = 0; i < sizeof(initfuncs)/sizeof(initfuncs[0]); i++)
-               if (initfuncs[i])
-                       initfuncs[i]();
+#ifndef DISABLE_IPV6
+       init_extensions6();
+#endif
 }
 
 struct fw3_ipt_handle *
index 61a292e758c9591318d5782e33a9647958d64804..fabefa8abea870ff0331f29a8da9fb96786aff49 100644 (file)
 # error "Unsupported xtables version"
 #endif
 
-/* libext.a interface */
-#define FW3_IPT_MODULES                        \
-       __ipt_module(comment)           \
-       __ipt_module(conntrack)         \
-       __ipt_module(icmp)                      \
-       __ipt_module(icmp6)                     \
-       __ipt_module(limit)                     \
-       __ipt_module(connlimit)                 \
-       __ipt_module(mac)                       \
-       __ipt_module(mark)                      \
-       __ipt_module(multiport)                 \
-       __ipt_module(set)                       \
-       __ipt_module(standard)          \
-       __ipt_module(tcp)                       \
-       __ipt_module(time)                      \
-       __ipt_module(udp)                       \
-       __ipt_module(CT)                        \
-       __ipt_module(DNAT)                      \
-       __ipt_module(LOG)                       \
-       __ipt_module(MARK)                      \
-       __ipt_module(MASQUERADE)        \
-       __ipt_module(REDIRECT)          \
-       __ipt_module(REJECT)            \
-       __ipt_module(SET)                       \
-       __ipt_module(SNAT)                      \
-       __ipt_module(TCPMSS)
-
-#ifdef DISABLE_IPV6
-#undef __ipt_module
-#define __ipt_module(x) \
-       extern void libxt_##x##_init(void) __attribute__((weak)); \
-       extern void libipt_##x##_init(void) __attribute__((weak));
-#else
-#undef __ipt_module
-#define __ipt_module(x) \
-       extern void libxt_##x##_init(void) __attribute__((weak)); \
-       extern void libipt_##x##_init(void) __attribute__((weak)); \
-       extern void libip6t_##x##_init(void) __attribute__((weak));
-#endif
-
-FW3_IPT_MODULES
-
+/* libipt*ext.so interfaces */
+extern void init_extensions(void);
+extern void init_extensions4(void);
+extern void init_extensions6(void);
 
 /* Required by certain extensions like SNAT and DNAT */
 extern int kernel_version;