Skip to content

Commit 73c900a

Browse files
gdetalkuba-moo
authored andcommitted
mptcp: add net.mptcp.available_schedulers
The sysctl lists the available schedulers that can be set using net.mptcp.scheduler similarly to net.ipv4.tcp_available_congestion_control. Signed-off-by: Gregory Detal <[email protected]> Reviewed-by: Mat Martineau <[email protected]> Tested-by: Geliang Tang <[email protected]> Reviewed-by: Matthieu Baerts (NGI0) <[email protected]> Signed-off-by: Matthieu Baerts (NGI0) <[email protected]> Signed-off-by: Mat Martineau <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent ce5f6f7 commit 73c900a

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

include/net/mptcp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ struct mptcp_out_options {
9797
};
9898

9999
#define MPTCP_SCHED_NAME_MAX 16
100+
#define MPTCP_SCHED_MAX 128
101+
#define MPTCP_SCHED_BUF_MAX (MPTCP_SCHED_NAME_MAX * MPTCP_SCHED_MAX)
102+
100103
#define MPTCP_SUBFLOWS_MAX 8
101104

102105
struct mptcp_sched_data {

net/mptcp/ctrl.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,24 @@ static int proc_scheduler(struct ctl_table *ctl, int write,
133133
return ret;
134134
}
135135

136+
static int proc_available_schedulers(struct ctl_table *ctl,
137+
int write, void *buffer,
138+
size_t *lenp, loff_t *ppos)
139+
{
140+
struct ctl_table tbl = { .maxlen = MPTCP_SCHED_BUF_MAX, };
141+
int ret;
142+
143+
tbl.data = kmalloc(tbl.maxlen, GFP_USER);
144+
if (!tbl.data)
145+
return -ENOMEM;
146+
147+
mptcp_get_available_schedulers(tbl.data, MPTCP_SCHED_BUF_MAX);
148+
ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
149+
kfree(tbl.data);
150+
151+
return ret;
152+
}
153+
136154
static struct ctl_table mptcp_sysctl_table[] = {
137155
{
138156
.procname = "enabled",
@@ -187,6 +205,12 @@ static struct ctl_table mptcp_sysctl_table[] = {
187205
.mode = 0644,
188206
.proc_handler = proc_scheduler,
189207
},
208+
{
209+
.procname = "available_schedulers",
210+
.maxlen = MPTCP_SCHED_BUF_MAX,
211+
.mode = 0644,
212+
.proc_handler = proc_available_schedulers,
213+
},
190214
{
191215
.procname = "close_timeout",
192216
.maxlen = sizeof(unsigned int),
@@ -214,7 +238,8 @@ static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet)
214238
table[4].data = &pernet->stale_loss_cnt;
215239
table[5].data = &pernet->pm_type;
216240
table[6].data = &pernet->scheduler;
217-
table[7].data = &pernet->close_timeout;
241+
/* table[7] is for available_schedulers which is read-only info */
242+
table[8].data = &pernet->close_timeout;
218243

219244
hdr = register_net_sysctl_sz(net, MPTCP_SYSCTL_PATH, table,
220245
ARRAY_SIZE(mptcp_sysctl_table));

net/mptcp/protocol.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,7 @@ unsigned int mptcp_stale_loss_cnt(const struct net *net);
686686
unsigned int mptcp_close_timeout(const struct sock *sk);
687687
int mptcp_get_pm_type(const struct net *net);
688688
const char *mptcp_get_scheduler(const struct net *net);
689+
void mptcp_get_available_schedulers(char *buf, size_t maxlen);
689690
void __mptcp_subflow_fully_established(struct mptcp_sock *msk,
690691
struct mptcp_subflow_context *subflow,
691692
const struct mptcp_options_received *mp_opt);

net/mptcp/sched.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,28 @@ struct mptcp_sched_ops *mptcp_sched_find(const char *name)
5151
return ret;
5252
}
5353

54+
/* Build string with list of available scheduler values.
55+
* Similar to tcp_get_available_congestion_control()
56+
*/
57+
void mptcp_get_available_schedulers(char *buf, size_t maxlen)
58+
{
59+
struct mptcp_sched_ops *sched;
60+
size_t offs = 0;
61+
62+
rcu_read_lock();
63+
spin_lock(&mptcp_sched_list_lock);
64+
list_for_each_entry_rcu(sched, &mptcp_sched_list, list) {
65+
offs += snprintf(buf + offs, maxlen - offs,
66+
"%s%s",
67+
offs == 0 ? "" : " ", sched->name);
68+
69+
if (WARN_ON_ONCE(offs >= maxlen))
70+
break;
71+
}
72+
spin_unlock(&mptcp_sched_list_lock);
73+
rcu_read_unlock();
74+
}
75+
5476
int mptcp_register_scheduler(struct mptcp_sched_ops *sched)
5577
{
5678
if (!sched->get_subflow)

0 commit comments

Comments
 (0)