]> err.no Git - linux-2.6/commitdiff
[NETFILTER]: Clean up table initialization
authorPatrick McHardy <kaber@trash.net>
Thu, 10 May 2007 21:14:16 +0000 (14:14 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Fri, 11 May 2007 06:47:43 +0000 (23:47 -0700)
- move arp_tables initial table structure definitions to arp_tables.h
  similar to ip_tables and ip6_tables

- use C99 initializers

- use initializer macros where possible

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
12 files changed:
include/linux/netfilter/x_tables.h
include/linux/netfilter_arp/arp_tables.h
include/linux/netfilter_ipv4/ip_tables.h
include/linux/netfilter_ipv6/ip6_tables.h
net/ipv4/netfilter/arptable_filter.c
net/ipv4/netfilter/iptable_filter.c
net/ipv4/netfilter/iptable_mangle.c
net/ipv4/netfilter/iptable_raw.c
net/ipv4/netfilter/nf_nat_rule.c
net/ipv6/netfilter/ip6table_filter.c
net/ipv6/netfilter/ip6table_mangle.c
net/ipv6/netfilter/ip6table_raw.c

index 022edfa97ed977dfe6fd8f74b28472804067d5a8..7e733a6ba4f6b91031051fc08f7f4f0ca599593b 100644 (file)
@@ -54,6 +54,14 @@ struct xt_entry_target
        unsigned char data[0];
 };
 
