netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHSET] netfilter, cgroup: implement xt_cgroup2 match
@ 2015-11-17 19:40 Tejun Heo
  2015-11-17 19:40 ` [PATCH 1/5] cgroup: record ancestor IDs and reimplement cgroup_is_descendant() using it Tejun Heo
                   ` (5 more replies)
  0 siblings, 6 replies; 22+ messages in thread
From: Tejun Heo @ 2015-11-17 19:40 UTC (permalink / raw)
  To: davem, pablo, kaber, kadlec, lizefan, hannes
  Cc: netdev, netfilter-devel, coreteam, cgroups, linux-kernel,
	kernel-team, daniel, daniel.wagner, nhorman

Hello,

In cgroup v1, dealing with cgroup membership was difficult because the
number of membership associations was unbound.  As a result, cgroup v1
grew several controllers whose primary purpose is either tagging
membership or pull in configuration knobs from other subsystems so
that cgroup membership test can be avoided.

net_cls and net_prio controllers are examples of the latter.  They
allow configuring network-specific attributes from cgroup side so that
network subsystem can avoid testing cgroup membership; unfortunately,
these are not only cumbersome but also problematic.

Both net_cls and net_prio aren't properly hierarchical.  Both inherit
configuration from the parent on creation but there's no interaction
afterwards.  An ancestor doesn't restrict the behavior in its subtree
in anyway and configuration changes aren't propagated downwards.
Especially when combined with cgroup delegation, this is problematic
because delegatees can mess up whatever network configuration
implemented at the system level.  net_prio would allow the delegatees
to set whatever priority value regardless of CAP_NET_ADMIN and net_cls
the same for classid.

While it is possible to solve these issues from controller side by
implementing hierarchical allowable ranges in both controllers, it
would involve quite a bit of complexity in the controllers and further
obfuscate network configuration as it becomes even more difficult to
tell what's actually being configured looking from the network side.
While not much can be done for v1 at this point, as membership
handling is sane on cgroup v2, it'd be better to make cgroup matching
behave like other network matches and classifiers than introducing
further complications.

Unfortunately, this ends up adding another cgroup related field to
struct sock - sock->sk_cgroup.  I tried to think of a way to overload
the fields for net_cls and net_prio but couldn't come up with a sane
way to do that.  In the long term, it should be possible to disable
net_cls and net_prio.

This patchset includes the following five patches.

 0001-cgroup-record-ancestor-IDs-and-reimplement-cgroup_is.patch
 0002-kernfs-implement-kernfs_walk_and_get.patch
 0003-cgroup-implement-cgroup_get_from_path-and-expose-cgr.patch
 0004-sock-cgroup-add-sock-sk_cgroup.patch
 0005-netfilter-implement-xt_cgroup2-match.patch

0001-0003 are prepatory patches in kernfs and cgroup.  0004 adds
sock->sk_cgroup to track socket to cgroup association.  0005
implements the new xt_cgroup2 match.

This patchset is on top of v4.4-rc1 and also available in the
following git branch.

 git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git review-xt_cgroup2

I'll post iptables extension as a reply.  diffstat follows.  Thanks.

 fs/kernfs/dir.c                           |   48 +++++++++++++++
 include/linux/cgroup-defs.h               |   14 ++++
 include/linux/cgroup.h                    |   33 ++++++++++
 include/linux/kernfs.h                    |   12 +++
 include/net/sock.h                        |    4 +
 include/uapi/linux/netfilter/xt_cgroup2.h |   14 ++++
 kernel/cgroup.c                           |   95 +++++++++++++++++++++---------
 net/core/sock.c                           |    2 
 net/netfilter/Kconfig                     |    9 ++
 net/netfilter/Makefile                    |    1 
 net/netfilter/xt_cgroup2.c                |   75 +++++++++++++++++++++++
 11 files changed, 278 insertions(+), 29 deletions(-)

--
tejun

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2015-11-17 23:09 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-17 19:40 [PATCHSET] netfilter, cgroup: implement xt_cgroup2 match Tejun Heo
2015-11-17 19:40 ` [PATCH 1/5] cgroup: record ancestor IDs and reimplement cgroup_is_descendant() using it Tejun Heo
2015-11-17 22:54   ` Jan Engelhardt
2015-11-17 23:03     ` Tejun Heo
2015-11-17 19:40 ` [PATCH 2/5] kernfs: implement kernfs_walk_and_get() Tejun Heo
2015-11-17 21:20   ` David Miller
2015-11-17 21:22     ` Tejun Heo
     [not found]     ` <20151117.162040.1412296298973879057.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2015-11-17 22:48       ` Jan Engelhardt
     [not found] ` <1447789240-29394-1-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-11-17 19:40   ` [PATCH 3/5] cgroup: implement cgroup_get_from_path() and expose cgroup_put() Tejun Heo
2015-11-17 19:40 ` [PATCH 4/5] sock, cgroup: add sock->sk_cgroup Tejun Heo
     [not found]   ` <1447789240-29394-5-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-11-17 21:25     ` David Miller
     [not found]       ` <20151117.162554.314531574043190960.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2015-11-17 21:31         ` Tejun Heo
     [not found]           ` <20151117213126.GH22864-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2015-11-17 21:46             ` David Miller
2015-11-17 21:48             ` Daniel Borkmann
2015-11-17 22:17               ` Tejun Heo
2015-11-17 21:46   ` Daniel Borkmann
     [not found]     ` <564BA036.4000602-FeC+5ew28dpmcu3hnIyYJQ@public.gmane.org>
2015-11-17 22:21       ` Tejun Heo
2015-11-17 19:40 ` [PATCH 5/5] netfilter: implement xt_cgroup2 match Tejun Heo
     [not found]   ` <1447789240-29394-6-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-11-17 22:56     ` Jan Engelhardt
2015-11-17 19:42 ` [PATCH iptables] libxt_cgroup2: add support for cgroup2 path matching Tejun Heo
2015-11-17 23:02   ` Jan Engelhardt
     [not found]     ` <alpine.LSU.2.20.1511172356570.13966-Og55a6x16tXH9RFtKMg/Ng@public.gmane.org>
2015-11-17 23:09       ` Tejun Heo

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).