public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Stanislav Fomichev <sdf@google•com>
To: netdev@vger•kernel.org, bpf@vger•kernel.org
Cc: davem@davemloft•net, ast@kernel•org, daniel@iogearbox•net,
	Stanislav Fomichev <sdf@google•com>
Subject: [PATCH bpf-next 0/7] bpf: getsockopt and setsockopt hooks
Date: Tue,  4 Jun 2019 14:35:17 -0700	[thread overview]
Message-ID: <20190604213524.76347-1-sdf@google.com> (raw)

This series implements two new per-cgroup hooks: getsockopt and
setsockopt along with a new sockopt program type. The idea is pretty
similar to recently introduced cgroup sysctl hooks, but
implementation is simpler (no need to convert to/from strings).

What this can be applied to:
* move business logic of what tos/priority/etc can be set by
  containers (either pass or reject)
* handle existing options (or introduce new ones) differently by
  propagating some information in cgroup/socket local storage

Compared to a simple syscall/{g,s}etsockopt tracepoint, those
hooks are context aware. Meaning, they can access underlying socket
and use cgroup and socket local storage.

Stanislav Fomichev (7):
  bpf: implement getsockopt and setsockopt hooks
  bpf: sync bpf.h to tools/
  libbpf: support sockopt hooks
  selftests/bpf: test sockopt section name
  selftests/bpf: add sockopt test
  bpf: add sockopt documentation
  bpftool: support cgroup sockopt

 Documentation/bpf/index.rst                   |   1 +
 Documentation/bpf/prog_cgroup_sockopt.rst     |  42 +
 include/linux/bpf-cgroup.h                    |  29 +
 include/linux/bpf.h                           |   2 +
 include/linux/bpf_types.h                     |   1 +
 include/linux/filter.h                        |  19 +
 include/uapi/linux/bpf.h                      |  17 +-
 kernel/bpf/cgroup.c                           | 288 +++++++
 kernel/bpf/syscall.c                          |  19 +
 kernel/bpf/verifier.c                         |  12 +
 net/core/filter.c                             |   4 +-
 net/socket.c                                  |  18 +
 .../bpftool/Documentation/bpftool-cgroup.rst  |   7 +-
 .../bpftool/Documentation/bpftool-prog.rst    |   2 +-
 tools/bpf/bpftool/bash-completion/bpftool     |   8 +-
 tools/bpf/bpftool/cgroup.c                    |   5 +-
 tools/bpf/bpftool/main.h                      |   1 +
 tools/bpf/bpftool/prog.c                      |   3 +-
 tools/include/uapi/linux/bpf.h                |  17 +-
 tools/lib/bpf/libbpf.c                        |   5 +
 tools/lib/bpf/libbpf_probes.c                 |   1 +
 tools/testing/selftests/bpf/.gitignore        |   1 +
 tools/testing/selftests/bpf/Makefile          |   3 +-
 tools/testing/selftests/bpf/bpf_helpers.h     |   2 +
 .../selftests/bpf/test_section_names.c        |  10 +
 tools/testing/selftests/bpf/test_sockopt.c    | 789 ++++++++++++++++++
 26 files changed, 1293 insertions(+), 13 deletions(-)
 create mode 100644 Documentation/bpf/prog_cgroup_sockopt.rst
 create mode 100644 tools/testing/selftests/bpf/test_sockopt.c

-- 
2.22.0.rc1.311.g5d7573a151-goog

             reply	other threads:[~2019-06-04 21:35 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-04 21:35 Stanislav Fomichev [this message]
2019-06-04 21:35 ` [PATCH bpf-next 1/7] bpf: implement getsockopt and setsockopt hooks Stanislav Fomichev
2019-06-05 18:47   ` Martin Lau
2019-06-05 19:17     ` Stanislav Fomichev
2019-06-05 20:50       ` Martin Lau
2019-06-05 21:16         ` Stanislav Fomichev
2019-06-05 21:41           ` Martin Lau
2019-06-05 19:32   ` Andrii Nakryiko
2019-06-05 20:54     ` Stanislav Fomichev
2019-06-05 21:12       ` Andrii Nakryiko
2019-06-05 21:30         ` Stanislav Fomichev
2019-06-04 21:35 ` [PATCH bpf-next 2/7] bpf: sync bpf.h to tools/ Stanislav Fomichev
2019-06-04 21:35 ` [PATCH bpf-next 3/7] libbpf: support sockopt hooks Stanislav Fomichev
2019-06-04 21:35 ` [PATCH bpf-next 4/7] selftests/bpf: test sockopt section name Stanislav Fomichev
2019-06-04 21:35 ` [PATCH bpf-next 5/7] selftests/bpf: add sockopt test Stanislav Fomichev
2019-06-04 21:35 ` [PATCH bpf-next 6/7] bpf: add sockopt documentation Stanislav Fomichev
2019-06-04 21:35 ` [PATCH bpf-next 7/7] bpftool: support cgroup sockopt Stanislav Fomichev
2019-06-04 21:55   ` Jakub Kicinski

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=20190604213524.76347-1-sdf@google.com \
    --to=sdf@google$(echo .)com \
    --cc=ast@kernel$(echo .)org \
    --cc=bpf@vger$(echo .)kernel.org \
    --cc=daniel@iogearbox$(echo .)net \
    --cc=davem@davemloft$(echo .)net \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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