From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: "Jan Engelhardt" <jengelh@inai.de>,
"Maciej Żenczykowski" <zenczykowski@gmail.com>,
"Cong Wang" <amwang@redhat.com>,
netfilter-devel@vger.kernel.org,
"Patrick McHardy" <kaber@trash.net>,
"David S. Miller" <davem@davemloft.net>,
netfilter@vger.kernel.org
Subject: Re: [Patch net-next] netfilter: remove xt_NOTRACK
Date: Mon, 3 Sep 2012 21:24:55 +0200 [thread overview]
Message-ID: <20120903192455.GA3527@1984> (raw)
In-Reply-To: <20120903153121.GA19926@1984>
[-- Attachment #1: Type: text/plain, Size: 1067 bytes --]
On Mon, Sep 03, 2012 at 05:31:21PM +0200, Pablo Neira Ayuso wrote:
> On Mon, Sep 03, 2012 at 03:57:53PM +0800, Cong Wang wrote:
> > On Mon, Aug 27, 2012 at 4:04 AM, Jan Engelhardt <jengelh@inai.de> wrote:
> > > On Sunday 2012-08-26 12:42, Maciej Żenczykowski wrote:
> > >
> > >>Sounds like the old -t raw ... -j NOTRACK is replaced by -t raw ... -j
> > >>CT --notrack.
> > >>Will -j NOTRACK continue to work? Could it be added as an alias to CT?
> > >
> > > No, and, dunno. There are currently no provisions for aliasing in the
> > > userspace side.
> >
> > So no objections from you, right? :)
>
> Applied, thanks.
>
> I think it can be possible to rewrite the iptables NOTRACK user-space
> extension to use the CT target. Still I would need to check if some
> more sophisticated aliasing can be possible.
>
> And iptables-save will show the CT target though, but that shouldn't
> be a problem.
I've made the following patch. It adds some simple aliasing to
iptables. Now NOTRACK uses the CT target, it also spots a warning
telling that it's been deprecated.
[-- Attachment #2: alias.patch --]
[-- Type: text/x-diff, Size: 4176 bytes --]
diff --git a/extensions/libxt_NOTRACK.c b/extensions/libxt_NOTRACK.c
index ca58700..a6b66af 100644
--- a/extensions/libxt_NOTRACK.c
+++ b/extensions/libxt_NOTRACK.c
@@ -1,15 +1,78 @@
-/* Shared library add-on to iptables to add NOTRACK target support. */
+/*
+ * (C) 2012 by Pablo Neira Ayuso <pablo@netfilter.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+/*
+ * Shared library add-on to iptables to add NOTRACK target support: This
+ * is an alias of the CT target, since it has been deprecated.
+ */
+
+#include <stdio.h>
#include <xtables.h>
+#include <linux/netfilter/nf_conntrack_common.h>
+#include <linux/netfilter/xt_CT.h>
+
+static void ct_tg_init_v0(struct xt_entry_target *target)
+{
+ struct xt_ct_target_info *info = (void *)target->data;
+
+ fprintf(stderr, "warning: NOTRACK target is deprecated, "
+ "use CT target instead\n");
+ info->flags |= XT_CT_NOTRACK;
+}
+
+static void ct_tg_init_v1(struct xt_entry_target *target)
+{
+ struct xt_ct_target_info_v1 *info = (void *)target->data;
+
+ fprintf(stderr, "warning: NOTRACK target is deprecated, "
+ "use CT target instead\n");
+ info->flags |= XT_CT_NOTRACK;
+}
+
+static void
+ct_tg_print(const void *ip, const struct xt_entry_target *target, int numeric)
+{
+ printf(" CT notrack");
+}
+
+static void ct_tg_save(const void *ip, const struct xt_entry_target *target)
+{
+ printf(" --notrack");
+}
-static struct xtables_target notrack_target = {
- .family = NFPROTO_UNSPEC,
- .name = "NOTRACK",
- .version = XTABLES_VERSION,
- .size = XT_ALIGN(0),
- .userspacesize = XT_ALIGN(0),
+static struct xtables_target ct_tg_target_reg[] = {
+ {
+ .family = NFPROTO_UNSPEC,
+ .name = "NOTRACK",
+ .alias = "CT",
+ .revision = 0,
+ .version = XTABLES_VERSION,
+ .size = XT_ALIGN(sizeof(struct xt_ct_target_info)),
+ .userspacesize = offsetof(struct xt_ct_target_info, ct),
+ .print = ct_tg_print,
+ .save = ct_tg_save,
+ .init = ct_tg_init_v0,
+ },
+ {
+ .family = NFPROTO_UNSPEC,
+ .name = "NOTRACK",
+ .alias = "CT",
+ .revision = 1,
+ .version = XTABLES_VERSION,
+ .size = XT_ALIGN(sizeof(struct xt_ct_target_info_v1)),
+ .userspacesize = offsetof(struct xt_ct_target_info_v1, ct),
+ .print = ct_tg_print,
+ .save = ct_tg_save,
+ .init = ct_tg_init_v1,
+ },
};
void _init(void)
{
- xtables_register_target(¬rack_target);
+ xtables_register_targets(ct_tg_target_reg, ARRAY_SIZE(ct_tg_target_reg));
}
diff --git a/include/xtables.h.in b/include/xtables.h.in
index db69c03..99a71a7 100644
--- a/include/xtables.h.in
+++ b/include/xtables.h.in
@@ -280,9 +280,11 @@ struct xtables_target
struct xtables_target *next;
-
const char *name;
+ /* Real target behind this, if any. */
+ const char *alias;
+
/* Revision of target (0 by default). */
u_int8_t revision;
diff --git a/iptables/ip6tables.c b/iptables/ip6tables.c
index b191d5d..cc708cd 100644
--- a/iptables/ip6tables.c
+++ b/iptables/ip6tables.c
@@ -1286,7 +1286,11 @@ static void command_jump(struct iptables_command_state *cs)
cs->target->t = xtables_calloc(1, size);
cs->target->t->u.target_size = size;
- strcpy(cs->target->t->u.user.name, cs->jumpto);
+ if (cs->target->alias == NULL)
+ strcpy(cs->target->t->u.user.name, cs->jumpto);
+ else
+ strcpy(cs->target->t->u.user.name, cs->target->alias);
+
cs->target->t->u.user.revision = cs->target->revision;
xs_init_target(cs->target);
if (cs->target->x6_options != NULL)
diff --git a/iptables/iptables.c b/iptables/iptables.c
index 03ac63b..eb58b8c 100644
--- a/iptables/iptables.c
+++ b/iptables/iptables.c
@@ -1295,7 +1295,11 @@ static void command_jump(struct iptables_command_state *cs)
cs->target->t = xtables_calloc(1, size);
cs->target->t->u.target_size = size;
- strcpy(cs->target->t->u.user.name, cs->jumpto);
+ if (cs->target->alias == NULL)
+ strcpy(cs->target->t->u.user.name, cs->jumpto);
+ else
+ strcpy(cs->target->t->u.user.name, cs->target->alias);
+
cs->target->t->u.user.revision = cs->target->revision;
xs_init_target(cs->target);
next prev parent reply other threads:[~2012-09-03 19:24 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-26 6:23 [Patch net-next] netfilter: remove xt_NOTRACK Cong Wang
2012-08-26 10:42 ` Maciej Żenczykowski
2012-08-26 20:04 ` Jan Engelhardt
2012-08-26 20:04 ` Jan Engelhardt
2012-09-03 7:57 ` Cong Wang
2012-09-03 7:57 ` Cong Wang
2012-09-03 8:33 ` Oliver
2012-09-03 11:50 ` Maciej Żenczykowski
2012-09-03 15:31 ` Pablo Neira Ayuso
2012-09-03 15:31 ` Pablo Neira Ayuso
2012-09-03 19:24 ` Pablo Neira Ayuso [this message]
2012-09-04 0:14 ` Maciej Żenczykowski
2012-09-04 3:57 ` Jan Engelhardt
2012-09-04 3:57 ` Jan Engelhardt
2012-09-04 5:29 ` Maciej Żenczykowski
2012-09-04 8:58 ` Pablo Neira Ayuso
2012-09-04 8:58 ` Pablo Neira Ayuso
2012-09-04 15:15 ` Jan Engelhardt
2012-09-04 15:15 ` Jan Engelhardt
2012-09-04 15:58 ` Pablo Neira Ayuso
2012-09-04 15:58 ` Pablo Neira Ayuso
2012-09-04 13:58 ` Pablo Neira Ayuso
2012-09-04 13:58 ` Pablo Neira Ayuso
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=20120903192455.GA3527@1984 \
--to=pablo@netfilter.org \
--cc=amwang@redhat.com \
--cc=davem@davemloft.net \
--cc=jengelh@inai.de \
--cc=kaber@trash.net \
--cc=netfilter-devel@vger.kernel.org \
--cc=netfilter@vger.kernel.org \
--cc=xiyou.wangcong@gmail.com \
--cc=zenczykowski@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.