From: Shivani Bhardwaj <shivanib134@gmail.com>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH] extensions: libxt_MARK: Add translation to nft
Date: Wed, 23 Dec 2015 21:03:53 +0530 [thread overview]
Message-ID: <20151223153353.GA17748@gmail.com> (raw)
Add translation for target MARK to nftables.
Examples:
$ sudo iptables-translate -t mangle -A PREROUTING -j MARK --set-mark 12
nft add rule ip mangle PREROUTING counter mark set 0xc
$ sudo iptables-translate -t mangle -A PREROUTING -p tcp --dport 22 -j MARK --set-mark 2
nft add rule ip mangle PREROUTING tcp dport 22 counter mark set 0x2
Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
---
extensions/libxt_MARK.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/extensions/libxt_MARK.c b/extensions/libxt_MARK.c
index 556dbde..c5de763 100644
--- a/extensions/libxt_MARK.c
+++ b/extensions/libxt_MARK.c
@@ -242,7 +242,24 @@ static void mark_tg_save(const void *ip, const struct xt_entry_target *target)
{
const struct xt_mark_tginfo2 *info = (const void *)target->data;
- printf(" --set-xmark 0x%x/0x%x", info->mark, info->mask);
+ printf(" --set mark 0x%x/0x%x", info->mark, info->mask);
+}
+
+static void
+print_mark_xlate(unsigned long mark, struct xt_buf *buf)
+{
+ xt_buf_add(buf, " 0x%lx", mark);
+}
+
+static int mark_tg_xlate(const struct xt_entry_target *target,
+ struct xt_buf *buf, int numeric)
+{
+ const struct xt_mark_tginfo2 *info = (const void *)target->data;
+
+ xt_buf_add(buf, "mark set");
+ print_mark_xlate(info->mark, buf);
+
+ return 1;
}
static struct xtables_target mark_tg_reg[] = {
@@ -259,6 +276,7 @@ static struct xtables_target mark_tg_reg[] = {
.x6_parse = MARK_parse_v0,
.x6_fcheck = MARK_check,
.x6_options = MARK_opts,
+ .xlate = mark_tg_xlate,
},
{
.family = NFPROTO_IPV4,
@@ -273,6 +291,7 @@ static struct xtables_target mark_tg_reg[] = {
.x6_parse = MARK_parse_v1,
.x6_fcheck = MARK_check,
.x6_options = MARK_opts,
+ .xlate = mark_tg_xlate,
},
{
.version = XTABLES_VERSION,
@@ -287,6 +306,7 @@ static struct xtables_target mark_tg_reg[] = {
.x6_parse = mark_tg_parse,
.x6_fcheck = mark_tg_check,
.x6_options = mark_tg_opts,
+ .xlate = mark_tg_xlate,
},
};
--
1.9.1
next reply other threads:[~2015-12-23 15:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-23 15:33 Shivani Bhardwaj [this message]
2015-12-23 15:38 ` [PATCH] extensions: libxt_MARK: Add translation to nft Shivani Bhardwaj
2015-12-23 18:21 ` Florian Westphal
2015-12-23 16:15 ` Jan Engelhardt
2015-12-23 16:22 ` Shivani Bhardwaj
2015-12-25 12:14 ` Pablo Neira Ayuso
-- strict thread matches above, loose matches on Subject: below --
2015-12-05 13:19 [PATCH] extensions: libxt_mark: " Shivani Bhardwaj
2015-12-05 19:14 ` Pablo Neira Ayuso
2015-12-05 19:44 ` Shivani Bhardwaj
2015-12-05 23:14 ` Pablo Neira Ayuso
2015-12-06 2:48 ` Shivani Bhardwaj
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=20151223153353.GA17748@gmail.com \
--to=shivanib134@gmail.com \
--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 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.