diff options
author | Jan Engelhardt <jengelh@medozas.de> | 2009-06-17 16:14:54 -0400 |
---|---|---|
committer | Jan Engelhardt <jengelh@medozas.de> | 2010-02-10 11:50:47 -0500 |
commit | e3eaa9910b380530cfd2c0670fcd3f627674da8a (patch) | |
tree | 309e522e78f78149ec3cb99ffc386d1b72415a96 /net/ipv4 | |
parent | 2b95efe7f6bb750256a702cc32d33b0cb2cd8223 (diff) |
netfilter: xtables: generate initial table on-demand
The static initial tables are pretty large, and after the net
namespace has been instantiated, they just hang around for nothing.
This commit removes them and creates tables on-demand at runtime when
needed.
Size shrinks by 7735 bytes (x86_64).
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/netfilter/arp_tables.c | 7 | ||||
-rw-r--r-- | net/ipv4/netfilter/arptable_filter.c | 40 | ||||
-rw-r--r-- | net/ipv4/netfilter/ip_tables.c | 7 | ||||
-rw-r--r-- | net/ipv4/netfilter/iptable_filter.c | 46 | ||||
-rw-r--r-- | net/ipv4/netfilter/iptable_mangle.c | 46 | ||||
-rw-r--r-- | net/ipv4/netfilter/iptable_raw.c | 36 | ||||
-rw-r--r-- | net/ipv4/netfilter/iptable_security.c | 39 | ||||
-rw-r--r-- | net/ipv4/netfilter/nf_nat_rule.c | 39 |
8 files changed, 61 insertions, 199 deletions
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c index 90203e1b9187..72723ea1054b 100644 --- a/net/ipv4/netfilter/arp_tables.c +++ b/net/ipv4/netfilter/arp_tables.c | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | #include <linux/netfilter/x_tables.h> | 28 | #include <linux/netfilter/x_tables.h> |
29 | #include <linux/netfilter_arp/arp_tables.h> | 29 | #include <linux/netfilter_arp/arp_tables.h> |
30 | #include "../../netfilter/xt_repldata.h" | ||
30 | 31 | ||
31 | MODULE_LICENSE("GPL"); | 32 | MODULE_LICENSE("GPL"); |
32 | MODULE_AUTHOR("David S. Miller <davem@redhat.com>"); | 33 | MODULE_AUTHOR("David S. Miller <davem@redhat.com>"); |
@@ -58,6 +59,12 @@ do { \ | |||
58 | #define ARP_NF_ASSERT(x) | 59 | #define ARP_NF_ASSERT(x) |
59 | #endif | 60 | #endif |
60 | 61 | ||
62 | void *arpt_alloc_initial_table(const struct xt_table *info) | ||
63 | { | ||
64 | return xt_alloc_initial_table(arpt, ARPT); | ||
65 | } | ||
66 | EXPORT_SYMBOL_GPL(arpt_alloc_initial_table); | ||
67 | |||
61 | static inline int arp_devaddr_compare(const struct arpt_devaddr_info *ap, | 68 | static inline int arp_devaddr_compare(const struct arpt_devaddr_info *ap, |
62 | const char *hdr_addr, int len) | 69 | const char *hdr_addr, int len) |
63 | { | 70 | { |
diff --git a/net/ipv4/netfilter/arptable_filter.c b/net/ipv4/netfilter/arptable_filter.c index b361de0dac4c..bfe26f32b930 100644 --- a/net/ipv4/netfilter/arptable_filter.c +++ b/net/ipv4/netfilter/arptable_filter.c | |||
@@ -6,6 +6,7 @@ | |||
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include <linux/module.h> | 8 | #include <linux/module.h> |
9 | #include <linux/netfilter/x_tables.h> | ||
9 | #include <linux/netfilter_arp/arp_tables.h> | 10 | #include <linux/netfilter_arp/arp_tables.h> |
10 | 11 | ||
11 | MODULE_LICENSE("GPL"); | 12 | MODULE_LICENSE("GPL"); |
@@ -15,36 +16,6 @@ MODULE_DESCRIPTION("arptables filter table"); | |||
15 | #define FILTER_VALID_HOOKS ((1 << NF_ARP_IN) | (1 << NF_ARP_OUT) | \ | 16 | #define FILTER_VALID_HOOKS ((1 << NF_ARP_IN) | (1 << NF_ARP_OUT) | \ |
16 | (1 << NF_ARP_FORWARD)) | 17 | (1 << NF_ARP_FORWARD)) |
17 | 18 | ||
18 | static const struct | ||
19 | { | ||
20 | struct arpt_replace repl; | ||
21 | struct arpt_standard entries[3]; | ||
22 | struct arpt_error term; | ||
23 | } initial_table __net_initdata = { | ||
24 | .repl = { | ||
25 | .name = "filter", | ||
26 | .valid_hooks = FILTER_VALID_HOOKS, | ||
27 | .num_entries = 4, | ||
28 | .size = sizeof(struct arpt_standard) * 3 + sizeof(struct arpt_error), | ||
29 | .hook_entry = { | ||
30 | [NF_ARP_IN] = 0, | ||
31 | [NF_ARP_OUT] = sizeof(struct arpt_standard), | ||
32 | [NF_ARP_FORWARD] = 2 * sizeof(struct arpt_standard), | ||
33 | }, | ||
34 | .underflow = { | ||
35 | [NF_ARP_IN] = 0, | ||
36 | [NF_ARP_OUT] = sizeof(struct arpt_standard), | ||
37 | [NF_ARP_FORWARD] = 2 * sizeof(struct arpt_standard), | ||
38 | }, | ||
39 | }, | ||
40 | .entries = { | ||
41 | ARPT_STANDARD_INIT(NF_ACCEPT), /* ARP_IN */ | ||
42 | ARPT_STANDARD_INIT(NF_ACCEPT), /* ARP_OUT */ | ||
43 | ARPT_STANDARD_INIT(NF_ACCEPT), /* ARP_FORWARD */ | ||
44 | }, | ||
45 | .term = ARPT_ERROR_INIT, | ||
46 | }; | ||
47 | |||
48 | static const struct xt_table packet_filter = { | 19 | static const struct xt_table packet_filter = { |
49 | .name = "filter", | 20 | .name = "filter", |
50 | .valid_hooks = FILTER_VALID_HOOKS, | 21 | .valid_hooks = FILTER_VALID_HOOKS, |
@@ -68,9 +39,14 @@ static struct nf_hook_ops *arpfilter_ops __read_mostly; | |||
68 | 39 | ||
69 | static int __net_init arptable_filter_net_init(struct net *net) | 40 | static int __net_init arptable_filter_net_init(struct net *net) |
70 | { | 41 | { |
71 | /* Register table */ | 42 | struct arpt_replace *repl; |
43 | |||
44 | repl = arpt_alloc_initial_table(&packet_filter); | ||
45 | if (repl == NULL) | ||
46 | return -ENOMEM; | ||
72 | net->ipv4.arptable_filter = | 47 | net->ipv4.arptable_filter = |
73 | arpt_register_table(net, &packet_filter, &initial_table.repl); | 48 | arpt_register_table(net, &packet_filter, repl); |
49 | kfree(repl); | ||
74 | if (IS_ERR(net->ipv4.arptable_filter)) | 50 | if (IS_ERR(net->ipv4.arptable_filter)) |
75 | return PTR_ERR(net->ipv4.arptable_filter); | 51 | return PTR_ERR(net->ipv4.arptable_filter); |
76 | return 0; | 52 | return 0; |
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c index 5bf7de1527a5..2057b1bb6178 100644 --- a/net/ipv4/netfilter/ip_tables.c +++ b/net/ipv4/netfilter/ip_tables.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/netfilter/x_tables.h> | 28 | #include <linux/netfilter/x_tables.h> |
29 | #include <linux/netfilter_ipv4/ip_tables.h> | 29 | #include <linux/netfilter_ipv4/ip_tables.h> |
30 | #include <net/netfilter/nf_log.h> | 30 | #include <net/netfilter/nf_log.h> |
31 | #include "../../netfilter/xt_repldata.h" | ||
31 | 32 | ||
32 | MODULE_LICENSE("GPL"); | 33 | MODULE_LICENSE("GPL"); |
33 | MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>"); | 34 | MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>"); |
@@ -66,6 +67,12 @@ do { \ | |||
66 | #define inline | 67 | #define inline |
67 | #endif | 68 | #endif |
68 | 69 | ||
70 | void *ipt_alloc_initial_table(const struct xt_table *info) | ||
71 | { | ||
72 | return xt_alloc_initial_table(ipt, IPT); | ||
73 | } | ||
74 | EXPORT_SYMBOL_GPL(ipt_alloc_initial_table); | ||
75 | |||
69 | /* | 76 | /* |
70 | We keep a set of rules for each CPU, so we can avoid write-locking | 77 | We keep a set of rules for each CPU, so we can avoid write-locking |
71 | them in the softirq when updating the counters and therefore | 78 | them in the softirq when updating the counters and therefore |
diff --git a/net/ipv4/netfilter/iptable_filter.c b/net/ipv4/netfilter/iptable_filter.c index c14bb85db1d9..c8dc9800d620 100644 --- a/net/ipv4/netfilter/iptable_filter.c +++ b/net/ipv4/netfilter/iptable_filter.c | |||
@@ -23,36 +23,6 @@ MODULE_DESCRIPTION("iptables filter table"); | |||
23 | (1 << NF_INET_FORWARD) | \ | 23 | (1 << NF_INET_FORWARD) | \ |
24 | (1 << NF_INET_LOCAL_OUT)) | 24 | (1 << NF_INET_LOCAL_OUT)) |
25 | 25 | ||
26 | static struct | ||
27 | { | ||
28 | struct ipt_replace repl; | ||
29 | struct ipt_standard entries[3]; | ||
30 | struct ipt_error term; | ||
31 | } initial_table __net_initdata = { | ||
32 | .repl = { | ||
33 | .name = "filter", | ||
34 | .valid_hooks = FILTER_VALID_HOOKS, | ||
35 | .num_entries = 4, | ||
36 | .size = sizeof(struct ipt_standard) * 3 + sizeof(struct ipt_error), | ||
37 | .hook_entry = { | ||
38 | [NF_INET_LOCAL_IN] = 0, | ||
39 | [NF_INET_FORWARD] = sizeof(struct ipt_standard), | ||
40 | [NF_INET_LOCAL_OUT] = sizeof(struct ipt_standard) * 2, | ||
41 | }, | ||
42 | .underflow = { | ||
43 | [NF_INET_LOCAL_IN] = 0, | ||
44 | [NF_INET_FORWARD] = sizeof(struct ipt_standard), | ||
45 | [NF_INET_LOCAL_OUT] = sizeof(struct ipt_standard) * 2, | ||
46 | }, | ||
47 | }, | ||
48 | .entries = { | ||
49 | IPT_STANDARD_INIT(NF_ACCEPT), /* LOCAL_IN */ | ||
50 | IPT_STANDARD_INIT(NF_ACCEPT), /* FORWARD */ | ||
51 | IPT_STANDARD_INIT(NF_ACCEPT), /* LOCAL_OUT */ | ||
52 | }, | ||
53 | .term = IPT_ERROR_INIT, /* ERROR */ | ||
54 | }; | ||
55 | |||
56 | static const struct xt_table packet_filter = { | 26 | static const struct xt_table packet_filter = { |
57 | .name = "filter", | 27 | .name = "filter", |
58 | .valid_hooks = FILTER_VALID_HOOKS, | 28 | .valid_hooks = FILTER_VALID_HOOKS, |
@@ -86,9 +56,18 @@ module_param(forward, bool, 0000); | |||
86 | 56 | ||
87 | static int __net_init iptable_filter_net_init(struct net *net) | 57 | static int __net_init iptable_filter_net_init(struct net *net) |
88 | { | 58 | { |
89 | /* Register table */ | 59 | struct ipt_replace *repl; |
60 | |||
61 | repl = ipt_alloc_initial_table(&packet_filter); | ||
62 | if (repl == NULL) | ||
63 | return -ENOMEM; | ||
64 | /* Entry 1 is the FORWARD hook */ | ||
65 | ((struct ipt_standard *)repl->entries)[1].target.verdict = | ||
66 | -forward - 1; | ||
67 | |||
90 | net->ipv4.iptable_filter = | 68 | net->ipv4.iptable_filter = |
91 | ipt_register_table(net, &packet_filter, &initial_table.repl); | 69 | ipt_register_table(net, &packet_filter, repl); |
70 | kfree(repl); | ||
92 | if (IS_ERR(net->ipv4.iptable_filter)) | 71 | if (IS_ERR(net->ipv4.iptable_filter)) |
93 | return PTR_ERR(net->ipv4.iptable_filter); | 72 | return PTR_ERR(net->ipv4.iptable_filter); |
94 | return 0; | 73 | return 0; |
@@ -113,9 +92,6 @@ static int __init iptable_filter_init(void) | |||
113 | return -EINVAL; | 92 | return -EINVAL; |
114 | } | 93 | } |
115 | 94 | ||
116 | /* Entry 1 is the FORWARD hook */ | ||
117 | initial_table.entries[1].target.verdict = -forward - 1; | ||
118 | |||
119 | ret = register_pernet_subsys(&iptable_filter_net_ops); | 95 | ret = register_pernet_subsys(&iptable_filter_net_ops); |
120 | if (ret < 0) | 96 | if (ret < 0) |
121 | return ret; | 97 | return ret; |
diff --git a/net/ipv4/netfilter/iptable_mangle.c b/net/ipv4/netfilter/iptable_mangle.c index 2355a229f8ee..58d7097baa3d 100644 --- a/net/ipv4/netfilter/iptable_mangle.c +++ b/net/ipv4/netfilter/iptable_mangle.c | |||
@@ -27,43 +27,6 @@ MODULE_DESCRIPTION("iptables mangle table"); | |||
27 | (1 << NF_INET_LOCAL_OUT) | \ | 27 | (1 << NF_INET_LOCAL_OUT) | \ |
28 | (1 << NF_INET_POST_ROUTING)) | 28 | (1 << NF_INET_POST_ROUTING)) |
29 | 29 | ||
30 | /* Ouch - five different hooks? Maybe this should be a config option..... -- BC */ | ||
31 | static const struct | ||
32 | { | ||
33 | struct ipt_replace repl; | ||
34 | struct ipt_standard entries[5]; | ||
35 | struct ipt_error term; | ||
36 | } initial_table __net_initdata = { | ||
37 | .repl = { | ||
38 | .name = "mangle", | ||
39 | .valid_hooks = MANGLE_VALID_HOOKS, | ||
40 | .num_entries = 6, | ||
41 | .size = sizeof(struct ipt_standard) * 5 + sizeof(struct ipt_error), | ||
42 | .hook_entry = { | ||
43 | [NF_INET_PRE_ROUTING] = 0, | ||
44 | [NF_INET_LOCAL_IN] = sizeof(struct ipt_standard), | ||
45 | [NF_INET_FORWARD] = sizeof(struct ipt_standard) * 2, | ||
46 | [NF_INET_LOCAL_OUT] = sizeof(struct ipt_standard) * 3, | ||
47 | [NF_INET_POST_ROUTING] = sizeof(struct ipt_standard) * 4, | ||
48 | }, | ||
49 | .underflow = { | ||
50 | [NF_INET_PRE_ROUTING] = 0, | ||
51 | [NF_INET_LOCAL_IN] = sizeof(struct ipt_standard), | ||
52 | [NF_INET_FORWARD] = sizeof(struct ipt_standard) * 2, | ||
53 | [NF_INET_LOCAL_OUT] = sizeof(struct ipt_standard) * 3, | ||
54 | [NF_INET_POST_ROUTING] = sizeof(struct ipt_standard) * 4, | ||
55 | }, | ||
56 | }, | ||
57 | .entries = { | ||
58 | IPT_STANDARD_INIT(NF_ACCEPT), /* PRE_ROUTING */ | ||
59 | IPT_STANDARD_INIT(NF_ACCEPT), /* LOCAL_IN */ | ||
60 | IPT_STANDARD_INIT(NF_ACCEPT), /* FORWARD */ | ||
61 | IPT_STANDARD_INIT(NF_ACCEPT), /* LOCAL_OUT */ | ||
62 | IPT_STANDARD_INIT(NF_ACCEPT), /* POST_ROUTING */ | ||
63 | }, | ||
64 | .term = IPT_ERROR_INIT, /* ERROR */ | ||
65 | }; | ||
66 | |||
67 | static const struct xt_table packet_mangler = { | 30 | static const struct xt_table packet_mangler = { |
68 | .name = "mangle", | 31 | .name = "mangle", |
69 | .valid_hooks = MANGLE_VALID_HOOKS, | 32 | .valid_hooks = MANGLE_VALID_HOOKS, |
@@ -134,9 +97,14 @@ static struct nf_hook_ops *mangle_ops __read_mostly; | |||
134 | 97 | ||
135 | static int __net_init iptable_mangle_net_init(struct net *net) | 98 | static int __net_init iptable_mangle_net_init(struct net *net) |
136 | { | 99 | { |
137 | /* Register table */ | 100 | struct ipt_replace *repl; |
101 | |||
102 | repl = ipt_alloc_initial_table(&packet_mangler); | ||
103 | if (repl == NULL) | ||
104 | return -ENOMEM; | ||
138 | net->ipv4.iptable_mangle = | 105 | net->ipv4.iptable_mangle = |
139 | ipt_register_table(net, &packet_mangler, &initial_table.repl); | 106 | ipt_register_table(net, &packet_mangler, repl); |
107 | kfree(repl); | ||
140 | if (IS_ERR(net->ipv4.iptable_mangle)) | 108 | if (IS_ERR(net->ipv4.iptable_mangle)) |
141 | return PTR_ERR(net->ipv4.iptable_mangle); | 109 | return PTR_ERR(net->ipv4.iptable_mangle); |
142 | return 0; | 110 | return 0; |
diff --git a/net/ipv4/netfilter/iptable_raw.c b/net/ipv4/netfilter/iptable_raw.c index 62a99154f14c..06fb9d11953c 100644 --- a/net/ipv4/netfilter/iptable_raw.c +++ b/net/ipv4/netfilter/iptable_raw.c | |||
@@ -9,33 +9,6 @@ | |||
9 | 9 | ||
10 | #define RAW_VALID_HOOKS ((1 << NF_INET_PRE_ROUTING) | (1 << NF_INET_LOCAL_OUT)) | 10 | #define RAW_VALID_HOOKS ((1 << NF_INET_PRE_ROUTING) | (1 << NF_INET_LOCAL_OUT)) |
11 | 11 | ||
12 | static const struct | ||
13 | { | ||
14 | struct ipt_replace repl; | ||
15 | struct ipt_standard entries[2]; | ||
16 | struct ipt_error term; | ||
17 | } initial_table __net_initdata = { | ||
18 | .repl = { | ||
19 | .name = "raw", | ||
20 | .valid_hooks = RAW_VALID_HOOKS, | ||
21 | .num_entries = 3, | ||
22 | .size = sizeof(struct ipt_standard) * 2 + sizeof(struct ipt_error), | ||
23 | .hook_entry = { | ||
24 | [NF_INET_PRE_ROUTING] = 0, | ||
25 | [NF_INET_LOCAL_OUT] = sizeof(struct ipt_standard) | ||
26 | }, | ||
27 | .underflow = { | ||
28 | [NF_INET_PRE_ROUTING] = 0, | ||
29 | [NF_INET_LOCAL_OUT] = sizeof(struct ipt_standard) | ||
30 | }, | ||
31 | }, | ||
32 | .entries = { | ||
33 | IPT_STANDARD_INIT(NF_ACCEPT), /* PRE_ROUTING */ | ||
34 | IPT_STANDARD_INIT(NF_ACCEPT), /* LOCAL_OUT */ | ||
35 | }, | ||
36 | .term = IPT_ERROR_INIT, /* ERROR */ | ||
37 | }; | ||
38 | |||
39 | static const struct xt_table packet_raw = { | 12 | static const struct xt_table packet_raw = { |
40 | .name = "raw", | 13 | .name = "raw", |
41 | .valid_hooks = RAW_VALID_HOOKS, | 14 | .valid_hooks = RAW_VALID_HOOKS, |
@@ -66,9 +39,14 @@ static struct nf_hook_ops *rawtable_ops __read_mostly; | |||
66 | 39 | ||
67 | static int __net_init iptable_raw_net_init(struct net *net) | 40 | static int __net_init iptable_raw_net_init(struct net *net) |
68 | { | 41 | { |
69 | /* Register table */ | 42 | struct ipt_replace *repl; |
43 | |||
44 | repl = ipt_alloc_initial_table(&packet_raw); | ||
45 | if (repl == NULL) | ||
46 | return -ENOMEM; | ||
70 | net->ipv4.iptable_raw = | 47 | net->ipv4.iptable_raw = |
71 | ipt_register_table(net, &packet_raw, &initial_table.repl); | 48 | ipt_register_table(net, &packet_raw, repl); |
49 | kfree(repl); | ||
72 | if (IS_ERR(net->ipv4.iptable_raw)) | 50 | if (IS_ERR(net->ipv4.iptable_raw)) |
73 | return PTR_ERR(net->ipv4.iptable_raw); | 51 | return PTR_ERR(net->ipv4.iptable_raw); |
74 | return 0; | 52 | return 0; |
diff --git a/net/ipv4/netfilter/iptable_security.c b/net/ipv4/netfilter/iptable_security.c index b1bf3ca2c6c7..cce2f64e6f21 100644 --- a/net/ipv4/netfilter/iptable_security.c +++ b/net/ipv4/netfilter/iptable_security.c | |||
@@ -27,36 +27,6 @@ MODULE_DESCRIPTION("iptables security table, for MAC rules"); | |||
27 | (1 << NF_INET_FORWARD) | \ | 27 | (1 << NF_INET_FORWARD) | \ |
28 | (1 << NF_INET_LOCAL_OUT) | 28 | (1 << NF_INET_LOCAL_OUT) |
29 | 29 | ||
30 | static const struct | ||
31 | { | ||
32 | struct ipt_replace repl; | ||
33 | struct ipt_standard entries[3]; | ||
34 | struct ipt_error term; | ||
35 | } initial_table __net_initdata = { | ||
36 | .repl = { | ||
37 | .name = "security", | ||
38 | .valid_hooks = SECURITY_VALID_HOOKS, | ||
39 | .num_entries = 4, | ||
40 | .size = sizeof(struct ipt_standard) * 3 + sizeof(struct ipt_error), | ||
41 | .hook_entry = { | ||
42 | [NF_INET_LOCAL_IN] = 0, | ||
43 | [NF_INET_FORWARD] = sizeof(struct ipt_standard), | ||
44 | [NF_INET_LOCAL_OUT] = sizeof(struct ipt_standard) * 2, | ||
45 | }, | ||
46 | .underflow = { | ||
47 | [NF_INET_LOCAL_IN] = 0, | ||
48 | [NF_INET_FORWARD] = sizeof(struct ipt_standard), | ||
49 | [NF_INET_LOCAL_OUT] = sizeof(struct ipt_standard) * 2, | ||
50 | }, | ||
51 | }, | ||
52 | .entries = { | ||
53 | IPT_STANDARD_INIT(NF_ACCEPT), /* LOCAL_IN */ | ||
54 | IPT_STANDARD_INIT(NF_ACCEPT), /* FORWARD */ | ||
55 | IPT_STANDARD_INIT(NF_ACCEPT), /* LOCAL_OUT */ | ||
56 | }, | ||
57 | .term = IPT_ERROR_INIT, /* ERROR */ | ||
58 | }; | ||
59 | |||
60 | static const struct xt_table security_table = { | 30 | static const struct xt_table security_table = { |
61 | .name = "security", | 31 | .name = "security", |
62 | .valid_hooks = SECURITY_VALID_HOOKS, | 32 | .valid_hooks = SECURITY_VALID_HOOKS, |
@@ -87,9 +57,14 @@ static struct nf_hook_ops *sectbl_ops __read_mostly; | |||
87 | 57 | ||
88 | static int __net_init iptable_security_net_init(struct net *net) | 58 | static int __net_init iptable_security_net_init(struct net *net) |
89 | { | 59 | { |
90 | net->ipv4.iptable_security = | 60 | struct ipt_replace *repl; |
91 | ipt_register_table(net, &security_table, &initial_table.repl); | ||
92 | 61 | ||
62 | repl = ipt_alloc_initial_table(&security_table); | ||
63 | if (repl == NULL) | ||
64 | return -ENOMEM; | ||
65 | net->ipv4.iptable_security = | ||
66 | ipt_register_table(net, &security_table, repl); | ||
67 | kfree(repl); | ||
93 | if (IS_ERR(net->ipv4.iptable_security)) | 68 | if (IS_ERR(net->ipv4.iptable_security)) |
94 | return PTR_ERR(net->ipv4.iptable_security); | 69 | return PTR_ERR(net->ipv4.iptable_security); |
95 | 70 | ||
diff --git a/net/ipv4/netfilter/nf_nat_rule.c b/net/ipv4/netfilter/nf_nat_rule.c index 85da34fdc755..ab74cc0535e2 100644 --- a/net/ipv4/netfilter/nf_nat_rule.c +++ b/net/ipv4/netfilter/nf_nat_rule.c | |||
@@ -28,36 +28,6 @@ | |||
28 | (1 << NF_INET_POST_ROUTING) | \ | 28 | (1 << NF_INET_POST_ROUTING) | \ |
29 | (1 << NF_INET_LOCAL_OUT)) | 29 | (1 << NF_INET_LOCAL_OUT)) |
30 | 30 | ||
31 | static const struct | ||
32 | { | ||
33 | struct ipt_replace repl; | ||
34 | struct ipt_standard entries[3]; | ||
35 | struct ipt_error term; | ||
36 | } nat_initial_table __net_initdata = { | ||
37 | .repl = { | ||
38 | .name = "nat", | ||
39 | .valid_hooks = NAT_VALID_HOOKS, | ||
40 | .num_entries = 4, | ||
41 | .size = sizeof(struct ipt_standard) * 3 + sizeof(struct ipt_error), | ||
42 | .hook_entry = { | ||
43 | [NF_INET_PRE_ROUTING] = 0, | ||
44 | [NF_INET_POST_ROUTING] = sizeof(struct ipt_standard), | ||
45 | [NF_INET_LOCAL_OUT] = sizeof(struct ipt_standard) * 2 | ||
46 | }, | ||
47 | .underflow = { | ||
48 | [NF_INET_PRE_ROUTING] = 0, | ||
49 | [NF_INET_POST_ROUTING] = sizeof(struct ipt_standard), | ||
50 | [NF_INET_LOCAL_OUT] = sizeof(struct ipt_standard) * 2 | ||
51 | }, | ||
52 | }, | ||
53 | .entries = { | ||
54 | IPT_STANDARD_INIT(NF_ACCEPT), /* PRE_ROUTING */ | ||
55 | IPT_STANDARD_INIT(NF_ACCEPT), /* POST_ROUTING */ | ||
56 | IPT_STANDARD_INIT(NF_ACCEPT), /* LOCAL_OUT */ | ||
57 | }, | ||
58 | .term = IPT_ERROR_INIT, /* ERROR */ | ||
59 | }; | ||
60 | |||
61 | static const struct xt_table nat_table = { | 31 | static const struct xt_table nat_table = { |
62 | .name = "nat", | 32 | .name = "nat", |
63 | .valid_hooks = NAT_VALID_HOOKS, | 33 | .valid_hooks = NAT_VALID_HOOKS, |
@@ -186,8 +156,13 @@ static struct xt_target ipt_dnat_reg __read_mostly = { | |||
186 | 156 | ||
187 | static int __net_init nf_nat_rule_net_init(struct net *net) | 157 | static int __net_init nf_nat_rule_net_init(struct net *net) |
188 | { | 158 | { |
189 | net->ipv4.nat_table = ipt_register_table(net, &nat_table, | 159 | struct ipt_replace *repl; |
190 | &nat_initial_table.repl); | 160 | |
161 | repl = ipt_alloc_initial_table(&nat_table); | ||
162 | if (repl == NULL) | ||
163 | return -ENOMEM; | ||
164 | net->ipv4.nat_table = ipt_register_table(net, &nat_table, repl); | ||
165 | kfree(repl); | ||
191 | if (IS_ERR(net->ipv4.nat_table)) | 166 | if (IS_ERR(net->ipv4.nat_table)) |
192 | return PTR_ERR(net->ipv4.nat_table); | 167 | return PTR_ERR(net->ipv4.nat_table); |
193 | return 0; | 168 | return 0; |