@@ -81,11 +81,11 @@ static void mptcp_parse_option(const struct sk_buff *skb,
81
81
* is if both hosts in their SYNs set A=0."
82
82
*/
83
83
if (flags & MPTCP_CAP_CHECKSUM_REQD )
84
- mp_opt -> csum_reqd = 1 ;
84
+ mp_opt -> suboptions |= OPTION_MPTCP_CSUMREQD ;
85
85
86
86
mp_opt -> deny_join_id0 = !!(flags & MPTCP_CAP_DENY_JOIN_ID0 );
87
87
88
- mp_opt -> mp_capable = 1 ;
88
+ mp_opt -> suboptions |= OPTIONS_MPTCP_MPC ;
89
89
if (opsize >= TCPOLEN_MPTCP_MPC_SYNACK ) {
90
90
mp_opt -> sndr_key = get_unaligned_be64 (ptr );
91
91
ptr += 8 ;
@@ -100,15 +100,15 @@ static void mptcp_parse_option(const struct sk_buff *skb,
100
100
* equivalent to those in a DSS option and can be used
101
101
* interchangeably."
102
102
*/
103
- mp_opt -> dss = 1 ;
103
+ mp_opt -> suboptions |= OPTION_MPTCP_DSS ;
104
104
mp_opt -> use_map = 1 ;
105
105
mp_opt -> mpc_map = 1 ;
106
106
mp_opt -> data_len = get_unaligned_be16 (ptr );
107
107
ptr += 2 ;
108
108
}
109
109
if (opsize == TCPOLEN_MPTCP_MPC_ACK_DATA_CSUM ) {
110
110
mp_opt -> csum = (__force __sum16 )get_unaligned_be16 (ptr );
111
- mp_opt -> csum_reqd = 1 ;
111
+ mp_opt -> suboptions |= OPTION_MPTCP_CSUMREQD ;
112
112
ptr += 2 ;
113
113
}
114
114
pr_debug ("MP_CAPABLE version=%x, flags=%x, optlen=%d sndr=%llu, rcvr=%llu len=%d csum=%u" ,
@@ -117,7 +117,7 @@ static void mptcp_parse_option(const struct sk_buff *skb,
117
117
break ;
118
118
119
119
case MPTCPOPT_MP_JOIN :
120
- mp_opt -> mp_join = 1 ;
120
+ mp_opt -> suboptions |= OPTIONS_MPTCP_MPJ ;
121
121
if (opsize == TCPOLEN_MPTCP_MPJ_SYN ) {
122
122
mp_opt -> backup = * ptr ++ & MPTCPOPT_BACKUP ;
123
123
mp_opt -> join_id = * ptr ++ ;
@@ -143,7 +143,7 @@ static void mptcp_parse_option(const struct sk_buff *skb,
143
143
memcpy (mp_opt -> hmac , ptr , MPTCPOPT_HMAC_LEN );
144
144
pr_debug ("MP_JOIN hmac" );
145
145
} else {
146
- mp_opt -> mp_join = 0 ;
146
+ mp_opt -> suboptions &= ~ OPTIONS_MPTCP_MPJ ;
147
147
}
148
148
break ;
149
149
@@ -191,8 +191,7 @@ static void mptcp_parse_option(const struct sk_buff *skb,
191
191
opsize != expected_opsize + TCPOLEN_MPTCP_DSS_CHECKSUM )
192
192
break ;
193
193
194
- mp_opt -> dss = 1 ;
195
-
194
+ mp_opt -> suboptions |= OPTION_MPTCP_DSS ;
196
195
if (mp_opt -> use_ack ) {
197
196
if (mp_opt -> ack64 ) {
198
197
mp_opt -> data_ack = get_unaligned_be64 (ptr );
@@ -221,14 +220,15 @@ static void mptcp_parse_option(const struct sk_buff *skb,
221
220
ptr += 2 ;
222
221
223
222
if (opsize == expected_opsize + TCPOLEN_MPTCP_DSS_CHECKSUM ) {
224
- mp_opt -> csum_reqd = 1 ;
223
+ mp_opt -> suboptions |= OPTION_MPTCP_CSUMREQD ;
225
224
mp_opt -> csum = (__force __sum16 )get_unaligned_be16 (ptr );
226
225
ptr += 2 ;
227
226
}
228
227
229
228
pr_debug ("data_seq=%llu subflow_seq=%u data_len=%u csum=%d:%u" ,
230
229
mp_opt -> data_seq , mp_opt -> subflow_seq ,
231
- mp_opt -> data_len , mp_opt -> csum_reqd , mp_opt -> csum );
230
+ mp_opt -> data_len , !!(mp_opt -> suboptions & OPTION_MPTCP_CSUMREQD ),
231
+ mp_opt -> csum );
232
232
}
233
233
234
234
break ;
@@ -259,7 +259,7 @@ static void mptcp_parse_option(const struct sk_buff *skb,
259
259
break ;
260
260
}
261
261
262
- mp_opt -> add_addr = 1 ;
262
+ mp_opt -> suboptions |= OPTION_MPTCP_ADD_ADDR ;
263
263
mp_opt -> addr .id = * ptr ++ ;
264
264
mp_opt -> addr .port = 0 ;
265
265
mp_opt -> ahmac = 0 ;
@@ -299,7 +299,7 @@ static void mptcp_parse_option(const struct sk_buff *skb,
299
299
300
300
ptr ++ ;
301
301
302
- mp_opt -> rm_addr = 1 ;
302
+ mp_opt -> suboptions |= OPTION_MPTCP_RM_ADDR ;
303
303
mp_opt -> rm_list .nr = opsize - TCPOLEN_MPTCP_RM_ADDR_BASE ;
304
304
for (i = 0 ; i < mp_opt -> rm_list .nr ; i ++ )
305
305
mp_opt -> rm_list .ids [i ] = * ptr ++ ;
@@ -310,7 +310,7 @@ static void mptcp_parse_option(const struct sk_buff *skb,
310
310
if (opsize != TCPOLEN_MPTCP_PRIO )
311
311
break ;
312
312
313
- mp_opt -> mp_prio = 1 ;
313
+ mp_opt -> suboptions |= OPTION_MPTCP_PRIO ;
314
314
mp_opt -> backup = * ptr ++ & MPTCP_PRIO_BKUP ;
315
315
pr_debug ("MP_PRIO: prio=%d" , mp_opt -> backup );
316
316
break ;
@@ -322,7 +322,7 @@ static void mptcp_parse_option(const struct sk_buff *skb,
322
322
ptr += 2 ;
323
323
mp_opt -> rcvr_key = get_unaligned_be64 (ptr );
324
324
ptr += 8 ;
325
- mp_opt -> fastclose = 1 ;
325
+ mp_opt -> suboptions |= OPTION_MPTCP_FASTCLOSE ;
326
326
break ;
327
327
328
328
case MPTCPOPT_RST :
@@ -331,7 +331,8 @@ static void mptcp_parse_option(const struct sk_buff *skb,
331
331
332
332
if (!(TCP_SKB_CB (skb )-> tcp_flags & TCPHDR_RST ))
333
333
break ;
334
- mp_opt -> reset = 1 ;
334
+
335
+ mp_opt -> suboptions |= OPTION_MPTCP_RST ;
335
336
flags = * ptr ++ ;
336
337
mp_opt -> reset_transient = flags & MPTCP_RST_TRANSIENT ;
337
338
mp_opt -> reset_reason = * ptr ;
@@ -342,7 +343,7 @@ static void mptcp_parse_option(const struct sk_buff *skb,
342
343
break ;
343
344
344
345
ptr += 2 ;
345
- mp_opt -> mp_fail = 1 ;
346
+ mp_opt -> suboptions |= OPTION_MPTCP_FAIL ;
346
347
mp_opt -> fail_seq = get_unaligned_be64 (ptr );
347
348
pr_debug ("MP_FAIL: data_seq=%llu" , mp_opt -> fail_seq );
348
349
break ;
@@ -361,16 +362,7 @@ void mptcp_get_options(const struct sock *sk,
361
362
int length ;
362
363
363
364
/* initialize option status */
364
- mp_opt -> mp_capable = 0 ;
365
- mp_opt -> mp_join = 0 ;
366
- mp_opt -> add_addr = 0 ;
367
- mp_opt -> fastclose = 0 ;
368
- mp_opt -> rm_addr = 0 ;
369
- mp_opt -> dss = 0 ;
370
- mp_opt -> mp_prio = 0 ;
371
- mp_opt -> reset = 0 ;
372
- mp_opt -> csum_reqd = 0 ;
373
- mp_opt -> mp_fail = 0 ;
365
+ mp_opt -> suboptions = 0 ;
374
366
375
367
length = (th -> doff * 4 ) - sizeof (struct tcphdr );
376
368
ptr = (const unsigned char * )(th + 1 );
@@ -924,7 +916,7 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk,
924
916
*/
925
917
if (TCP_SKB_CB (skb )-> seq == subflow -> ssn_offset + 1 &&
926
918
TCP_SKB_CB (skb )-> end_seq == TCP_SKB_CB (skb )-> seq &&
927
- subflow -> mp_join && mp_opt -> mp_join &&
919
+ subflow -> mp_join && ( mp_opt -> suboptions & OPTIONS_MPTCP_MPJ ) &&
928
920
READ_ONCE (msk -> pm .server_side ))
929
921
tcp_send_ack (ssk );
930
922
goto fully_established ;
@@ -941,8 +933,8 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk,
941
933
return subflow -> mp_capable ;
942
934
}
943
935
944
- if ((mp_opt -> dss && mp_opt -> use_ack ) ||
945
- (mp_opt -> add_addr && !mp_opt -> echo )) {
936
+ if ((( mp_opt -> suboptions & OPTION_MPTCP_DSS ) && mp_opt -> use_ack ) ||
937
+ (( mp_opt -> suboptions & OPTION_MPTCP_ADD_ADDR ) && !mp_opt -> echo )) {
946
938
/* subflows are fully established as soon as we get any
947
939
* additional ack, including ADD_ADDR.
948
940
*/
@@ -955,7 +947,7 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk,
955
947
* then fallback to TCP. Fallback scenarios requires a reset for
956
948
* MP_JOIN subflows.
957
949
*/
958
- if (!mp_opt -> mp_capable ) {
950
+ if (!( mp_opt -> suboptions & OPTIONS_MPTCP_MPC ) ) {
959
951
if (subflow -> mp_join )
960
952
goto reset ;
961
953
subflow -> mp_capable = 0 ;
@@ -1119,13 +1111,13 @@ bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)
1119
1111
if (!check_fully_established (msk , sk , subflow , skb , & mp_opt ))
1120
1112
return sk -> sk_state != TCP_CLOSE ;
1121
1113
1122
- if (mp_opt .fastclose &&
1114
+ if (( mp_opt .suboptions & OPTION_MPTCP_FASTCLOSE ) &&
1123
1115
msk -> local_key == mp_opt .rcvr_key ) {
1124
1116
WRITE_ONCE (msk -> rcv_fastclose , true);
1125
1117
mptcp_schedule_work ((struct sock * )msk );
1126
1118
}
1127
1119
1128
- if (mp_opt .add_addr && add_addr_hmac_valid (msk , & mp_opt )) {
1120
+ if (( mp_opt .suboptions & OPTION_MPTCP_ADD_ADDR ) && add_addr_hmac_valid (msk , & mp_opt )) {
1129
1121
if (!mp_opt .echo ) {
1130
1122
mptcp_pm_add_addr_received (msk , & mp_opt .addr );
1131
1123
MPTCP_INC_STATS (sock_net (sk ), MPTCP_MIB_ADDADDR );
@@ -1137,34 +1129,28 @@ bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)
1137
1129
1138
1130
if (mp_opt .addr .port )
1139
1131
MPTCP_INC_STATS (sock_net (sk ), MPTCP_MIB_PORTADD );
1140
-
1141
- mp_opt .add_addr = 0 ;
1142
1132
}
1143
1133
1144
- if (mp_opt .rm_addr ) {
1134
+ if (mp_opt .suboptions & OPTION_MPTCP_RM_ADDR )
1145
1135
mptcp_pm_rm_addr_received (msk , & mp_opt .rm_list );
1146
- mp_opt .rm_addr = 0 ;
1147
- }
1148
1136
1149
- if (mp_opt .mp_prio ) {
1137
+ if (mp_opt .suboptions & OPTION_MPTCP_PRIO ) {
1150
1138
mptcp_pm_mp_prio_received (sk , mp_opt .backup );
1151
1139
MPTCP_INC_STATS (sock_net (sk ), MPTCP_MIB_MPPRIORX );
1152
- mp_opt .mp_prio = 0 ;
1153
1140
}
1154
1141
1155
- if (mp_opt .mp_fail ) {
1142
+ if (mp_opt .suboptions & OPTION_MPTCP_FAIL ) {
1156
1143
mptcp_pm_mp_fail_received (sk , mp_opt .fail_seq );
1157
1144
MPTCP_INC_STATS (sock_net (sk ), MPTCP_MIB_MPFAILRX );
1158
- mp_opt .mp_fail = 0 ;
1159
1145
}
1160
1146
1161
- if (mp_opt .reset ) {
1147
+ if (mp_opt .suboptions & OPTION_MPTCP_RST ) {
1162
1148
subflow -> reset_seen = 1 ;
1163
1149
subflow -> reset_reason = mp_opt .reset_reason ;
1164
1150
subflow -> reset_transient = mp_opt .reset_transient ;
1165
1151
}
1166
1152
1167
- if (!mp_opt .dss )
1153
+ if (!( mp_opt .suboptions & OPTION_MPTCP_DSS ) )
1168
1154
return true;
1169
1155
1170
1156
/* we can't wait for recvmsg() to update the ack_seq, otherwise
@@ -1213,7 +1199,7 @@ bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)
1213
1199
}
1214
1200
mpext -> data_len = mp_opt .data_len ;
1215
1201
mpext -> use_map = 1 ;
1216
- mpext -> csum_reqd = mp_opt .csum_reqd ;
1202
+ mpext -> csum_reqd = !!( mp_opt .suboptions & OPTION_MPTCP_CSUMREQD ) ;
1217
1203
1218
1204
if (mpext -> csum_reqd )
1219
1205
mpext -> csum = mp_opt .csum ;
0 commit comments