Skip to content

Commit 804c72e

Browse files
matttbekuba-moo
authored andcommitted
mptcp: support SYSCTL only if enabled
Since the introduction of the sysctl support in MPTCP with commit 784325e ("mptcp: new sysctl to control the activation per NS"), we don't check CONFIG_SYSCTL. Until now, that was not an issue: the register and unregister functions were replaced by NO-OP one if SYSCTL was not enabled in the config. The only thing we could have avoid is not to reserve memory for the table but that's for the moment only a small table per net-ns. But the following commit is going to use SYSCTL_ZERO and SYSCTL_ONE which are not be defined if SYSCTL is not enabled in the config. This causes 'undefined reference' errors from the linker. Reported-by: kernel test robot <[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 eb5fb62 commit 804c72e

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

net/mptcp/ctrl.c

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
* Copyright (c) 2019, Tessares SA.
55
*/
66

7+
#ifdef CONFIG_SYSCTL
78
#include <linux/sysctl.h>
9+
#endif
810

911
#include <net/net_namespace.h>
1012
#include <net/netns/generic.h>
@@ -15,7 +17,9 @@
1517

1618
static int mptcp_pernet_id;
1719
struct mptcp_pernet {
20+
#ifdef CONFIG_SYSCTL
1821
struct ctl_table_header *ctl_table_hdr;
22+
#endif
1923

2024
int mptcp_enabled;
2125
unsigned int add_addr_timeout;
@@ -36,6 +40,13 @@ unsigned int mptcp_get_add_addr_timeout(struct net *net)
3640
return mptcp_get_pernet(net)->add_addr_timeout;
3741
}
3842

43+
static void mptcp_pernet_set_defaults(struct mptcp_pernet *pernet)
44+
{
45+
pernet->mptcp_enabled = 1;
46+
pernet->add_addr_timeout = TCP_RTO_MAX;
47+
}
48+
49+
#ifdef CONFIG_SYSCTL
3950
static struct ctl_table mptcp_sysctl_table[] = {
4051
{
4152
.procname = "enabled",
@@ -55,12 +66,6 @@ static struct ctl_table mptcp_sysctl_table[] = {
5566
{}
5667
};
5768

58-
static void mptcp_pernet_set_defaults(struct mptcp_pernet *pernet)
59-
{
60-
pernet->mptcp_enabled = 1;
61-
pernet->add_addr_timeout = TCP_RTO_MAX;
62-
}
63-
6469
static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet)
6570
{
6671
struct ctl_table_header *hdr;
@@ -100,6 +105,17 @@ static void mptcp_pernet_del_table(struct mptcp_pernet *pernet)
100105
kfree(table);
101106
}
102107

108+
#else
109+
110+
static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet)
111+
{
112+
return 0;
113+
}
114+
115+
static void mptcp_pernet_del_table(struct mptcp_pernet *pernet) {}
116+
117+
#endif /* CONFIG_SYSCTL */
118+
103119
static int __net_init mptcp_net_init(struct net *net)
104120
{
105121
struct mptcp_pernet *pernet = mptcp_get_pernet(net);

0 commit comments

Comments
 (0)