From: John Fastabend <john.fastabend@gmail.com>
To: davem@davemloft.net, ast@fb.com
Cc: netdev@vger.kernel.org, daniel@iogearbox.net
Subject: [RFC PATCH 0/6] BPF socket redirect
Date: Thu, 03 Aug 2017 16:36:31 -0700 [thread overview]
Message-ID: <20170803232443.12107.24752.stgit@john-Precision-Tower-5810> (raw)
This series implements socket redirect for BPF using XDP redirect
as a model. The user flow and internals are similar in many ways.
First we add a new map type called, sockmap. A sockmap holds
references to sock structs. Next a bpf helper call is added to
support redirect between sockets,
bpf_sk_redirect_map(map, key, flags)
This allows BPF programs to redirect packets between sockets.
Finally, we need a call site, as a first call site to implement
we added hooks to recv_sock using the existing strparser blocks.
The call site is added via a new BPF attach map call.
For details see patches. The final patch provides a sample program
that shows a real example that uses cgroups.
I probably need a few more iterations of fixes/cleanup etc. to
get these ready for non-RFC submission, but because its working
with "real" traffic now and is running without issues getting
some feedback would be great. I tried to add comments in the code
with "TBD" around areas I know need some work or where I see a bug
could happen in the error case, etc.
For people who prefer git over pulling patches out of their mail
editor I've posted the code here,
https://github.com/jrfastab/linux-kernel-xdp/tree/kproxy_sockmap7
TBD:
- bpf program refcnting cleanup
- publish performance numbers
- probably a couple more iterations of cleanup
- build a better cover letter ;)
Thanks to Daniel Borkmann for reviewing and providing feedback even
though some of it just made it into the TBD column so far.
Parts of this code started with initial kproxy RFC patches (Tom
Herbert) here,
https://patchwork.ozlabs.org/patch/782406/
although its been heavily modified/changed/etc by now.
Some original ideas/dissussions around this started at netconf here
is a link with notes. Search for "In-kernel layer-7 proxying" and
presentation from Thomas Graf,
https://lwn.net/Articles/719985/
Sorry if I forgot citing anyone :) its just an RFC after all.
Thanks,
John
---
John Fastabend (6):
net: early init support for strparser
net: add sendmsg_locked and sendpage_locked to af_inet6
net: fixes for skb_send_sock
net: sockmap with sk redirect support
net: bpf, add skb to sk lookup routines
net: sockmap sample program
include/linux/bpf.h | 11 +
include/linux/bpf_types.h | 1
include/uapi/linux/bpf.h | 15 +
kernel/bpf/Makefile | 2
kernel/bpf/helpers.c | 20 +
kernel/bpf/sockmap.c | 623 +++++++++++++++++++++++++++++
kernel/bpf/syscall.c | 41 ++
net/core/filter.c | 87 ++++
net/core/skbuff.c | 2
net/ipv6/af_inet6.c | 2
net/socket.c | 2
net/strparser/strparser.c | 10
samples/sockmap/Makefile | 78 ++++
samples/sockmap/sockmap_kern.c | 143 +++++++
samples/sockmap/sockmap_user.c | 84 ++++
tools/include/uapi/linux/bpf.h | 1
tools/lib/bpf/bpf.c | 11 -
tools/lib/bpf/bpf.h | 4
tools/testing/selftests/bpf/bpf_helpers.h | 12 +
19 files changed, 1136 insertions(+), 13 deletions(-)
create mode 100644 kernel/bpf/sockmap.c
create mode 100644 samples/sockmap/Makefile
create mode 100644 samples/sockmap/sockmap_kern.c
create mode 100644 samples/sockmap/sockmap_user.c
next reply other threads:[~2017-08-03 23:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-03 23:36 John Fastabend [this message]
2017-08-03 23:36 ` [RFC PATCH 1/6] net: early init support for strparser John Fastabend
2017-08-03 23:37 ` [RFC PATCH 2/6] net: add sendmsg_locked and sendpage_locked to af_inet6 John Fastabend
2017-08-03 23:37 ` [RFC PATCH 3/6] net: fixes for skb_send_sock John Fastabend
2017-08-03 23:37 ` [RFC PATCH 4/6] net: sockmap with sk redirect support John Fastabend
2017-08-04 4:22 ` Tom Herbert
2017-08-04 4:49 ` John Fastabend
2017-08-04 4:49 ` John Fastabend
2017-08-03 23:38 ` [RFC PATCH 5/6] net: bpf, add skb to sk lookup routines John Fastabend
2017-08-03 23:38 ` [RFC PATCH 6/6] net: sockmap sample program John Fastabend
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=20170803232443.12107.24752.stgit@john-Precision-Tower-5810 \
--to=john.fastabend@gmail.com \
--cc=ast@fb.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.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