mirror of
git://git.code.sf.net/p/xtables-addons/xtables-addons
synced 2025-09-08 21:54:57 +02:00
xt_condition: namespace support #2
This commit is contained in:

committed by
Jan Engelhardt

parent
c839e87bbb
commit
89d1b808b9
@@ -7,7 +7,7 @@
|
|||||||
* Authors:
|
* Authors:
|
||||||
* Stephane Ouellette <ouellettes [at] videotron ca>, 2002-10-22
|
* Stephane Ouellette <ouellettes [at] videotron ca>, 2002-10-22
|
||||||
* Massimiliano Hofer <max [at] nucleus it>, 2006-05-15
|
* Massimiliano Hofer <max [at] nucleus it>, 2006-05-15
|
||||||
* Grzegorz Kuczyński <grzegorz.kuczynski [at] koba pl>, 2017-05-20
|
* Grzegorz Kuczyński <grzegorz.kuczynski [at] koba pl>, 2017-02-27
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU General Public License; either version 2
|
* under the terms of the GNU General Public License; either version 2
|
||||||
@@ -65,6 +65,7 @@ static DEFINE_MUTEX(proc_lock);
|
|||||||
struct condition_net {
|
struct condition_net {
|
||||||
struct list_head conditions_list;
|
struct list_head conditions_list;
|
||||||
struct proc_dir_entry *proc_net_condition;
|
struct proc_dir_entry *proc_net_condition;
|
||||||
|
bool after_clear;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int condition_net_id;
|
static int condition_net_id;
|
||||||
@@ -189,11 +190,15 @@ static void condition_mt_destroy(const struct xt_mtdtor_param *par)
|
|||||||
{
|
{
|
||||||
const struct xt_condition_mtinfo *info = par->matchinfo;
|
const struct xt_condition_mtinfo *info = par->matchinfo;
|
||||||
struct condition_variable *var = info->condvar;
|
struct condition_variable *var = info->condvar;
|
||||||
|
struct condition_net *cnet = condition_pernet(par->net);
|
||||||
|
|
||||||
|
if (cnet->after_clear)
|
||||||
|
return;
|
||||||
|
|
||||||
mutex_lock(&proc_lock);
|
mutex_lock(&proc_lock);
|
||||||
if (--var->refcount == 0) {
|
if (--var->refcount == 0) {
|
||||||
list_del(&var->list);
|
list_del(&var->list);
|
||||||
proc_remove(var->status_proc);
|
remove_proc_entry(var->name, cnet->proc_net_condition);
|
||||||
mutex_unlock(&proc_lock);
|
mutex_unlock(&proc_lock);
|
||||||
kfree(var);
|
kfree(var);
|
||||||
return;
|
return;
|
||||||
@@ -233,6 +238,7 @@ static int __net_init condition_net_init(struct net *net)
|
|||||||
condition_net->proc_net_condition = proc_mkdir(dir_name, net->proc_net);
|
condition_net->proc_net_condition = proc_mkdir(dir_name, net->proc_net);
|
||||||
if (condition_net->proc_net_condition == NULL)
|
if (condition_net->proc_net_condition == NULL)
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
|
condition_net->after_clear = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,7 +248,7 @@ static void __net_exit condition_net_exit(struct net *net)
|
|||||||
struct list_head *pos, *q;
|
struct list_head *pos, *q;
|
||||||
struct condition_variable *var = NULL;
|
struct condition_variable *var = NULL;
|
||||||
|
|
||||||
remove_proc_entry(dir_name, init_net.proc_net);
|
remove_proc_subtree(dir_name, net->proc_net);
|
||||||
mutex_lock(&proc_lock);
|
mutex_lock(&proc_lock);
|
||||||
list_for_each_safe(pos, q, &condition_net->conditions_list) {
|
list_for_each_safe(pos, q, &condition_net->conditions_list) {
|
||||||
var = list_entry(pos, struct condition_variable, list);
|
var = list_entry(pos, struct condition_variable, list);
|
||||||
@@ -250,6 +256,7 @@ static void __net_exit condition_net_exit(struct net *net)
|
|||||||
kfree(var);
|
kfree(var);
|
||||||
}
|
}
|
||||||
mutex_unlock(&proc_lock);
|
mutex_unlock(&proc_lock);
|
||||||
|
condition_net->after_clear = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct pernet_operations condition_net_ops = {
|
static struct pernet_operations condition_net_ops = {
|
||||||
|
Reference in New Issue
Block a user