提交 456afe01 编写于 作者: M Matthieu Baerts 提交者: David S. Miller

mptcp: ADD_ADDRs with echo bit are smaller

The MPTCP ADD_ADDR suboption with echo-flag=1 has no HMAC, the size is
smaller than the one initially sent without echo-flag=1. We then need to
use the correct size everywhere when we need this echo bit.

Before this patch, the wrong size was reserved but the correct amount of
bytes were written (and read): the remaining bytes contained garbage.

Fixes: 6a6c05a8 ("mptcp: send out ADD_ADDR with echo flag")
Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/95Reported-and-tested-by: NDavide Caratti <dcaratti@redhat.com>
Acked-by: NGeliang Tang <geliangtang@gmail.com>
Signed-off-by: NMatthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 3a56268e
......@@ -587,7 +587,7 @@ static bool mptcp_established_options_add_addr(struct sock *sk,
!(mptcp_pm_add_addr_signal(msk, remaining, &saddr, &echo)))
return false;
len = mptcp_add_addr_len(saddr.family);
len = mptcp_add_addr_len(saddr.family, echo);
if (remaining < len)
return false;
......
......@@ -183,11 +183,12 @@ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
if (!mptcp_pm_should_add_signal(msk))
goto out_unlock;
if (remaining < mptcp_add_addr_len(msk->pm.local.family))
*echo = READ_ONCE(msk->pm.add_addr_echo);
if (remaining < mptcp_add_addr_len(msk->pm.local.family, *echo))
goto out_unlock;
*saddr = msk->pm.local;
*echo = READ_ONCE(msk->pm.add_addr_echo);
WRITE_ONCE(msk->pm.add_addr_signal, false);
ret = true;
......
......@@ -464,11 +464,12 @@ static inline bool mptcp_pm_should_rm_signal(struct mptcp_sock *msk)
return READ_ONCE(msk->pm.rm_addr_signal);
}
static inline unsigned int mptcp_add_addr_len(int family)
static inline unsigned int mptcp_add_addr_len(int family, bool echo)
{
if (family == AF_INET)
return TCPOLEN_MPTCP_ADD_ADDR;
return TCPOLEN_MPTCP_ADD_ADDR6;
return echo ? TCPOLEN_MPTCP_ADD_ADDR_BASE
: TCPOLEN_MPTCP_ADD_ADDR;
return echo ? TCPOLEN_MPTCP_ADD_ADDR6_BASE : TCPOLEN_MPTCP_ADD_ADDR6;
}
bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册