+#define XT_TARGET_INIT(__name, __size)                                        \
+{                                                                             \
+       .target.u.user = {                                                     \
+               .target_size    = XT_ALIGN(__size),                            \
+               .name           = __name,                                      \
+       },                                                                     \
+}
+
 struct xt_standard_target
 {
        struct xt_entry_target target;
index 24c8786d12e9f0bc2af9b3fde7bf092ad87439be..584cd1b18f12db6b2ed8520e86343fe9949f7858 100644 (file)
@@ -238,6 +238,47 @@ static __inline__ struct arpt_entry_target *arpt_get_target(struct arpt_entry *e
  */
 #ifdef __KERNEL__
 
+/* Standard entry. */
+struct arpt_standard
+{
+       struct arpt_entry entry;
+       struct arpt_standard_target target;
+};
+
+struct arpt_error_target
+{
+       struct arpt_entry_target target;
+       char errorname[ARPT_FUNCTION_MAXNAMELEN];
+};
+
+struct arpt_error
+{
+       struct arpt_entry entry;
+       struct arpt_error_target target;
+};
+
+#define ARPT_ENTRY_INIT(__size)                                                       \
+{                                                                             \
+       .target_offset  = sizeof(struct arpt_entry),                           \
+       .next_offset    = (__size),                                            \
+}
+
+#define ARPT_STANDARD_INIT(__verdict)                                         \
+{                                                                             \
+       .entry          = ARPT_ENTRY_INIT(sizeof(struct arpt_standard)),       \
+       .target         = XT_TARGET_INIT(ARPT_STANDARD_TARGET,                 \
+                                        sizeof(struct arpt_standard_target)), \
+       .target.verdict = -(__verdict) - 1,                                    \
+}
+
+#define ARPT_ERROR_INIT                                                               \
+{                                                                             \
+       .entry          = ARPT_ENTRY_INIT(sizeof(struct arpt_error)),          \
+       .target         = XT_TARGET_INIT(ARPT_ERROR_TARGET,                    \
+                                        sizeof(struct arpt_error_target)),    \
+       .target.errorname = "ERROR",                                           \
+}
+
 #define arpt_register_target(tgt)      \
 ({     (tgt)->family = NF_ARP;         \
        xt_register_target(tgt); })
index 9527296595cd41f9cf1b437e7d204b687ee83ea1..2f46dd728ee1fa9596e4a491782543fc44946012 100644 (file)
@@ -295,6 +295,28 @@ struct ipt_error
        struct ipt_error_target target;
 };
 
+#define IPT_ENTRY_INIT(__size)                                                \
+{                                                                             \
+       .target_offset  = sizeof(struct ipt_entry),                            \
+       .next_offset    = (__size),                                            \
+}
+
+#define IPT_STANDARD_INIT(__verdict)                                          \
+{                                                                             \
+       .entry          = IPT_ENTRY_INIT(sizeof(struct ipt_standard)),         \
+       .target         = XT_TARGET_INIT(IPT_STANDARD_TARGET,                  \
+                                        sizeof(struct xt_standard_target)),   \
+       .target.verdict = -(__verdict) - 1,                                    \
+}
+
+#define IPT_ERROR_INIT                                                        \
+{                                                                             \
+       .entry          = IPT_ENTRY_INIT(sizeof(struct ipt_error)),            \
+       .target         = XT_TARGET_INIT(IPT_ERROR_TARGET,                     \
+                                        sizeof(struct ipt_error_target)),     \
+       .target.errorname = "ERROR",                                           \
+}
+
 extern unsigned int ipt_do_table(struct sk_buff **pskb,
                                 unsigned int hook,
                                 const struct net_device *in,
index 61aa10412fc8b52c81229c1ee466678bd73b4840..4686f8342cbd73db22f6fd847f51f647f6e6c661 100644 (file)
@@ -123,6 +123,28 @@ struct ip6t_error
        struct ip6t_error_target target;
 };
 
+#define IP6T_ENTRY_INIT(__size)                                                       \
+{                                                                             \
+       .target_offset  = sizeof(struct ip6t_entry),                           \
+       .next_offset    = (__size),                                            \
+}
+
+#define IP6T_STANDARD_INIT(__verdict)                                         \
+{                                                                             \
+       .entry          = IP6T_ENTRY_INIT(sizeof(struct ip6t_standard)),       \
+       .target         = XT_TARGET_INIT(IP6T_STANDARD_TARGET,                 \
+                                        sizeof(struct ip6t_standard_target)), \
+       .target.verdict = -(__verdict) - 1,                                    \
+}
+
+#define IP6T_ERROR_INIT                                                               \
+{                                                                             \
+       .entry          = IP6T_ENTRY_INIT(sizeof(struct ip6t_error)),          \
+       .target         = XT_TARGET_INIT(IP6T_ERROR_TARGET,                    \
+                                        sizeof(struct ip6t_error_target)),    \
+       .target.errorname = "ERROR",                                           \
+}
+
 /*
  * New IP firewall options for [gs]etsockopt at the RAW IP level.
  * Unlike BSD Linux inherits IP options so you don't have to use
index 7edea2a1696c010930cd77d89c76cc558f217063..75c0230625331e91ac2ed5d28841072a24a8db33 100644 (file)
@@ -15,128 +15,34 @@ MODULE_DESCRIPTION("arptables filter table");
 #define FILTER_VALID_HOOKS ((1 << NF_ARP_IN) | (1 << NF_ARP_OUT) | \
                           (1 << NF_ARP_FORWARD))
 
-/* Standard entry. */
-struct arpt_standard
-{
-       struct arpt_entry entry;
-       struct arpt_standard_target target;
-};
-
-struct arpt_error_target
-{
-       struct arpt_entry_target target;
-       char errorname[ARPT_FUNCTION_MAXNAMELEN];
-};
-
-struct arpt_error
-{
-       struct arpt_entry entry;
-       struct arpt_error_target target;
-};
-
 static struct
 {
        struct arpt_replace repl;
        struct arpt_standard entries[3];
        struct arpt_error term;
-} initial_table __initdata
-= { { "filter", FILTER_VALID_HOOKS, 4,
-      sizeof(struct arpt_standard) * 3 + sizeof(struct arpt_error),
-      { [NF_ARP_IN] = 0,
-       [NF_ARP_OUT] = sizeof(struct arpt_standard),
-       [NF_ARP_FORWARD] = 2 * sizeof(struct arpt_standard), },
-      { [NF_ARP_IN] = 0,
-       [NF_ARP_OUT] = sizeof(struct arpt_standard),
-       [NF_ARP_FORWARD] = 2 * sizeof(struct arpt_standard), },
-      0, NULL, { } },
-    {
-           /* ARP_IN */
-           {
-                   {
-                           {
-                                   { 0 }, { 0 }, { 0 }, { 0 },
-                                   0, 0,
-                                   { { 0, }, { 0, } },
-                                   { { 0, }, { 0, } },
-                                   0, 0,
-                                   0, 0,
-                                   0, 0,
-                                   "", "", { 0 }, { 0 },
-                                   0, 0
-                           },
-                           sizeof(struct arpt_entry),
-                           sizeof(struct arpt_standard),
-                           0,
-                           { 0, 0 }, { } },
-                   { { { { ARPT_ALIGN(sizeof(struct arpt_standard_target)), "" } }, { } },
-                     -NF_ACCEPT - 1 }
-           },
-           /* ARP_OUT */
-           {
-                   {
-                           {
-                                   { 0 }, { 0 }, { 0 }, { 0 },
-                                   0, 0,
-                                   { { 0, }, { 0, } },
-                                   { { 0, }, { 0, } },
-                                   0, 0,
-                                   0, 0,
-                                   0, 0,
-                                   "", "", { 0 }, { 0 },
-                                   0, 0
-                           },
-                           sizeof(struct arpt_entry),
-                           sizeof(struct arpt_standard),
-                           0,
-                           { 0, 0 }, { } },
-                   { { { { ARPT_ALIGN(sizeof(struct arpt_standard_target)), "" } }, { } },
-                     -NF_ACCEPT - 1 }
-           },
-           /* ARP_FORWARD */
-           {
-                   {
-                           {
-                                   { 0 }, { 0 }, { 0 }, { 0 },
-                                   0, 0,
-                                   { { 0, }, { 0, } },
-                                   { { 0, }, { 0, } },
-                                   0, 0,
-                                   0, 0,
-                                   0, 0,
-                                   "", "", { 0 }, { 0 },
-                                   0, 0
-                           },
-                           sizeof(struct arpt_entry),
-                           sizeof(struct arpt_standard),
-                           0,
-                           { 0, 0 }, { } },
-                   { { { { ARPT_ALIGN(sizeof(struct arpt_standard_target)), "" } }, { } },
-                     -NF_ACCEPT - 1 }
-           }
-    },
-    /* ERROR */
-    {
-           {
-                   {
-                           { 0 }, { 0 }, { 0 }, { 0 },
-                           0, 0,
-                           { { 0, }, { 0, } },
-                           { { 0, }, { 0, } },
-                           0, 0,
-                           0, 0,
-                           0, 0,
-                           "", "", { 0 }, { 0 },
-                           0, 0
-                   },
-                   sizeof(struct arpt_entry),
-                   sizeof(struct arpt_error),
-                   0,
-                   { 0, 0 }, { } },
-           { { { { ARPT_ALIGN(sizeof(struct arpt_error_target)), ARPT_ERROR_TARGET } },
-               { } },
-             "ERROR"
-           }
-    }
+} initial_table __initdata = {
+       .repl = {
+               .name = "filter",
+               .valid_hooks = FILTER_VALID_HOOKS,
+               .num_entries = 4,
+               .size = sizeof(struct arpt_standard) * 3 + sizeof(struct arpt_error),
+               .hook_entry = {
+                       [NF_ARP_IN] = 0,
+                       [NF_ARP_OUT] = sizeof(struct arpt_standard),
+                       [NF_ARP_FORWARD] = 2 * sizeof(struct arpt_standard),
+               },
+               .underflow = {
+                       [NF_ARP_IN] = 0,
+                       [NF_ARP_OUT] = sizeof(struct arpt_standard),
+                       [NF_ARP_FORWARD] = 2 * sizeof(struct arpt_standard),
+               },
+       },
+       .entries = {
+               ARPT_STANDARD_INIT(NF_ACCEPT),  /* ARP_IN */
+               ARPT_STANDARD_INIT(NF_ACCEPT),  /* ARP_OUT */
+               ARPT_STANDARD_INIT(NF_ACCEPT),  /* ARP_FORWARD */
+       },
+       .term = ARPT_ERROR_INIT,
 };
 
 static struct arpt_table packet_filter = {
index 42728909eba0577a64693f4a460eb2f1edf133a9..ea14979d8a8225eed4056a63893c73840f8215b0 100644 (file)
@@ -26,53 +26,29 @@ static struct
        struct ipt_replace repl;
        struct ipt_standard entries[3];
        struct ipt_error term;
-} initial_table __initdata
-= { { "filter", FILTER_VALID_HOOKS, 4,
-      sizeof(struct ipt_standard) * 3 + sizeof(struct ipt_error),
-      { [NF_IP_LOCAL_IN] = 0,
-       [NF_IP_FORWARD] = sizeof(struct ipt_standard),
-       [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 2 },
-      { [NF_IP_LOCAL_IN] = 0,
-       [NF_IP_FORWARD] = sizeof(struct ipt_standard),
-       [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 2 },
-      0, NULL, { } },
-    {
-           /* LOCAL_IN */
-           { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 },
-               0,
-               sizeof(struct ipt_entry),
-               sizeof(struct ipt_standard),
-               0, { 0, 0 }, { } },
-             { { { { IPT_ALIGN(sizeof(struct ipt_standard_target)), "" } }, { } },
-               -NF_ACCEPT - 1 } },
-           /* FORWARD */
-           { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 },
-               0,
-               sizeof(struct ipt_entry),
-               sizeof(struct ipt_standard),
-               0, { 0, 0 }, { } },
-             { { { { IPT_ALIGN(sizeof(struct ipt_standard_target)), "" } }, { } },
-               -NF_ACCEPT - 1 } },
-           /* LOCAL_OUT */
-           { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 },
-               0,
-               sizeof(struct ipt_entry),
-               sizeof(struct ipt_standard),
-               0, { 0, 0 }, { } },
-             { { { { IPT_ALIGN(sizeof(struct ipt_standard_target)), "" } }, { } },
-               -NF_ACCEPT - 1 } }
-    },
-    /* ERROR */
-    { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 },
-       0,
-       sizeof(struct ipt_entry),
-       sizeof(struct ipt_error),
-       0, { 0, 0 }, { } },
-      { { { { IPT_ALIGN(sizeof(struct ipt_error_target)), IPT_ERROR_TARGET } },
-         { } },
-       "ERROR"
-      }
-    }
+} initial_table __initdata = {
+       .repl = {
+               .name = "filter",
+               .valid_hooks = FILTER_VALID_HOOKS,
+               .num_entries = 4,
+               .size = sizeof(struct ipt_standard) * 3 + sizeof(struct ipt_error),
+               .hook_entry = {
+                       [NF_IP_LOCAL_IN] = 0,
+                       [NF_IP_FORWARD] = sizeof(struct ipt_standard),
+                       [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 2,
+               },
+               .underflow = {
+                       [NF_IP_LOCAL_IN] = 0,
+                       [NF_IP_FORWARD] = sizeof(struct ipt_standard),
+                       [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 2,
+               },
+       },
+       .entries = {
+               IPT_STANDARD_INIT(NF_ACCEPT),   /* LOCAL_IN */
+               IPT_STANDARD_INIT(NF_ACCEPT),   /* FORWARD */
+               IPT_STANDARD_INIT(NF_ACCEPT),   /* LOCAL_OUT */
+       },
+       .term = IPT_ERROR_INIT,                 /* ERROR */
 };
 
 static struct xt_table packet_filter = {
index 9278802f2742ce14df5a2fba0da8c36b027cbfb6..c3827bae3b660f45d3afc808546900db0d079187 100644 (file)
@@ -33,73 +33,35 @@ static struct
        struct ipt_replace repl;
        struct ipt_standard entries[5];
        struct ipt_error term;
-} initial_table __initdata
-= { { "mangle", MANGLE_VALID_HOOKS, 6,
-      sizeof(struct ipt_standard) * 5 + sizeof(struct ipt_error),
-      { [NF_IP_PRE_ROUTING]    = 0,
-       [NF_IP_LOCAL_IN]        = sizeof(struct ipt_standard),
-       [NF_IP_FORWARD]         = sizeof(struct ipt_standard) * 2,
-       [NF_IP_LOCAL_OUT]       = sizeof(struct ipt_standard) * 3,
-       [NF_IP_POST_ROUTING]    = sizeof(struct ipt_standard) * 4 },
-      { [NF_IP_PRE_ROUTING]    = 0,
-       [NF_IP_LOCAL_IN]        = sizeof(struct ipt_standard),
-       [NF_IP_FORWARD]         = sizeof(struct ipt_standard) * 2,
-       [NF_IP_LOCAL_OUT]       = sizeof(struct ipt_standard) * 3,
-       [NF_IP_POST_ROUTING]    = sizeof(struct ipt_standard) * 4 },
-      0, NULL, { } },
-    {
-           /* PRE_ROUTING */
-           { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 },
-               0,
-               sizeof(struct ipt_entry),
-               sizeof(struct ipt_standard),
-               0, { 0, 0 }, { } },
-             { { { { IPT_ALIGN(sizeof(struct ipt_standard_target)), "" } }, { } },
-               -NF_ACCEPT - 1 } },
-           /* LOCAL_IN */
-           { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 },
-               0,
-               sizeof(struct ipt_entry),
-               sizeof(struct ipt_standard),
-               0, { 0, 0 }, { } },
-             { { { { IPT_ALIGN(sizeof(struct ipt_standard_target)), "" } }, { } },
-               -NF_ACCEPT - 1 } },
-           /* FORWARD */
-           { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 },
-               0,
-               sizeof(struct ipt_entry),
-               sizeof(struct ipt_standard),
-               0, { 0, 0 }, { } },
-             { { { { IPT_ALIGN(sizeof(struct ipt_standard_target)), "" } }, { } },
-               -NF_ACCEPT - 1 } },
-           /* LOCAL_OUT */
-           { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 },
-               0,
-               sizeof(struct ipt_entry),
-               sizeof(struct ipt_standard),
-               0, { 0, 0 }, { } },
-             { { { { IPT_ALIGN(sizeof(struct ipt_standard_target)), "" } }, { } },
-               -NF_ACCEPT - 1 } },
-           /* POST_ROUTING */
-           { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 },
-               0,
-               sizeof(struct ipt_entry),
-               sizeof(struct ipt_standard),
-               0, { 0, 0 }, { } },
-             { { { { IPT_ALIGN(sizeof(struct ipt_standard_target)), "" } }, { } },
-               -NF_ACCEPT - 1 } },
-    },
-    /* ERROR */
-    { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 },
-       0,
-       sizeof(struct ipt_entry),
-       sizeof(struct ipt_error),
-       0, { 0, 0 }, { } },
-      { { { { IPT_ALIGN(sizeof(struct ipt_error_target)), IPT_ERROR_TARGET } },
-         { } },
-       "ERROR"
-      }
-    }
+} initial_table __initdata = {
+       .repl = {
+               .name = "mangle",
+               .valid_hooks = MANGLE_VALID_HOOKS,
+               .num_entries = 6,
+               .size = sizeof(struct ipt_standard) * 5 + sizeof(struct ipt_error),
+               .hook_entry = {
+                       [NF_IP_PRE_ROUTING]     = 0,
+                       [NF_IP_LOCAL_IN]        = sizeof(struct ipt_standard),
+                       [NF_IP_FORWARD]         = sizeof(struct ipt_standard) * 2,
+                       [NF_IP_LOCAL_OUT]       = sizeof(struct ipt_standard) * 3,
+                       [NF_IP_POST_ROUTING]    = sizeof(struct ipt_standard) * 4,
+               },
+               .underflow = {
+                       [NF_IP_PRE_ROUTING]     = 0,
+                       [NF_IP_LOCAL_IN]        = sizeof(struct ipt_standard),
+                       [NF_IP_FORWARD]         = sizeof(struct ipt_standard) * 2,
+                       [NF_IP_LOCAL_OUT]       = sizeof(struct ipt_standard) * 3,
+                       [NF_IP_POST_ROUTING]    = sizeof(struct ipt_standard) * 4,
+               },
+       },
+       .entries = {
+               IPT_STANDARD_INIT(NF_ACCEPT),   /* PRE_ROUTING */
+               IPT_STANDARD_INIT(NF_ACCEPT),   /* LOCAL_IN */
+               IPT_STANDARD_INIT(NF_ACCEPT),   /* FORWARD */
+               IPT_STANDARD_INIT(NF_ACCEPT),   /* LOCAL_OUT */
+               IPT_STANDARD_INIT(NF_ACCEPT),   /* POST_ROUTING */
+       },
+       .term = IPT_ERROR_INIT,                 /* ERROR */
 };
 
 static struct xt_table packet_mangler = {
index 18c3d4c9ff51e23ecd8ffece105407d7fed94e91..f7d28fd748e216dff406cc530cda7726fe39f55a 100644 (file)
@@ -21,62 +21,18 @@ static struct
                .size = sizeof(struct ipt_standard) * 2 + sizeof(struct ipt_error),
                .hook_entry = {
                        [NF_IP_PRE_ROUTING] = 0,
-                       [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) },
+                       [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard)
+               },
                .underflow = {
                        [NF_IP_PRE_ROUTING] = 0,
-                       [NF_IP_LOCAL_OUT]  = sizeof(struct ipt_standard) },
+                       [NF_IP_LOCAL_OUT]  = sizeof(struct ipt_standard)
+               },
        },
        .entries = {
-            /* PRE_ROUTING */
-            {
-                    .entry = {
-                            .target_offset = sizeof(struct ipt_entry),
-                            .next_offset = sizeof(struct ipt_standard),
-                    },
-                    .target = {
-                         .target = {
-                                 .u = {
-                                         .target_size = IPT_ALIGN(sizeof(struct ipt_standard_target)),
-                                 },
-                         },
-                         .verdict = -NF_ACCEPT - 1,
-                    },
-            },
-
-            /* LOCAL_OUT */
-            {
-                    .entry = {
-                            .target_offset = sizeof(struct ipt_entry),
-                            .next_offset = sizeof(struct ipt_standard),
-                    },
-                    .target = {
-                            .target = {
-                                    .u = {
-                                            .target_size = IPT_ALIGN(sizeof(struct ipt_standard_target)),
-                                    },
-                            },
-                            .verdict = -NF_ACCEPT - 1,
-                    },
-            },
+               IPT_STANDARD_INIT(NF_ACCEPT),   /* PRE_ROUTING */
+               IPT_STANDARD_INIT(NF_ACCEPT),   /* LOCAL_OUT */
        },
