From: rodanber@gmail.com
To: arturo.borrero.glez@gmail.com, netfilter-devel@vger.kernel.org
Cc: pablo@netfilter.org, "Roberto García" <rodanber@gmail.com>
Subject: [PATCH] iptables: extensions: libxt_ecn: Add translation to nft
Date: Tue, 28 Jun 2016 21:58:57 +0200 [thread overview]
Message-ID: <1467143937-19755-1-git-send-email-rodanber@gmail.com> (raw)
From: Roberto García <rodanber@gmail.com>
Add translation of the ecn match to nftables.
Examples:
# iptables-translate -A INPUT -m ecn --ecn-ip-ect 0
nft add rule ip filter INPUT ip ecn not-ect counter
# iptables-translate -A INPUT -m ecn --ecn-ip-ect 1
nft add rule ip filter INPUT ip ecn ect1 counter
# iptables-translate -A INPUT -m ecn --ecn-ip-ect 2
nft add rule ip filter INPUT ip ecn ect0 counter
# iptables-translate -A INPUT -m ecn --ecn-ip-ect 3
nft add rule ip filter INPUT ip ecn ce counter
# iptables-translate -A INPUT -m ecn ! --ecn-ip-ect 0
nft add rule ip filter INPUT ip ecn != not-ect counter
# iptables-translate -A INPUT -m ecn ! --ecn-ip-ect 1
nft add rule ip filter INPUT ip ecn != ect1 counter
# iptables-translate -A INPUT -m ecn ! --ecn-ip-ect 2
nft add rule ip filter INPUT ip ecn != ect0 counter
# iptables-translate -A INPUT -m ecn ! --ecn-ip-ect 3
nft add rule ip filter INPUT ip ecn != ce counter
Signed-off-by: Roberto García <rodanber@gmail.com>
---
extensions/libxt_ecn.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/extensions/libxt_ecn.c b/extensions/libxt_ecn.c
index 286782a..8e0c35b 100644
--- a/extensions/libxt_ecn.c
+++ b/extensions/libxt_ecn.c
@@ -118,6 +118,50 @@ static void ecn_save(const void *ip, const struct xt_entry_match *match)
}
}
+static int ecn_xlate(const void *ip, const struct xt_entry_match *match,
+ struct xt_xlate *xl, int numeric)
+{
+ const struct xt_ecn_info *einfo =
+ (const struct xt_ecn_info *)match->data;
+
+ if (einfo->operation & XT_ECN_OP_MATCH_IP) {
+ xt_xlate_add(xl, "ip ecn ");
+ if (einfo->invert) {
+ switch (einfo->ip_ect) {
+ case 0:
+ xt_xlate_add(xl, "!= not-ect ");
+ break;
+ case 1:
+ xt_xlate_add(xl, "!= ect1 ");
+ break;
+ case 2:
+ xt_xlate_add(xl, "!= ect0 ");
+ break;
+ case 3:
+ xt_xlate_add(xl, "!= ce ");
+ break;
+ }
+ } else {
+ switch (einfo->ip_ect) {
+ case 0:
+ xt_xlate_add(xl, "not-ect ");
+ break;
+ case 1:
+ xt_xlate_add(xl, "ect1 ");
+ break;
+ case 2:
+ xt_xlate_add(xl, "ect0 ");
+ break;
+ case 3:
+ xt_xlate_add(xl, "ce ");
+ break;
+ }
+ }
+ return 1;
+ } else
+ return 0;
+}
+
static struct xtables_match ecn_mt_reg = {
.name = "ecn",
.version = XTABLES_VERSION,
@@ -130,6 +174,7 @@ static struct xtables_match ecn_mt_reg = {
.x6_parse = ecn_parse,
.x6_fcheck = ecn_check,
.x6_options = ecn_opts,
+ .xlate = ecn_xlate,
};
void _init(void)
--
2.8.0
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next reply other threads:[~2016-06-28 19:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-28 19:58 rodanber [this message]
2016-06-29 6:41 ` [PATCH] iptables: extensions: libxt_ecn: Add translation to nft Arturo Borrero Gonzalez
2016-06-29 8:29 ` Arturo Borrero Gonzalez
2016-06-29 8:50 ` Roberto García
-- strict thread matches above, loose matches on Subject: below --
2016-06-29 9:24 rodanber
2016-06-29 9:28 ` Arturo Borrero Gonzalez
2016-06-29 18:48 rodanber
2016-06-29 22:15 ` Roberto García
2016-07-01 14:17 ` 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=1467143937-19755-1-git-send-email-rodanber@gmail.com \
--to=rodanber@gmail.com \
--cc=arturo.borrero.glez@gmail.com \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.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 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.