Skip to content

Commit 466ab12

Browse files
Geliang Tangintel-lab-lkp
authored andcommitted
mptcp: sysctl: add available_path_managers
Similarly to net.mptcp.available_schedulers, this patch adds a new one net.mptcp.available_path_managers to list the available path managers. Signed-off-by: Geliang Tang <[email protected]>
1 parent ce988b8 commit 466ab12

File tree

5 files changed

+51
-0
lines changed

5 files changed

+51
-0
lines changed

Documentation/networking/mptcp-sysctl.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ allow_join_initial_addr_port - BOOLEAN
3030

3131
Default: 1
3232

33+
available_path_managers - STRING
34+
Shows the available path managers choices that are registered. More
35+
path managers may be available, but not loaded.
36+
3337
available_schedulers - STRING
3438
Shows the available schedulers choices that are registered. More packet
3539
schedulers may be available, but not loaded.

include/net/mptcp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ struct mptcp_sched_ops {
114114
} ____cacheline_aligned_in_smp;
115115

116116
#define MPTCP_PM_NAME_MAX 16
117+
#define MPTCP_PM_MAX 128
118+
#define MPTCP_PM_BUF_MAX (MPTCP_PM_NAME_MAX * MPTCP_PM_MAX)
117119

118120
struct mptcp_pm_ops {
119121
int (*get_local_id)(struct mptcp_sock *msk,

net/mptcp/ctrl.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,24 @@ static int proc_pm_type(const struct ctl_table *ctl, int write,
251251
return ret;
252252
}
253253

254+
static int proc_available_path_managers(const struct ctl_table *ctl,
255+
int write, void *buffer,
256+
size_t *lenp, loff_t *ppos)
257+
{
258+
struct ctl_table tbl = { .maxlen = MPTCP_PM_BUF_MAX, };
259+
int ret;
260+
261+
tbl.data = kmalloc(tbl.maxlen, GFP_USER);
262+
if (!tbl.data)
263+
return -ENOMEM;
264+
265+
mptcp_pm_get_available(tbl.data, MPTCP_PM_BUF_MAX);
266+
ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
267+
kfree(tbl.data);
268+
269+
return ret;
270+
}
271+
254272
static struct ctl_table mptcp_sysctl_table[] = {
255273
{
256274
.procname = "enabled",
@@ -336,6 +354,12 @@ static struct ctl_table mptcp_sysctl_table[] = {
336354
.mode = 0644,
337355
.proc_handler = proc_path_manager,
338356
},
357+
{
358+
.procname = "available_path_managers",
359+
.maxlen = MPTCP_PM_BUF_MAX,
360+
.mode = 0444,
361+
.proc_handler = proc_available_path_managers,
362+
},
339363
};
340364

341365
static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet)
@@ -362,6 +386,7 @@ static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet)
362386
table[9].data = &pernet->blackhole_timeout;
363387
table[10].data = &pernet->syn_retrans_before_tcp_fallback;
364388
table[11].data = &pernet->path_manager;
389+
/* table[12] is for available_path_managers which is read-only info */
365390

366391
hdr = register_net_sysctl_sz(net, MPTCP_SYSCTL_PATH, table,
367392
ARRAY_SIZE(mptcp_sysctl_table));

net/mptcp/pm.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,3 +1085,22 @@ void mptcp_pm_unregister(struct mptcp_pm_ops *pm_ops)
10851085
list_del_rcu(&pm_ops->list);
10861086
spin_unlock(&mptcp_pm_list_lock);
10871087
}
1088+
1089+
/* Build string with list of available path manager values.
1090+
* Similar to tcp_get_available_congestion_control()
1091+
*/
1092+
void mptcp_pm_get_available(char *buf, size_t maxlen)
1093+
{
1094+
struct mptcp_pm_ops *pm_ops;
1095+
size_t offs = 0;
1096+
1097+
rcu_read_lock();
1098+
list_for_each_entry_rcu(pm_ops, &mptcp_pm_list, list) {
1099+
offs += snprintf(buf + offs, maxlen - offs, "%s%s",
1100+
offs == 0 ? "" : " ", pm_ops->name);
1101+
1102+
if (WARN_ON_ONCE(offs >= maxlen))
1103+
break;
1104+
}
1105+
rcu_read_unlock();
1106+
}

net/mptcp/protocol.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,7 @@ struct mptcp_pm_ops *mptcp_pm_find(const char *name);
10601060
int mptcp_pm_register(struct mptcp_pm_ops *pm_ops);
10611061
void mptcp_pm_unregister(struct mptcp_pm_ops *pm_ops);
10621062
int mptcp_pm_validate(struct mptcp_pm_ops *pm_ops);
1063+
void mptcp_pm_get_available(char *buf, size_t maxlen);
10631064

10641065
void mptcp_userspace_pm_free_local_addr_list(struct mptcp_sock *msk);
10651066

0 commit comments

Comments
 (0)