Skip to content

Commit 744ee14

Browse files
matttbekuba-moo
authored andcommitted
mptcp: restrict values of 'enabled' sysctl
To avoid confusions, it seems better to parse this sysctl parameter as a boolean. We use it as a boolean, no need to parse an integer and bring confusions if we see a value different from 0 and 1, especially with this parameter name: enabled. It seems fine to do this modification because the default value is 1 (enabled). Then the only other interesting value to set is 0 (disabled). All other values would not have changed the default behaviour. Suggested-by: Florian Westphal <[email protected]> Acked-by: Florian Westphal <[email protected]> Signed-off-by: Matthieu Baerts <[email protected]> Signed-off-by: Mat Martineau <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 804c72e commit 744ee14

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

Documentation/networking/mptcp-sysctl.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ MPTCP Sysfs variables
77
/proc/sys/net/mptcp/* Variables
88
===============================
99

10-
enabled - INTEGER
10+
enabled - BOOLEAN
1111
Control whether MPTCP sockets can be created.
1212

13-
MPTCP sockets can be created if the value is nonzero. This is
14-
a per-namespace sysctl.
13+
MPTCP sockets can be created if the value is 1. This is a
14+
per-namespace sysctl.
1515

16-
Default: 1
16+
Default: 1 (enabled)
1717

1818
add_addr_timeout - INTEGER (seconds)
1919
Set the timeout after which an ADD_ADDR control message will be

net/mptcp/ctrl.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ struct mptcp_pernet {
2121
struct ctl_table_header *ctl_table_hdr;
2222
#endif
2323

24-
int mptcp_enabled;
24+
u8 mptcp_enabled;
2525
unsigned int add_addr_timeout;
2626
};
2727

@@ -50,12 +50,14 @@ static void mptcp_pernet_set_defaults(struct mptcp_pernet *pernet)
5050
static struct ctl_table mptcp_sysctl_table[] = {
5151
{
5252
.procname = "enabled",
53-
.maxlen = sizeof(int),
53+
.maxlen = sizeof(u8),
5454
.mode = 0644,
5555
/* users with CAP_NET_ADMIN or root (not and) can change this
5656
* value, same as other sysctl or the 'net' tree.
5757
*/
58-
.proc_handler = proc_dointvec,
58+
.proc_handler = proc_dou8vec_minmax,
59+
.extra1 = SYSCTL_ZERO,
60+
.extra2 = SYSCTL_ONE
5961
},
6062
{
6163
.procname = "add_addr_timeout",

0 commit comments

Comments
 (0)