From: Daniel Mack <daniel@zonque.org>
To: htejun@fb.com, daniel@iogearbox.net, ast@fb.com
Cc: davem@davemloft.net, kafai@fb.com, fw@strlen.de,
pablo@netfilter.org, harald@redhat.com, netdev@vger.kernel.org,
Daniel Mack <daniel@zonque.org>
Subject: [RFC PATCH 2/5] cgroup: add bpf_{e,in}gress pointers
Date: Wed, 17 Aug 2016 16:00:45 +0200 [thread overview]
Message-ID: <1471442448-1248-3-git-send-email-daniel@zonque.org> (raw)
In-Reply-To: <1471442448-1248-1-git-send-email-daniel@zonque.org>
Add two pointers for eBPF programs to struct cgroup. These will be used
to store programs for ingress and egress for accounting and filtering.
This new feature is guarded by CONFIG_CGROUP_BPF.
Signed-off-by: Daniel Mack <daniel@zonque.org>
---
include/linux/cgroup-defs.h | 6 ++++++
init/Kconfig | 8 ++++++++
kernel/cgroup.c | 9 +++++++++
3 files changed, 23 insertions(+)
diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h
index 5b17de6..cff3560 100644
--- a/include/linux/cgroup-defs.h
+++ b/include/linux/cgroup-defs.h
@@ -300,6 +300,12 @@ struct cgroup {
/* used to schedule release agent */
struct work_struct release_agent_work;
+#ifdef CONFIG_CGROUP_BPF
+ /* used by the networking layer */
+ struct bpf_prog *bpf_ingress;
+ struct bpf_prog *bpf_egress;
+#endif
+
/* ids of the ancestors at each level including self */
int ancestor_ids[];
};
diff --git a/init/Kconfig b/init/Kconfig
index cac3f09..8bf2f3e 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1144,6 +1144,14 @@ config CGROUP_PERF
Say N if unsure.
+config CGROUP_BPF
+ bool "Enable eBPF programs in cgroups"
+ depends on BPF_SYSCALL
+ help
+ This options allows cgroups to accommodate eBPF programs that
+ can be used for network traffic filtering and accounting. See
+ Documentation/networking/filter.txt for more information.
+
config CGROUP_DEBUG
bool "Example controller"
default n
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index d1c51b7..65e5701 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -62,6 +62,7 @@
#include <linux/proc_ns.h>
#include <linux/nsproxy.h>
#include <linux/file.h>
+#include <linux/bpf.h>
#include <net/sock.h>
/*
@@ -5461,6 +5462,14 @@ static int cgroup_destroy_locked(struct cgroup *cgrp)
for_each_css(css, ssid, cgrp)
kill_css(css);
+#ifdef CONFIG_CGROUP_BPF
+ if (cgrp->bpf_ingress)
+ bpf_prog_put(cgrp->bpf_ingress);
+
+ if (cgrp->bpf_egress)
+ bpf_prog_put(cgrp->bpf_egress);
+#endif
+
/*
* Remove @cgrp directory along with the base files. @cgrp has an
* extra ref on its kn.
--
2.5.5
next prev parent reply other threads:[~2016-08-17 14:11 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-17 14:00 [RFC PATCH 0/5] Add eBPF hooks for cgroups Daniel Mack
2016-08-17 14:00 ` [RFC PATCH 1/5] bpf: add new prog type for cgroup socket filtering Daniel Mack
2016-08-17 14:00 ` Daniel Mack [this message]
2016-08-17 14:10 ` [RFC PATCH 2/5] cgroup: add bpf_{e,in}gress pointers Tejun Heo
2016-08-17 17:50 ` Alexei Starovoitov
2016-08-17 17:56 ` Tejun Heo
2016-08-17 14:00 ` [RFC PATCH 3/5] bpf: add BPF_PROG_ATTACH and BPF_PROG_DETACH commands Daniel Mack
2016-08-17 14:20 ` Tejun Heo
2016-08-17 14:35 ` Daniel Mack
2016-08-17 15:06 ` Tejun Heo
2016-08-17 15:51 ` Daniel Mack
2016-08-17 17:48 ` Alexei Starovoitov
2016-08-17 15:08 ` Tejun Heo
2016-08-17 16:16 ` Eric Dumazet
2016-08-17 18:10 ` Alexei Starovoitov
2016-08-18 15:17 ` Daniel Mack
2016-08-17 14:00 ` [RFC PATCH 4/5] net: filter: run cgroup eBPF programs Daniel Mack
2016-08-17 14:23 ` Tejun Heo
2016-08-17 14:36 ` Daniel Mack
2016-08-17 14:58 ` Tejun Heo
2016-08-17 18:20 ` Alexei Starovoitov
2016-08-17 18:23 ` Alexei Starovoitov
2016-08-21 20:14 ` Sargun Dhillon
2016-08-25 19:37 ` Tejun Heo
2016-08-17 14:00 ` [RFC PATCH 5/5] samples: bpf: add userspace example for attaching eBPF programs to cgroups Daniel Mack
2016-08-19 9:19 ` [RFC PATCH 0/5] Add eBPF hooks for cgroups Pablo Neira Ayuso
2016-08-19 10:35 ` Daniel Mack
2016-08-19 11:20 ` Daniel Borkmann
2016-08-19 16:31 ` Pablo Neira Ayuso
2016-08-19 16:37 ` Thomas Graf
2016-08-19 16:21 ` Pablo Neira Ayuso
2016-08-19 17:07 ` Thomas Graf
2016-08-22 16:06 ` Pablo Neira Ayuso
2016-08-22 16:22 ` Daniel Mack
2016-08-22 17:20 ` Sargun Dhillon
2016-08-23 8:27 ` Daniel Mack
2016-08-23 9:54 ` Sargun Dhillon
2016-08-23 10:03 ` Daniel Mack
2016-08-19 16:01 ` Alexei Starovoitov
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=1471442448-1248-3-git-send-email-daniel@zonque.org \
--to=daniel@zonque.org \
--cc=ast@fb.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=fw@strlen.de \
--cc=harald@redhat.com \
--cc=htejun@fb.com \
--cc=kafai@fb.com \
--cc=netdev@vger.kernel.org \
--cc=pablo@netfilter.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).