diff options
-rw-r--r-- | include/net/netns/conntrack.h | 2 | ||||
-rw-r--r-- | net/netfilter/nf_conntrack_core.c | 36 |
2 files changed, 14 insertions, 24 deletions
diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h index 1e751bf176fa..38b1a80517f0 100644 --- a/include/net/netns/conntrack.h +++ b/include/net/netns/conntrack.h | |||
@@ -84,7 +84,6 @@ struct netns_ct { | |||
84 | struct ctl_table_header *event_sysctl_header; | 84 | struct ctl_table_header *event_sysctl_header; |
85 | struct ctl_table_header *helper_sysctl_header; | 85 | struct ctl_table_header *helper_sysctl_header; |
86 | #endif | 86 | #endif |
87 | char *slabname; | ||
88 | unsigned int sysctl_log_invalid; /* Log invalid packets */ | 87 | unsigned int sysctl_log_invalid; /* Log invalid packets */ |
89 | int sysctl_events; | 88 | int sysctl_events; |
90 | int sysctl_acct; | 89 | int sysctl_acct; |
@@ -93,7 +92,6 @@ struct netns_ct { | |||
93 | int sysctl_tstamp; | 92 | int sysctl_tstamp; |
94 | int sysctl_checksum; | 93 | int sysctl_checksum; |
95 | 94 | ||
96 | struct kmem_cache *nf_conntrack_cachep; | ||
97 | struct ct_pcpu __percpu *pcpu_lists; | 95 | struct ct_pcpu __percpu *pcpu_lists; |
98 | struct ip_conntrack_stat __percpu *stat; | 96 | struct ip_conntrack_stat __percpu *stat; |
99 | struct nf_ct_event_notifier __rcu *nf_conntrack_event_cb; | 97 | struct nf_ct_event_notifier __rcu *nf_conntrack_event_cb; |
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index f58a70410c69..0cd29365004f 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c | |||
@@ -72,6 +72,7 @@ EXPORT_SYMBOL_GPL(nf_conntrack_expect_lock); | |||
72 | struct hlist_nulls_head *nf_conntrack_hash __read_mostly; | 72 | struct hlist_nulls_head *nf_conntrack_hash __read_mostly; |
73 | EXPORT_SYMBOL_GPL(nf_conntrack_hash); | 73 | EXPORT_SYMBOL_GPL(nf_conntrack_hash); |
74 | 74 | ||
75 | static __read_mostly struct kmem_cache *nf_conntrack_cachep; | ||
75 | static __read_mostly spinlock_t nf_conntrack_locks_all_lock; | 76 | static __read_mostly spinlock_t nf_conntrack_locks_all_lock; |
76 | static __read_mostly seqcount_t nf_conntrack_generation; | 77 | static __read_mostly seqcount_t nf_conntrack_generation; |
77 | static __read_mostly bool nf_conntrack_locks_all; | 78 | static __read_mostly bool nf_conntrack_locks_all; |
@@ -910,7 +911,7 @@ __nf_conntrack_alloc(struct net *net, | |||
910 | * Do not use kmem_cache_zalloc(), as this cache uses | 911 | * Do not use kmem_cache_zalloc(), as this cache uses |
911 | * SLAB_DESTROY_BY_RCU. | 912 | * SLAB_DESTROY_BY_RCU. |
912 | */ | 913 | */ |
913 | ct = kmem_cache_alloc(net->ct.nf_conntrack_cachep, gfp); | 914 | ct = kmem_cache_alloc(nf_conntrack_cachep, gfp); |
914 | if (ct == NULL) | 915 | if (ct == NULL) |
915 | goto out; | 916 | goto out; |
916 | 917 | ||
@@ -937,7 +938,7 @@ __nf_conntrack_alloc(struct net *net, | |||
937 | atomic_set(&ct->ct_general.use, 0); | 938 | atomic_set(&ct->ct_general.use, 0); |
938 | return ct; | 939 | return ct; |
939 | out_free: | 940 | out_free: |
940 | kmem_cache_free(net->ct.nf_conntrack_cachep, ct); | 941 | kmem_cache_free(nf_conntrack_cachep, ct); |
941 | out: | 942 | out: |
942 | atomic_dec(&net->ct.count); | 943 | atomic_dec(&net->ct.count); |
943 | return ERR_PTR(-ENOMEM); | 944 | return ERR_PTR(-ENOMEM); |
@@ -964,7 +965,7 @@ void nf_conntrack_free(struct nf_conn *ct) | |||
964 | 965 | ||
965 | nf_ct_ext_destroy(ct); | 966 | nf_ct_ext_destroy(ct); |
966 | nf_ct_ext_free(ct); | 967 | nf_ct_ext_free(ct); |
967 | kmem_cache_free(net->ct.nf_conntrack_cachep, ct); | 968 | kmem_cache_free(nf_conntrack_cachep, ct); |
968 | smp_mb__before_atomic(); | 969 | smp_mb__before_atomic(); |
969 | atomic_dec(&net->ct.count); | 970 | atomic_dec(&net->ct.count); |
970 | } | 971 | } |
@@ -1587,8 +1588,6 @@ i_see_dead_people: | |||
1587 | nf_conntrack_tstamp_pernet_fini(net); | 1588 | nf_conntrack_tstamp_pernet_fini(net); |
1588 | nf_conntrack_acct_pernet_fini(net); | 1589 | nf_conntrack_acct_pernet_fini(net); |
1589 | nf_conntrack_expect_pernet_fini(net); | 1590 | nf_conntrack_expect_pernet_fini(net); |
1590 | kmem_cache_destroy(net->ct.nf_conntrack_cachep); | ||
1591 | kfree(net->ct.slabname); | ||
1592 | free_percpu(net->ct.stat); | 1591 | free_percpu(net->ct.stat); |
1593 | free_percpu(net->ct.pcpu_lists); | 1592 | free_percpu(net->ct.pcpu_lists); |
1594 | } | 1593 | } |
@@ -1693,7 +1692,8 @@ EXPORT_SYMBOL_GPL(nf_ct_untracked_status_or); | |||
1693 | int nf_conntrack_init_start(void) | 1692 | int nf_conntrack_init_start(void) |
1694 | { | 1693 | { |
1695 | int max_factor = 8; | 1694 | int max_factor = 8; |
1696 | int i, ret, cpu; | 1695 | int ret = -ENOMEM; |
1696 | int i, cpu; | ||
1697 | 1697 | ||
1698 | seqcount_init(&nf_conntrack_generation); | 1698 | seqcount_init(&nf_conntrack_generation); |
1699 | 1699 | ||
@@ -1729,6 +1729,12 @@ int nf_conntrack_init_start(void) | |||
1729 | 1729 | ||
1730 | nf_conntrack_max = max_factor * nf_conntrack_htable_size; | 1730 | nf_conntrack_max = max_factor * nf_conntrack_htable_size; |
1731 | 1731 | ||
1732 | nf_conntrack_cachep = kmem_cache_create("nf_conntrack", | ||
1733 | sizeof(struct nf_conn), 0, | ||
1734 | SLAB_DESTROY_BY_RCU, NULL); | ||
1735 | if (!nf_conntrack_cachep) | ||
1736 | goto err_cachep; | ||
1737 | |||
1732 | printk(KERN_INFO "nf_conntrack version %s (%u buckets, %d max)\n", | 1738 | printk(KERN_INFO "nf_conntrack version %s (%u buckets, %d max)\n", |
1733 | NF_CONNTRACK_VERSION, nf_conntrack_htable_size, | 1739 | NF_CONNTRACK_VERSION, nf_conntrack_htable_size, |
1734 | nf_conntrack_max); | 1740 | nf_conntrack_max); |
@@ -1805,6 +1811,8 @@ err_tstamp: | |||
1805 | err_acct: | 1811 | err_acct: |
1806 | nf_conntrack_expect_fini(); | 1812 | nf_conntrack_expect_fini(); |
1807 | err_expect: | 1813 | err_expect: |
1814 | kmem_cache_destroy(nf_conntrack_cachep); | ||
1815 | err_cachep: | ||
1808 | nf_ct_free_hashtable(nf_conntrack_hash, nf_conntrack_htable_size); | 1816 | nf_ct_free_hashtable(nf_conntrack_hash, nf_conntrack_htable_size); |
1809 | return ret; | 1817 | return ret; |
1810 | } | 1818 | } |
@@ -1846,18 +1854,6 @@ int nf_conntrack_init_net(struct net *net) | |||
1846 | if (!net->ct.stat) | 1854 | if (!net->ct.stat) |
1847 | goto err_pcpu_lists; | 1855 | goto err_pcpu_lists; |
1848 | 1856 | ||
1849 | net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net); | ||
1850 | if (!net->ct.slabname) | ||
1851 | goto err_slabname; | ||
1852 | |||
1853 | net->ct.nf_conntrack_cachep = kmem_cache_create(net->ct.slabname, | ||
1854 | sizeof(struct nf_conn), 0, | ||
1855 | SLAB_DESTROY_BY_RCU, NULL); | ||
1856 | if (!net->ct.nf_conntrack_cachep) { | ||
1857 | printk(KERN_ERR "Unable to create nf_conn slab cache\n"); | ||
1858 | goto err_cache; | ||
1859 | } | ||
1860 | |||
1861 | ret = nf_conntrack_expect_pernet_init(net); | 1857 | ret = nf_conntrack_expect_pernet_init(net); |
1862 | if (ret < 0) | 1858 | if (ret < 0) |
1863 | goto err_expect; | 1859 | goto err_expect; |
@@ -1889,10 +1885,6 @@ err_tstamp: | |||
1889 | err_acct: | 1885 | err_acct: |
1890 | nf_conntrack_expect_pernet_fini(net); | 1886 | nf_conntrack_expect_pernet_fini(net); |
1891 | err_expect: | 1887 | err_expect: |
1892 | kmem_cache_destroy(net->ct.nf_conntrack_cachep); | ||
1893 | err_cache: | ||
1894 | kfree(net->ct.slabname); | ||
1895 | err_slabname: | ||
1896 | free_percpu(net->ct.stat); | 1888 | free_percpu(net->ct.stat); |
1897 | err_pcpu_lists: | 1889 | err_pcpu_lists: |
1898 | free_percpu(net->ct.pcpu_lists); | 1890 | free_percpu(net->ct.pcpu_lists); |