mptcp: Don't call mptcp_lookup_join on every SYN for IPv4

Use the options parsed for a normal SYN to check if this is a SYN+MP_JOIN.
This avoid parsing the options multiple times searching for MP_JOIN and reuses some of the normal TCP code.
The initial handling code is still present in case a SYN is sent to a socket that is not listening.

Signed-off-by: Mihai P. Andrei <mihai.p.andrei@intel.com>
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
mptcp: Minor coding style fixes

Minor coding style fixes for the patch "Don't call mptcp_lookup_join on every SYN for IPv4".

Signed-off-by: Mihai P. Andrei <mihai.p.andrei@intel.com>
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
mptcp: Don't call mptcp_lookup_join on every SYN for IPv6

Same changes as for IPv4 are applied to IPv6 functions.

Signed-off-by: Mihai P. Andrei <mihai.p.andrei@intel.com>
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Fix: Correctly initialize security on meta-sk

When creating the meta-sk we have also to set the sk_security-pointer.
Otherwise he will be pointing to the one from the master_sk and will
thus get free'd twice at the end.

Reporde-by: Stephen Hankinson <stephen.hankinson@quarkengineering.com>
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Handle rcv_ssthresh at the meta-level

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Fix: Set pushed_seq and snd_up in mptcp_alloc_mpcb

pushed_seq and snd_up were not initialized correctly in the meta-sk.

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Initialize snd_wl1 and snd_wnd in mptcp_alloc_mpcb

This simplifies a little bit the window-code.

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Set advmss in mptcp_alloc_mpcb

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Cleanup usage of mptcp_update_window_clamp

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Make the rcvbuf fully handled at the meta-level

With the previous design, where tcp_rcv_space_adjust was called on the
subsocket, as soon as copied-seq changed, it behaved as if the
application is reading at infinite speed. Because segments are always
directly taken out of the subflow-receive-queue.

We have to calculate the receive-buffer at the meta-level, taking into
account the application-speed.

This patch fixes this, by calling tcp_rcv_space_adjust on the
meta-socket.

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Restore the old tcp_prequeue

We now add the packets in the meta-level prequeue. This largely
simplifies the code, is safer in terms of receive-buffer-handling and
reduces cpu-cycles as we don't anymore have to iterate over all sockets
in tcp_recvmsg.

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Review buffer-handling when new subflows are added.

We just add the new subflow's rcv-buffer and window-clamp to the
meta-buffer. This allows traffic on the new subflow. Auto-tuning will
later further increase the meta-buffer to allow full speed on the new
subflow.

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Cleanup tcp_copy_to_iovec

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Cleanup: remove some old exports

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Cleanup: Restore old tcp_openreq_init

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Remove BUG() in address-handler

It may be, that the user-space tries to add twice the same address. This
will still generate a net-event. Even if it doesn't has an impact on the
interface-configuration itself.

We would then crash, because the address is already in the list. Adding
twice the same address is maybe not very smart from the user-space, but
he is allowed to do so.

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Call sock_rps_record_flow in mptcp_v*_do_rcv

A call to sock_rps_record_flow was added to mptcp_v*_do_rcv in order to
mimic what is done in tcp_v*_do_rcv. This allows to enable RPS directly
for new subflows when receiving the third ack and not after receiving
the first data segment.

Signed-off-by: Gregory Detal <gregory.detal@uclouvain.be>
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Fix: Don't increase copied_seq for each fin

Otherwise, retransmitted subflow-FIN's will result in copied_seq to
become bigger than rcv_nxt. This should never happen.

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Fix: Always send an ack upon data-fin

The meta-socket may already be in close-state, but we can still receive
data-fin's (retransmissions). In that case, we also have to acknowledge
the data-fin by sending a subflow-ack.

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Fix: Only close a subflow, if we received the data-ack of the data-fin

If we are a passive closer, and we receive a subflow-fin, we should not
close the subflow until we received the data-ack, meaning
snd_una == write_seq.

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>