mptcp: add core-enforced subflow avoid flag
Subsystems (5)
v8 cover mptcp: add core-enforced subflow avoid flag
The MPTCP scheduler needs a persistent way for BPF schedulers to mark subflows that should be avoided across scheduling rounds.
This series introduces a scheduler-owned avoid flag in mptcp_subflow_context, exposes it to BPF struct_ops schedulers through a kfunc, and exports its state through MPTCP diagnostics.
The MPTCP core enforces the avoid preference for send and retransmission selection. Non-avoided subflows are preferred while preserving the existing active/backup selection priorities. Avoided subflows remain available as fallback candidates.
When a BPF scheduler schedules both avoided and non-avoided subflows, the core drops the avoided selections. If only avoided subflows are selected, the core retries through the default selector.
The second patch adds a BPF struct_ops selftest that deliberately schedules avoided and non-avoided subflows and checks core filtering and persistent avoid state across scheduling rounds.
Changes since v7:
- Enforce avoid preference in core send and retransmission selection.
- Preserve active/backup priorities and avoided fallback candidates.
- Exercise core filtering and persistent state in the BPF selftest.
- Handle scheduler success without a selected subflow correctly.
Kalpan Jani (2):
mptcp: sched: add subflow avoid flag for BPF schedulers
selftests: mptcp: bpf: exercise the subflow avoid flag across rounds
include/uapi/linux/mptcp.h | 1 + net/mptcp/bpf.c | 1 + net/mptcp/diag.c | 2 + net/mptcp/protocol.c | 76 +++++++--- net/mptcp/protocol.h | 3 + net/mptcp/sched.c | 141 ++++++++++++++++-- .../testing/selftests/bpf/prog_tests/mptcp.c | 15 ++ .../selftests/bpf/progs/mptcp_bpf_avoid.c | 86 +++++++++++ 8 files changed, 287 insertions(+), 38 deletions(-) create mode 100644 tools/testing/selftests/bpf/progs/mptcp_bpf_avoid.c
Signature · 1 line
2.43.0
PATCH v8 1/2 mptcp: sched: add subflow avoid flag for BPF schedulers
The core marks a subflow as stale after net.mptcp.stale_loss_cnt retransmission intervals without progress. That bit belongs to the core and is tightly coupled to the RTO: it gets cleared as soon as a packet is acked on the subflow (mptcp_subflow_active() calls mptcp_subflow_set_active() once rcv_tstamp moves forward).
"scheduled" doesn't cover this either. The core clears it right after every send/retrans pass the scheduler set it in, so there's no way to express "leave this subflow alone across future rounds" with it.
Add a scheduler-owned "avoid" bool to mptcp_subflow_context:
- only mptcp_subflow_set_avoid() writes it. It is exposed to BPF struct_ops schedulers as a kfunc with the same registration and filter as mptcp_subflow_set_scheduled(), so only a BPF scheduler can change its value;
- it is a standalone bool, alongside "scheduled" and "data_avail", rather than a bit in the adjacent flag bitfield. mptcp_subflow_data_available() clears map_valid, a bit in that bitfield, from the subflow's own receive path without holding the msk lock, while set_avoid() runs under the msk lock from BPF scheduler context. Bitfield writes are non-atomic read-modify-write operations on the whole containing word, so placing avoid there would race with that update and risk corrupting neighbouring bits. The standalone bool is accessed with READ_ONCE()/WRITE_ONCE();
- the flag is exported through MPTCP diagnostics, allowing userspace to observe whether a subflow has been marked as avoided.
Make the MPTCP core consume the avoid state. Both send and retransmission selection prefer non-avoided subflows while preserving the existing active/backup selection priority. Avoided subflows remain usable when no non-avoided alternative is available.
When a BPF scheduler schedules both avoided and non-avoided subflows, the core drops the avoided selections. If it schedules only avoided subflows, the core retries selection through the default selector. This makes avoid a core-enforced preference rather than state that each BPF scheduler must independently enforce.
---
Changes since v7:
- Enforce the avoid preference in the MPTCP core for send and retransmission selection.
- Prefer non-avoided subflows while preserving active/backup selection priorities and retaining avoided fallback candidates.
- Drop avoided BPF selections when eligible non-avoided selections exist; retry the default selector when only avoided subflows are selected.
- Handle scheduler success without a selected subflow correctly.
v7: https://lore.kernel.org/all/[email protected]/
--- include/uapi/linux/mptcp.h | 1 + net/mptcp/bpf.c | 1 + net/mptcp/diag.c | 2 + net/mptcp/protocol.c | 76 +++++++++++++------- net/mptcp/protocol.h | 3 + net/mptcp/sched.c | 141 +++++++++++++++++++++++++++++++++---- 6 files changed, 186 insertions(+), 38 deletions(-)
include/uapi/linux/mptcp.h +1 -0
@@ -22,6 +22,7 @@#define MPTCP_SUBFLOW_FLAG_FULLY_ESTABLISHED _BITUL(6)#define MPTCP_SUBFLOW_FLAG_CONNECTED _BITUL(7)#define MPTCP_SUBFLOW_FLAG_MAPVALID _BITUL(8) +#define MPTCP_SUBFLOW_FLAG_AVOID _BITUL(9)#define MPTCP_PM_CMD_GRP_NAME "mptcp_pm_cmds"#define MPTCP_PM_EV_GRP_NAME "mptcp_pm_events"
net/mptcp/bpf.c +1 -0
@@ -312,6 +312,7 @@ BTF_KFUNCS_START(bpf_mptcp_common_kfunc_ids) BTF_ID_FLAGS(func, bpf_mptcp_subflow_ctx, KF_RET_NULL) BTF_ID_FLAGS(func, bpf_mptcp_subflow_tcp_sock, KF_RET_NULL) BTF_ID_FLAGS(func, mptcp_subflow_set_scheduled) +BTF_ID_FLAGS(func, mptcp_subflow_set_avoid) BTF_ID_FLAGS(func, mptcp_subflow_active) BTF_ID_FLAGS(func, mptcp_set_timeout)BTF_ID_FLAGS (func, mptcp_wnd_end)
net/mptcp/diag.c +2 -0
@@ -49,6 +49,8 @@ static int subflow_get_info(struct sock *sk, struct sk_buff *skb, bool net_admin flags |=MPTCP_SUBFLOW_FLAG_BKUP_LOC ;if (READ_ONCE (sf->fully_established)) flags |=MPTCP_SUBFLOW_FLAG_FULLY_ESTABLISHED ; +if (READ_ONCE (sf->avoid)) + flags |=MPTCP_SUBFLOW_FLAG_AVOID ;if (sf->conn_finished) flags |=MPTCP_SUBFLOW_FLAG_CONNECTED ;if (sf->map_valid)
net/mptcp/protocol.c +52 -24
139 lines not on this page · raw message
net/mptcp/protocol.h +3 -0
@@ -607,6 +607,7 @@ struct mptcp_subflow_context { __unused :9 ;bool data_avail;bool scheduled; +bool avoid;/* pkt scheduler: skip subflow if possible */ bool pm_listener;/* a listener managed by the kernel PM? */ bool fully_established;/* path validated */ bool close_event_done;/* has done the post-closed part,
@@ -935,6 +936,8 @@ static inline bool __mptcp_subflow_active(struct mptcp_subflow_context *subflow)void mptcp_subflow_set_active (struct mptcp_subflow_context *subflow); +void mptcp_subflow_set_avoid (struct mptcp_subflow_context *subflow,bool avoid); +bool mptcp_subflow_active (struct mptcp_subflow_context *subflow);void mptcp_subflow_drop_ctx (struct sock *ssk);
net/mptcp/sched.c +127 -14
174 lines not on this page · raw message
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH mptcp-next v8 1/2] mptcp: sched: add subflow avoid flag for BPF schedulers
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider.
Critical: 1 · High: 0 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Critical] A BPF struct_ops scheduler can store a value other than 0 or 1 in the bool field subflow->avoid.
- [Medium] The core enforcement of avoid can throw away a usable BPF selection and send or retransmit nothing.
- [Low] The patch changes the result and scheduled-flag semantics of mptcp_sched_get_send() and mptcp_sched_get_retrans() for every…
--
mptcp: sched: add subflow avoid flag for BPF schedulers
This adds an "avoid" bool to mptcp_subflow_context. BPF struct_ops schedulers set it through a new mptcp_subflow_set_avoid() kfunc, and it is exported through MPTCP diag. The default send and retransmit selectors now prefer non-avoided subflows, and mptcp_sched_get_send() / mptcp_sched_get_retrans() either drop avoided selections or fall back to the default selector when only avoided subflows are scheduled.
Quoted 11 lines
net/mptcp/protocol.c +1
-1@@ -1639,26 +1639,30 @@ bool mptcp_subflow_active(struct mptcp_subflow_context *subflow)*/ struct sock *mptcp_subflow_get_send (struct mptcp_sock *msk) { -struct subflow_send_info send_info[SSK_MODE_MAX ]; +struct subflow_send_info send_info[SSK_MODE_MAX ][2 ];struct mptcp_subflow_context *subflow;
[ ... ]
Quoted 4 lines
net/mptcp/protocol.c +2
-0mptcp_for_each_subflow (msk, subflow) {bool backup = subflow->backup || subflow->request_bkup; +bool avoid =READ_ONCE (subflow->avoid); +int mode = backup ?SSK_MODE_BACKUP :SSK_MODE_ACTIVE ;
[ ... ]
net/mptcp/protocol.c struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk) · line 1684
Quoted 13 lines
net/mptcp/protocol.c +5
-4@@ -1673,17 +1677,29 @@ struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk)continue ; } - linger_time =div_u64 ((u64 )READ_ONCE (ssk->sk_wmem_queued) <<32 , pace); -if (linger_time < send_info[backup].linger_time) { - send_info[backup].ssk = ssk; - send_info[backup].linger_time = linger_time; + linger_time =div_u64 ((u64 )READ_ONCE (ssk->sk_wmem_queued) <<32 , + pace); +if (linger_time < send_info[mode][avoid].linger_time) { + send_info[mode][avoid].ssk = ssk; + send_info[mode][avoid].linger_time = linger_time;
[Severity: Critical]
Can subflow->avoid hold a value other than 0 or 1 here?
Its only writer is the new kfunc:
net/mptcp/sched.c:mptcp_subflow_set_avoid() {
WRITE_ONCE(subflow->avoid, avoid);
}The verifier treats the bool argument as a plain scalar. check_func_args() does no range check for ARG_SCALAR. The x86-64 JIT passes the full BPF R2 in RSI. The callee assumes a _Bool argument is already 0 or 1, so it stores the low byte unchanged.
libbpf also treats integer types as compatible for ksym externs. A struct_ops scheduler could declare the extern with a __u64 parameter and call mptcp_subflow_set_avoid(subflow, 0xff).
In that case, would send_info[mode][avoid] be indexed with a value up to 255? That would read and write .ssk and .linger_time on the stack, well past the end of the 2x2 array.
The same applies to mptcp_subflow_get_retrans(). There a struct sock pointer would be written past the end of the 2-element pick[] and backup[] arrays:
if (!pick[avoid]) pick[avoid] = ssk;
Could the kfunc take a u32 or int parameter and store !!avoid? Alternatively, the users could index with READ_ONCE(subflow->avoid) ? 1 : 0.
[ ... ]
Quoted 4 lines
net/mptcp/sched.c +0
-0
[ ... ]
Quoted 31 lines
net/mptcp/sched.c +21
-3@@ -182,34 +237,92 @@ int mptcp_sched_get_send(struct mptcp_sock *msk)return -EINVAL ; } -mptcp_for_each_subflow (msk, subflow) { -if (READ_ONCE (subflow->scheduled)) -return 0 ; + state =mptcp_sched_get_subflow_state (msk); +if (state ==MPTCP_SCHED_SUBFLOW_ELIGIBLE ) +return 0 ; + +if (state ==MPTCP_SCHED_SUBFLOW_AVOIDED_ONLY ) { +mptcp_sched_clear_scheduled (msk); +return mptcp_sched_default_get_send (msk); }if (msk->sched == &mptcp_sched_default || !msk->sched) + err =mptcp_sched_default_get_send (msk); +else + err = msk->sched->get_send (msk); + + state =mptcp_sched_get_subflow_state (msk); +if (state ==MPTCP_SCHED_SUBFLOW_ELIGIBLE ) { +if (err) { +mptcp_sched_clear_scheduled (msk); +return err; + } +return 0 ; + } + +if (state ==MPTCP_SCHED_SUBFLOW_AVOIDED_ONLY ) {
net/mptcp/sched.c int mptcp_sched_get_send(struct mptcp_sock *msk) · line 273
Quoted 10 lines
net/mptcp/sched.c +9
-0+if (err) { +mptcp_sched_clear_scheduled (msk); +return err; + } + +if (msk->sched == &mptcp_sched_default || !msk->sched) +return 0 ; + +mptcp_sched_clear_scheduled (msk);return mptcp_sched_default_get_send (msk);
[Severity: Medium]
Can this throw away a usable selection from the BPF scheduler and send nothing?
The commit message says:
"Avoided subflows remain usable when no non-avoided alternative is available."
Suppose a scheduler returns 0 with only an avoided subflow X scheduled. This branch clears X and uses the default selector instead.
mptcp_subflow_get_send() now always takes the best non-avoided candidate Y when there is one. It checks free memory only on that candidate:
ssk = send_info[SSK_MODE_ACTIVE][0].ssk; if (!ssk) ssk = send_info[SSK_MODE_ACTIVE][1].ssk; ... if (!ssk || !sk_stream_memory_free(ssk)) return NULL;
If Y has full wmem and X has room, the result is -EINVAL. __mptcp_push_pending() then stops without sending, even though X was the scheduler's explicit choice.
mptcp_sched_get_retrans() has the same override. mptcp_subflow_get_retrans() skips any subflow that still has TCP-level data queued:
if (!tcp_rtx_and_write_queues_empty(ssk)) {
...
continue;
}It also uses backups only when min_stale_count > 1. So if a BPF get_retrans() picks an avoided subflow with data in flight, could that become -EINVAL and leave __mptcp_retrans() with nothing retransmitted? Before this patch the BPF selection was used.
The early AVOIDED_ONLY branch at function entry acts on leftover scheduled flags. One example is a flag left on a delegated subflow by __mptcp_subflow_push_pending(). Another is an avoided fallback picked by the default selector itself.
Is it intended that this branch replaces those flags with a fresh default selection before msk->sched->get_send() runs? That path also updates msk->snd_burst, avg_pacing_rate and timer_ival for a BPF-scheduled socket. The retrans entry path has the same branch.
The stall seems to recover once wmem frees, a subflow goes stale, or the rtx timer fires. Still, avoid acts as more than a preference here.
net/mptcp/sched.c int mptcp_sched_get_send(struct mptcp_sock *msk) · line 277
Quoted 5 lines
net/mptcp/sched.c +3
-1-return msk->sched->get_send (msk); + } + +return err ?: -EINVAL ; }
[Severity: Low]
This changes the return value and scheduled-flag behaviour for every scheduler, including BPF schedulers that never call mptcp_subflow_set_avoid(). Should the commit message describe this?
A scheduler that returns 0 with nothing scheduled now gets -EINVAL. Before, the 0 was passed through.
In __mptcp_subflow_push_pending(), the old behaviour could keep the loop
spinning: keep_pushing stays true and the scheduler is called again on every iteration:
if (mptcp_sched_get_send(msk)) goto out;
So this looks like a fix for an existing hang. Would it fit better as a separate patch with a Fixes: tag, so it can be considered for stable?
Two more changes apply to all schedulers:
- A scheduler that returns an error after scheduling subflows now has all of its flags cleared.
- mptcp_sched_get_subflow_state() now clears scheduled on avoided subflows whenever a non-avoided subflow is also scheduled.
mptcp_sched_get_retrans() has the same changes.
The only mention is the changelog line "Handle scheduler success without a selected subflow correctly". It sits below the --- line, so it won't reach git history.
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124102214.3930527-1-kalpan.jani%40mpiricsoftware.com
PATCH v8 2/2 selftests: mptcp: bpf: exercise the subflow avoid flag across rounds
In reply to Kalpan JaniAdd a BPF struct_ops scheduler selftest for mptcp_subflow_set_avoid(), and add the required extern declarations for it and for mptcp_subflow_active().
The test marks the second subflow as avoided once it becomes available. Unlike a scheduler that filters avoided subflows itself, the test deliberately schedules both avoided and non-avoided subflows when they are active.
This exercises the MPTCP core enforcement: when both kinds are scheduled, the core must discard the avoided selection and retain the eligible one. When only avoided subflows are selected, the core falls back to its default selector.
The test also verifies that the avoid state persists across subsequent scheduling rounds without calling set_avoid() again. Per-msk state is kept in BPF_MAP_TYPE_SK_STORAGE, following the pattern used by mptcp_bpf_rr.c.
---
Changes since v7:
- Deliberately schedule both avoided and non-avoided active subflows to exercise MPTCP core filtering.
- Verify that the avoid state persists across scheduling rounds without setting the flag again.
- Keep per-MPTCP-socket test state in BPF_MAP_TYPE_SK_STORAGE.
v7: https://lore.kernel.org/all/[email protected]/
--- .../testing/selftests/bpf/prog_tests/mptcp.c | 15 ++++ .../selftests/bpf/progs/mptcp_bpf_avoid.c | 86 +++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 tools/testing/selftests/bpf/progs/mptcp_bpf_avoid.c
tools/testing/selftests/bpf/prog_tests/mptcp.c +15 -0
@@ -18,6 +18,7 @@#include "mptcp_bpf_rr.skel.h" #include "mptcp_bpf_red.skel.h" #include "mptcp_bpf_burst.skel.h" +#include "mptcp_bpf_avoid.skel.h" #define NS_TEST "mptcp_ns"#define ADDR_1 "10.0.1.1"
@@ -820,6 +821,18 @@ static void test_burst(void)mptcp_bpf_burst__destroy (skel); } +static void test_avoid (void ) +{ +struct mptcp_bpf_avoid *skel; + + skel =mptcp_bpf_avoid__open_and_load (); +if (!ASSERT_OK_PTR (skel,"open_and_load: avoid" )) +return ; + +test_bpf_sched (skel->maps.avoid,"avoid" ,WITH_DATA ,WITHOUT_DATA ); +mptcp_bpf_avoid__destroy (skel); +} +void test_mptcp (void ) {if (test__start_subtest ("base" ))
@@ -842,4 +855,6 @@ void test_mptcp(void)test_red ();if (test__start_subtest ("burst" ))test_burst (); +if (test__start_subtest ("avoid" )) +test_avoid (); }
tools/testing/selftests/bpf/progs/mptcp_bpf_avoid.c new file +86 -0
86 lines not on this page · raw message
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH mptcp-next v8 2/2] selftests: mptcp: bpf: exercise the subflow avoid flag across rounds
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 2
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [High] The kfunc mptcp_subflow_set_avoid() in net/mptcp/sched.c was added by the earlier commit "mptcp: sched: add subflow avoid flag for…
- [Low] The commit message says the test "exercises the MPTCP core enforcement" and lists two branches: both kinds scheduled (drop the…
- [Low] The 'avoid' subtest's only check is test_bpf_sched(..., WITH_DATA, WITHOUT_DATA).
--
selftests: mptcp: bpf: exercise the subflow avoid flag across rounds
This adds a BPF struct_ops MPTCP scheduler selftest. It marks the second subflow as avoided with mptcp_subflow_set_avoid(), then schedules both the avoided and the non-avoided subflows, so the MPTCP core has to filter out the avoided one. Per-msk state is kept in a BPF_MAP_TYPE_SK_STORAGE map, and the new "avoid" subtest expects data only on ADDR_1.
Quoted 4 lines
tools/testing/selftests/bpf/prog_tests/mptcp.c +0
-0
[ ... ]
tools/testing/selftests/bpf/prog_tests/mptcp.c static void test_burst(void) · line 832
Quoted 13 lines
tools/testing/selftests/bpf/prog_tests/mptcp.c +9
-0@@ -820,6 +821,18 @@ static void test_burst(void)mptcp_bpf_burst__destroy (skel); } +static void test_avoid (void ) +{ +struct mptcp_bpf_avoid *skel; + + skel =mptcp_bpf_avoid__open_and_load (); +if (!ASSERT_OK_PTR (skel,"open_and_load: avoid" )) +return ; + +test_bpf_sched (skel->maps.avoid,"avoid" ,WITH_DATA ,WITHOUT_DATA );
[Severity: Low]
Can this check tell the avoid filtering apart from a scheduler that never touches the second subflow? WITH_DATA on ADDR_1 and WITHOUT_DATA on ADDR_2 is the same expectation that test_first() uses.
Nothing records whether the second subflow joined, was marked avoided, or was scheduled. Nothing shows that mptcp_sched_get_subflow_state() took this branch either:
net/mptcp/sched.c:mptcp_sched_get_subflow_state() {
...
if (eligible && avoided) {
mptcp_for_each_subflow(msk, subflow) {
if (READ_ONCE(subflow->scheduled) &&
READ_ONCE(subflow->avoid))
mptcp_subflow_set_scheduled(subflow, false);
}
}
...
}If the second subflow never joins or never becomes active, bpf_avoid_get_send() never calls mptcp_subflow_set_avoid() or schedules it, and the test still passes.
The test also can't tell "retain the eligible one" apart from a core that drops the whole selection and falls back to mptcp_subflow_get_send(). That function prefers send_info[SSK_MODE_ACTIVE][0] over send_info[SSK_MODE_ACTIVE][1], so it would also pick ADDR_1.
Would it make sense to expose a counter or global from bpf_avoid_get_send() that userspace can assert on? Another option is to check the MPTCP_SUBFLOW_FLAG_AVOID flag that net/mptcp/diag.c already reports.
Quoted 2 lines
tools/testing/selftests/bpf/prog_tests/mptcp.c +2
-0+mptcp_bpf_avoid__destroy (skel); +}
[ ... ]
Quoted 5 lines
tools/testing/selftests/bpf/progs/mptcp_bpf_avoid.c new file +0
-0
[ ... ]
tools/testing/selftests/bpf/progs/mptcp_bpf_avoid.c line 62
Quoted 8 lines
tools/testing/selftests/bpf/progs/mptcp_bpf_avoid.c new file +8
-0+bpf_for_each (mptcp_subflow, subflow, (struct sock *)msk) { +if (!first) { + first = subflow; +continue ; + } + +if (!ptr->avoid_marked) { +mptcp_subflow_set_avoid (subflow, true);
[Severity: High]
This test only ever passes true here. That hides a problem in the kfunc it exercises, which was added by the earlier "mptcp: sched: add subflow avoid flag for BPF schedulers" patch:
net/mptcp/sched.c:__bpf_kfunc void mptcp_subflow_set_avoid(struct mptcp_subflow_context *subflow,
bool avoid)
{
WRITE_ONCE(subflow->avoid, avoid);
}The verifier handles scalar kfunc arguments as ARG_SCALAR and does not check the range of bool. libbpf also treats all BTF integer types as compatible.
So a struct_ops program can declare this extern with an int second argument and pass something like 42. On x86-64, the raw low byte then ends up in subflow->avoid.
The core then uses that byte directly as an index into on-stack arrays:
net/mptcp/protocol.c:mptcp_subflow_get_send() {
...
bool avoid = READ_ONCE(subflow->avoid);
...
if (linger_time < send_info[mode][avoid].linger_time) {
send_info[mode][avoid].ssk = ssk;
send_info[mode][avoid].linger_time = linger_time;
...
}mptcp_subflow_get_retrans() does the same:
if (subflow->backup || subflow->request_bkup) {
if (!backup[avoid])
backup[avoid] = ssk;
continue;
}
if (!pick[avoid])
pick[avoid] = ssk;With a value of 2..255, can this write a socket pointer and linger_time past the end of send_info[SSK_MODE_MAX][2], or past pick[2] and backup[2]? The bad value stays in the subflow context. Every later send or retransmit pass would repeat the out-of-bounds access.
Should mptcp_subflow_set_avoid() normalize the value, for example with WRITE_ONCE(subflow->avoid, !!avoid)?
tools/testing/selftests/bpf/progs/mptcp_bpf_avoid.c line 75
Quoted 13 lines
tools/testing/selftests/bpf/progs/mptcp_bpf_avoid.c new file +13
-0+ ptr->avoid_marked = true; + } + +if (mptcp_subflow_active (subflow)) { +mptcp_subflow_set_scheduled (subflow, true); + scheduled = true; + } + } + +if (first &&mptcp_subflow_active (first)) { +mptcp_subflow_set_scheduled (first, true); + scheduled = true; + }
[Severity: Low]
The commit message says:
This exercises the MPTCP core enforcement: when both kinds are scheduled, the core must discard the avoided selection and retain the eligible one. When only avoided subflows are selected, the core falls back to its default selector.
Is the second part actually covered by this test? This block schedules the first subflow whenever it is active. So whenever the avoided subflow is scheduled, a non-avoided one is scheduled too, and mptcp_sched_get_subflow_state() returns MPTCP_SCHED_SUBFLOW_ELIGIBLE.
Reaching the MPTCP_SCHED_SUBFLOW_AVOIDED_ONLY fallback in mptcp_sched_get_send() would need the first subflow to be inactive while the second one is active. Nothing in the test sets that up.
If that fallback were reached, mptcp_sched_default_get_send() would correctly fall back to send_info[SSK_MODE_ACTIVE][1], which is the avoided ADDR_2 subflow. Wouldn't test_avoid() then fail because of its WITHOUT_DATA expectation on ADDR_2?
Could the commit message be reworded to say that only the "both kinds scheduled" path is exercised?
Quoted 3 lines
tools/testing/selftests/bpf/progs/mptcp_bpf_avoid.c new file +3
-0+ +return scheduled ?0 :-1 ; +}
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124102214.3930527-1-kalpan.jani%40mpiricsoftware.com
Matthieu Baerts
maintainerHi Kalpan,
Quoted 2 lines · Kalpan Jani
The MPTCP scheduler needs a persistent way for BPF schedulers to mark subflows that should be avoided across scheduling rounds.
Thank you for the new version. I didn't review this series yet, but just a quick note: could you please not rename the patch series (here "mptcp:
add core-enforced subflow avoid flag" and before "mptcp: add scheduler-owned subflow avoid flag") otherwise it is hard for us to track versions, and it doesn't help to follow the modifications.
Ideally, try to do the same with the patches as well: change their titles only when the scope changes.
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Hi Matt,
Thank you for the feedback.
Understood. I'll keep the series title and individual patch titles consistent across future revisions, changing them only when the scope changes.
I'll follow this approach in the next version.
Cheers,
Kalpan Jani
From: Matthieu Baerts <[email protected]>
To: "Kalpan Jani"<[email protected]>
Cc: <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>
Date: Tue, 24 Nov 2026 16:20:54 +0530
Subject: Re: [PATCH mptcp-next v8 0/2] mptcp: add core-enforced subflow avoid flag
Quoted 21 lines
Hi Kalpan,
Quoted 2 lines · Kalpan Jani
The MPTCP scheduler needs a persistent way for BPF schedulers to mark subflows that should be avoided across scheduling rounds.
Thank you for the new version. I didn't review this series yet, but just a quick note: could you please not rename the patch series (here "mptcp:
add core-enforced subflow avoid flag" and before "mptcp: add scheduler-owned subflow avoid flag") otherwise it is hard for us to track versions, and it doesn't help to follow the modifications.Ideally, try to do the same with the patches as well: change their titles only when the scope changes.
Cheers,
MattSignature · 1 line
Sponsored by the NGI0 Core fund.