From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Song Liu <song@kernel.org>
Cc: Nicolas Rybowski <nicolas.rybowski@tessares.net>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
Yonghong Song <yhs@fb.com>, Andrii Nakryiko <andriin@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@chromium.org>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Matthieu Baerts <matthieu.baerts@tessares.net>,
Mat Martineau <mathew.j.martineau@linux.intel.com>,
Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH bpf-next v2 1/5] bpf: expose is_mptcp flag to bpf_tcp_sock
Date: Mon, 14 Sep 2020 15:13:31 -0700 [thread overview]
Message-ID: <CAEf4Bza3yEmxEOXoS-sFBCBXju4O_z4XhC2Um+FM-3F793kz-A@mail.gmail.com> (raw)
In-Reply-To: <CAPhsuW74oqvhySsVqLKrtz9r-EJxHrXza0gSGK2nm6GnKjmakQ@mail.gmail.com>
On Mon, Sep 14, 2020 at 11:21 AM Song Liu <song@kernel.org> wrote:
>
> On Fri, Sep 11, 2020 at 8:07 AM Nicolas Rybowski
> <nicolas.rybowski@tessares.net> wrote:
> >
> > is_mptcp is a field from struct tcp_sock used to indicate that the
> > current tcp_sock is part of the MPTCP protocol.
> >
> > In this protocol, a first socket (mptcp_sock) is created with
> > sk_protocol set to IPPROTO_MPTCP (=262) for control purpose but it
> > isn't directly on the wire. This is the role of the subflow (kernel)
> > sockets which are classical tcp_sock with sk_protocol set to
> > IPPROTO_TCP. The only way to differentiate such sockets from plain TCP
> > sockets is the is_mptcp field from tcp_sock.
> >
> > Such an exposure in BPF is thus required to be able to differentiate
> > plain TCP sockets from MPTCP subflow sockets in BPF_PROG_TYPE_SOCK_OPS
> > programs.
> >
> > The choice has been made to silently pass the case when CONFIG_MPTCP is
> > unset by defaulting is_mptcp to 0 in order to make BPF independent of
> > the MPTCP configuration. Another solution is to make the verifier fail
> > in 'bpf_tcp_sock_is_valid_ctx_access' but this will add an additional
> > '#ifdef CONFIG_MPTCP' in the BPF code and a same injected BPF program
> > will not run if MPTCP is not set.
> >
> > An example use-case is provided in
> > https://github.com/multipath-tcp/mptcp_net-next/tree/scripts/bpf/examples
> >
> > Suggested-by: Matthieu Baerts <matthieu.baerts@tessares.net>
> > Acked-by: Matthieu Baerts <matthieu.baerts@tessares.net>
> > Acked-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
> > Signed-off-by: Nicolas Rybowski <nicolas.rybowski@tessares.net>
> > ---
> > include/uapi/linux/bpf.h | 1 +
> > net/core/filter.c | 9 ++++++++-
> > tools/include/uapi/linux/bpf.h | 1 +
> > 3 files changed, 10 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
> > index 7dd314176df7..7d179eada1c3 100644
> > --- a/include/uapi/linux/bpf.h
> > +++ b/include/uapi/linux/bpf.h
> > @@ -4060,6 +4060,7 @@ struct bpf_tcp_sock {
> > __u32 delivered; /* Total data packets delivered incl. rexmits */
> > __u32 delivered_ce; /* Like the above but only ECE marked packets */
> > __u32 icsk_retransmits; /* Number of unrecovered [RTO] timeouts */
> > + __u32 is_mptcp; /* Is MPTCP subflow? */
>
> Shall we have an __u32 flags, and make is_mptcp a bit of it?
>
Bitfields are slow and more annoying to rewrite in verifier, so having
an __u32 field is actually good.
> Thanks,
> Song
> [...]
prev parent reply other threads:[~2020-09-14 22:13 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-11 14:30 [PATCH bpf-next v2 1/5] bpf: expose is_mptcp flag to bpf_tcp_sock Nicolas Rybowski
2020-09-11 14:30 ` [PATCH bpf-next v2 2/5] mptcp: attach subflow socket to parent cgroup Nicolas Rybowski
2020-09-14 20:52 ` Song Liu
2020-09-11 14:30 ` [PATCH bpf-next v2 3/5] bpf: add 'bpf_mptcp_sock' structure and helper Nicolas Rybowski
2020-09-14 21:00 ` Song Liu
2020-09-11 14:30 ` [PATCH bpf-next v2 4/5] bpf: selftests: add MPTCP test base Nicolas Rybowski
2020-09-14 18:07 ` Song Liu
2020-09-15 16:35 ` Nicolas Rybowski
2020-09-15 17:18 ` Song Liu
2020-09-11 14:30 ` [PATCH bpf-next v2 5/5] bpf: selftests: add bpf_mptcp_sock() verifier tests Nicolas Rybowski
2020-09-14 18:08 ` Song Liu
2020-09-11 14:30 ` [PATCH bpf-next v2 0/5] bpf: add MPTCP subflow support Nicolas Rybowski
2020-09-14 18:20 ` [PATCH bpf-next v2 1/5] bpf: expose is_mptcp flag to bpf_tcp_sock Song Liu
2020-09-14 22:13 ` 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=CAEf4Bza3yEmxEOXoS-sFBCBXju4O_z4XhC2Um+FM-3F793kz-A@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=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@chromium.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathew.j.martineau@linux.intel.com \
--cc=matthieu.baerts@tessares.net \
--cc=netdev@vger.kernel.org \
--cc=nicolas.rybowski@tessares.net \
--cc=song@kernel.org \
--cc=songliubraving@fb.com \
--cc=yhs@fb.com \
/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).