Commit 26a89e43 authored by Gao feng's avatar Gao feng Committed by Pablo Neira Ayuso

netfilter: ipt_CLUSTERIP: make clusterip_list per net namespace

clusterip_configs should be per net namespace, so operate
cluster in one net namespace won't affect other net
namespace. right now, only allow to operate the clusterip_configs
of init net namespace.
Signed-off-by: default avatarGao feng <gaofeng@cn.fujitsu.com>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent ce4ff76c
...@@ -58,8 +58,6 @@ struct clusterip_config { ...@@ -58,8 +58,6 @@ struct clusterip_config {
struct rcu_head rcu; struct rcu_head rcu;
}; };
static LIST_HEAD(clusterip_configs);
/* clusterip_lock protects the clusterip_configs list */ /* clusterip_lock protects the clusterip_configs list */
static DEFINE_SPINLOCK(clusterip_lock); static DEFINE_SPINLOCK(clusterip_lock);
...@@ -70,6 +68,7 @@ static const struct file_operations clusterip_proc_fops; ...@@ -70,6 +68,7 @@ static const struct file_operations clusterip_proc_fops;
static int clusterip_net_id __read_mostly; static int clusterip_net_id __read_mostly;
struct clusterip_net { struct clusterip_net {
struct list_head configs;
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
struct proc_dir_entry *procdir; struct proc_dir_entry *procdir;
#endif #endif
...@@ -124,8 +123,9 @@ static struct clusterip_config * ...@@ -124,8 +123,9 @@ static struct clusterip_config *
__clusterip_config_find(__be32 clusterip) __clusterip_config_find(__be32 clusterip)
{ {
struct clusterip_config *c; struct clusterip_config *c;
struct clusterip_net *cn = net_generic(&init_net, clusterip_net_id);
list_for_each_entry_rcu(c, &clusterip_configs, list) { list_for_each_entry_rcu(c, &cn->configs, list) {
if (c->clusterip == clusterip) if (c->clusterip == clusterip)
return c; return c;
} }
...@@ -199,7 +199,7 @@ clusterip_config_init(const struct ipt_clusterip_tgt_info *i, __be32 ip, ...@@ -199,7 +199,7 @@ clusterip_config_init(const struct ipt_clusterip_tgt_info *i, __be32 ip,
#endif #endif
spin_lock_bh(&clusterip_lock); spin_lock_bh(&clusterip_lock);
list_add_rcu(&c->list, &clusterip_configs); list_add_rcu(&c->list, &cn->configs);
spin_unlock_bh(&clusterip_lock); spin_unlock_bh(&clusterip_lock);
return c; return c;
...@@ -709,9 +709,11 @@ static const struct file_operations clusterip_proc_fops = { ...@@ -709,9 +709,11 @@ static const struct file_operations clusterip_proc_fops = {
static int clusterip_net_init(struct net *net) static int clusterip_net_init(struct net *net)
{ {
#ifdef CONFIG_PROC_FS
struct clusterip_net *cn = net_generic(net, clusterip_net_id); struct clusterip_net *cn = net_generic(net, clusterip_net_id);
INIT_LIST_HEAD(&cn->configs);
#ifdef CONFIG_PROC_FS
cn->procdir = proc_mkdir("ipt_CLUSTERIP", net->proc_net); cn->procdir = proc_mkdir("ipt_CLUSTERIP", net->proc_net);
if (!cn->procdir) { if (!cn->procdir) {
pr_err("Unable to proc dir entry\n"); pr_err("Unable to proc dir entry\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment