bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Jakub Sitnicki <jakub@cloudflare.com>
Cc: bpf <bpf@vger.kernel.org>, Networking <netdev@vger.kernel.org>,
	kernel-team <kernel-team@cloudflare.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Andrii Nakryiko <andriin@fb.com>,
	Lorenz Bauer <lmb@cloudflare.com>,
	Marek Majkowski <marek@cloudflare.com>,
	Martin KaFai Lau <kafai@fb.com>, Yonghong Song <yhs@fb.com>
Subject: Re: [PATCH bpf-next v4 00/16] Run a BPF program on socket lookup
Date: Wed, 15 Jul 2020 19:25:57 -0700	[thread overview]
Message-ID: <CAEf4Bza0o1km866baqy5DErZGR_BbHrjGX+AP7+p4V-nSrN7bQ@mail.gmail.com> (raw)
In-Reply-To: <20200713174654.642628-1-jakub@cloudflare.com>

On Mon, Jul 13, 2020 at 10:47 AM Jakub Sitnicki <jakub@cloudflare.com> wrote:
>
> Dependencies
> ============
>
> This patch series depends on:
>
> 1. 'bpf-multi-prog-prep' series in 'bpf' [0]
>    (commit 951f38cf0835 ("Merge branch 'bpf-multi-prog-prep'"))
> 2. "bpf: Shift and mask loads narrower than context field size" patch
>    https://lore.kernel.org/bpf/20200710173123.427983-1-jakub@cloudflare.com/
>

[...]

>
> Overview
> ========
>
> This series proposes a new BPF program type named BPF_PROG_TYPE_SK_LOOKUP,
> or BPF sk_lookup for short.
>
> BPF sk_lookup program runs when transport layer is looking up a listening
> socket for a new connection request (TCP), or when looking up an
> unconnected socket for a packet (UDP).
>
> This serves as a mechanism to overcome the limits of what bind() API allows
> to express. Two use-cases driving this work are:
>
>  (1) steer packets destined to an IP range, fixed port to a single socket
>
>      192.0.2.0/24, port 80 -> NGINX socket
>
>  (2) steer packets destined to an IP address, any port to a single socket
>
>      198.51.100.1, any port -> L7 proxy socket
>
> In its context, program receives information about the packet that
> triggered the socket lookup. Namely IP version, L4 protocol identifier, and
> address 4-tuple.
>
> To select a socket BPF program fetches it from a map holding socket
> references, like SOCKMAP or SOCKHASH, calls bpf_sk_assign(ctx, sk, ...)
> helper to record the selection, and returns SK_PASS code. Transport layer
> then uses the selected socket as a result of socket lookup.
>
> Alternatively, program can also fail the lookup (SK_DROP), or let the
> lookup continue as usual (SK_PASS without selecting a socket).
>
> This lets the user match packets with listening (TCP) or receiving (UDP)
> sockets freely at the last possible point on the receive path, where we
> know that packets are destined for local delivery after undergoing
> policing, filtering, and routing.
>
> Program is attached to a network namespace, similar to BPF flow_dissector.
> We add a new attach type, BPF_SK_LOOKUP, for this. Multiple programs can be
> attached at the same time, in which case their return values are aggregated
> according the rules outlined in patch #4 description.
>
> Series structure
> ================
>
> Patches are organized as so:
>
>  1: enables multiple link-based prog attachments for bpf-netns
>  2: introduces sk_lookup program type
>  3-4: hook up the program to run on ipv4/tcp socket lookup
>  5-6: hook up the program to run on ipv6/tcp socket lookup
>  7-8: hook up the program to run on ipv4/udp socket lookup
>  9-10: hook up the program to run on ipv6/udp socket lookup
>  11-13: libbpf & bpftool support for sk_lookup
>  14-16: verifier and selftests for sk_lookup
>
> Patches are also available on GH:
>
>   https://github.com/jsitnicki/linux/commits/bpf-inet-lookup-v4
>
> Follow-up work
> ==============
>
> I'll follow up with below items, which IMHO don't block the review:
>
> - benchmark results for udp6 small packet flood scenario,
> - user docs for new BPF prog type, Documentation/bpf/prog_sk_lookup.rst,
> - timeout for accept() in tests after extending network_helper.[ch].
>

Looks good to me overall. I've looked through networking-specific code
and didn't spot anything, but I might be missing some subtleties,
hopefully not, though.

I left a few suggestions, please take a look, and if they make sense,
apply them in the follow up(s). Thanks!

For the series:

Acked-by: Andrii Nakryiko <andriin@fb.com>

