Skip to content

Commit 2ecfbbf

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 mangers. Signed-off-by: Geliang Tang <[email protected]>
1 parent ef5a3c4 commit 2ecfbbf

File tree

5 files changed

+52
-0
lines changed

5 files changed

+52
-0
lines changed

Documentation/networking/mptcp-sysctl.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ path_manager - STRING
8989

9090
Default: "in-kernel"
9191

92+
available_path_managers - STRING
93+
Shows the available path managers choices that are registered. More
94+
path managers may be available, but not loaded.
95+
9296
scheduler - STRING
9397
Select the scheduler of your choice.
9498

include/net/mptcp.h

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

125125
#define MPTCP_PM_NAME_MAX 16
126+
#define MPTCP_PM_MAX 128
127+
#define MPTCP_PM_BUF_MAX (MPTCP_PM_NAME_MAX * MPTCP_PM_MAX)
126128

127129
struct mptcp_pm_ops {
128130
int (*created)(struct mptcp_sock *msk);

net/mptcp/ctrl.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,24 @@ static int proc_path_manager(const struct ctl_table *ctl, int write,
136136
return ret;
137137
}
138138

139+
static int proc_available_path_managers(const struct ctl_table *ctl,
140+
int write, void *buffer,
141+
size_t *lenp, loff_t *ppos)
142+
{
143+
struct ctl_table tbl = { .maxlen = MPTCP_PM_BUF_MAX, };
144+
int ret;
145+
146+
tbl.data = kmalloc(tbl.maxlen, GFP_USER);
147+
if (!tbl.data)
148+
return -ENOMEM;
149+
150+
mptcp_pm_get_available(tbl.data, MPTCP_PM_BUF_MAX);
151+
ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
152+
kfree(tbl.data);
153+
154+
return ret;
155+
}
156+
139157
static int mptcp_set_scheduler(char *scheduler, const char *name)
140158
{
141159
struct mptcp_sched_ops *sched;
@@ -252,6 +270,12 @@ static struct ctl_table mptcp_sysctl_table[] = {
252270
.mode = 0644,
253271
.proc_handler = proc_path_manager,
254272
},
273+
{
274+
.procname = "available_path_managers",
275+
.maxlen = MPTCP_PM_BUF_MAX,
276+
.mode = 0444,
277+
.proc_handler = proc_available_path_managers,
278+
},
255279
{
256280
.procname = "scheduler",
257281
.maxlen = MPTCP_SCHED_NAME_MAX,
@@ -304,6 +328,7 @@ static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet)
304328
table[i++].data = &pernet->allow_join_initial_addr_port;
305329
table[i++].data = &pernet->stale_loss_cnt;
306330
table[i++].data = &pernet->path_manager;
331+
i++; /* table[i] is for available_path_managers which is read-only info */
307332
table[i++].data = &pernet->scheduler;
308333
i++; /* table[i] is for available_schedulers which is read-only info */
309334
table[i++].data = &pernet->close_timeout;

net/mptcp/pm.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,26 @@ struct mptcp_pm_ops *mptcp_pm_find(const char *name)
673673
return NULL;
674674
}
675675

676+
/* Build string with list of available path manager values.
677+
* Similar to tcp_get_available_congestion_control()
678+
*/
679+
void mptcp_pm_get_available(char *buf, size_t maxlen)
680+
{
681+
struct mptcp_pm_ops *pm;
682+
size_t offs = 0;
683+
684+
rcu_read_lock();
685+
list_for_each_entry_rcu(pm, &mptcp_pm_list, list) {
686+
offs += snprintf(buf + offs, maxlen - offs,
687+
"%s%s",
688+
offs == 0 ? "" : " ", pm->name);
689+
690+
if (WARN_ON_ONCE(offs >= maxlen))
691+
break;
692+
}
693+
rcu_read_unlock();
694+
}
695+
676696
int mptcp_pm_validate(struct mptcp_pm_ops *pm)
677697
{
678698
if (!pm->get_local_id || !pm->get_priority) {

net/mptcp/protocol.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,7 @@ void mptcp_pm_remove_addr_entry(struct mptcp_sock *msk,
10501050
extern struct mptcp_pm_ops mptcp_in_kernel_pm;
10511051

10521052
struct mptcp_pm_ops *mptcp_pm_find(const char *name);
1053+
void mptcp_pm_get_available(char *buf, size_t maxlen);
10531054
int mptcp_pm_validate(struct mptcp_pm_ops *pm);
10541055
int mptcp_pm_register(struct mptcp_pm_ops *pm);
10551056
void mptcp_pm_unregister(struct mptcp_pm_ops *pm);

0 commit comments

Comments
 (0)