Message ID | c83ba5bf407386ae9160ce1e570a93d3eb74e3b1.1741088339.git.tanggeliang@kylinos.cn (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Matthieu Baerts |
Headers | show |
Series | BPF path manager, part 5 | expand |
Hi Geliang, On 04/03/2025 12:40, Geliang Tang wrote: > From: Geliang Tang <tanggeliang@kylinos.cn> > > This patch maps the newly added path manager sysctl "path_manager" > to the old one "pm_type". > > Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn> > --- > net/mptcp/ctrl.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/net/mptcp/ctrl.c b/net/mptcp/ctrl.c > index d425fcbd036a..a158a337cdb5 100644 > --- a/net/mptcp/ctrl.c > +++ b/net/mptcp/ctrl.c > @@ -200,6 +200,9 @@ static int mptcp_set_path_manager(char *path_manager, const char *name) > static int proc_path_manager(const struct ctl_table *ctl, int write, > void *buffer, size_t *lenp, loff_t *ppos) > { > + struct mptcp_pernet *pernet = container_of(ctl->data, > + struct mptcp_pernet, > + path_manager); > char (*path_manager)[MPTCP_PM_NAME_MAX] = ctl->data; > char val[MPTCP_PM_NAME_MAX]; > const struct ctl_table tbl = { > @@ -211,8 +214,14 @@ static int proc_path_manager(const struct ctl_table *ctl, int write, > strscpy(val, *path_manager, MPTCP_PM_NAME_MAX); > > ret = proc_dostring(&tbl, write, buffer, lenp, ppos); > - if (write && ret == 0) > + if (write && ret == 0) { > + u8 pm_type = MPTCP_PM_TYPE_KERNEL; > + > + if (!strncmp(val, "userspace", MPTCP_PM_NAME_MAX)) (detail: please use '== 0', that feels more natural than "not strncmp") > + pm_type = MPTCP_PM_TYPE_USERSPACE; > + pernet->pm_type = pm_type; Should we not already cope with the future BPF PMs? if "kernel": pm_type = MPTCP_PM_TYPE_KERNEL; elif "userspace: pm_type = MPTCP_PM_TYPE_USERSPACE; else: pm_type = __MPTCP_PM_TYPE_NR; Please check that this doesn't cause issue to display "pm_type" to 2 here -- note that we should not change the current mptcp_pm_type_max: the userspace **cannot** set "net.mptcp.pm_type=2". In other words, please check that this is OK: # sysctl net.mptcp.pm_type=2 sysctl: setting key "net.mptcp.pm_type": Invalid argument # sysctl -q net.mptcp.path_manager = "$BPF_PM" # sysctl -n net.mptcp.pm_type 2 > ret = mptcp_set_path_manager(*path_manager, val); > + } > > return ret; > } Cheers, Matt
diff --git a/net/mptcp/ctrl.c b/net/mptcp/ctrl.c index d425fcbd036a..a158a337cdb5 100644 --- a/net/mptcp/ctrl.c +++ b/net/mptcp/ctrl.c @@ -200,6 +200,9 @@ static int mptcp_set_path_manager(char *path_manager, const char *name) static int proc_path_manager(const struct ctl_table *ctl, int write, void *buffer, size_t *lenp, loff_t *ppos) { + struct mptcp_pernet *pernet = container_of(ctl->data, + struct mptcp_pernet, + path_manager); char (*path_manager)[MPTCP_PM_NAME_MAX] = ctl->data; char val[MPTCP_PM_NAME_MAX]; const struct ctl_table tbl = { @@ -211,8 +214,14 @@ static int proc_path_manager(const struct ctl_table *ctl, int write, strscpy(val, *path_manager, MPTCP_PM_NAME_MAX); ret = proc_dostring(&tbl, write, buffer, lenp, ppos); - if (write && ret == 0) + if (write && ret == 0) { + u8 pm_type = MPTCP_PM_TYPE_KERNEL; + + if (!strncmp(val, "userspace", MPTCP_PM_NAME_MAX)) + pm_type = MPTCP_PM_TYPE_USERSPACE; + pernet->pm_type = pm_type; ret = mptcp_set_path_manager(*path_manager, val); + } return ret; }