Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Geliang Tang and committed by
Paolo Abeni
fa3ee9dd 7982ed0e

+51
+4
Documentation/networking/mptcp-sysctl.rst
··· 30 30 31 31 Default: 1 32 32 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 + 33 37 available_schedulers - STRING 34 38 Shows the available schedulers choices that are registered. More packet 35 39 schedulers may be available, but not loaded.
+2
include/net/mptcp.h
··· 123 123 } ____cacheline_aligned_in_smp; 124 124 125 125 #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) 126 128 127 129 struct mptcp_pm_ops { 128 130 char name[MPTCP_PM_NAME_MAX];
+25
net/mptcp/ctrl.c
··· 253 253 return ret; 254 254 } 255 255 256 + static int proc_available_path_managers(const struct ctl_table *ctl, 257 + int write, void *buffer, 258 + size_t *lenp, loff_t *ppos) 259 + { 260 + struct ctl_table tbl = { .maxlen = MPTCP_PM_BUF_MAX, }; 261 + int ret; 262 + 263 + tbl.data = kmalloc(tbl.maxlen, GFP_USER); 264 + if (!tbl.data) 265 + return -ENOMEM; 266 + 267 + mptcp_pm_get_available(tbl.data, MPTCP_PM_BUF_MAX); 268 + ret = proc_dostring(&tbl, write, buffer, lenp, ppos); 269 + kfree(tbl.data); 270 + 271 + return ret; 272 + } 273 + 256 274 static struct ctl_table mptcp_sysctl_table[] = { 257 275 { 258 276 .procname = "enabled", ··· 356 338 .mode = 0644, 357 339 .proc_handler = proc_path_manager, 358 340 }, 341 + { 342 + .procname = "available_path_managers", 343 + .maxlen = MPTCP_PM_BUF_MAX, 344 + .mode = 0444, 345 + .proc_handler = proc_available_path_managers, 346 + }, 359 347 }; 360 348 361 349 static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet) ··· 388 364 table[9].data = &pernet->blackhole_timeout; 389 365 table[10].data = &pernet->syn_retrans_before_tcp_fallback; 390 366 table[11].data = &pernet->path_manager; 367 + /* table[12] is for available_path_managers which is read-only info */ 391 368 392 369 hdr = register_net_sysctl_sz(net, MPTCP_SYSCTL_PATH, table, 393 370 ARRAY_SIZE(mptcp_sysctl_table));
+19
net/mptcp/pm.c
··· 1070 1070 list_del_rcu(&pm_ops->list); 1071 1071 spin_unlock(&mptcp_pm_list_lock); 1072 1072 } 1073 + 1074 + /* Build string with list of available path manager values. 1075 + * Similar to tcp_get_available_congestion_control() 1076 + */ 1077 + void mptcp_pm_get_available(char *buf, size_t maxlen) 1078 + { 1079 + struct mptcp_pm_ops *pm_ops; 1080 + size_t offs = 0; 1081 + 1082 + rcu_read_lock(); 1083 + list_for_each_entry_rcu(pm_ops, &mptcp_pm_list, list) { 1084 + offs += snprintf(buf + offs, maxlen - offs, "%s%s", 1085 + offs == 0 ? "" : " ", pm_ops->name); 1086 + 1087 + if (WARN_ON_ONCE(offs >= maxlen)) 1088 + break; 1089 + } 1090 + rcu_read_unlock(); 1091 + }
+1
net/mptcp/protocol.h
··· 1058 1058 int mptcp_pm_register(struct mptcp_pm_ops *pm_ops); 1059 1059 void mptcp_pm_unregister(struct mptcp_pm_ops *pm_ops); 1060 1060 int mptcp_pm_validate(struct mptcp_pm_ops *pm_ops); 1061 + void mptcp_pm_get_available(char *buf, size_t maxlen); 1061 1062 1062 1063 void mptcp_userspace_pm_free_local_addr_list(struct mptcp_sock *msk); 1063 1064