MPTCP Archive mirror
 help / color / mirror / Atom feed
From: Geliang Tang <geliang@kernel.org>
To: Mat Martineau <martineau@kernel.org>
Cc: mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-next v5 06/14] selftests/bpf: Add mptcp subflow example
Date: Wed, 03 Apr 2024 10:21:52 +0800	[thread overview]
Message-ID: <693d06adab316872e68130afd47857a5b352ac0e.camel@kernel.org> (raw)
In-Reply-To: <4843ee1e-5983-34be-31a6-02b358616613@kernel.org>

On Mon, 2024-04-01 at 10:06 -0700, Mat Martineau wrote:
> On Thu, 28 Mar 2024, Geliang Tang wrote:
> 
> > From: Geliang Tang <tanggeliang@kylinos.cn>
> > 
> > Move Nicolas's patch into bpf selftests directory. This example
> > added a
> > test that was adding a different mark (SO_MARK) on each subflow,
> > and
> > changing the TCP CC only on the first subflow.
> > 
> > This example shows how it is possible to:
> > 
> >    Identify the parent msk of an MPTCP subflow.
> >    Put different sockopt for each subflow of a same MPTCP
> > connection.
> > 
> > Here especially, we implemented two different behaviours:
> > 
> >    A socket mark (SOL_SOCKET SO_MARK) is put on each subflow of a
> > same
> >    MPTCP connection. The order of creation of the current subflow
> > defines
> >    its mark. The TCP CC algorithm of the very first subflow of an
> > MPTCP
> >    connection is set to "reno".
> > 
> > Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/76
> > Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> 
> Hi Geliang -
> 
> This patch (and patch 07/14) are listed as "New" in patchwork, while
> the 
> rest of the series is superseded by "refactor mptcp bpf tests".
> 
> Do patches 6 and 7 of this series still need review? Are there any 
> dependencies on the "refactor bpf tests" series?

Hi Mat,

I changed them as "Superseded" since v6 of this series has been sent
out yesterday.

Thanks,
-Geliang

