* [PATCH] extensions: libxt_cgroup: Add translation to nft
@ 2016-01-08 19:53 Shivani Bhardwaj
2016-01-11 19:00 ` Pablo Neira Ayuso
0 siblings, 1 reply; 5+ messages in thread
From: Shivani Bhardwaj @ 2016-01-08 19:53 UTC (permalink / raw)
To: netfilter-devel
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] extensions: libxt_cgroup: Add translation to nft
2016-01-08 19:53 [PATCH] extensions: libxt_cgroup: Add translation to nft Shivani Bhardwaj
@ 2016-01-11 19:00 ` Pablo Neira Ayuso
0 siblings, 0 replies; 5+ messages in thread
From: Pablo Neira Ayuso @ 2016-01-11 19:00 UTC (permalink / raw)
To: Shivani Bhardwaj; +Cc: netfilter-devel
On Sat, Jan 09, 2016 at 01:23:13AM +0530, Shivani Bhardwaj wrote:
> 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
Please, rebase upon the xlate4 branch. Tejun sent us the cgroups2
updates and this patch doesn't apply on top of those.
Thanks Shivani.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] extensions: libxt_cgroup: Add translation to nft
@ 2016-06-09 19:54 Laura Garcia Liebana
2016-06-14 16:48 ` Pablo Neira Ayuso
0 siblings, 1 reply; 5+ messages in thread
From: Laura Garcia Liebana @ 2016-06-09 19:54 UTC (permalink / raw)
To: netfilter-devel
Add translation for cgroup to nft. Path parameter not supported in nft
yet.
Examples:
$ sudo iptables-translate -t filter -A INPUT -m cgroup --cgroup 0 -j ACCEPT
nft add rule ip filter INPUT meta cgroup 0 counter accept
$ sudo iptables-translate -t filter -A INPUT -m cgroup ! --cgroup 0 -j ACCEPT
nft add rule ip filter INPUT meta cgroup != 0 counter accept
Signed-off-by: Laura Garcia Liebana <nevola@gmail.com>
---
extensions/libxt_cgroup.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/extensions/libxt_cgroup.c b/extensions/libxt_cgroup.c
index 3be42ad..1191815 100644
--- a/extensions/libxt_cgroup.c
+++ b/extensions/libxt_cgroup.c
@@ -121,6 +121,32 @@ static void cgroup_save_v1(const void *ip, const struct xt_entry_match *match)
info->classid);
}
+static int cgroup_xlate_v0(const void *ip, const struct xt_entry_match *match,
+ struct xt_xlate *xl, int numeric)
+{
+ const struct xt_cgroup_info_v0 *info = (void *)match->data;
+
+ xt_xlate_add(xl, "meta cgroup %s%u ", info->invert ? "!= " : "",
+ info->id);
+ return 1;
+}
+
+static int cgroup_xlate_v1(const void *ip, const struct xt_entry_match *match,
+ struct xt_xlate *xl, int numeric)
+{
+ const struct xt_cgroup_info_v1 *info = (void *)match->data;
+
+ if (info->has_path)
+ return 0;
+
+ if (info->has_classid)
+ xt_xlate_add(xl, "meta cgroup %s%u ",
+ info->invert_classid ? "!= " : "",
+ info->classid);
+
+ return 1;
+}
+
static struct xtables_match cgroup_match[] = {
{
.family = NFPROTO_UNSPEC,
@@ -134,6 +160,7 @@ static struct xtables_match cgroup_match[] = {
.save = cgroup_save_v0,
.x6_parse = cgroup_parse_v0,
.x6_options = cgroup_opts_v0,
+ .xlate = cgroup_xlate_v0,
},
{
.family = NFPROTO_UNSPEC,
@@ -147,6 +174,7 @@ static struct xtables_match cgroup_match[] = {
.save = cgroup_save_v1,
.x6_parse = cgroup_parse_v1,
.x6_options = cgroup_opts_v1,
+ .xlate = cgroup_xlate_v1,
},
};
--
2.7.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] extensions: libxt_cgroup: Add translation to nft
2016-06-09 19:54 Laura Garcia Liebana
@ 2016-06-14 16:48 ` Pablo Neira Ayuso
2016-06-15 14:13 ` Laura Garcia
0 siblings, 1 reply; 5+ messages in thread
From: Pablo Neira Ayuso @ 2016-06-14 16:48 UTC (permalink / raw)
To: Laura Garcia Liebana; +Cc: netfilter-devel
On Thu, Jun 09, 2016 at 09:54:22PM +0200, Laura Garcia Liebana wrote:
> Add translation for cgroup to nft. Path parameter not supported in nft
> yet.
>
> Examples:
>
> $ sudo iptables-translate -t filter -A INPUT -m cgroup --cgroup 0 -j ACCEPT
> nft add rule ip filter INPUT meta cgroup 0 counter accept
>
> $ sudo iptables-translate -t filter -A INPUT -m cgroup ! --cgroup 0 -j ACCEPT
> nft add rule ip filter INPUT meta cgroup != 0 counter accept
Applied, thanks.
Please, document on the wikipage that we don't support yet the new
cgroup2 path-based on nft so we don't forget to discuss about this at
some point.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] extensions: libxt_cgroup: Add translation to nft
2016-06-14 16:48 ` Pablo Neira Ayuso
@ 2016-06-15 14:13 ` Laura Garcia
0 siblings, 0 replies; 5+ messages in thread
From: Laura Garcia @ 2016-06-15 14:13 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: netfilter-devel
On Tue, Jun 14, 2016 at 06:48:51PM +0200, Pablo Neira Ayuso wrote:
> Please, document on the wikipage that we don't support yet the new
> cgroup2 path-based on nft so we don't forget to discuss about this at
> some point.
Just included in the wiki.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-06-15 14:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-08 19:53 [PATCH] extensions: libxt_cgroup: Add translation to nft Shivani Bhardwaj
2016-01-11 19:00 ` 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
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).