Commit a9382d93 authored by Eric Dumazet's avatar Eric Dumazet Committed by Pablo Neira Ayuso

netfilter: nfnetlink: add netns refcount tracker to struct nfulnl_instance

If compiled with CONFIG_NET_NS_REFCNT_TRACKER=y,
using put_net_track() in nfulnl_instance_free_rcu()
and get_net_track() in instance_create()
might help us finding netns refcount imbalances.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent 604ba230
...@@ -66,6 +66,7 @@ struct nfulnl_instance { ...@@ -66,6 +66,7 @@ struct nfulnl_instance {
struct sk_buff *skb; /* pre-allocatd skb */ struct sk_buff *skb; /* pre-allocatd skb */
struct timer_list timer; struct timer_list timer;
struct net *net; struct net *net;
netns_tracker ns_tracker;
struct user_namespace *peer_user_ns; /* User namespace of the peer process */ struct user_namespace *peer_user_ns; /* User namespace of the peer process */
u32 peer_portid; /* PORTID of the peer process */ u32 peer_portid; /* PORTID of the peer process */
...@@ -140,7 +141,7 @@ static void nfulnl_instance_free_rcu(struct rcu_head *head) ...@@ -140,7 +141,7 @@ static void nfulnl_instance_free_rcu(struct rcu_head *head)
struct nfulnl_instance *inst = struct nfulnl_instance *inst =
container_of(head, struct nfulnl_instance, rcu); container_of(head, struct nfulnl_instance, rcu);
put_net(inst->net); put_net_track(inst->net, &inst->ns_tracker);
kfree(inst); kfree(inst);
module_put(THIS_MODULE); module_put(THIS_MODULE);
} }
...@@ -187,7 +188,7 @@ instance_create(struct net *net, u_int16_t group_num, ...@@ -187,7 +188,7 @@ instance_create(struct net *net, u_int16_t group_num,
timer_setup(&inst->timer, nfulnl_timer, 0); timer_setup(&inst->timer, nfulnl_timer, 0);
inst->net = get_net(net); inst->net = get_net_track(net, &inst->ns_tracker, GFP_ATOMIC);
inst->peer_user_ns = user_ns; inst->peer_user_ns = user_ns;
inst->peer_portid = portid; inst->peer_portid = portid;
inst->group_num = group_num; inst->group_num = group_num;
......
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