Skip to content

Commit

Permalink
mptcp: send out checksum for DSS
Browse files Browse the repository at this point in the history
In mptcp_write_options, if the checksum is enabled, adjust the option
length and send out the data checksum with DSS suboption.

Co-developed-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
  • Loading branch information
geliangtang authored and matttbe committed May 6, 2021
1 parent c227599 commit 020aa27
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions net/mptcp/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,9 @@ static bool mptcp_established_options_mp(struct sock *sk, struct sk_buff *skb,
if (data_len > 0) {
len = TCPOLEN_MPTCP_MPC_ACK_DATA;
if (opts->csum_reqd) {
/* we need to propagate more info to csum the pseudo hdr */
opts->ext_copy.data_seq = mpext->data_seq;
opts->ext_copy.subflow_seq = mpext->subflow_seq;
opts->ext_copy.csum = mpext->csum;
len += TCPOLEN_MPTCP_DSS_CHECKSUM;
}
Expand Down Expand Up @@ -549,18 +552,21 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,
bool ret = false;
u64 ack_seq;

opts->csum_reqd = READ_ONCE(msk->csum_enabled);
mpext = skb ? mptcp_get_ext(skb) : NULL;

if (!skb || (mpext && mpext->use_map) || snd_data_fin_enable) {
unsigned int map_size;
unsigned int map_size = TCPOLEN_MPTCP_DSS_BASE + TCPOLEN_MPTCP_DSS_MAP64;

map_size = TCPOLEN_MPTCP_DSS_BASE + TCPOLEN_MPTCP_DSS_MAP64;
if (mpext) {
if (opts->csum_reqd)
map_size += TCPOLEN_MPTCP_DSS_CHECKSUM;

remaining -= map_size;
dss_size = map_size;
if (mpext)
opts->ext_copy = *mpext;
}

remaining -= map_size;
dss_size = map_size;
if (skb && snd_data_fin_enable)
mptcp_write_data_fin(subflow, skb, &opts->ext_copy);
ret = true;
Expand Down Expand Up @@ -1350,6 +1356,9 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp,
flags |= MPTCP_DSS_HAS_MAP | MPTCP_DSS_DSN64;
if (mpext->data_fin)
flags |= MPTCP_DSS_DATA_FIN;

if (opts->csum_reqd)
len += TCPOLEN_MPTCP_DSS_CHECKSUM;
}

*ptr++ = mptcp_option(MPTCPOPT_DSS, len, 0, flags);
Expand All @@ -1369,8 +1378,13 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp,
ptr += 2;
put_unaligned_be32(mpext->subflow_seq, ptr);
ptr += 1;
put_unaligned_be32(mpext->data_len << 16 |
TCPOPT_NOP << 8 | TCPOPT_NOP, ptr);
if (opts->csum_reqd) {
put_unaligned_be32(mpext->data_len << 16 |
mptcp_make_csum(mpext), ptr);
} else {
put_unaligned_be32(mpext->data_len << 16 |
TCPOPT_NOP << 8 | TCPOPT_NOP, ptr);
}
}
}

Expand Down

0 comments on commit 020aa27

Please sign in to comment.