> Thanks to the reviewers for their feedback to this patch series:
>
> Cc: Alexei Starovoitov <ast@kernel.org>
> Cc: Andrii Nakryiko <andriin@fb.com>
> Cc: Lorenz Bauer <lmb@cloudflare.com>
> Cc: Marek Majkowski <marek@cloudflare.com>
> Cc: Martin KaFai Lau <kafai@fb.com>
> Cc: Yonghong Song <yhs@fb.com>
>
> -jkbs
>

[...]

      parent reply	other threads:[~2020-07-16  2:26 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-13 17:46 Jakub Sitnicki
2020-07-13 17:46 ` [PATCH bpf-next v4 01/16] bpf, netns: Handle multiple link attachments Jakub Sitnicki
2020-07-15 21:30   ` Andrii Nakryiko
2020-07-13 17:46 ` [PATCH bpf-next v4 02/16] bpf: Introduce SK_LOOKUP program type with a dedicated attach point Jakub Sitnicki
2020-07-16  1:41   ` Andrii Nakryiko
2020-07-16 12:17     ` Jakub Sitnicki
2020-07-13 17:46 ` [PATCH bpf-next v4 03/16] inet: Extract helper for selecting socket from reuseport group Jakub Sitnicki
2020-07-16  1:44   ` Andrii Nakryiko
2020-07-13 17:46 ` [PATCH bpf-next v4 04/16] inet: Run SK_LOOKUP BPF program on socket lookup Jakub Sitnicki
2020-07-16  2:23   ` Andrii Nakryiko
2020-07-16 12:32     ` Jakub Sitnicki
2020-07-13 17:46 ` [PATCH bpf-next v4 05/16] inet6: Extract helper for selecting socket from reuseport group Jakub Sitnicki
2020-07-13 17:46 ` [PATCH bpf-next v4 06/16] inet6: Run SK_LOOKUP BPF program on socket lookup Jakub Sitnicki
2020-07-13 17:46 ` [PATCH bpf-next v4 07/16] udp: Extract helper for selecting socket from reuseport group Jakub Sitnicki
2020-07-13 17:46 ` [PATCH bpf-next v4 08/16] udp: Run SK_LOOKUP BPF program on socket lookup Jakub Sitnicki
2020-07-13 17:46 ` [PATCH bpf-next v4 09/16] udp6: Extract helper for selecting socket from reuseport group Jakub Sitnicki
2020-07-13 17:46 ` [PATCH bpf-next v4 10/16] udp6: Run SK_LOOKUP BPF program on socket lookup Jakub Sitnicki
2020-07-13 17:46 ` [PATCH bpf-next v4 11/16] bpf: Sync linux/bpf.h to tools/ Jakub Sitnicki
2020-07-13 17:46 ` [PATCH bpf-next v4 12/16] libbpf: Add support for SK_LOOKUP program type Jakub Sitnicki
2020-07-13 17:46 ` [PATCH bpf-next v4 13/16] tools/bpftool: Add name mappings for SK_LOOKUP prog and attach type Jakub Sitnicki
2020-07-16  2:10   ` Andrii Nakryiko
2020-07-13 17:46 ` [PATCH bpf-next v4 14/16] selftests/bpf: Add verifier tests for bpf_sk_lookup context access Jakub Sitnicki
2020-07-16  2:13   ` Andrii Nakryiko
2020-07-13 17:46 ` [PATCH bpf-next v4 15/16] selftests/bpf: Rename test_sk_lookup_kern.c to test_ref_track_kern.c Jakub Sitnicki
2020-07-13 17:46 ` [PATCH bpf-next v4 16/16] selftests/bpf: Tests for BPF_SK_LOOKUP attach point Jakub Sitnicki
2020-07-16  2:19   ` Andrii Nakryiko
2020-07-16  2:25 ` Andrii Nakryiko [this message]

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=CAEf4Bza0o1km866baqy5DErZGR_BbHrjGX+AP7+p4V-nSrN7bQ@mail.gmail.com \
    --to=andrii.nakryiko@gmail.com \
    --cc=andriin@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=jakub@cloudflare.com \
    --cc=kafai@fb.com \
    --cc=kernel-team@cloudflare.com \
    --cc=kuba@kernel.org \
    --cc=lmb@cloudflare.com \
    --cc=marek@cloudflare.com \
    --cc=netdev@vger.kernel.org \
    --cc=yhs@fb.com \
    --subject='Re: [PATCH bpf-next v4 00/16] Run a BPF program on socket lookup' \
    /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

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