> 
> 
> Thanks,
> Mat
> 
> 
> > ---
> > .../selftests/bpf/progs/mptcp_subflow.c       | 73
> > +++++++++++++++++++
> > 1 file changed, 73 insertions(+)
> > create mode 100644
> > tools/testing/selftests/bpf/progs/mptcp_subflow.c
> > 
> > diff --git a/tools/testing/selftests/bpf/progs/mptcp_subflow.c
> > b/tools/testing/selftests/bpf/progs/mptcp_subflow.c
> > new file mode 100644
> > index 000000000000..9553099ffd5f
> > --- /dev/null
> > +++ b/tools/testing/selftests/bpf/progs/mptcp_subflow.c
> > @@ -0,0 +1,73 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/* Copyright (c) 2020, Tessares SA. */
> > +/* Copyright (c) 2024, Kylin Software */
> > +/* Author: Nicolas Rybowski */
> > +
> > +#include <sys/socket.h> // SOL_SOCKET, SO_MARK, ...
> > +#include <linux/tcp.h>  // TCP_CONGESTION
> > +#include <linux/bpf.h>
> > +#include <bpf/bpf_helpers.h>
> > +#include "bpf_tcp_helpers.h"
> > +
> > +char _license[] SEC("license") = "GPL";
> > +
> > +#ifndef SOL_TCP
> > +#define SOL_TCP 6
> > +#endif
> > +
> > +#ifndef TCP_CA_NAME_MAX
> > +#define TCP_CA_NAME_MAX 16
> > +#endif
> > +
> > +char cc[TCP_CA_NAME_MAX] = "reno";
> > +
> > +/* Associate a subflow counter to each token */
> > +struct {
> > +	__uint(type, BPF_MAP_TYPE_HASH);
> > +	__uint(key_size, sizeof(__u32));
> > +	__uint(value_size, sizeof(__u32));
> > +	__uint(max_entries, 100);
> > +} mptcp_sf SEC(".maps");
> > +
> > +SEC("sockops")
> > +int mptcp_subflow(struct bpf_sock_ops *skops)
> > +{
> > +	__u32 init = 1, key, mark, *cnt;
> > +	struct mptcp_sock *msk;
> > +	struct bpf_sock *sk;
> > +	int err;
> > +
> > +	if (skops->op != BPF_SOCK_OPS_TCP_CONNECT_CB)
> > +		return 1;
> > +
> > +	sk = skops->sk;
> > +	if (!sk)
> > +		return 1;
> > +
> > +	msk = bpf_skc_to_mptcp_sock(sk);
> > +	if (!msk)
> > +		return 1;
> > +
> > +	key = msk->token;
> > +	cnt = bpf_map_lookup_elem(&mptcp_sf, &key);
> > +	if (cnt) {
> > +		/* A new subflow is added to an existing MPTCP
> > connection */
> > +		__sync_fetch_and_add(cnt, 1);
> > +		mark = *cnt;
> > +	} else {
> > +		/* A new MPTCP connection is just initiated and
> > this is its primary
> > +		 *  subflow
> > +		 */
> > +		bpf_map_update_elem(&mptcp_sf, &key, &init,
> > BPF_ANY);
> > +		mark = init;
> > +	}
> > +
> > +	/* Set the mark of the subflow's socket to its apparition
> > order */
> > +	err = bpf_setsockopt(skops, SOL_SOCKET, SO_MARK, &mark,
> > sizeof(mark));
> > +	if (err < 0)
> > +		return 1;
> > +	if (mark == 1)
> > +		err = bpf_setsockopt(skops, SOL_TCP,
> > TCP_CONGESTION, cc, TCP_CA_NAME_MAX);
> > +
> > +	return 1;
> > +}
> > -- 
> > 2.40.1
> > 
> > 
> > 
> 


  reply	other threads:[~2024-04-03  2:21 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-28  8:04 [PATCH mptcp-next v5 00/14] setsockopt per subflow: BPF Geliang Tang
2024-03-28  8:04 ` [PATCH mptcp-next v5 01/14] Squash to "selftests/bpf: Add bpf scheduler test" - fix Geliang Tang
2024-03-28  8:04 ` [PATCH mptcp-next v5 02/14] selftests/bpf: Refactor mptcp_sock test Geliang Tang
2024-03-28  8:04 ` [PATCH mptcp-next v5 03/14] selftests/bpf: Refactor mptcpify test Geliang Tang
2024-03-28  8:04 ` [PATCH mptcp-next v5 04/14] selftests/bpf: Add MPTCP_BASE_TEST macro Geliang Tang
2024-03-28  8:04 ` [PATCH mptcp-next v5 05/14] selftests/bpf: Add RUN_MPTCP_TEST macro Geliang Tang
2024-03-28  8:04 ` [PATCH mptcp-next v5 06/14] selftests/bpf: Add mptcp subflow example Geliang Tang
2024-04-01 17:06   ` Mat Martineau
2024-04-03  2:21     ` Geliang Tang [this message]
2024-03-28  8:04 ` [PATCH mptcp-next v5 07/14] selftests/bpf: Add mptcp subflow subtest Geliang Tang
2024-03-28  8:04 ` [PATCH mptcp-next v5 08/14] Squash to "selftests/bpf: Add bpf scheduler test" - cleanups Geliang Tang
2024-03-28  8:04 ` [PATCH mptcp-next v5 09/14] Squash to "selftests/bpf: Add bpf_first test" Geliang Tang
2024-03-28  8:04 ` [PATCH mptcp-next v5 10/14] Squash to "selftests/bpf: Add bpf_bkup test" Geliang Tang
2024-03-28  8:04 ` [PATCH mptcp-next v5 11/14] Squash to "selftests/bpf: Add bpf_rr test" Geliang Tang
2024-03-28  8:04 ` [PATCH mptcp-next v5 12/14] Squash to "selftests/bpf: Add bpf_red test" Geliang Tang
2024-03-28  8:05 ` [PATCH mptcp-next v5 13/14] Squash to "selftests/bpf: Add bpf_burst test" Geliang Tang
2024-03-28  8:05 ` [PATCH mptcp-next v5 14/14] Squash to "selftests/bpf: Add bpf scheduler test" Geliang Tang
2024-03-28  8:16 ` [PATCH mptcp-next v5 00/14] setsockopt per subflow: BPF Matthieu Baerts
2024-03-28  8:54 ` MPTCP CI

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=693d06adab316872e68130afd47857a5b352ac0e.camel@kernel.org \
    --to=geliang@kernel.org \
    --cc=martineau@kernel.org \
    --cc=mptcp@lists.linux.dev \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).