From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: [PATCH 9/9] netfilter: nft_masq: register/unregister notifiers on module init/exit
Date: Fri, 3 Oct 2014 19:20:24 +0200 [thread overview]
Message-ID: <1412356824-6362-10-git-send-email-pablo@netfilter.org> (raw)
In-Reply-To: <1412356824-6362-1-git-send-email-pablo@netfilter.org>
From: Arturo Borrero <arturo.borrero.glez@gmail.com>
We have to register the notifiers in the masquerade expression from
the the module _init and _exit path.
This fixes crashes when removing the masquerade rule with no
ipt_MASQUERADE support in place (which was masking the problem).
Fixes: 9ba1f72 ("netfilter: nf_tables: add new nft_masq expression")
Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/ipv4/netfilter/nft_masq_ipv4.c | 34 +++++++++++-----------------------
net/ipv6/netfilter/nft_masq_ipv6.c | 34 +++++++++++-----------------------
2 files changed, 22 insertions(+), 46 deletions(-)
diff --git a/net/ipv4/netfilter/nft_masq_ipv4.c b/net/ipv4/netfilter/nft_masq_ipv4.c
index 6ea1d20..1c636d6 100644
--- a/net/ipv4/netfilter/nft_masq_ipv4.c
+++ b/net/ipv4/netfilter/nft_masq_ipv4.c
@@ -32,33 +32,12 @@ static void nft_masq_ipv4_eval(const struct nft_expr *expr,
data[NFT_REG_VERDICT].verdict = verdict;
}
-static int nft_masq_ipv4_init(const struct nft_ctx *ctx,
- const struct nft_expr *expr,
- const struct nlattr * const tb[])
-{
- int err;
-
- err = nft_masq_init(ctx, expr, tb);
- if (err < 0)
- return err;
-
- nf_nat_masquerade_ipv4_register_notifier();
- return 0;
-}
-
-static void nft_masq_ipv4_destroy(const struct nft_ctx *ctx,
- const struct nft_expr *expr)
-{
- nf_nat_masquerade_ipv4_unregister_notifier();
-}
-
static struct nft_expr_type nft_masq_ipv4_type;
static const struct nft_expr_ops nft_masq_ipv4_ops = {
.type = &nft_masq_ipv4_type,
.size = NFT_EXPR_SIZE(sizeof(struct nft_masq)),
.eval = nft_masq_ipv4_eval,
- .init = nft_masq_ipv4_init,
- .destroy = nft_masq_ipv4_destroy,
+ .init = nft_masq_init,
.dump = nft_masq_dump,
};
@@ -73,12 +52,21 @@ static struct nft_expr_type nft_masq_ipv4_type __read_mostly = {
static int __init nft_masq_ipv4_module_init(void)
{
- return nft_register_expr(&nft_masq_ipv4_type);
+ int ret;
+
+ ret = nft_register_expr(&nft_masq_ipv4_type);
+ if (ret < 0)
+ return ret;
+
+ nf_nat_masquerade_ipv4_register_notifier();
+
+ return ret;
}
static void __exit nft_masq_ipv4_module_exit(void)
{
nft_unregister_expr(&nft_masq_ipv4_type);
+ nf_nat_masquerade_ipv4_unregister_notifier();
}
module_init(nft_masq_ipv4_module_init);
diff --git a/net/ipv6/netfilter/nft_masq_ipv6.c b/net/ipv6/netfilter/nft_masq_ipv6.c
index 4e51334..556262f 100644
--- a/net/ipv6/netfilter/nft_masq_ipv6.c
+++ b/net/ipv6/netfilter/nft_masq_ipv6.c
@@ -32,33 +32,12 @@ static void nft_masq_ipv6_eval(const struct nft_expr *expr,
data[NFT_REG_VERDICT].verdict = verdict;
}
-static int nft_masq_ipv6_init(const struct nft_ctx *ctx,
- const struct nft_expr *expr,
- const struct nlattr * const tb[])
-{
- int err;
-
- err = nft_masq_init(ctx, expr, tb);
- if (err < 0)
- return err;
-
- nf_nat_masquerade_ipv6_register_notifier();
- return 0;
-}
-
-static void nft_masq_ipv6_destroy(const struct nft_ctx *ctx,
- const struct nft_expr *expr)
-{
- nf_nat_masquerade_ipv6_unregister_notifier();
-}
-
static struct nft_expr_type nft_masq_ipv6_type;
static const struct nft_expr_ops nft_masq_ipv6_ops = {
.type = &nft_masq_ipv6_type,
.size = NFT_EXPR_SIZE(sizeof(struct nft_masq)),
.eval = nft_masq_ipv6_eval,
- .init = nft_masq_ipv6_init,
- .destroy = nft_masq_ipv6_destroy,
+ .init = nft_masq_init,
.dump = nft_masq_dump,
};
@@ -73,12 +52,21 @@ static struct nft_expr_type nft_masq_ipv6_type __read_mostly = {
static int __init nft_masq_ipv6_module_init(void)
{
- return nft_register_expr(&nft_masq_ipv6_type);
+ int ret;
+
+ ret = nft_register_expr(&nft_masq_ipv6_type);
+ if (ret < 0)
+ return ret;
+
+ nf_nat_masquerade_ipv6_register_notifier();
+
+ return ret;
}
static void __exit nft_masq_ipv6_module_exit(void)
{
nft_unregister_expr(&nft_masq_ipv6_type);
+ nf_nat_masquerade_ipv6_unregister_notifier();
}
module_init(nft_masq_ipv6_module_init);
--
1.7.10.4
next prev parent reply other threads:[~2014-10-03 17:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-03 17:20 [PATCH 0/9] Netfilter/IPVS updates for net-next Pablo Neira Ayuso
2014-10-03 17:20 ` [PATCH 1/9] netfilter: nft_reject: introduce icmp code abstraction for inet and bridge Pablo Neira Ayuso
2014-10-03 17:20 ` [PATCH 2/9] netfilter: move nf_send_resetX() code to nf_reject_ipvX modules Pablo Neira Ayuso
2014-10-07 14:45 ` Eric Dumazet
2014-10-03 17:20 ` [PATCH 3/9] netfilter: use IS_ENABLED(CONFIG_BRIDGE_NETFILTER) Pablo Neira Ayuso
2014-10-03 17:20 ` [PATCH 4/9] netfilter: nf_tables: wait for call_rcu completion on module removal Pablo Neira Ayuso
2014-10-03 17:20 ` [PATCH 5/9] netfilter: nft_compat: remove incomplete 32/64 bits arch compat code Pablo Neira Ayuso
2014-10-03 17:20 ` [PATCH 6/9] netfilter: nf_tables: allow to filter from prerouting and postrouting Pablo Neira Ayuso
2014-10-03 17:20 ` [PATCH 7/9] netfilter: explicit module dependency between br_netfilter and physdev Pablo Neira Ayuso
2014-10-03 17:20 ` [PATCH 8/9] ipvs: Clean up comment style in ip_vs.h Pablo Neira Ayuso
2014-10-03 17:20 ` Pablo Neira Ayuso [this message]
2014-10-06 1:33 ` [PATCH 0/9] Netfilter/IPVS updates for net-next David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1412356824-6362-10-git-send-email-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).