netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shivani Bhardwaj <shivanib134@gmail.com>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH] extensions: libxt_cgroup: Add translation to nft
Date: Sat, 9 Jan 2016 01:23:13 +0530	[thread overview]
Message-ID: <20160108195313.GA2507@gmail.com> (raw)

Add translation for the network classifier cgroup to nftables.

Examples:

$ sudo iptables-translate -A input -m cgroup --cgroup 0x100001 -j DROP
nft add rule ip filter input meta cgroup 1048577 counter drop

$ sudo iptables-translate -A input -m cgroup ! --cgroup 0x100001 -j DROP
nft add rule ip filter input meta cgroup != 1048577 counter drop

Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
---
 extensions/libxt_cgroup.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/extensions/libxt_cgroup.c b/extensions/libxt_cgroup.c
index e304e33..dea1417 100644
--- a/extensions/libxt_cgroup.c
+++ b/extensions/libxt_cgroup.c
@@ -48,6 +48,17 @@ static void cgroup_save(const void *ip, const struct xt_entry_match *match)
 	printf("%s --cgroup %u", info->invert ? " !" : "", info->id);
 }
 
+static int cgroup_xlate(const struct xt_entry_match *match,
+			struct xt_buf *buf, int numeric)
+{
+	const struct xt_cgroup_info *info = (void *) match->data;
+
+	xt_buf_add(buf, "meta cgroup%s %u ",
+		   info->invert ? " !=" : "", info->id);
+
+	return 1;
+}
+
 static struct xtables_match cgroup_match = {
 	.family		= NFPROTO_UNSPEC,
 	.name		= "cgroup",
@@ -59,6 +70,7 @@ static struct xtables_match cgroup_match = {
 	.save		= cgroup_save,
 	.x6_parse	= cgroup_parse,
 	.x6_options	= cgroup_opts,
+	.xlate		= cgroup_xlate,
 };
 
 void _init(void)
-- 
1.9.1


             reply	other threads:[~2016-01-08 19:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-08 19:53 Shivani Bhardwaj [this message]
2016-01-11 19:00 ` [PATCH] extensions: libxt_cgroup: Add translation to nft Pablo Neira Ayuso
  -- strict thread matches above, loose matches on Subject: below --
2016-06-09 19:54 Laura Garcia Liebana
2016-06-14 16:48 ` Pablo Neira Ayuso
2016-06-15 14:13   ` Laura Garcia

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=20160108195313.GA2507@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).