MPTCP Linux Development
 help / color / mirror / Atom feed
From: Martin KaFai Lau <martin.lau@linux.dev>
To: Geliang Tang <geliang@kernel.org>, Matthieu Baerts <matttbe@kernel.org>
Cc: Geliang Tang <tanggeliang@kylinos.cn>,
	mptcp@lists.linux.dev, Martin KaFai Lau <martin.lau@kernel.org>
Subject: Re: [PATCH mptcp-next 2/2] selftests/bpf: Add getsockopt to inspect mptcp subflow
Date: Mon, 26 Aug 2024 22:22:32 -0700	[thread overview]
Message-ID: <54ce6f90-e86c-4921-b1e0-423fcd655d32@linux.dev> (raw)
In-Reply-To: <010b2338434b7df67ac418ad7063543e91c946b9.camel@kernel.org>

On 8/26/24 2:24 AM, Geliang Tang wrote:
>> I'm not an expert in this, but I guess it means you cannot use
>> 'mptcp_subflow_active()', because it can modify the 'subflow'
>> structure
>> that you got with bpf_core_cast() for a read-only usage.
> 
> A read-only function will get the same error.
> 
> I added a read-only function mptcp_subflow_get_scheduled() for testing:
> 
> bool mptcp_subflow_get_scheduled(struct mptcp_subflow_context *subflow)
> {
>          return subflow->scheduled;
> }
> 
> And invoke it from BPF in mptcp_for_each_subflow() loop:
> 
> int BPF_PROG(bpf_first_get_subflow, struct mptcp_sock *msk,
>               struct mptcp_sched_data *data)
> {
>          struct mptcp_subflow_context *subflow, *tmp;
> 
>          mptcp_for_each_subflow(msk, tmp) {
>                  subflow = bpf_core_cast(tmp, struct
> mptcp_subflow_context);
>                  mptcp_subflow_get_scheduled(subflow);
>          }
>          return 0;
> }
> 
> The same "arg#0 is untrusted_ptr_ expected ptr_ or socket" occurs.
> 
> Hope Martin can give us a solution for this issue.

I don't know the context for this list walking + modify-by-kfunc usage, so the 
following could be a grain of salt.

It seems like fitting the bpf_iter use case. Take a look at some recent bpf_iter 
additions, e.g. bpf_iter_{task,css}_next(). Also the bpf_for_each macro usage in 
selftests. There may be some secondary things that need to consider, e.g. how 
the walked subflow is protected, rcu, refcnt...etc.


  parent reply	other threads:[~2024-08-27  5:22 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-20  8:44 [PATCH mptcp-next 0/2] fixes for "new MPTCP subflow subtest v4" Geliang Tang
2024-08-20  8:44 ` [PATCH mptcp-next 1/2] Squash to "selftests/bpf: Add mptcp subflow subtest" Geliang Tang
2024-08-20  8:53   ` Matthieu Baerts
2024-08-20  8:44 ` [PATCH mptcp-next 2/2] selftests/bpf: Add getsockopt to inspect mptcp subflow Geliang Tang
2024-08-20  9:48   ` Matthieu Baerts
2024-08-21  8:00     ` Geliang Tang
2024-08-21  9:37       ` Matthieu Baerts
2024-08-21 23:54         ` Martin KaFai Lau
2024-08-26  2:57         ` Geliang Tang
2024-08-26  8:44           ` Matthieu Baerts
2024-08-26  9:24             ` Geliang Tang
2024-08-26  9:49               ` Matthieu Baerts
2024-08-26 10:40                 ` Geliang Tang
2024-08-27  5:22               ` Martin KaFai Lau [this message]
2024-09-04 10:20                 ` Geliang Tang
2024-08-20  9:43 ` [PATCH mptcp-next 0/2] fixes for "new MPTCP subflow subtest v4" 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=54ce6f90-e86c-4921-b1e0-423fcd655d32@linux.dev \
    --to=martin.lau@linux.dev \
    --cc=geliang@kernel.org \
    --cc=martin.lau@kernel.org \
    --cc=matttbe@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=tanggeliang@kylinos.cn \
    /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