Skip to content

Commit 456afe0

Browse files
matttbedavem330
authored andcommitted
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: 6a6c05a ("mptcp: send out ADD_ADDR with echo flag") Closes: multipath-tcp/mptcp_net-next#95 Reported-and-tested-by: Davide Caratti <[email protected]> Acked-by: Geliang Tang <[email protected]> Signed-off-by: Matthieu Baerts <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3a56268 commit 456afe0

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

net/mptcp/options.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ static bool mptcp_established_options_add_addr(struct sock *sk,
587587
!(mptcp_pm_add_addr_signal(msk, remaining, &saddr, &echo)))
588588
return false;
589589

590-
len = mptcp_add_addr_len(saddr.family);
590+
len = mptcp_add_addr_len(saddr.family, echo);
591591
if (remaining < len)
592592
return false;
593593

net/mptcp/pm.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,12 @@ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
183183
if (!mptcp_pm_should_add_signal(msk))
184184
goto out_unlock;
185185

186-
if (remaining < mptcp_add_addr_len(msk->pm.local.family))
186+
*echo = READ_ONCE(msk->pm.add_addr_echo);
187+
188+
if (remaining < mptcp_add_addr_len(msk->pm.local.family, *echo))
187189
goto out_unlock;
188190

189191
*saddr = msk->pm.local;
190-
*echo = READ_ONCE(msk->pm.add_addr_echo);
191192
WRITE_ONCE(msk->pm.add_addr_signal, false);
192193
ret = true;
193194

net/mptcp/protocol.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,11 +464,12 @@ static inline bool mptcp_pm_should_rm_signal(struct mptcp_sock *msk)
464464
return READ_ONCE(msk->pm.rm_addr_signal);
465465
}
466466

467-
static inline unsigned int mptcp_add_addr_len(int family)
467+
static inline unsigned int mptcp_add_addr_len(int family, bool echo)
468468
{
469469
if (family == AF_INET)
470-
return TCPOLEN_MPTCP_ADD_ADDR;
471-
return TCPOLEN_MPTCP_ADD_ADDR6;
470+
return echo ? TCPOLEN_MPTCP_ADD_ADDR_BASE
471+
: TCPOLEN_MPTCP_ADD_ADDR;
472+
return echo ? TCPOLEN_MPTCP_ADD_ADDR6_BASE : TCPOLEN_MPTCP_ADD_ADDR6;
472473
}
473474

474475
bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,

0 commit comments

Comments
 (0)