mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/
synced 2025-04-19 20:58:31 +09:00
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 <tanggeliang@kylinos.cn> Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20250313-net-next-mptcp-pm-ops-intro-v1-11-f4e4a88efc50@kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
7982ed0edd
commit
fa3ee9dd80
@ -30,6 +30,10 @@ allow_join_initial_addr_port - BOOLEAN
|
||||
|
||||
Default: 1
|
||||
|
||||
available_path_managers - STRING
|
||||
Shows the available path managers choices that are registered. More
|
||||
path managers may be available, but not loaded.
|
||||
|
||||
available_schedulers - STRING
|
||||
Shows the available schedulers choices that are registered. More packet
|
||||
schedulers may be available, but not loaded.
|
||||
|
@ -123,6 +123,8 @@ struct mptcp_sched_ops {
|
||||
} ____cacheline_aligned_in_smp;
|
||||
|
||||
#define MPTCP_PM_NAME_MAX 16
|
||||
#define MPTCP_PM_MAX 128
|
||||
#define MPTCP_PM_BUF_MAX (MPTCP_PM_NAME_MAX * MPTCP_PM_MAX)
|
||||
|
||||
struct mptcp_pm_ops {
|
||||
char name[MPTCP_PM_NAME_MAX];
|
||||
|
@ -253,6 +253,24 @@ static int proc_pm_type(const struct ctl_table *ctl, int write,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int proc_available_path_managers(const struct ctl_table *ctl,
|
||||
int write, void *buffer,
|
||||
size_t *lenp, loff_t *ppos)
|
||||
{
|
||||
struct ctl_table tbl = { .maxlen = MPTCP_PM_BUF_MAX, };
|
||||
int ret;
|
||||
|
||||
tbl.data = kmalloc(tbl.maxlen, GFP_USER);
|
||||
if (!tbl.data)
|
||||
return -ENOMEM;
|
||||
|
||||
mptcp_pm_get_available(tbl.data, MPTCP_PM_BUF_MAX);
|
||||
ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
|
||||
kfree(tbl.data);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct ctl_table mptcp_sysctl_table[] = {
|
||||
{
|
||||
.procname = "enabled",
|
||||
@ -338,6 +356,12 @@ static struct ctl_table mptcp_sysctl_table[] = {
|
||||
.mode = 0644,
|
||||
.proc_handler = proc_path_manager,
|
||||
},
|
||||
{
|
||||
.procname = "available_path_managers",
|
||||
.maxlen = MPTCP_PM_BUF_MAX,
|
||||
.mode = 0444,
|
||||
.proc_handler = proc_available_path_managers,
|
||||
},
|
||||
};
|
||||
|
||||
static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet)
|
||||
@ -364,6 +388,7 @@ static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet)
|
||||
table[9].data = &pernet->blackhole_timeout;
|
||||
table[10].data = &pernet->syn_retrans_before_tcp_fallback;
|
||||
table[11].data = &pernet->path_manager;
|
||||
/* table[12] is for available_path_managers which is read-only info */
|
||||
|
||||
hdr = register_net_sysctl_sz(net, MPTCP_SYSCTL_PATH, table,
|
||||
ARRAY_SIZE(mptcp_sysctl_table));
|
||||
|
@ -1070,3 +1070,22 @@ void mptcp_pm_unregister(struct mptcp_pm_ops *pm_ops)
|
||||
list_del_rcu(&pm_ops->list);
|
||||
spin_unlock(&mptcp_pm_list_lock);
|
||||
}
|
||||
|
||||
/* Build string with list of available path manager values.
|
||||
* Similar to tcp_get_available_congestion_control()
|
||||
*/
|
||||
void mptcp_pm_get_available(char *buf, size_t maxlen)
|
||||
{
|
||||
struct mptcp_pm_ops *pm_ops;
|
||||
size_t offs = 0;
|
||||
|
||||
rcu_read_lock();
|
||||
list_for_each_entry_rcu(pm_ops, &mptcp_pm_list, list) {
|
||||
offs += snprintf(buf + offs, maxlen - offs, "%s%s",
|
||||
offs == 0 ? "" : " ", pm_ops->name);
|
||||
|
||||
if (WARN_ON_ONCE(offs >= maxlen))
|
||||
break;
|
||||
}
|
||||
rcu_read_unlock();
|
||||
}
|
||||
|
@ -1058,6 +1058,7 @@ struct mptcp_pm_ops *mptcp_pm_find(const char *name);
|
||||
int mptcp_pm_register(struct mptcp_pm_ops *pm_ops);
|
||||
void mptcp_pm_unregister(struct mptcp_pm_ops *pm_ops);
|
||||
int mptcp_pm_validate(struct mptcp_pm_ops *pm_ops);
|
||||
void mptcp_pm_get_available(char *buf, size_t maxlen);
|
||||
|
||||
void mptcp_userspace_pm_free_local_addr_list(struct mptcp_sock *msk);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user