Fix: Check path-array and fail_rcvd after mptcp_post_parse_options

As the MPTCP-options are read only in mptcp_post_parse_options, we have
to move the code out of tcp_fast_parse_options into
tcp_validate_incoming, where mptcp_post_parse_options is called.

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Add comment in tcp_rcv_state_process

To better understand, why this 'if' is there.

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Fix: Don't close if already SOCK_DEAD

We may call tcp_close twice, if the socket is already dead. We have to
prevent this!

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Fix: memleak of reinjected segments

We should not increase the dataref for pskb_copy'd segments in
mptcp_write_xmit.

Because, this segment gets removed from the reinject-queue and will only
exist in the subflow-send-queue. Thus, the dataref should be one,
because the subflow-send-queue is the only place where we access this
segment.

If we increase the dataref, the linear part of the skb will not get
freed from kfree_skb() in tcp_clean_rtx_queue and we have a memory-leak,
as no one else (except the subflow-send-queue) had access to this
segment.

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Fix: Correctly extract idsn out of sha-1

With big-endian machines the previous extract was wrong. We should just
convert it by using a u64 pointer.

Reported-by: Stephen Hankinson <stephen.hankinson@quarkengineering.com>
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Tested-by: Stephen Hankinson <stephen.hankinson@quarkengineering.com>
Fix: Set inet_opt to NULL when deleting socket

Otherwise we will call a double-free in inet_sock_destruct, because we
will free the meta-sk (who has the same inet_opt-pointer as the
master_sk).

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
ipv4: Use newinet->inet_opt in inet_csk_route_child_sock()

Since 0e734419923bd ("ipv4: Use inet_csk_route_child_sock() in DCCP and
TCP."), inet_csk_route_child_sock() is called instead of
inet_csk_route_req().

However, after creating the child-sock in tcp/dccp_v4_syn_recv_sock(),
ireq->opt is set to NULL, before calling inet_csk_route_child_sock().
Thus, inside inet_csk_route_child_sock() opt is always NULL and the
SRR-options are not respected anymore.
Packets sent by the server won't have the correct destination-IP.

This patch fixes it by accessing newinet->inet_opt instead of ireq->opt
inside inet_csk_route_child_sock().

Reported-by: Luca Boccassi <luca.boccassi@gmail.com>
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Display meta-sock addresses in /proc/net/mptcp_pm

Signed-off-by: Gregory Detal <gregory.detal@uclouvain.be>
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Merge remote-tracking branch 'upstream/mptcp_trunk' into mptcp_trunk
Cleanup multipath_options

Remove useless field mptcp_opt_type that was only used in
mptcp_check_req_child to see whether the MP_JOIN(ACK) option was present
in the incomming segment.

Signed-off-by: Gregory Detal <gregory.detal@uclouvain.be>
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
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>