From: Martin KaFai Lau <kafai@fb.com>
To: Mat Martineau <mathew.j.martineau@linux.intel.com>, andrii@kernel.org
Cc: netdev@vger.kernel.org, bpf@vger.kernel.org,
Nicolas Rybowski <nicolas.rybowski@tessares.net>,
ast@kernel.org, daniel@iogearbox.net, mptcp@lists.linux.dev,
Matthieu Baerts <matthieu.baerts@tessares.net>
Subject: Re: [PATCH bpf-next v3 1/8] bpf: expose is_mptcp flag to bpf_tcp_sock
Date: Tue, 10 May 2022 17:48:18 -0700 [thread overview]
Message-ID: <20220511004818.qnfpzgepmg7xufwd@kafai-mbp.dhcp.thefacebook.com> (raw)
In-Reply-To: <20220502211235.142250-2-mathew.j.martineau@linux.intel.com>
On Mon, May 02, 2022 at 02:12:27PM -0700, Mat Martineau wrote:
> From: Nicolas Rybowski <nicolas.rybowski@tessares.net>
>
> 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.
There is already bpf_skc_to_tcp_sock() and its returned tcp_sock pointer
can access all fields of the "struct tcp_sock" without extending
the bpf_tcp_sock.
iiuc, I believe the needs to extend bpf_tcp_sock here is to make the
same bpf sockops prog works for kernel with and without CONFIG_MPTCP
because tp->is_mptcp is not always available:
struct tcp_sock {
/* ... */
#if IS_ENABLED(CONFIG_MPTCP)
bool is_mptcp;
#endif
};
Andrii, do you think bpf_core_field_exists() can be used in
the bpf prog to test if is_mptcp is available in the running kernel
such that the same bpf prog can be used in kernel with and without
CONFIG_MPTCP?
next prev parent reply other threads:[~2022-05-11 0:48 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-02 21:12 [PATCH bpf-next v3 0/8] bpf: mptcp: Support for mptcp_sock and is_mptcp Mat Martineau
2022-05-02 21:12 ` [PATCH bpf-next v3 1/8] bpf: expose is_mptcp flag to bpf_tcp_sock Mat Martineau
2022-05-11 0:48 ` Martin KaFai Lau [this message]
2022-05-11 5:02 ` Andrii Nakryiko
2022-05-11 6:10 ` Geliang Tang
2022-05-02 21:12 ` [PATCH bpf-next v3 2/8] bpf: add bpf_skc_to_mptcp_sock_proto Mat Martineau
2022-05-02 21:12 ` [PATCH bpf-next v3 3/8] selftests: bpf: Enable CONFIG_IKCONFIG_PROC in config Mat Martineau
2022-05-06 22:25 ` Andrii Nakryiko
2022-05-02 21:12 ` [PATCH bpf-next v3 4/8] selftests: bpf: add MPTCP test base Mat Martineau
2022-05-06 22:24 ` Andrii Nakryiko
2022-05-02 21:12 ` [PATCH bpf-next v3 5/8] selftests: bpf: test bpf_skc_to_mptcp_sock Mat Martineau
2022-05-06 22:26 ` Andrii Nakryiko
2022-05-09 9:00 ` Matthieu Baerts
2022-05-09 21:00 ` Andrii Nakryiko
2022-05-10 13:48 ` Matthieu Baerts
2022-05-02 21:12 ` [PATCH bpf-next v3 6/8] selftests: bpf: verify token of struct mptcp_sock Mat Martineau
2022-05-02 22:14 ` Mat Martineau
2022-05-06 22:27 ` Andrii Nakryiko
2022-05-10 21:59 ` Mat Martineau
2022-05-10 23:58 ` Andrii Nakryiko
2022-05-02 21:12 ` [PATCH bpf-next v3 7/8] selftests: bpf: verify ca_name " Mat Martineau
2022-05-02 21:12 ` [PATCH bpf-next v3 8/8] selftests: bpf: verify first " Mat Martineau
2022-05-06 22:28 ` [PATCH bpf-next v3 0/8] bpf: mptcp: Support for mptcp_sock and is_mptcp Andrii Nakryiko
2022-05-06 23:06 ` Mat Martineau
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=20220511004818.qnfpzgepmg7xufwd@kafai-mbp.dhcp.thefacebook.com \
--to=kafai@fb.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=mathew.j.martineau@linux.intel.com \
--cc=matthieu.baerts@tessares.net \
--cc=mptcp@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=nicolas.rybowski@tessares.net \
/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).