[PATCH 1/2] Remove unused variables, causes compile warnings
by Peter Krystad
squashto: Add key generation and token tree
Signed-off-by: Peter Krystad <peter.krystad(a)linux.intel.com>
---
net/mptcp/token.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/net/mptcp/token.c b/net/mptcp/token.c
index d7d81bb2e1c2..2324a477d513 100644
--- a/net/mptcp/token.c
+++ b/net/mptcp/token.c
@@ -66,7 +66,6 @@ static struct sock *lookup_token(u32 token)
static void new_req_token(struct request_sock *req,
const struct sk_buff *skb)
{
- const struct inet_request_sock *ireq = inet_rsk(req);
struct subflow_request_sock *subflow_req = subflow_rsk(req);
crypto_key_gen_sha1(&subflow_req->local_key, &subflow_req->token,
@@ -132,7 +131,6 @@ static int new_join_valid(struct request_sock *req, struct sock *sk,
static void new_token(const struct sock *sk)
{
struct subflow_context *subflow = subflow_ctx(sk);
- const struct inet_sock *isk = inet_sk(sk);
crypto_key_gen_sha1(&subflow->local_key, &subflow->token,
&subflow->idsn);
--
2.17.2
2 years, 10 months
[PATCH v2 00/10] Implement outgoing MP_JOIN
by Peter Krystad
This is several accumulated fixes that are required for MP_JOIN
(secondary subflows) plus the outgoing code.
Both outgoing and incoming MP_JOIN now inter-operate
with the multipath.org implementation although there is
still a deadlock when incoming is fully established.
Since the incoming direction did not work at all before
this is an improvement. I have not yet tested running our
implmentation against itself.
The final patch in the set is an "interim path manager", this
is throw-away code that I include for testing purposes. For an
incoming connection it is necessary for the server to advertise
a secondary address and for my testing I have been hard-coding the IP
address of my secondary interface when I build the kernel.
Obviously not the final solution but we need to discuss what
approach to use for the self tests. I also think we may not want
to publish this patch on our net-next branch.
v2:
- move mptcp_options_received formatting to options.c
- resolve conflicts with Davide's crypto commit
- make helper for setting request fields
- fix locking in token_lookup()
- move token_lookup() to "Implement path manager interface commands:
(where it belongs)
- split interim path manager out of final commit, will submit seperately
- remove use of local_id in pm_create_subflow
- restrict announcing addresses to server side only
- add one more commit with get_local_id fix for incoming MP_JOIN
Peter Krystad (10):
Extend path manager interface
Fix locking in mptcp_finish_join.
Fix parsing MP_JOIN third ACK.
Re-factor and fixes for crypto_hmac_sha1()
Rename mptcp_attach_dss()
Fix return value if no DSS option is created.
Move setting request_ fields of subflow to MPTCP layer helper
mptcp: Add handling of outgoing MP_JOIN requests
Use pm_get_local_id() to get the real local address id.
mptcp: Implement path manager interface commands
include/net/mptcp.h | 12 ++--
net/ipv4/tcp_input.c | 4 +-
net/mptcp/crypto.c | 23 +++----
net/mptcp/options.c | 95 ++++++++++++++++++++++++++---
net/mptcp/pm.c | 141 +++++++++++++++++++++++++++++++++++++++----
net/mptcp/protocol.c | 22 +++++--
net/mptcp/protocol.h | 58 ++++++++++++++----
net/mptcp/subflow.c | 72 +++++++++++++++++++---
net/mptcp/token.c | 89 +++++++++++++++++++++------
9 files changed, 429 insertions(+), 87 deletions(-)
--
2.17.2
2 years, 10 months
LPC networking CfP: abstract: draft
by Matthieu Baerts
Hello,
Yesterday, we discussed options for a Linux Plumber's Conference
networking track talk.
Here is a first draft of an abstract. Feel free to comment and react:
===
Multipath TCP (MPTCP) is more and more popular these days but it is not
in the upstream Linux kernel yet. A fork is still being maintained on
the side and has been since March 2009. But it cannot be upstreamed as
it is because this implementation is designed for MPTCP and the TCP
stack is too heavily impacted in term of maintainability but also a bit
regarding the performances.
In this presentation, we would like to present the challenges we are
facing. Some are introduced by this MPTCP protocol, others by objectives
we defined: limit at the maximum the impact on the existing TCP stack.
We would like to have no performance regression, a maintainable and
configurable solution and an MPTCP implementation that can be used in a
variety of deployments.
The MPTCP upstreaming community is working on a RFC patch set for
net-next. We should be able to send it before the next LPC in September.
In the current situation, a socket can be created with IPPROTO_MPTCP to
initiate and accept an MPTCP connection. This socket remains compatible
with regular TCP and IPPROTO_TCP socket behavior is unchanged. This
implementation makes use of ULP between the userspace-facing MPTCP
socket and the set of in-kernel TCP sockets it controls to limit the
minimum impact on the current TCP stack. ULP has been extended for use
with listening sockets. skb_ext is used to carry MPTCP metadata.
Both the communication and the code are public and opened. You can find
us at mptcp(a)lists.01.org and https://is.gd/mptcp_upstream
===
Do not hesitate to improve it, fix typo or restart from scratch if
needed, I don't mind!
Cheers,
Matt
--
Matthieu Baerts | R&D Engineer
matthieu.baerts(a)tessares.net
Tessares SA | Hybrid Access Solutions
www.tessares.net
1 Avenue Jean Monnet, 1348 Louvain-la-Neuve, Belgium
2 years, 10 months
[RFC PATCH] mptcp: new sysctl to control the activation per NS
by Matthieu Baerts
New MPTCP sockets will return -ENOPROTOOPT if MPTCP support is disabled
for the current net namespace.
For security reasons, it is interesting to have a global switch for
MPTCP. To start, MPTCP will be disabled by default and only privileged
users will be able to modify this. The reason is that because MPTCP is
new, it will not be tested and reviewed by many and security issues can
then take time to be discovered and fixed.
The value of this new sysctl can be different per namespace. We can then
restrict the usage of MPTCP to the selected NS. In case of serious
issues with MPTCP, administrators can now easily turn MPTCP off.
MPTCP' kselftest has been modified to validate that the correct error is
reported when creating a socket while MPTCP support is disabled.
Signed-off-by: Matthieu Baerts <matthieu.baerts(a)tessares.net>
---
Notes:
As just discussed at the meeting we just had, here is a RFC patch to
add a new sysctl for MPTCP.
Because it is not linked to the protocol itself, I simply created a new
file, ctrl.c like in mptcp.org.
A few questions:
- Is it OK to reserve space per ns via the "pernet_operations"
structure? Because MPTCP would not be compiled as a module, we could
directly store stuff in the net structure as other parts of the code
do but maybe better to keep MPTCP code on the side as done here.
- In mptcp.org, all sysctls are prepended with 'mptcp_', e.g.
'net.mptcp.mptcp_enabled'. Do we need this? Is it better to keep the
same names if possible or better to differentiate? In this version,
'mptcp_' is not prepended.
- This sysctl will only block new sockets to be created. Is it enough?
- ENOPROTOOPT is returned, maybe something else to return? EPERM is
maybe too generic? ENOTSUPP is not translated by perror().
- Should we start the documentation now for the sysctl?
- A simple test has been added, because it is not linked to the rest, I
put separeted as first test.
- Of course do not hesitate to comment. Even on the idea of having a
sysctl for this purpose.
net/mptcp/Makefile | 2 +-
net/mptcp/ctrl.c | 109 ++++++++++++++++++
net/mptcp/protocol.c | 12 +-
net/mptcp/protocol.h | 4 +
.../selftests/net/mptcp/mptcp_connect.sh | 24 ++++
5 files changed, 148 insertions(+), 3 deletions(-)
create mode 100644 net/mptcp/ctrl.c
diff --git a/net/mptcp/Makefile b/net/mptcp/Makefile
index 7fe7aa64eda0..289fdf4339c1 100644
--- a/net/mptcp/Makefile
+++ b/net/mptcp/Makefile
@@ -1,4 +1,4 @@
# SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_MPTCP) += mptcp.o
-mptcp-y := protocol.o subflow.o options.o token.o crypto.o pm.o
+mptcp-y := protocol.o subflow.o options.o token.o crypto.o pm.o ctrl.o
diff --git a/net/mptcp/ctrl.c b/net/mptcp/ctrl.c
new file mode 100644
index 000000000000..4c9a6a2cfeb3
--- /dev/null
+++ b/net/mptcp/ctrl.c
@@ -0,0 +1,109 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Multipath TCP
+ *
+ * Copyright (c) 2019, Tessares SA.
+ */
+
+#include <linux/sysctl.h>
+
+#include <net/net_namespace.h>
+#include <net/netns/generic.h>
+
+#include "protocol.h"
+
+#define MPTCP_SYSCTL_PATH "net/mptcp"
+
+static int mptcp_pernet_id;
+struct mptcp_pernet {
+ struct ctl_table_header *ctl_table_hdr;
+
+ int mptcp_enabled;
+};
+
+static struct mptcp_pernet *mptcp_get_pernet(struct net *net)
+{
+ return net_generic(net, mptcp_pernet_id);
+}
+
+int mptcp_is_enabled(struct net *net)
+{
+ return mptcp_get_pernet(net)->mptcp_enabled;
+}
+
+static struct ctl_table mptcp_sysctl_table[] = {
+ {
+ .procname = "enabled",
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = proc_dointvec,
+ },
+ {}
+};
+
+static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet)
+{
+ struct ctl_table_header *hdr;
+ struct ctl_table *table;
+
+ table = mptcp_sysctl_table;
+ if (!net_eq(net, &init_net)) {
+ table = kmemdup(table, sizeof(mptcp_sysctl_table), GFP_KERNEL);
+ if (!table)
+ goto err_alloc;
+ }
+
+ table[0].data = &pernet->mptcp_enabled;
+
+ hdr = register_net_sysctl(net, MPTCP_SYSCTL_PATH, table);
+ if (!hdr)
+ goto err_reg;
+
+ pernet->ctl_table_hdr = hdr;
+
+ return 0;
+
+err_reg:
+ if (!net_eq(net, &init_net))
+ kfree(table);
+err_alloc:
+ return -ENOMEM;
+}
+
+static void mptcp_pernet_del_table(struct mptcp_pernet *pernet)
+{
+ struct ctl_table *table = pernet->ctl_table_hdr->ctl_table_arg;
+
+ unregister_net_sysctl_table(pernet->ctl_table_hdr);
+
+ kfree(table);
+}
+
+static int __net_init mptcp_net_init(struct net *net)
+{
+ struct mptcp_pernet *pernet = mptcp_get_pernet(net);
+
+ return mptcp_pernet_new_table(net, pernet);
+}
+
+/* Note: the callback will only be called per extra netns */
+static void __net_exit mptcp_net_exit(struct net *net)
+{
+ struct mptcp_pernet *pernet = mptcp_get_pernet(net);
+
+ mptcp_pernet_del_table(pernet);
+}
+
+static struct pernet_operations mptcp_pernet_ops = {
+ .init = mptcp_net_init,
+ .exit = mptcp_net_exit,
+ .id = &mptcp_pernet_id,
+ .size = sizeof(struct mptcp_pernet),
+};
+
+void __init mptcp_init(void)
+{
+ mptcp_proto_init();
+
+ if (register_pernet_subsys(&mptcp_pernet_ops) < 0)
+ panic("Failed to register MPTCP pernet subsystem.\n");
+}
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 774ed25d3b6d..18399cb63f35 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -559,6 +559,14 @@ static int mptcp_init_sock(struct sock *sk)
return 0;
}
+static int mptcp_init_sock_cb(struct sock *sk)
+{
+ if (!mptcp_is_enabled(sock_net(sk)))
+ return -ENOPROTOOPT;
+
+ return mptcp_init_sock(sk);
+}
+
static void mptcp_close(struct sock *sk, long timeout)
{
struct mptcp_sock *msk = mptcp_sk(sk);
@@ -801,7 +809,7 @@ bool mptcp_sk_is_subflow(const struct sock *sk)
static struct proto mptcp_prot = {
.name = "MPTCP",
.owner = THIS_MODULE,
- .init = mptcp_init_sock,
+ .init = mptcp_init_sock_cb,
.close = mptcp_close,
.accept = mptcp_accept,
.setsockopt = mptcp_setsockopt,
@@ -993,7 +1001,7 @@ static struct inet_protosw mptcp_protosw = {
.flags = INET_PROTOSW_ICSK,
};
-void __init mptcp_init(void)
+void mptcp_proto_init(void)
{
mptcp_prot.h.hashinfo = tcp_prot.h.hashinfo;
mptcp_stream_ops = inet_stream_ops;
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 7f15f6aab93d..715ce80d0ae1 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -183,11 +183,15 @@ mptcp_subflow_tcp_socket(const struct subflow_context *subflow)
return subflow->tcp_sock;
}
+int mptcp_is_enabled(struct net *net);
+
void subflow_init(void);
int subflow_create_socket(struct sock *sk, struct socket **new_sock);
extern const struct inet_connection_sock_af_ops ipv4_specific;
+void mptcp_proto_init(void);
+
void mptcp_get_options(const struct sk_buff *skb,
struct tcp_options_received *opt_rx);
diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
index 4418163af001..d029bdc5946d 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
@@ -45,6 +45,7 @@ trap cleanup EXIT
for i in 1 2 3 4;do
ip netns add ns$i || exit $ksft_skip
ip -net ns$i link set lo up
+ ip netns exec ns$i sysctl -q net.mptcp.enabled=1
done
# ns1 ns2 ns3 ns4
@@ -106,6 +107,27 @@ check_transfer()
return 0
}
+check_mptcp_disabled()
+{
+ disabled_ns="ns_disabled"
+ ip netns add ${disabled_ns} || exit $ksft_skip
+ # by default: sysctl net.mptcp.enabled=0
+
+ local err=0
+ LANG=C ip netns exec ${disabled_ns} ./mptcp_connect -t $timeout -p 10000 -s MPTCP 127.0.0.1 < "$cin" 2>&1 | \
+ grep -q "^socket: Protocol not available$" && err=1
+ ip netns delete ${disabled_ns}
+
+ if [ ${err} -eq 0 ]; then
+ echo -e "MPTCP is not disabled by default as expected\t[ FAIL ]"
+ ret=1
+ return 1
+ fi
+
+ echo -e "MPTCP is disabled by default as expected\t[ OK ]"
+ return 0
+}
+
do_ping()
{
listener_ns="$1"
@@ -241,6 +263,8 @@ run_tests()
make_file "$cin" "client"
make_file "$sin" "server"
+check_mptcp_disabled
+
for sender in 1 2 3 4;do
do_ping ns1 ns$sender 10.0.1.1
--
2.20.1
2 years, 10 months
roadmap proposal/discussion
by Paolo Abeni
Hi all,
I spent some time reviewing the current code-base looking for missing
pieces required for multiple subflow support, and I think there are a
bunch of things that would be needed no matter what.
I'd like to share the list, with some random implementation details, to
possibly avoid duplicate effort and/or large misunderstanding on my
side. Here it goes:
* Update msk data_ack:
- hook in mptcp_attach_dss() - possibly rename the function to
mptcp_data_ready()
- cope with 32bit ack
- possibly some additional msk-level [spin-]lock would be required to
protect from concurrent updates when multiple sub-flows are running
- while at this, eventually re-consider (again!) conn_list
locking ?!?
* Store in msk pending data, to allow retransmissions
- in sendmsg(), queue pending (unacked) xmit msg on msk rtx_queue
- does it need to be a rb tree?
- sort by mptcp seq
- cope with 32bit seq
- allocate the node element from the msk page frag's allocator
- each node must contains: all the data frag, mptcp seq,
[mptcp seq_end?]
- NO need to check vs mptcp window before tcp_push()
unless we want to update the window size as per RFC
(max of subflow's window size)
because msk ws is greater equal than subflows ws
- free acked nodes (and data) still in sendmsg(),
just after acquiring msk lock, before doing any real
sendmsg related work
* Implement msk-level retransmission
- add msk-level [hr-]timer
- schedule it in sendmsg, after tcp_push()
- e.g. if msk ack != msk seq
- which timeout? subflow's rtt based ?
- when the timer expires, trigger retransmit if msk ack is not
changed (increased) since the timer's scheduling
- reuse/factor-out part of current sendmsg_frag() retransmit
a bunch of already-in-kernel page frags.
I hope the all above can be quite independent from e.g. path management
implementation.
If there is agreement on that, my plan would be to work on the listed
items, in order. As usual, any feedback more than welcome!
Thanks,
Paolo
2 years, 11 months
[PATCH 0/9] Implement outgoing MP_JOIN
by Peter Krystad
This is several accumulated fixes that are required for MP_JOIN
(secondary subflows) plus the outgoing code.
Both outgoing and incoming MP_JOIN now inter-operate
with the multipath.org implementation although there is
still a deadlock when incoming is fully established.
Since the incoming direction did not work at all before
this is an improvement. I have not yet tested running our
implmentation against itself.
The final patch in the set is an "interim path manager", this
is throw-away code that I include for testing purposes. For an
incoming connection it is necessary for the server to advertise
a secondary address and for my testing I have been hard-coding the IP
address of my secondary interface when I build the kernel.
Obviously not the final solution but we need to discuss what
approach to use for the self tests. I also think we may not want
to publish this patch on our net-next branch.
Peter Krystad (9):
Extend path manager interface
Fix locking in mptcp_finish_join.
Fix parsing MP_JOIN third ACK.
Re-factor and fixes for crypto_hmac_sha1()
Rename mptcp_attach_dss()
Fix return value if no DSS option is created.
Move setting request_ fields of subflow to MPTCP layer
mptcp: Add handling of outgoing MP_JOIN requests
mptcp: Implement interim path manager
include/net/mptcp.h | 12 +--
net/ipv4/tcp_input.c | 4 +-
net/mptcp/crypto.c | 23 +++---
net/mptcp/options.c | 77 ++++++++++++++++---
net/mptcp/pm.c | 171 +++++++++++++++++++++++++++++++++++++++++--
net/mptcp/protocol.c | 29 ++++++--
net/mptcp/protocol.h | 54 +++++++++++---
net/mptcp/subflow.c | 72 ++++++++++++++++--
net/mptcp/token.c | 82 ++++++++++++++++++---
9 files changed, 452 insertions(+), 72 deletions(-)
--
2.17.2
2 years, 11 months
[Weekly meetings] MoM - 25th of July 2019
by Matthieu Baerts
Hello,
We just had our 59th meeting with Mat, Peter and Ossama (Intel OTC) and
myself (Tessares).
Thanks again for this new good meeting!
Here are the minutes of the meeting:
Accepted patches:
- mptcp: harmonize locking on all socket operations:
- by Paolo
- accepted by Mat and Peter
- added at the end of the patch series
- mptcp: simplify crypto.c:
- by Davide
- v2 accepted by Matt (after a v1 reviewed by Mat and us at the
last meeting)
- "squashed" in "mptcp: Add key generation and token tree" and
"mptcp: Add handling of incoming MP_JOIN requests"
- mptcp: avoid validating MP_CAPABLE keys on 3way HS handling:
- by Paolo
- accepted by Peter, Mat, Christoph
- "squashed" in "mptcp: Create SUBFLOW socket for incoming
connections"
- should fix instability in the kselftests
- *Note*: Mat ran the kselftests in a loop for one hour and he
didn't see any issue!
Pending patches:
- mptcp: Make MPTCP socket block/wakeup ignore sk_receive_queue :
- by Mat
- commented by Paolo
- *Note*: Mat is looking at adding spinlock, he will check if it
could trigger deadlocks, more for a long term solution
- mptcp: new sysctl to control the activation per NS:
- by Matthieu
- Note*: still some open questions, feel free to comment ;-)
- Note*: if there is no comment, Matth will send a new version
tomorrow with two small changes (one comment, one renamed function)
- Implement outgoing MP_JOIN:
- patch-set (9 patches) by Peter
- *Note*: for the addition of the sysctl for the IP to announce,
this patch could be based on top of "mptcp: new sysctl to control the
activation per NS". Other solution is to temporary set a kernel module
option but because it is not set as a module, it will have to be set at
startup :)
- Note*: Peter will send a v2 soon, applying Paolo's
recommendations (it includes a split of the PM patch to have one patch
we will remove later on)
Feedback from netdev:
- nobody at the meeting receives any feedback
Feedback from LPC:
- any feedback? Should arrive next week or the week after:
> Proposals must be submitted by August 2nd, and submitters will
be notified of acceptance by August 9th.
Testing MPTCP Upstream with Sparse:
- anybody did that?
- Davide did some tests, not big issues. See:
https://paste.fedoraproject.org/paste/boVPC8dzVYZzxfLWDJ~T~g
roadmap proposal/discussion:
- see: https://lists.01.org/pipermail/mptcp/2019-July/001505.html
- seems that Peter is not working on the mentioned topics, maybe Mat is
- Mat will comment on the list
- Could be good to discuss about that in the meeting with Paolo next
time.
Next meeting:
- We propose to have it next Thursday, the 1st of August.
- Usual time: 16:00 UTC (9am PDT, 6pm CEST)
- Still open to everyone!
- https://annuel2.framapad.org/p/mptcp_upstreaming_20190801
Feel free to comment on these points and propose new ones for the next
meeting!
Talk to you next week,
Matthieu
--
Matthieu Baerts | R&D Engineer
matthieu.baerts(a)tessares.net
Tessares SA | Hybrid Access Solutions
www.tessares.net
1 Avenue Jean Monnet, 1348 Louvain-la-Neuve, Belgium
2 years, 11 months
[PATCH] mptcp: Make MPTCP socket block/wakeup ignore sk_receive_queue
by Mat Martineau
The MPTCP-level socket doesn't use sk_receive_queue, so it was possible
for mptcp_recvmsg() to remain blocked when there was data ready for it
to read. When the MPTCP socket is waiting for additional data and it
releases the subflow socket lock, the subflow may have incoming packets
ready to process and it sometimes called subflow_data_ready() before the
MPTCP socket called sk_wait_data().
This change adds new functions for the MPTCP socket to use to wait and
to signal that data is ready. Atomic bitops are used to set, test, and
clear a MPTCP socket flag that indicates waiting subflow data. This flag
replaces the sk_receive_queue checks used by other socket types.
Signed-off-by: Mat Martineau <mathew.j.martineau(a)linux.intel.com>
---
Squashing this into "mptcp: Implement MPTCP receive path" has a few
conflicts with later commits that also fix up the receive code. It's
fine to add this to the end of the commit chain.
net/mptcp/protocol.c | 40 +++++++++++++++++++++++++++++++++++++++-
net/mptcp/protocol.h | 4 ++++
2 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 774ed25d3b6d..5555ee1529bb 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -357,6 +357,26 @@ static enum mapping_status mptcp_get_mapping(struct sock *ssk)
return ret;
}
+static void mptcp_wait_data(struct sock *sk, long *timeo)
+{
+ DEFINE_WAIT_FUNC(wait, woken_wake_function);
+ struct mptcp_sock *msk = mptcp_sk(sk);
+
+ add_wait_queue(sk_sleep(sk), &wait);
+ sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk);
+
+ release_sock(sk);
+
+ if (!test_and_clear_bit(MPTCP_DATA_READY, &msk->flags))
+ *timeo = wait_woken(&wait, TASK_INTERRUPTIBLE, *timeo);
+
+ sched_annotate_sleep();
+ lock_sock(sk);
+
+ sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk);
+ remove_wait_queue(sk_sleep(sk), &wait);
+}
+
static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
int nonblock, int flags, int *addr_len)
{
@@ -403,6 +423,7 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
u64 old_ack;
u32 ssn;
+ clear_bit(MPTCP_DATA_READY, &msk->flags);
status = mptcp_get_mapping(ssk);
if (status == MAPPING_ADDED) {
@@ -536,7 +557,7 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
pr_debug("block");
release_sock(ssk);
- sk_wait_data(sk, &timeo, NULL);
+ mptcp_wait_data(sk, &timeo);
lock_sock(ssk);
}
@@ -548,6 +569,22 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
return copied;
}
+static void mptcp_data_ready(struct sock *sk)
+{
+ struct mptcp_sock *msk = mptcp_sk(sk);
+ struct socket_wq *wq;
+
+ set_bit(MPTCP_DATA_READY, &msk->flags);
+
+ rcu_read_lock();
+ wq = rcu_dereference(sk->sk_wq);
+ if (skwq_has_sleeper(wq))
+ wake_up_interruptible_sync_poll(&wq->wait, EPOLLIN | EPOLLPRI |
+ EPOLLRDNORM | EPOLLRDBAND);
+ sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN);
+ rcu_read_unlock();
+}
+
static int mptcp_init_sock(struct sock *sk)
{
struct mptcp_sock *msk = mptcp_sk(sk);
@@ -555,6 +592,7 @@ static int mptcp_init_sock(struct sock *sk)
pr_debug("msk=%p", msk);
INIT_LIST_HEAD(&msk->conn_list);
+ sk->sk_data_ready = mptcp_data_ready;
return 0;
}
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 7f15f6aab93d..ca5e6d839575 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -71,6 +71,9 @@
#define MPTCP_ADDR_IPVERSION_4 4
#define MPTCP_ADDR_IPVERSION_6 6
+/* MPTCP socket flags */
+#define MPTCP_DATA_READY BIT(0)
+
static inline u32 mptcp_option(u8 subopt, u8 len, u8 nib, u8 field)
{
return htonl((TCPOPT_MPTCP << 24) | (len << 16) | (subopt << 12) |
@@ -97,6 +100,7 @@ struct mptcp_sock {
u64 write_seq;
u64 ack_seq;
u32 token;
+ unsigned long flags;
struct list_head conn_list;
struct socket *subflow; /* outgoing connect/listener/!mp_capable */
struct pm_data pm;
--
2.22.0
2 years, 11 months
[PATCH v2 0/2] mptcp: simplify crypto.c
by Davide Caratti
his series wants to simplify, and hopefully improve, random generation
of keys and nonces in crypto.c, While at it, I removed some unneeded
#includes on top of the file. Any feedbacks are welcome!
Note:
in case you think the code is ok, I will propose to squash it into
commit a564283a1e38 ("mptcp: Add key generation and token tree")
Changes since v1:
- add a comment that suggests use of hash to improve performance,
thanks to Matthieu
- remove useless #include <tcp.h>, thanks Mat
Changes since RFC:
- use get_random_bytes() instead of siphash, thanks to Florian / Mat
Davide Caratti (2):
net: mptcp: remove useless #includes in crypto.c
net: mptcp: randomness improvements for crypto.c
net/mptcp/crypto.c | 76 --------------------------------------------
net/mptcp/protocol.c | 1 -
net/mptcp/protocol.h | 24 +++++++-------
net/mptcp/token.c | 54 ++++---------------------------
4 files changed, 19 insertions(+), 136 deletions(-)
--
2.20.1
2 years, 11 months