From: Shivani Bhardwaj <shivanib134@gmail.com>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH v2] extensions: libxt_mark: Add translation to nft
Date: Sun, 6 Dec 2015 09:02:14 +0530 [thread overview]
Message-ID: <20151206033214.GA5939@gmail.com> (raw)
Add translation of the metainformation mark to nft.
Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
---
Changes in v2:
Fix syntax according to nft and remove trailing whitespaces
extensions/libxt_mark.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 62 insertions(+), 2 deletions(-)
diff --git a/extensions/libxt_mark.c b/extensions/libxt_mark.c
index 7f8c995..b0c06c2 100644
--- a/extensions/libxt_mark.c
+++ b/extensions/libxt_mark.c
@@ -75,7 +75,7 @@ mark_print(const void *ip, const struct xt_entry_match *match, int numeric)
if (info->invert)
printf(" !");
-
+
print_mark(info->mark, info->mask);
}
@@ -97,11 +97,69 @@ mark_save(const void *ip, const struct xt_entry_match *match)
if (info->invert)
printf(" !");
-
+
printf(" --mark");
print_mark(info->mark, info->mask);
}
+static void
+print_mark_xlate(struct xt_buf *buf,
+ unsigned int mark, unsigned int mask)
+{
+ if (mask != 0xffffffffU)
+ xt_buf_add(buf, " & x%x == x%x", mark, mask);
+ else
+ xt_buf_add(buf, " & x%x", mark);
+}
+
+static void
+mark_mt_xlate_print(const struct xt_entry_match *match,
+ struct xt_buf *buf, int numeric)
+{
+ const struct xt_mark_mtinfo1 *info = (const void *)match->data;
+
+ if (info->invert)
+ xt_buf_add(buf, " !=");
+ print_mark_xlate(buf, info->mark, info->mask);
+}
+
+static int
+mark_mt_xlate(const struct xt_entry_match *match,
+ struct xt_buf *buf, int numeric)
+{
+ const struct xt_mark_mtinfo1 *info = (const void *)match->data;
+
+ xt_buf_add(buf, "ct mark %s", info->invert ? " !=" : "");
+ print_mark_xlate(buf, info->mark, info->mask);
+ xt_buf_add(buf, " ");
+
+ return 1;
+}
+
+static void
+mark_xlate_print(const struct xt_entry_match *match,
+ struct xt_buf *buf, int numeric)
+{
+ const struct xt_mark_info *info = (const void *)match->data;
+
+ if (info->invert)
+ xt_buf_add(buf, " !=");
+ print_mark_xlate(buf, info->mark, info->mask);
+}
+
+static int
+mark_xlate(const struct xt_entry_match *match,
+ struct xt_buf *buf, int numeric)
+{
+ const struct xt_mark_info *info = (const void *)match->data;
+
+ xt_buf_add(buf, "ct mark %s", info->invert ? " !=" : "");
+ print_mark_xlate(buf, info->mark, info->mask);
+ xt_buf_add(buf, " ");
+
+ return 1;
+}
+
static struct xtables_match mark_mt_reg[] = {
{
.family = NFPROTO_UNSPEC,
@@ -115,6 +173,7 @@ static struct xtables_match mark_mt_reg[] = {
.save = mark_save,
.x6_parse = mark_parse,
.x6_options = mark_mt_opts,
+ .xlate = mark_xlate,
},
{
.version = XTABLES_VERSION,
@@ -128,6 +187,7 @@ static struct xtables_match mark_mt_reg[] = {
.save = mark_mt_save,
.x6_parse = mark_mt_parse,
.x6_options = mark_mt_opts,
+ .xlate = mark_mt_xlate,
},
};
--
1.9.1
next reply other threads:[~2015-12-06 3:32 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-06 3:32 Shivani Bhardwaj [this message]
2015-12-09 13:26 ` [PATCH v2] extensions: libxt_mark: Add translation to nft Pablo Neira Ayuso
2015-12-16 9:19 ` Shivani Bhardwaj
2015-12-17 22:26 ` Shivani Bhardwaj
2015-12-18 4:09 ` Shivani Bhardwaj
2015-12-18 21:40 ` Pablo Neira Ayuso
2015-12-19 5:56 ` Shivani Bhardwaj
2015-12-19 14:26 ` Shivani Bhardwaj
2015-12-19 17:47 ` Pablo Neira Ayuso
2015-12-19 18:11 ` Shivani Bhardwaj
2015-12-19 18:21 ` Shivani Bhardwaj
[not found] ` <20151219183443.GA2170@salvia>
2015-12-19 19:36 ` Shivani Bhardwaj
2015-12-20 2:18 ` 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=20151206033214.GA5939@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 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).