netfilter: conntrack: remove module owner field
No need to get/put module owner reference, none of these can be removed anymore. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
parent
197c4300ae
commit
b184356d0a
@ -74,9 +74,6 @@ struct nf_conntrack_l4proto {
|
|||||||
|
|
||||||
/* Return the per-net protocol part. */
|
/* Return the per-net protocol part. */
|
||||||
struct nf_proto_net *(*get_net_proto)(struct net *net);
|
struct nf_proto_net *(*get_net_proto)(struct net *net);
|
||||||
|
|
||||||
/* Module (if any) which this is connected to. */
|
|
||||||
struct module *me;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bool icmp_pkt_to_tuple(const struct sk_buff *skb,
|
bool icmp_pkt_to_tuple(const struct sk_buff *skb,
|
||||||
@ -148,7 +145,6 @@ extern const struct nf_conntrack_l4proto nf_conntrack_l4proto_generic;
|
|||||||
const struct nf_conntrack_l4proto *__nf_ct_l4proto_find(u8 l4proto);
|
const struct nf_conntrack_l4proto *__nf_ct_l4proto_find(u8 l4proto);
|
||||||
|
|
||||||
const struct nf_conntrack_l4proto *nf_ct_l4proto_find_get(u8 l4proto);
|
const struct nf_conntrack_l4proto *nf_ct_l4proto_find_get(u8 l4proto);
|
||||||
void nf_ct_l4proto_put(const struct nf_conntrack_l4proto *p);
|
|
||||||
|
|
||||||
/* Protocol pernet registration. */
|
/* Protocol pernet registration. */
|
||||||
int nf_ct_l4proto_pernet_register_one(struct net *net,
|
int nf_ct_l4proto_pernet_register_one(struct net *net,
|
||||||
|
@ -139,20 +139,12 @@ const struct nf_conntrack_l4proto *nf_ct_l4proto_find_get(u8 l4num)
|
|||||||
|
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
p = __nf_ct_l4proto_find(l4num);
|
p = __nf_ct_l4proto_find(l4num);
|
||||||
if (!try_module_get(p->me))
|
|
||||||
p = &nf_conntrack_l4proto_generic;
|
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(nf_ct_l4proto_find_get);
|
EXPORT_SYMBOL_GPL(nf_ct_l4proto_find_get);
|
||||||
|
|
||||||
void nf_ct_l4proto_put(const struct nf_conntrack_l4proto *p)
|
|
||||||
{
|
|
||||||
module_put(p->me);
|
|
||||||
}
|
|
||||||
EXPORT_SYMBOL_GPL(nf_ct_l4proto_put);
|
|
||||||
|
|
||||||
static int kill_l4proto(struct nf_conn *i, void *data)
|
static int kill_l4proto(struct nf_conn *i, void *data)
|
||||||
{
|
{
|
||||||
const struct nf_conntrack_l4proto *l4proto;
|
const struct nf_conntrack_l4proto *l4proto;
|
||||||
|
@ -373,7 +373,6 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_gre = {
|
|||||||
#endif
|
#endif
|
||||||
.packet = gre_packet,
|
.packet = gre_packet,
|
||||||
.destroy = gre_destroy,
|
.destroy = gre_destroy,
|
||||||
.me = THIS_MODULE,
|
|
||||||
#if IS_ENABLED(CONFIG_NF_CT_NETLINK)
|
#if IS_ENABLED(CONFIG_NF_CT_NETLINK)
|
||||||
.tuple_to_nlattr = nf_ct_port_tuple_to_nlattr,
|
.tuple_to_nlattr = nf_ct_port_tuple_to_nlattr,
|
||||||
.nlattr_tuple_size = nf_ct_port_nlattr_tuple_size,
|
.nlattr_tuple_size = nf_ct_port_nlattr_tuple_size,
|
||||||
|
@ -152,7 +152,6 @@ static int cttimeout_new_timeout(struct net *net, struct sock *ctnl,
|
|||||||
err:
|
err:
|
||||||
kfree(timeout);
|
kfree(timeout);
|
||||||
err_proto_put:
|
err_proto_put:
|
||||||
nf_ct_l4proto_put(l4proto);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,7 +301,6 @@ static int ctnl_timeout_try_del(struct net *net, struct ctnl_timeout *timeout)
|
|||||||
if (refcount_dec_if_one(&timeout->refcnt)) {
|
if (refcount_dec_if_one(&timeout->refcnt)) {
|
||||||
/* We are protected by nfnl mutex. */
|
/* We are protected by nfnl mutex. */
|
||||||
list_del_rcu(&timeout->head);
|
list_del_rcu(&timeout->head);
|
||||||
nf_ct_l4proto_put(timeout->timeout.l4proto);
|
|
||||||
nf_ct_untimeout(net, &timeout->timeout);
|
nf_ct_untimeout(net, &timeout->timeout);
|
||||||
kfree_rcu(timeout, rcu_head);
|
kfree_rcu(timeout, rcu_head);
|
||||||
} else {
|
} else {
|
||||||
@ -372,10 +370,8 @@ static int cttimeout_default_set(struct net *net, struct sock *ctnl,
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
nf_ct_l4proto_put(l4proto);
|
|
||||||
return 0;
|
return 0;
|
||||||
err:
|
err:
|
||||||
nf_ct_l4proto_put(l4proto);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -511,7 +507,6 @@ static int cttimeout_default_get(struct net *net, struct sock *ctnl,
|
|||||||
/* this avoids a loop in nfnetlink. */
|
/* this avoids a loop in nfnetlink. */
|
||||||
return ret == -EAGAIN ? -ENOBUFS : ret;
|
return ret == -EAGAIN ? -ENOBUFS : ret;
|
||||||
err:
|
err:
|
||||||
nf_ct_l4proto_put(l4proto);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -592,7 +587,6 @@ static void __net_exit cttimeout_net_exit(struct net *net)
|
|||||||
|
|
||||||
list_for_each_entry_safe(cur, tmp, &net->nfct_timeout_list, head) {
|
list_for_each_entry_safe(cur, tmp, &net->nfct_timeout_list, head) {
|
||||||
list_del_rcu(&cur->head);
|
list_del_rcu(&cur->head);
|
||||||
nf_ct_l4proto_put(cur->timeout.l4proto);
|
|
||||||
|
|
||||||
if (refcount_dec_and_test(&cur->refcnt))
|
if (refcount_dec_and_test(&cur->refcnt))
|
||||||
kfree_rcu(cur, rcu_head);
|
kfree_rcu(cur, rcu_head);
|
||||||
|
@ -902,7 +902,6 @@ static int nft_ct_timeout_obj_init(const struct nft_ctx *ctx,
|
|||||||
err_free_timeout:
|
err_free_timeout:
|
||||||
kfree(timeout);
|
kfree(timeout);
|
||||||
err_proto_put:
|
err_proto_put:
|
||||||
nf_ct_l4proto_put(l4proto);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -913,7 +912,6 @@ static void nft_ct_timeout_obj_destroy(const struct nft_ctx *ctx,
|
|||||||
struct nf_ct_timeout *timeout = priv->timeout;
|
struct nf_ct_timeout *timeout = priv->timeout;
|
||||||
|
|
||||||
nf_ct_untimeout(ctx->net, timeout);
|
nf_ct_untimeout(ctx->net, timeout);
|
||||||
nf_ct_l4proto_put(timeout->l4proto);
|
|
||||||
nf_ct_netns_put(ctx->net, ctx->family);
|
nf_ct_netns_put(ctx->net, ctx->family);
|
||||||
kfree(priv->timeout);
|
kfree(priv->timeout);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user