All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geliang Tang <geliang@kernel.org>
To: Matthieu Baerts <matttbe@kernel.org>,
	Mat Martineau <martineau@kernel.org>
Cc: Geliang Tang <tanggeliang@kylinos.cn>, mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-next v3 1/2] mptcp: add bpf_iter_task for mptcp_sock
Date: Fri, 21 Mar 2025 18:05:02 +0800	[thread overview]
Message-ID: <45ade20cc4eadcb81fa022aabac69f25d32fc16f.camel@kernel.org> (raw)
In-Reply-To: <fac4638e-9e00-4762-99d9-90826187fcf6@kernel.org>

Hi Matt,

On Fri, 2025-03-21 at 10:19 +0100, Matthieu Baerts wrote:
> Hi Geliang,
> 
> On 21/03/2025 05:14, Geliang Tang wrote:
> > On Tue, 2025-03-18 at 12:26 +0100, Matthieu Baerts wrote:
> 
> (...)
> 
> > > Mmh, all 8 callbacks from add_addr to here seem to be linked to
> > > Netlink
> > > commands, right? If yes, they should not be here: they don't make
> > > sense
> > > for a BPF PM, no? BPF PMs should be configured with BPF, and not
> > > via
> > 
> > Do you have any idea how we can pass commands like ADD_ADDR and
> > addresses from user space to BPF?
> 
> The userspace can inject any kind of BPF program. Additional
> addresses
> can then be hardcoded in this program, or it can load them from eBPF
> maps, or read skel->bss->(...), etc.
> 
> Netlink is then not needed.
> 
> > What I can think of is passing through sockopt, the user space
> > passes
> > the command and the address through setsockopt, and the BPF program
> > handles it through the custom "cgroup/setsockopt". I would like to
> > hear
> > your opinions. If you also agree to use sockopt to implement it, I
> > can
> > write a test program for this.

I just tested it and found it difficult to use setsockopt.

"cgroup/setsockopt" program doesn't work. We need to invoke sleepable
kfuncs in BPF PM:

BTF_ID_FLAGS(func, mptcp_pm_remove_addr_entry, KF_SLEEPABLE)
BTF_ID_FLAGS(func, mptcp_pm_addr_send_ack, KF_SLEEPABLE)
BTF_ID_FLAGS(func, mptcp_pm_mp_prio_send_ack, KF_SLEEPABLE)
BTF_ID_FLAGS(func, bpf_mptcp_subflow_connect, KF_SLEEPABLE)
BTF_ID_FLAGS(func, mptcp_subflow_shutdown, KF_SLEEPABLE)
BTF_ID_FLAGS(func, mptcp_close_ssk, KF_SLEEPABLE)

They can't be invoked in "cgroup/setsockopt" program. And
"cgroup/setsockopt" program can't be set with BPF_F_SLEEPABLE flag:

        err = err ?: bpf_program__set_flags(skel->progs.pm_setsockopt,
                                            BPF_F_SLEEPABLE);

With this error occurs:

test_bpf_hashmap_pm:PASS:set sleepable flags 0 nsec
libbpf: prog 'pm_setsockopt': BPF program load failed: -EINVAL
libbpf: prog 'pm_setsockopt': -- BEGIN PROG LOAD LOG --
Only fentry/fexit/fmod_ret, lsm, iter, uprobe, and struct_ops programs
can be sleepable
processed 0 insns (limit 1000000) max_states_per_insn 0 total_states 0
peak_states 0 mark_read 0

It seems that we can only choose one of fentry/fexit/fmod_ret, lsm,
iter, uprobe, or struct_ops type to implement BPF PM.

Thanks,
-Geliang

> That's a good idea for userspace apps which want to control how the
> MPTCP PM is acting. I guess MPTCP BPF PM will generally not be linked
> to
> network apps: a separate application dedicated to inject and
> configure
> the BPF PM, no?
> 
> Cheers,
> Matt


  reply	other threads:[~2025-03-21 10:05 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-10  3:30 [PATCH mptcp-next v3 0/2] add bpf_iter_task Geliang Tang
2025-03-10  3:30 ` [PATCH mptcp-next v3 1/2] mptcp: add bpf_iter_task for mptcp_sock Geliang Tang
2025-03-17  9:41   ` Geliang Tang
2025-03-17 10:29     ` Matthieu Baerts
2025-03-17 10:59       ` Geliang Tang
2025-03-17 13:57         ` Matthieu Baerts
2025-03-18  1:25           ` Mat Martineau
2025-03-18 10:54             ` Matthieu Baerts
2025-03-18 20:09               ` Mat Martineau
2025-03-18 10:35           ` Geliang Tang
2025-03-18 11:26             ` Matthieu Baerts
2025-03-21  4:14               ` Geliang Tang
2025-03-21  9:19                 ` Matthieu Baerts
2025-03-21 10:05                   ` Geliang Tang [this message]
2025-03-21 10:16                     ` Matthieu Baerts
2025-03-10  3:30 ` [PATCH mptcp-next v3 2/2] bpf: Customize mptcp's own sock lock Geliang Tang
2025-03-10  5:12 ` [PATCH mptcp-next v3 0/2] add bpf_iter_task 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=45ade20cc4eadcb81fa022aabac69f25d32fc16f.camel@kernel.org \
    --to=geliang@kernel.org \
    --cc=martineau@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.