Added support to stop retransmitting the SYNs with MP_CAPABLE option after a number of packets.
The number can be set via the sysctl variable net.mptcp.mptcp_syn_retries.

Signed-off-by: Mihai P. Andrei <mihai.p.andrei@intel.com>
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Build-Fix : fix build without CONFIG_MPTCP

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
mptcp: Simpler check to limit SYNs sent with MP_CAPABLE option

Use icsk->icsk_retransmits instead of tcp_write_timeout.

Signed-off-by: Mihai P. Andrei <mihai.p.andrei@intel.com>
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Build-Fix: Compile without CONFIG_MPTCP

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Fix: mptcp_for_each_bit_set and mptcp_for_each_bit_unset

__ffs()'s behavior is undefined if input is 0. Same for ffz, whose
behavior is undefined if there are no zero-set bits.

This patch fixes it, by using the safer ffs().

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>
Cleanup

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Fix correctly shift the index

Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
mptcp: OPTION_ADD_ADDR truncates ipv6 addresses to ipv4

In function mptcp_options_write, the kind of address used is checked with:
if (opts->addr4) {...}
else if (opts->addr6) {...}
Because in tcp_out_options, addr4 and addr6 are in a union, addr4 will always be set if addr6 is.

Removed the union for now.

Signed-off-by: Mihai P. Andrei <mihai.p.andrei@intel.com>
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
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>
Merge branch 'mptcp_trunk' into mptcp_ipext
Merge branch 'mptcp_ipext' into mptcp_sockopt