Lines Matching refs:subflow

338 static bool subflow_thmac_valid(struct mptcp_subflow_context *subflow)  in subflow_thmac_valid()  argument
343 subflow_generate_hmac(subflow->remote_key, subflow->local_key, in subflow_thmac_valid()
344 subflow->remote_nonce, subflow->local_nonce, in subflow_thmac_valid()
349 subflow, subflow->token, thmac, subflow->thmac); in subflow_thmac_valid()
351 return thmac == subflow->thmac; in subflow_thmac_valid()
356 struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk); in mptcp_subflow_reset() local
357 struct sock *sk = subflow->conn; in mptcp_subflow_reset()
397 struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk); in subflow_finish_connect() local
399 struct sock *parent = subflow->conn; in subflow_finish_connect()
401 subflow->icsk_af_ops->sk_rx_dst_set(sk, skb); in subflow_finish_connect()
404 if (subflow->conn_finished) in subflow_finish_connect()
408 subflow->rel_write_seq = 1; in subflow_finish_connect()
409 subflow->conn_finished = 1; in subflow_finish_connect()
410 subflow->ssn_offset = TCP_SKB_CB(skb)->seq; in subflow_finish_connect()
411 pr_debug("subflow=%p synack seq=%x", subflow, subflow->ssn_offset); in subflow_finish_connect()
414 if (subflow->request_mptcp) { in subflow_finish_connect()
419 pr_fallback(mptcp_sk(subflow->conn)); in subflow_finish_connect()
427 subflow->mp_capable = 1; in subflow_finish_connect()
428 subflow->can_ack = 1; in subflow_finish_connect()
429 subflow->remote_key = mp_opt.sndr_key; in subflow_finish_connect()
430 pr_debug("subflow=%p, remote_key=%llu", subflow, in subflow_finish_connect()
431 subflow->remote_key); in subflow_finish_connect()
435 } else if (subflow->request_join) { in subflow_finish_connect()
439 subflow->reset_reason = MPTCP_RST_EMPTCP; in subflow_finish_connect()
443 subflow->backup = mp_opt.backup; in subflow_finish_connect()
444 subflow->thmac = mp_opt.thmac; in subflow_finish_connect()
445 subflow->remote_nonce = mp_opt.nonce; in subflow_finish_connect()
446 subflow->remote_id = mp_opt.join_id; in subflow_finish_connect()
448 subflow, subflow->thmac, subflow->remote_nonce, in subflow_finish_connect()
449 subflow->backup); in subflow_finish_connect()
451 if (!subflow_thmac_valid(subflow)) { in subflow_finish_connect()
453 subflow->reset_reason = MPTCP_RST_EMPTCP; in subflow_finish_connect()
460 subflow_generate_hmac(subflow->local_key, subflow->remote_key, in subflow_finish_connect()
461 subflow->local_nonce, in subflow_finish_connect()
462 subflow->remote_nonce, in subflow_finish_connect()
464 memcpy(subflow->hmac, hmac, MPTCPOPT_HMAC_LEN); in subflow_finish_connect()
466 subflow->mp_join = 1; in subflow_finish_connect()
483 subflow->reset_transient = 0; in subflow_finish_connect()
487 static void subflow_set_local_id(struct mptcp_subflow_context *subflow, int local_id) in subflow_set_local_id() argument
489 subflow->local_id = local_id; in subflow_set_local_id()
490 subflow->local_id_valid = 1; in subflow_set_local_id()
495 struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk); in subflow_chk_local_id() local
496 struct mptcp_sock *msk = mptcp_sk(subflow->conn); in subflow_chk_local_id()
499 if (likely(subflow->local_id_valid)) in subflow_chk_local_id()
506 subflow_set_local_id(subflow, err); in subflow_chk_local_id()
537 struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk); in subflow_v4_conn_request() local
539 pr_debug("subflow=%p", subflow); in subflow_v4_conn_request()
561 struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk); in subflow_v6_conn_request() local
563 pr_debug("subflow=%p", subflow); in subflow_v6_conn_request()
663 void mptcp_subflow_fully_established(struct mptcp_subflow_context *subflow, in mptcp_subflow_fully_established() argument
666 struct mptcp_sock *msk = mptcp_sk(subflow->conn); in mptcp_subflow_fully_established()
668 subflow->remote_key = mp_opt->sndr_key; in mptcp_subflow_fully_established()
669 subflow->fully_established = 1; in mptcp_subflow_fully_established()
670 subflow->can_ack = 1; in mptcp_subflow_fully_established()
851 static void dbg_bad_map(struct mptcp_subflow_context *subflow, u32 ssn) in dbg_bad_map() argument
854 ssn, subflow->map_subflow_seq, subflow->map_data_len); in dbg_bad_map()
859 struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk); in skb_is_fully_mapped() local
866 return skb->len - skb_consumed <= subflow->map_data_len - in skb_is_fully_mapped()
867 mptcp_subflow_get_map_offset(subflow); in skb_is_fully_mapped()
872 struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk); in validate_mapping() local
873 u32 ssn = tcp_sk(ssk)->copied_seq - subflow->ssn_offset; in validate_mapping()
875 if (unlikely(before(ssn, subflow->map_subflow_seq))) { in validate_mapping()
879 dbg_bad_map(subflow, ssn); in validate_mapping()
882 if (unlikely(!before(ssn, subflow->map_subflow_seq + in validate_mapping()
883 subflow->map_data_len))) { in validate_mapping()
885 dbg_bad_map(subflow, ssn); in validate_mapping()
894 struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk); in validate_data_csum() local
903 if (subflow->map_csum_len == subflow->map_data_len) in validate_data_csum()
911 delta = subflow->map_data_len - subflow->map_csum_len; in validate_data_csum()
913 seq = tcp_sk(ssk)->copied_seq + subflow->map_csum_len; in validate_data_csum()
924 subflow->map_data_csum = csum_block_add(subflow->map_data_csum, csum, in validate_data_csum()
925 subflow->map_csum_len); in validate_data_csum()
928 subflow->map_csum_len += len; in validate_data_csum()
957 csum = __mptcp_make_csum(subflow->map_seq, in validate_data_csum()
958 subflow->map_subflow_seq, in validate_data_csum()
959 subflow->map_data_len + subflow->map_data_fin, in validate_data_csum()
960 subflow->map_data_csum); in validate_data_csum()
966 subflow->valid_csum_seen = 1; in validate_data_csum()
973 struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk); in get_mapping_status() local
989 if (!subflow->map_valid && !skb->len) { in get_mapping_status()
1003 if (!subflow->map_valid) in get_mapping_status()
1015 subflow->map_data_len = 0; in get_mapping_status()
1024 if (subflow->map_valid) { in get_mapping_status()
1057 WRITE_ONCE(mptcp_sk(subflow->conn)->use_64bit_ack, !!mpext->dsn64); in get_mapping_status()
1059 if (subflow->map_valid) { in get_mapping_status()
1061 if (subflow->map_seq == map_seq && in get_mapping_status()
1062 subflow->map_subflow_seq == mpext->subflow_seq && in get_mapping_status()
1063 subflow->map_data_len == data_len && in get_mapping_status()
1064 subflow->map_csum_reqd == mpext->csum_reqd) { in get_mapping_status()
1081 subflow->map_seq = map_seq; in get_mapping_status()
1082 subflow->map_subflow_seq = mpext->subflow_seq; in get_mapping_status()
1083 subflow->map_data_len = data_len; in get_mapping_status()
1084 subflow->map_valid = 1; in get_mapping_status()
1085 subflow->map_data_fin = mpext->data_fin; in get_mapping_status()
1086 subflow->mpc_map = mpext->mpc_map; in get_mapping_status()
1087 subflow->map_csum_reqd = mpext->csum_reqd; in get_mapping_status()
1088 subflow->map_csum_len = 0; in get_mapping_status()
1089 subflow->map_data_csum = csum_unfold(mpext->csum); in get_mapping_status()
1092 if (unlikely(subflow->map_csum_reqd != csum_reqd)) in get_mapping_status()
1096 subflow->map_seq, subflow->map_subflow_seq, in get_mapping_status()
1097 subflow->map_data_len, subflow->map_csum_reqd, in get_mapping_status()
1098 subflow->map_data_csum); in get_mapping_status()
1118 struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk); in mptcp_subflow_discard_data() local
1125 subflow->map_subflow_seq); in mptcp_subflow_discard_data()
1130 if (mptcp_subflow_get_map_offset(subflow) >= subflow->map_data_len) in mptcp_subflow_discard_data()
1131 subflow->map_valid = 0; in mptcp_subflow_discard_data()
1150 static bool subflow_can_fallback(struct mptcp_subflow_context *subflow) in subflow_can_fallback() argument
1152 struct mptcp_sock *msk = mptcp_sk(subflow->conn); in subflow_can_fallback()
1154 if (subflow->mp_join) in subflow_can_fallback()
1157 return !subflow->valid_csum_seen; in subflow_can_fallback()
1159 return !subflow->fully_established; in subflow_can_fallback()
1164 struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk); in mptcp_subflow_fail() local
1183 WRITE_ONCE(subflow->fail_tout, fail_tout); in mptcp_subflow_fail()
1186 mptcp_reset_timeout(msk, subflow->fail_tout); in mptcp_subflow_fail()
1191 struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk); in subflow_check_data_avail() local
1197 WRITE_ONCE(subflow->data_avail, MPTCP_SUBFLOW_NODATA); in subflow_check_data_avail()
1198 if (subflow->data_avail) in subflow_check_data_avail()
1201 msk = mptcp_sk(subflow->conn); in subflow_check_data_avail()
1223 if (!subflow->mpc_map) in subflow_check_data_avail()
1225 WRITE_ONCE(msk->remote_key, subflow->remote_key); in subflow_check_data_avail()
1226 WRITE_ONCE(msk->ack_seq, subflow->map_seq); in subflow_check_data_avail()
1231 ack_seq = mptcp_subflow_get_mapped_dsn(subflow); in subflow_check_data_avail()
1239 WRITE_ONCE(subflow->data_avail, MPTCP_SUBFLOW_DATA_AVAIL); in subflow_check_data_avail()
1252 (subflow->mp_join || subflow->valid_csum_seen)) { in subflow_check_data_avail()
1253 subflow->send_mp_fail = 1; in subflow_check_data_avail()
1256 subflow->reset_transient = 0; in subflow_check_data_avail()
1257 subflow->reset_reason = MPTCP_RST_EMIDDLEBOX; in subflow_check_data_avail()
1261 WRITE_ONCE(subflow->data_avail, MPTCP_SUBFLOW_DATA_AVAIL); in subflow_check_data_avail()
1265 if (!subflow_can_fallback(subflow) && subflow->map_data_len) { in subflow_check_data_avail()
1269 subflow->reset_transient = 0; in subflow_check_data_avail()
1270 subflow->reset_reason = MPTCP_RST_EMPTCP; in subflow_check_data_avail()
1278 WRITE_ONCE(subflow->data_avail, MPTCP_SUBFLOW_NODATA); in subflow_check_data_avail()
1286 subflow->map_valid = 1; in subflow_check_data_avail()
1287 subflow->map_seq = READ_ONCE(msk->ack_seq); in subflow_check_data_avail()
1288 subflow->map_data_len = skb->len; in subflow_check_data_avail()
1289 subflow->map_subflow_seq = tcp_sk(ssk)->copied_seq - subflow->ssn_offset; in subflow_check_data_avail()
1290 WRITE_ONCE(subflow->data_avail, MPTCP_SUBFLOW_DATA_AVAIL); in subflow_check_data_avail()
1296 struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk); in mptcp_subflow_data_available() local
1299 if (subflow->map_valid && in mptcp_subflow_data_available()
1300 mptcp_subflow_get_map_offset(subflow) >= subflow->map_data_len) { in mptcp_subflow_data_available()
1301 subflow->map_valid = 0; in mptcp_subflow_data_available()
1302 WRITE_ONCE(subflow->data_avail, MPTCP_SUBFLOW_NODATA); in mptcp_subflow_data_available()
1305 subflow->map_subflow_seq, in mptcp_subflow_data_available()
1306 subflow->map_data_len); in mptcp_subflow_data_available()
1323 const struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk); in mptcp_space() local
1324 const struct sock *sk = subflow->conn; in mptcp_space()
1332 struct mptcp_subflow_context *subflow; in __mptcp_error_report() local
1335 mptcp_for_each_subflow(msk, subflow) { in __mptcp_error_report()
1336 struct sock *ssk = mptcp_subflow_tcp_sock(subflow); in __mptcp_error_report()
1372 struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk); in subflow_data_ready() local
1374 struct sock *parent = subflow->conn; in subflow_data_ready()
1389 WARN_ON_ONCE(!__mptcp_check_fallback(msk) && !subflow->mp_capable && in subflow_data_ready()
1390 !subflow->mp_join && !(state & TCPF_CLOSE)); in subflow_data_ready()
1419 struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk); in mptcpv6_handle_mapped() local
1426 subflow, sk->sk_family, icsk->icsk_af_ops, target, mapped); in mptcpv6_handle_mapped()
1431 subflow->icsk_af_ops = icsk->icsk_af_ops; in mptcpv6_handle_mapped()
1471 struct mptcp_subflow_context *subflow; in __mptcp_subflow_connect() local
1491 subflow = mptcp_subflow_ctx(ssk); in __mptcp_subflow_connect()
1493 get_random_bytes(&subflow->local_nonce, sizeof(u32)); in __mptcp_subflow_connect()
1494 } while (!subflow->local_nonce); in __mptcp_subflow_connect()
1497 subflow_set_local_id(subflow, local_id); in __mptcp_subflow_connect()
1501 subflow->remote_key = msk->remote_key; in __mptcp_subflow_connect()
1502 subflow->local_key = msk->local_key; in __mptcp_subflow_connect()
1503 subflow->token = msk->token; in __mptcp_subflow_connect()
1518 mptcp_crypto_key_sha(subflow->remote_key, &remote_token, NULL); in __mptcp_subflow_connect()
1521 subflow->remote_token = remote_token; in __mptcp_subflow_connect()
1522 subflow->remote_id = remote_id; in __mptcp_subflow_connect()
1523 subflow->request_join = 1; in __mptcp_subflow_connect()
1524 subflow->request_bkup = !!(flags & MPTCP_PM_ADDR_FLAG_BACKUP); in __mptcp_subflow_connect()
1528 list_add_tail(&subflow->node, &msk->conn_list); in __mptcp_subflow_connect()
1540 list_del(&subflow->node); in __mptcp_subflow_connect()
1541 sock_put(mptcp_subflow_tcp_sock(subflow)); in __mptcp_subflow_connect()
1544 subflow->disposable = 1; in __mptcp_subflow_connect()
1600 struct mptcp_subflow_context *subflow; in mptcp_subflow_create_socket() local
1645 subflow = mptcp_subflow_ctx(sf->sk); in mptcp_subflow_create_socket()
1646 pr_debug("subflow=%p", subflow); in mptcp_subflow_create_socket()
1650 subflow->conn = sk; in mptcp_subflow_create_socket()
1695 struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk); in subflow_state_change() local
1696 struct sock *parent = subflow->conn; in subflow_state_change()
1705 subflow->conn_finished = 1; in subflow_state_change()
1721 !subflow->rx_eof && subflow_is_done(sk)) { in subflow_state_change()
1722 subflow->rx_eof = 1; in subflow_state_change()
1736 struct mptcp_subflow_context *subflow; in mptcp_subflow_queue_clean() local
1743 subflow = mptcp_subflow_ctx(ssk); in mptcp_subflow_queue_clean()
1744 if (!subflow || !subflow->conn) in mptcp_subflow_queue_clean()
1748 msk = mptcp_sk(subflow->conn); in mptcp_subflow_queue_clean()
1900 struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk); in tcp_release_cb_override() local
1902 if (mptcp_subflow_has_delegated_action(subflow)) in tcp_release_cb_override()