Re: [PATCH 5/5] netfilter: implement xt_cgroup2 match

From
Jan Engelhardt <hidden>
Date
2015-11-17 22:56:05
Also in
cgroups, lkml, netfilter-devel
Reply to
Tejun Heo, 2015-11-17
On Tuesday 2015-11-17 20:40, Tejun Heo wrote:
quoted hunk ↗ jump to hunk
@@ -0,0 +1,14 @@
+#ifndef _XT_CGROUP2_H
+#define _XT_CGROUP2_H
+
+#include <linux/types.h>
+
+struct xt_cgroup2_info {
+	char				path[PATH_MAX];
+	__u8				invert;
Should <linux/limits.h> be included? (For PATH_MAX)
quoted hunk ↗ jump to hunk
+	/* kernel internal data */
+	void				*priv;
+};
void *priv __attribute__((aligned(8)));
quoted hunk ↗ jump to hunk
+static bool cgroup2_mt(const struct sk_buff *skb, struct xt_action_param *par)
+{
+	const struct xt_cgroup2_info *info = par->matchinfo;
+	struct cgroup *ancestor = info->priv;
There is no modification planned on the cgroup, so this too can be const struct
cgroup * if-and-when cgroup_is_descendant is made to take const ptrs as well.
quoted hunk ↗ jump to hunk
+	if (!skb->sk || !sk_fullsock(skb->sk))
+		return false;
+
+	return cgroup_is_descendant(skb->sk->sk_cgroup, ancestor) ^ info->invert;
+}
Thread (22 messages) 22 messages, 4 authors, last reply 2015-11-17
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help