Skip to content

Commit c5b39e2

Browse files
geliangtangdavem330
authored andcommitted
mptcp: send out checksum for DSS
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 <[email protected]> Signed-off-by: Paolo Abeni <[email protected]> Signed-off-by: Geliang Tang <[email protected]> Signed-off-by: Mat Martineau <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c94b1f9 commit c5b39e2

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

net/mptcp/options.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,9 @@ static bool mptcp_established_options_mp(struct sock *sk, struct sk_buff *skb,
478478
if (data_len > 0) {
479479
len = TCPOLEN_MPTCP_MPC_ACK_DATA;
480480
if (opts->csum_reqd) {
481+
/* we need to propagate more info to csum the pseudo hdr */
482+
opts->ext_copy.data_seq = mpext->data_seq;
483+
opts->ext_copy.subflow_seq = mpext->subflow_seq;
481484
opts->ext_copy.csum = mpext->csum;
482485
len += TCPOLEN_MPTCP_DSS_CHECKSUM;
483486
}
@@ -545,18 +548,21 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,
545548
bool ret = false;
546549
u64 ack_seq;
547550

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

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

553-
map_size = TCPOLEN_MPTCP_DSS_BASE + TCPOLEN_MPTCP_DSS_MAP64;
557+
if (mpext) {
558+
if (opts->csum_reqd)
559+
map_size += TCPOLEN_MPTCP_DSS_CHECKSUM;
554560

555-
remaining -= map_size;
556-
dss_size = map_size;
557-
if (mpext)
558561
opts->ext_copy = *mpext;
562+
}
559563

564+
remaining -= map_size;
565+
dss_size = map_size;
560566
if (skb && snd_data_fin_enable)
561567
mptcp_write_data_fin(subflow, skb, &opts->ext_copy);
562568
ret = true;
@@ -1346,6 +1352,9 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp,
13461352
flags |= MPTCP_DSS_HAS_MAP | MPTCP_DSS_DSN64;
13471353
if (mpext->data_fin)
13481354
flags |= MPTCP_DSS_DATA_FIN;
1355+
1356+
if (opts->csum_reqd)
1357+
len += TCPOLEN_MPTCP_DSS_CHECKSUM;
13491358
}
13501359

13511360
*ptr++ = mptcp_option(MPTCPOPT_DSS, len, 0, flags);
@@ -1365,8 +1374,13 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp,
13651374
ptr += 2;
13661375
put_unaligned_be32(mpext->subflow_seq, ptr);
13671376
ptr += 1;
1368-
put_unaligned_be32(mpext->data_len << 16 |
1369-
TCPOPT_NOP << 8 | TCPOPT_NOP, ptr);
1377+
if (opts->csum_reqd) {
1378+
put_unaligned_be32(mpext->data_len << 16 |
1379+
mptcp_make_csum(mpext), ptr);
1380+
} else {
1381+
put_unaligned_be32(mpext->data_len << 16 |
1382+
TCPOPT_NOP << 8 | TCPOPT_NOP, ptr);
1383+
}
13701384
}
13711385
}
13721386

0 commit comments

Comments
 (0)