Advertise our real mss

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Fix MSS with MPTCP-DSS-len as for timestamps

Everywhere in the TCP-stack, the MSS is fixed after timestamps have been
negotiated. We have to do the same for MPTCP.

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

Conflicts:
	net/ipv4/tcp_input.c

Signed-off-by: Gregory Detal <gregory.detal@uclouvain.be>
Correctly update mss_cache

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Send out correct sized packets

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

Conflicts:
	net/ipv4/tcp_output.c
	net/mptcp/mptcp_output.c

Signed-off-by: Gregory Detal <gregory.detal@uclouvain.be>
CCC support for variable MSS

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Signed-off-by: Gregory Detal <gregory.detal@uclouvain.be>
inet: Fix kmemleak in tcp_v4/6_syn_recv_sock and dccp_v4/6_request_recv_sock

If in either of the above functions inet_csk_route_child_sock() or
__inet_inherit_port() fails, the newsk will not be freed:

unreferenced object 0xffff88022e8a92c0 (size 1592):
  comm "softirq", pid 0, jiffies 4294946244 (age 726.160s)
  hex dump (first 32 bytes):
    0a 01 01 01 0a 01 01 02 00 00 00 00 a7 cc 16 00  ................
    02 00 03 01 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<ffffffff8153d190>] kmemleak_alloc+0x21/0x3e
    [<ffffffff810ab3e7>] kmem_cache_alloc+0xb5/0xc5
    [<ffffffff8149b65b>] sk_prot_alloc.isra.53+0x2b/0xcd
    [<ffffffff8149b784>] sk_clone_lock+0x16/0x21e
    [<ffffffff814d711a>] inet_csk_clone_lock+0x10/0x7b
    [<ffffffff814ebbc3>] tcp_create_openreq_child+0x21/0x481
    [<ffffffff814e8fa5>] tcp_v4_syn_recv_sock+0x3a/0x23b
    [<ffffffff814ec5ba>] tcp_check_req+0x29f/0x416
    [<ffffffff814e8e10>] tcp_v4_do_rcv+0x161/0x2bc
    [<ffffffff814eb917>] tcp_v4_rcv+0x6c9/0x701
    [<ffffffff814cea9f>] ip_local_deliver_finish+0x70/0xc4
    [<ffffffff814cec20>] ip_local_deliver+0x4e/0x7f
    [<ffffffff814ce9f8>] ip_rcv_finish+0x1fc/0x233
    [<ffffffff814cee68>] ip_rcv+0x217/0x267
    [<ffffffff814a7bbe>] __netif_receive_skb+0x49e/0x553
    [<ffffffff814a7cc3>] netif_receive_skb+0x50/0x82

This happens, because sk_clone_lock initializes sk_refcnt to 2, and thus
a single sock_put() is not enough to free the memory. Additionally, things
like xfrm, memcg, cookie_values,... may have been initialized.
We have to free them properly.

This is fixed by forcing a call to tcp_done(), ending up in
inet_csk_destroy_sock, doing the final sock_put(). tcp_done() is necessary,
because it ends up doing all the cleanup on xfrm, memcg, cookie_values,
xfrm,...

Before calling tcp_done, we have to set the socket to SOCK_DEAD, to
force it entering inet_csk_destroy_sock. To avoid the warning in
inet_csk_destroy_sock, inet_num has to be set to 0.
As inet_csk_destroy_sock does a dec on orphan_count, we first have to
increase it.

Calling tcp_done() allows us to remove the calls to
tcp_clear_xmit_timer() and tcp_cleanup_congestion_control().

A similar approach is taken for dccp by calling dccp_done().

This is in the kernel since 093d282321 (tproxy: fix hash locking issue
when using port redirection in __inet_inherit_port()), thus since
version >= 2.6.37.

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Signed-off-by: David S. Miller <davem@davemloft.net>

Conflicts:
	net/dccp/ipv4.c
	net/ipv4/tcp_ipv4.c

Signed-off-by: Gregory Detal <gregory.detal@uclouvain.be>
Cleanup: unused variable

Signed-off-by: Gregory Detal <gregory.detal@uclouvain.be>
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Signed-off-by: Gregory Detal <gregory.detal@uclouvain.be>
Fix: can set Olia as default CC even if not selected

Signed-off-by: Gregory Detal <gregory.detal@uclouvain.be>
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Signed-off-by: Gregory Detal <gregory.detal@uclouvain.be>
Cleanup

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Signed-off-by: Gregory Detal <gregory.detal@uclouvain.be>
Fix error-handling

Error-handling was not correct. This patch fixes it.

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Signed-off-by: Gregory Detal <gregory.detal@uclouvain.be>
Fix: Retransmissions of the third JOIN-ack

There was a problem with the previous design:
Retransmissions of the third join-ack had seq = snd_una - 1.
This is not correct, as tcp_check_req will drop the retransmitted third
ack.

So, we have to trigger an ack of these retransmissions manually in
mptcp_parse_options().

Additionally, we now move the fields is_mp_join and join_ack from
multipath_options to tcp_options_received. They really do not make any
sense at the meta-level. They are per-subflow information.

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Signed-off-by: Gregory Detal <gregory.detal@uclouvain.be>
Fix: Correctly increase the sk_refcnt

It may be, that sk_refcnt is already 0, when we found it in the
request-sock or tk_hashtable. So, we should do it like in
inet_lookup_established and do an atomic_inc_not_zero.

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Signed-off-by: Gregory Detal <gregory.detal@uclouvain.be>
Fix: Take the lock in mptcp_inherit_sk

This brings it closer to sk_clone and makes socket-handling safer
afterwards.

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Signed-off-by: Gregory Detal <gregory.detal@uclouvain.be>
Fix: deschedule time-wait socks earlier

Otherwise, inside mptcp_v4_do_rcv we will hit again on the
timewait-socket.

We have to prevent this, by descheduling it early in mptcp_lookup_join,
after we found a valid meta socket.

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

Conflicts:
	net/mptcp/mptcp_pm.c

Signed-off-by: Gregory Detal <gregory.detal@uclouvain.be>
Fix: Don't tw-put if it is a data-fin

The time-wait-put must NOT be done if we want to return TW_ACK. Because,
tcp_v4_timewait_ack does already a put on the tw-socket.

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Signed-off-by: Gregory Detal <gregory.detal@uclouvain.be>
Fix: Missing initialization of join_ack

join_ack must be set to 0 in tcp_clear_options.

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Signed-off-by: Gregory Detal <gregory.detal@uclouvain.be>
Build-Fix

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Signed-off-by: Gregory Detal <gregory.detal@uclouvain.be>
Fix: Use net-namespace when looking up the meta

We have to check the net-namespace when looking up the meta-sk.

This patch fixes it.

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

Conflicts:
	net/mptcp/mptcp_pm.c

Signed-off-by: Gregory Detal <gregory.detal@uclouvain.be>
Fix: Net-namespace when incrementing the MIB

Inside mptcp_do_join_short (and similar functions), we increment the MIB
of the skb's net-namespace if add_backlog fails.

However, skb->dev has been set to NULL in tcp_v4_rcv. Thus, we have to
pass the net-namespace as a parameter to the functions.

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

Conflicts:
	net/mptcp/mptcp_pm.c

Signed-off-by: Gregory Detal <gregory.detal@uclouvain.be>
Don't unset include_mpc always in mptcp_established_options

Only unset it, if it was set and an skb is present.

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Signed-off-by: Gregory Detal <gregory.detal@uclouvain.be>