Skip to content

Commit d2f7796

Browse files
geliangtangdavem330
authored andcommitted
mptcp: add sysctl allow_join_initial_addr_port
This patch added a new sysctl, named allow_join_initial_addr_port, to control whether allow peers to send join requests to the IP address and port number used by the initial subflow. Suggested-by: Florian Westphal <[email protected]> Acked-by: Paolo Abeni <[email protected]> Signed-off-by: Geliang Tang <[email protected]> Signed-off-by: Mat Martineau <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a432c77 commit d2f7796

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

Documentation/networking/mptcp-sysctl.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,16 @@ checksum_enabled - BOOLEAN
3232
per-namespace sysctl.
3333

3434
Default: 0
35+
36+
allow_join_initial_addr_port - BOOLEAN
37+
Allow peers to send join requests to the IP address and port number used
38+
by the initial subflow if the value is 1. This controls a flag that is
39+
sent to the peer at connection time, and whether such join requests are
40+
accepted or denied.
41+
42+
Joins to addresses advertised with ADD_ADDR are not affected by this
43+
value.
44+
45+
This is a per-namespace sysctl.
46+
47+
Default: 1

net/mptcp/ctrl.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ struct mptcp_pernet {
2424
u8 mptcp_enabled;
2525
unsigned int add_addr_timeout;
2626
u8 checksum_enabled;
27+
u8 allow_join_initial_addr_port;
2728
};
2829

2930
static struct mptcp_pernet *mptcp_get_pernet(struct net *net)
@@ -46,11 +47,17 @@ int mptcp_is_checksum_enabled(struct net *net)
4647
return mptcp_get_pernet(net)->checksum_enabled;
4748
}
4849

50+
int mptcp_allow_join_id0(struct net *net)
51+
{
52+
return mptcp_get_pernet(net)->allow_join_initial_addr_port;
53+
}
54+
4955
static void mptcp_pernet_set_defaults(struct mptcp_pernet *pernet)
5056
{
5157
pernet->mptcp_enabled = 1;
5258
pernet->add_addr_timeout = TCP_RTO_MAX;
5359
pernet->checksum_enabled = 0;
60+
pernet->allow_join_initial_addr_port = 1;
5461
}
5562

5663
#ifdef CONFIG_SYSCTL
@@ -80,6 +87,14 @@ static struct ctl_table mptcp_sysctl_table[] = {
8087
.extra1 = SYSCTL_ZERO,
8188
.extra2 = SYSCTL_ONE
8289
},
90+
{
91+
.procname = "allow_join_initial_addr_port",
92+
.maxlen = sizeof(u8),
93+
.mode = 0644,
94+
.proc_handler = proc_dou8vec_minmax,
95+
.extra1 = SYSCTL_ZERO,
96+
.extra2 = SYSCTL_ONE
97+
},
8398
{}
8499
};
85100

@@ -98,6 +113,7 @@ static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet)
98113
table[0].data = &pernet->mptcp_enabled;
99114
table[1].data = &pernet->add_addr_timeout;
100115
table[2].data = &pernet->checksum_enabled;
116+
table[3].data = &pernet->allow_join_initial_addr_port;
101117

102118
hdr = register_net_sysctl(net, MPTCP_SYSCTL_PATH, table);
103119
if (!hdr)

net/mptcp/protocol.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ static inline void mptcp_subflow_delegated_done(struct mptcp_subflow_context *su
540540
int mptcp_is_enabled(struct net *net);
541541
unsigned int mptcp_get_add_addr_timeout(struct net *net);
542542
int mptcp_is_checksum_enabled(struct net *net);
543+
int mptcp_allow_join_id0(struct net *net);
543544
void mptcp_subflow_fully_established(struct mptcp_subflow_context *subflow,
544545
struct mptcp_options_received *mp_opt);
545546
bool mptcp_subflow_data_available(struct sock *sk);

0 commit comments

Comments
 (0)