-       /* ERROR */
-       .term = {
-               .entry = {
-                       .target_offset = sizeof(struct ipt_entry),
-                       .next_offset = sizeof(struct ipt_error),
-               },
-               .target = {
-                       .target = {
-                               .u = {
-                                       .user = {
-                                               .target_size = IPT_ALIGN(sizeof(struct ipt_error_target)),
-                                               .name = IPT_ERROR_TARGET,
-                                       },
-                               },
-                       },
-                       .errorname = "ERROR",
-               },
-       }
+       .term = IPT_ERROR_INIT,                 /* ERROR */
 };
 
 static struct xt_table packet_raw = {
index 2534f718ab9286ae49693f1c1a78e16b3ea5241d..07e99e309402b55a8eb681b509f7666e7ff8f5d8 100644 (file)
@@ -46,77 +46,20 @@ static struct
                .hook_entry = {
                        [NF_IP_PRE_ROUTING] = 0,
                        [NF_IP_POST_ROUTING] = sizeof(struct ipt_standard),
-                       [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 2 },
+                       [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 2
+               },
                .underflow = {
                        [NF_IP_PRE_ROUTING] = 0,
                        [NF_IP_POST_ROUTING] = sizeof(struct ipt_standard),
-                       [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 2 },
+                       [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 2
+               },
        },
        .entries = {
-               /* PRE_ROUTING */
-               {
-                       .entry = {
-                               .target_offset = sizeof(struct ipt_entry),
-                               .next_offset = sizeof(struct ipt_standard),
-                       },
-                       .target = {
-                               .target = {
-                                       .u = {
-                                               .target_size = IPT_ALIGN(sizeof(struct ipt_standard_target)),
-                                       },
-                               },
-                               .verdict = -NF_ACCEPT - 1,
-                       },
-               },
-               /* POST_ROUTING */
-               {
-                       .entry = {
-                               .target_offset = sizeof(struct ipt_entry),
-                               .next_offset = sizeof(struct ipt_standard),
-                       },
-                       .target = {
-                               .target = {
-                                       .u = {
-                                               .target_size = IPT_ALIGN(sizeof(struct ipt_standard_target)),
-                                       },
-                               },
-                               .verdict = -NF_ACCEPT - 1,
-                       },
-               },
-               /* LOCAL_OUT */
-               {
-                       .entry = {
-                               .target_offset = sizeof(struct ipt_entry),
-                               .next_offset = sizeof(struct ipt_standard),
-                       },
-                       .target = {
-                               .target = {
-                                       .u = {
-                                               .target_size = IPT_ALIGN(sizeof(struct ipt_standard_target)),
-                                       },
-                               },
-                               .verdict = -NF_ACCEPT - 1,
-                       },
-               },
+               IPT_STANDARD_INIT(NF_ACCEPT),   /* PRE_ROUTING */
+               IPT_STANDARD_INIT(NF_ACCEPT),   /* POST_ROUTING */
+               IPT_STANDARD_INIT(NF_ACCEPT),   /* LOCAL_OUT */
        },
-       /* ERROR */
-       .term = {
-               .entry = {
-                       .target_offset = sizeof(struct ipt_entry),
-                       .next_offset = sizeof(struct ipt_error),
-               },
-               .target = {
-                       .target = {
-                               .u = {
-                                       .user = {
-                                               .target_size = IPT_ALIGN(sizeof(struct ipt_error_target)),
-                                               .name = IPT_ERROR_TARGET,
-                                       },
-                               },
-                       },
-                       .errorname = "ERROR",
-               },
-       }
+       .term = IPT_ERROR_INIT,                 /* ERROR */
 };
 
 static struct xt_table nat_table = {
index 76f0cf66f95c53cfb4e575b45dc93f36372572e1..7e32e2aaf7f7d62378fdcb11226a548435cfdaf0 100644 (file)
@@ -24,53 +24,29 @@ static struct
        struct ip6t_replace repl;
        struct ip6t_standard entries[3];
        struct ip6t_error term;
-} initial_table __initdata
-= { { "filter", FILTER_VALID_HOOKS, 4,
-      sizeof(struct ip6t_standard) * 3 + sizeof(struct ip6t_error),
-      { [NF_IP6_LOCAL_IN] = 0,
-       [NF_IP6_FORWARD] = sizeof(struct ip6t_standard),
-       [NF_IP6_LOCAL_OUT] = sizeof(struct ip6t_standard) * 2 },
-      { [NF_IP6_LOCAL_IN] = 0,
-       [NF_IP6_FORWARD] = sizeof(struct ip6t_standard),
-       [NF_IP6_LOCAL_OUT] = sizeof(struct ip6t_standard) * 2 },
-      0, NULL, { } },
-    {
-           /* LOCAL_IN */
-           { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 },
-               0,
-               sizeof(struct ip6t_entry),
-               sizeof(struct ip6t_standard),
-               0, { 0, 0 }, { } },
-             { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } },
-               -NF_ACCEPT - 1 } },
-           /* FORWARD */
-           { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 },
-               0,
-               sizeof(struct ip6t_entry),
-               sizeof(struct ip6t_standard),
-               0, { 0, 0 }, { } },
-             { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } },
-               -NF_ACCEPT - 1 } },
-           /* LOCAL_OUT */
-           { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 },
-               0,
-               sizeof(struct ip6t_entry),
-               sizeof(struct ip6t_standard),
-               0, { 0, 0 }, { } },
-             { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } },
-               -NF_ACCEPT - 1 } }
-    },
-    /* ERROR */
-    { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 },
-       0,
-       sizeof(struct ip6t_entry),
-       sizeof(struct ip6t_error),
-       0, { 0, 0 }, { } },
-      { { { { IP6T_ALIGN(sizeof(struct ip6t_error_target)), IP6T_ERROR_TARGET } },
-         { } },
-       "ERROR"
-      }
-    }
+} initial_table __initdata = {
+       .repl = {
+               .name = "filter",
+               .valid_hooks = FILTER_VALID_HOOKS,
+               .num_entries = 4,
+               .size = sizeof(struct ip6t_standard) * 3 + sizeof(struct ip6t_error),
+               .hook_entry = {
+                       [NF_IP6_LOCAL_IN] = 0,
+                       [NF_IP6_FORWARD] = sizeof(struct ip6t_standard),
+                       [NF_IP6_LOCAL_OUT] = sizeof(struct ip6t_standard) * 2
+               },
+               .underflow = {
+                       [NF_IP6_LOCAL_IN] = 0,
+                       [NF_IP6_FORWARD] = sizeof(struct ip6t_standard),
+                       [NF_IP6_LOCAL_OUT] = sizeof(struct ip6t_standard) * 2
+               },
+       },
+       .entries = {
+               IP6T_STANDARD_INIT(NF_ACCEPT),  /* LOCAL_IN */
+               IP6T_STANDARD_INIT(NF_ACCEPT),  /* FORWARD */
+               IP6T_STANDARD_INIT(NF_ACCEPT),  /* LOCAL_OUT */
+       },
+       .term = IP6T_ERROR_INIT,                /* ERROR */
 };
 
 static struct xt_table packet_filter = {
index a9f10e32c163ef6e186bd3d36cbf777625a83603..f2d26495f41350edbf981e12dbdc4c8f4b4087c8 100644 (file)
@@ -32,73 +32,35 @@ static struct
        struct ip6t_replace repl;
        struct ip6t_standard entries[5];
        struct ip6t_error term;
-} initial_table __initdata
-= { { "mangle", MANGLE_VALID_HOOKS, 6,
-      sizeof(struct ip6t_standard) * 5 + sizeof(struct ip6t_error),
-      { [NF_IP6_PRE_ROUTING]   = 0,
-       [NF_IP6_LOCAL_IN]       = sizeof(struct ip6t_standard),
-       [NF_IP6_FORWARD]        = sizeof(struct ip6t_standard) * 2,
-       [NF_IP6_LOCAL_OUT]      = sizeof(struct ip6t_standard) * 3,
-       [NF_IP6_POST_ROUTING]   = sizeof(struct ip6t_standard) * 4},
-      { [NF_IP6_PRE_ROUTING]   = 0,
-       [NF_IP6_LOCAL_IN]       = sizeof(struct ip6t_standard),
-       [NF_IP6_FORWARD]        = sizeof(struct ip6t_standard) * 2,
-       [NF_IP6_LOCAL_OUT]      = sizeof(struct ip6t_standard) * 3,
-       [NF_IP6_POST_ROUTING]   = sizeof(struct ip6t_standard) * 4},
-      0, NULL, { } },
-    {
-           /* PRE_ROUTING */
-           { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 },
-               0,
-               sizeof(struct ip6t_entry),
-               sizeof(struct ip6t_standard),
-               0, { 0, 0 }, { } },
-             { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } },
-               -NF_ACCEPT - 1 } },
-           /* LOCAL_IN */
-           { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 },
-               0,
-               sizeof(struct ip6t_entry),
-               sizeof(struct ip6t_standard),
-               0, { 0, 0 }, { } },
-             { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } },
-               -NF_ACCEPT - 1 } },
-           /* FORWARD */
-           { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 },
-               0,
-               sizeof(struct ip6t_entry),
-               sizeof(struct ip6t_standard),
-               0, { 0, 0 }, { } },
-             { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } },
-               -NF_ACCEPT - 1 } },
-           /* LOCAL_OUT */
-           { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 },
-               0,
-               sizeof(struct ip6t_entry),
-               sizeof(struct ip6t_standard),
-               0, { 0, 0 }, { } },
-             { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } },
-               -NF_ACCEPT - 1 } },
-           /* POST_ROUTING */
-           { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 },
-               0,
-               sizeof(struct ip6t_entry),
-               sizeof(struct ip6t_standard),
-               0, { 0, 0 }, { } },
-             { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } },
-               -NF_ACCEPT - 1 } }
-    },
-    /* ERROR */
-    { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 },
-       0,
-       sizeof(struct ip6t_entry),
-       sizeof(struct ip6t_error),
-       0, { 0, 0 }, { } },
-      { { { { IP6T_ALIGN(sizeof(struct ip6t_error_target)), IP6T_ERROR_TARGET } },
-         { } },
-       "ERROR"
-      }
-    }
+} initial_table __initdata = {
+       .repl = {
+               .name = "mangle",
+               .valid_hooks = MANGLE_VALID_HOOKS,
+               .num_entries = 6,
+               .size = sizeof(struct ip6t_standard) * 5 + sizeof(struct ip6t_error),
+               .hook_entry = {
+                       [NF_IP6_PRE_ROUTING]    = 0,
+                       [NF_IP6_LOCAL_IN]       = sizeof(struct ip6t_standard),
+                       [NF_IP6_FORWARD]        = sizeof(struct ip6t_standard) * 2,
+                       [NF_IP6_LOCAL_OUT]      = sizeof(struct ip6t_standard) * 3,
+                       [NF_IP6_POST_ROUTING]   = sizeof(struct ip6t_standard) * 4,
+               },
+               .underflow = {
+                       [NF_IP6_PRE_ROUTING]    = 0,
+                       [NF_IP6_LOCAL_IN]       = sizeof(struct ip6t_standard),
+                       [NF_IP6_FORWARD]        = sizeof(struct ip6t_standard) * 2,
+                       [NF_IP6_LOCAL_OUT]      = sizeof(struct ip6t_standard) * 3,
+                       [NF_IP6_POST_ROUTING]   = sizeof(struct ip6t_standard) * 4,
+               },
+       },
+       .entries = {
+               IP6T_STANDARD_INIT(NF_ACCEPT),  /* PRE_ROUTING */
+               IP6T_STANDARD_INIT(NF_ACCEPT),  /* LOCAL_IN */
+               IP6T_STANDARD_INIT(NF_ACCEPT),  /* FORWARD */
+               IP6T_STANDARD_INIT(NF_ACCEPT),  /* LOCAL_OUT */
+               IP6T_STANDARD_INIT(NF_ACCEPT),  /* POST_ROUTING */
+       },
+       .term = IP6T_ERROR_INIT,                /* ERROR */
 };
 
 static struct xt_table packet_mangler = {
index a3eb5b8ce18d0abe8a7062b0cc340e1b6bb5b160..0acda45d455d7251df207fe799464cd342aeb15d 100644 (file)
@@ -35,56 +35,10 @@ static struct
                },
        },
        .entries = {
-               /* PRE_ROUTING */
-               {
-                       .entry = {
-                               .target_offset = sizeof(struct ip6t_entry),
-                               .next_offset = sizeof(struct ip6t_standard),
-                       },
-                       .target = {
-                               .target = {
-                                       .u = {
-                                               .target_size = IP6T_ALIGN(sizeof(struct ip6t_standard_target)),
-                                       },
-                               },
-                               .verdict = -NF_ACCEPT - 1,
-                       },
-               },
-
-               /* LOCAL_OUT */
-               {
-                       .entry = {
-                               .target_offset = sizeof(struct ip6t_entry),
-                               .next_offset = sizeof(struct ip6t_standard),
-                       },
-                       .target = {
-                               .target = {
-                                       .u = {
-                                               .target_size = IP6T_ALIGN(sizeof(struct ip6t_standard_target)),
-                                       },
-                               },
-                               .verdict = -NF_ACCEPT - 1,
-                       },
-               },
+               IP6T_STANDARD_INIT(NF_ACCEPT),  /* PRE_ROUTING */
+               IP6T_STANDARD_INIT(NF_ACCEPT),  /* LOCAL_OUT */
        },
-       /* ERROR */
-       .term = {
-               .entry = {
-                       .target_offset = sizeof(struct ip6t_entry),
-                       .next_offset = sizeof(struct ip6t_error),
-               },
-               .target = {
-                       .target = {
-                               .u = {
-                                       .user = {
-                                               .target_size = IP6T_ALIGN(sizeof(struct ip6t_error_target)),
-                                               .name = IP6T_ERROR_TARGET,
-                                       },
-                               },
-                       },
-                       .errorname = "ERROR",
-               },
-       }
+       .term = IP6T_ERROR_INIT,                /* ERROR */
 };
 
 static struct xt_table packet_raw = {