From 4b7f599f95e05a4e5123384c622dea45a533bec7 Mon Sep 17 00:00:00 2001 From: fabriziodemaria Date: Mon, 23 Nov 2015 09:59:37 +0100 Subject: [PATCH] mptcp: Exclude MPTCP options with IPv6 ADD_ADDR2 This guarantees that ADD_ADDR2 fits in the TCP options in case of IPv6 address advertisement and no port field. In this implementation, only MPTCP DSS option and MP_PRIO option are excluded. Plain TCP options are not affected. Signed-off-by: Fabrizio Demaria --- net/mptcp/mptcp_fullmesh.c | 6 ++---- net/mptcp/mptcp_output.c | 11 ++++++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/net/mptcp/mptcp_fullmesh.c b/net/mptcp/mptcp_fullmesh.c index 28c5f6601e39..81a8d767d8d4 100644 --- a/net/mptcp/mptcp_fullmesh.c +++ b/net/mptcp/mptcp_fullmesh.c @@ -1555,8 +1555,7 @@ static void full_mesh_addr_signal(struct sock *sk, unsigned *size, ((mpcb->mptcp_ver == 0 && MAX_TCP_OPTION_SPACE - *size >= MPTCP_SUB_LEN_ADD_ADDR4_ALIGN) || (mpcb->mptcp_ver >= 1 && - MAX_TCP_OPTION_SPACE - *size >= - MPTCP_SUB_LEN_ADD_ADDR4_ALIGN_VER1))) { + MAX_TCP_OPTION_SPACE - *size >= MPTCP_SUB_LEN_ADD_ADDR4_ALIGN_VER1))) { int ind = mptcp_find_free_index(~unannouncedv4); opts->options |= OPTION_MPTCP; @@ -1597,8 +1596,7 @@ static void full_mesh_addr_signal(struct sock *sk, unsigned *size, ((mpcb->mptcp_ver == 0 && MAX_TCP_OPTION_SPACE - *size >= MPTCP_SUB_LEN_ADD_ADDR6_ALIGN) || (mpcb->mptcp_ver >= 1 && - MAX_TCP_OPTION_SPACE - *size >= - MPTCP_SUB_LEN_ADD_ADDR6_ALIGN_VER1))) { + MAX_TCP_OPTION_SPACE - *size >= MPTCP_SUB_LEN_ADD_ADDR6_ALIGN_VER1))) { int ind = mptcp_find_free_index(~unannouncedv6); opts->options |= OPTION_MPTCP; diff --git a/net/mptcp/mptcp_output.c b/net/mptcp/mptcp_output.c index 3a65fd09cc96..6a108651a93a 100644 --- a/net/mptcp/mptcp_output.c +++ b/net/mptcp/mptcp_output.c @@ -960,12 +960,20 @@ void mptcp_established_options(struct sock *sk, struct sk_buff *skb, if (skb) tp->mptcp->include_mpc = 0; } + if (unlikely(tp->mptcp->pre_established)) { opts->options |= OPTION_MPTCP; opts->mptcp_options |= OPTION_MP_JOIN | OPTION_TYPE_ACK; *size += MPTCP_SUB_LEN_JOIN_ACK_ALIGN; } + if (unlikely(mpcb->addr_signal) && mpcb->pm_ops->addr_signal) { + mpcb->pm_ops->addr_signal(sk, size, opts, skb); + if (opts->add_addr_v6) + /* Skip subsequent options */ + return; + } + if (!tp->mptcp->include_mpc && !tp->mptcp->pre_established) { opts->options |= OPTION_MPTCP; opts->mptcp_options |= OPTION_DATA_ACK; @@ -985,9 +993,6 @@ void mptcp_established_options(struct sock *sk, struct sk_buff *skb, *size += MPTCP_SUB_LEN_DSS_ALIGN; } - if (unlikely(mpcb->addr_signal) && mpcb->pm_ops->addr_signal) - mpcb->pm_ops->addr_signal(sk, size, opts, skb); - if (unlikely(tp->mptcp->send_mp_prio) && MAX_TCP_OPTION_SPACE - *size >= MPTCP_SUB_LEN_PRIO_ALIGN) { opts->options |= OPTION_MPTCP;