Lines Matching full:v2

114 	     iov_iter_is_discard(&con->v2.in_iter) ? "discard" : "need",  in ceph_tcp_recv()
115 iov_iter_count(&con->v2.in_iter)); in ceph_tcp_recv()
116 ret = do_recvmsg(con->sock, &con->v2.in_iter); in ceph_tcp_recv()
118 iov_iter_count(&con->v2.in_iter)); in ceph_tcp_recv()
201 iov_iter_count(&con->v2.out_iter), con->v2.out_iter_sendpage); in ceph_tcp_send()
202 if (con->v2.out_iter_sendpage) in ceph_tcp_send()
203 ret = do_try_sendpage(con->sock, &con->v2.out_iter); in ceph_tcp_send()
205 ret = do_sendmsg(con->sock, &con->v2.out_iter); in ceph_tcp_send()
207 iov_iter_count(&con->v2.out_iter)); in ceph_tcp_send()
213 BUG_ON(con->v2.in_kvec_cnt >= ARRAY_SIZE(con->v2.in_kvecs)); in add_in_kvec()
214 WARN_ON(!iov_iter_is_kvec(&con->v2.in_iter)); in add_in_kvec()
216 con->v2.in_kvecs[con->v2.in_kvec_cnt].iov_base = buf; in add_in_kvec()
217 con->v2.in_kvecs[con->v2.in_kvec_cnt].iov_len = len; in add_in_kvec()
218 con->v2.in_kvec_cnt++; in add_in_kvec()
220 con->v2.in_iter.nr_segs++; in add_in_kvec()
221 con->v2.in_iter.count += len; in add_in_kvec()
226 WARN_ON(iov_iter_count(&con->v2.in_iter)); in reset_in_kvecs()
228 con->v2.in_kvec_cnt = 0; in reset_in_kvecs()
229 iov_iter_kvec(&con->v2.in_iter, ITER_DEST, con->v2.in_kvecs, 0, 0); in reset_in_kvecs()
234 WARN_ON(iov_iter_count(&con->v2.in_iter)); in set_in_bvec()
236 con->v2.in_bvec = *bv; in set_in_bvec()
237 iov_iter_bvec(&con->v2.in_iter, ITER_DEST, &con->v2.in_bvec, 1, bv->bv_len); in set_in_bvec()
242 WARN_ON(iov_iter_count(&con->v2.in_iter)); in set_in_skip()
245 iov_iter_discard(&con->v2.in_iter, ITER_DEST, len); in set_in_skip()
250 BUG_ON(con->v2.out_kvec_cnt >= ARRAY_SIZE(con->v2.out_kvecs)); in add_out_kvec()
251 WARN_ON(!iov_iter_is_kvec(&con->v2.out_iter)); in add_out_kvec()
252 WARN_ON(con->v2.out_zero); in add_out_kvec()
254 con->v2.out_kvecs[con->v2.out_kvec_cnt].iov_base = buf; in add_out_kvec()
255 con->v2.out_kvecs[con->v2.out_kvec_cnt].iov_len = len; in add_out_kvec()
256 con->v2.out_kvec_cnt++; in add_out_kvec()
258 con->v2.out_iter.nr_segs++; in add_out_kvec()
259 con->v2.out_iter.count += len; in add_out_kvec()
264 WARN_ON(iov_iter_count(&con->v2.out_iter)); in reset_out_kvecs()
265 WARN_ON(con->v2.out_zero); in reset_out_kvecs()
267 con->v2.out_kvec_cnt = 0; in reset_out_kvecs()
269 iov_iter_kvec(&con->v2.out_iter, ITER_SOURCE, con->v2.out_kvecs, 0, 0); in reset_out_kvecs()
270 con->v2.out_iter_sendpage = false; in reset_out_kvecs()
276 WARN_ON(iov_iter_count(&con->v2.out_iter)); in set_out_bvec()
277 WARN_ON(con->v2.out_zero); in set_out_bvec()
279 con->v2.out_bvec = *bv; in set_out_bvec()
280 con->v2.out_iter_sendpage = zerocopy; in set_out_bvec()
281 iov_iter_bvec(&con->v2.out_iter, ITER_SOURCE, &con->v2.out_bvec, 1, in set_out_bvec()
282 con->v2.out_bvec.bv_len); in set_out_bvec()
287 WARN_ON(iov_iter_count(&con->v2.out_iter)); in set_out_bvec_zero()
288 WARN_ON(!con->v2.out_zero); in set_out_bvec_zero()
290 bvec_set_page(&con->v2.out_bvec, ceph_zero_page, in set_out_bvec_zero()
291 min(con->v2.out_zero, (int)PAGE_SIZE), 0); in set_out_bvec_zero()
292 con->v2.out_iter_sendpage = true; in set_out_bvec_zero()
293 iov_iter_bvec(&con->v2.out_iter, ITER_SOURCE, &con->v2.out_bvec, 1, in set_out_bvec_zero()
294 con->v2.out_bvec.bv_len); in set_out_bvec_zero()
300 con->v2.out_zero += len; in out_zero_add()
309 if (WARN_ON(con->v2.conn_buf_cnt >= ARRAY_SIZE(con->v2.conn_bufs))) in alloc_conn_buf()
316 con->v2.conn_bufs[con->v2.conn_buf_cnt++] = buf; in alloc_conn_buf()
322 while (con->v2.conn_buf_cnt) in free_conn_bufs()
323 kvfree(con->v2.conn_bufs[--con->v2.conn_buf_cnt]); in free_conn_bufs()
328 BUG_ON(con->v2.in_sign_kvec_cnt >= ARRAY_SIZE(con->v2.in_sign_kvecs)); in add_in_sign_kvec()
330 con->v2.in_sign_kvecs[con->v2.in_sign_kvec_cnt].iov_base = buf; in add_in_sign_kvec()
331 con->v2.in_sign_kvecs[con->v2.in_sign_kvec_cnt].iov_len = len; in add_in_sign_kvec()
332 con->v2.in_sign_kvec_cnt++; in add_in_sign_kvec()
337 con->v2.in_sign_kvec_cnt = 0; in clear_in_sign_kvecs()
342 BUG_ON(con->v2.out_sign_kvec_cnt >= ARRAY_SIZE(con->v2.out_sign_kvecs)); in add_out_sign_kvec()
344 con->v2.out_sign_kvecs[con->v2.out_sign_kvec_cnt].iov_base = buf; in add_out_sign_kvec()
345 con->v2.out_sign_kvecs[con->v2.out_sign_kvec_cnt].iov_len = len; in add_out_sign_kvec()
346 con->v2.out_sign_kvec_cnt++; in add_out_sign_kvec()
351 con->v2.out_sign_kvec_cnt = 0; in clear_out_sign_kvecs()
356 return con->v2.con_mode == CEPH_CON_MODE_SECURE; in con_secure()
567 con->v2.out_epil.late_status = aborted ? FRAME_LATE_STATUS_ABORTED : in encode_epilogue_plain()
569 cpu_to_le32s(&con->v2.out_epil.front_crc); in encode_epilogue_plain()
570 cpu_to_le32s(&con->v2.out_epil.middle_crc); in encode_epilogue_plain()
571 cpu_to_le32s(&con->v2.out_epil.data_crc); in encode_epilogue_plain()
576 memset(&con->v2.out_epil, 0, sizeof(con->v2.out_epil)); in encode_epilogue_secure()
577 con->v2.out_epil.late_status = aborted ? FRAME_LATE_STATUS_ABORTED : in encode_epilogue_secure()
641 int ctrl_len = con->v2.in_desc.fd_lens[0]; in verify_control_crc()
644 WARN_ON(con->v2.in_kvecs[0].iov_len != ctrl_len); in verify_control_crc()
645 WARN_ON(con->v2.in_kvecs[1].iov_len != CEPH_CRC_LEN); in verify_control_crc()
647 crc = crc32c(-1, con->v2.in_kvecs[0].iov_base, ctrl_len); in verify_control_crc()
648 expected_crc = get_unaligned_le32(con->v2.in_kvecs[1].iov_base); in verify_control_crc()
711 __func__, con, con->v2.con_mode, session_key_len, con_secret_len); in setup_crypto()
712 WARN_ON(con->v2.hmac_tfm || con->v2.gcm_tfm || con->v2.gcm_req); in setup_crypto()
714 if (con->v2.con_mode != CEPH_CON_MODE_CRC && in setup_crypto()
715 con->v2.con_mode != CEPH_CON_MODE_SECURE) { in setup_crypto()
716 pr_err("bad con_mode %d\n", con->v2.con_mode); in setup_crypto()
721 WARN_ON(con->v2.con_mode != CEPH_CON_MODE_CRC); in setup_crypto()
727 con->v2.hmac_tfm = crypto_alloc_shash("hmac(sha256)", 0, 0); in setup_crypto()
729 if (IS_ERR(con->v2.hmac_tfm)) { in setup_crypto()
730 ret = PTR_ERR(con->v2.hmac_tfm); in setup_crypto()
731 con->v2.hmac_tfm = NULL; in setup_crypto()
736 ret = crypto_shash_setkey(con->v2.hmac_tfm, session_key, in setup_crypto()
743 if (con->v2.con_mode == CEPH_CON_MODE_CRC) { in setup_crypto()
754 con->v2.gcm_tfm = crypto_alloc_aead("gcm(aes)", 0, 0); in setup_crypto()
756 if (IS_ERR(con->v2.gcm_tfm)) { in setup_crypto()
757 ret = PTR_ERR(con->v2.gcm_tfm); in setup_crypto()
758 con->v2.gcm_tfm = NULL; in setup_crypto()
764 crypto_aead_alignmask(con->v2.gcm_tfm)); in setup_crypto()
765 ret = crypto_aead_setkey(con->v2.gcm_tfm, con_secret, CEPH_GCM_KEY_LEN); in setup_crypto()
771 WARN_ON(crypto_aead_ivsize(con->v2.gcm_tfm) != CEPH_GCM_IV_LEN); in setup_crypto()
772 ret = crypto_aead_setauthsize(con->v2.gcm_tfm, CEPH_GCM_TAG_LEN); in setup_crypto()
778 con->v2.gcm_req = aead_request_alloc(con->v2.gcm_tfm, GFP_NOIO); in setup_crypto()
779 if (!con->v2.gcm_req) { in setup_crypto()
784 crypto_init_wait(&con->v2.gcm_wait); in setup_crypto()
785 aead_request_set_callback(con->v2.gcm_req, CRYPTO_TFM_REQ_MAY_BACKLOG, in setup_crypto()
786 crypto_req_done, &con->v2.gcm_wait); in setup_crypto()
788 memcpy(&con->v2.in_gcm_nonce, con_secret + CEPH_GCM_KEY_LEN, in setup_crypto()
790 memcpy(&con->v2.out_gcm_nonce, in setup_crypto()
799 SHASH_DESC_ON_STACK(desc, con->v2.hmac_tfm); /* tfm arg is ignored */ in hmac_sha256()
804 con->v2.hmac_tfm, kvec_cnt); in hmac_sha256()
806 if (!con->v2.hmac_tfm) { in hmac_sha256()
811 desc->tfm = con->v2.hmac_tfm; in hmac_sha256()
845 nonce = encrypt ? &con->v2.out_gcm_nonce : &con->v2.in_gcm_nonce; in gcm_crypt()
847 aead_request_set_ad(con->v2.gcm_req, 0); /* no AAD */ in gcm_crypt()
848 aead_request_set_crypt(con->v2.gcm_req, src, dst, src_len, (u8 *)nonce); in gcm_crypt()
849 ret = crypto_wait_req(encrypt ? crypto_aead_encrypt(con->v2.gcm_req) : in gcm_crypt()
850 crypto_aead_decrypt(con->v2.gcm_req), in gcm_crypt()
851 &con->v2.gcm_wait); in gcm_crypt()
1064 sg_init_one(&sg, con->v2.in_buf, CEPH_PREAMBLE_SECURE_LEN); in decrypt_preamble()
1070 int ctrl_len = con->v2.in_desc.fd_lens[0]; in decrypt_control_remainder()
1075 WARN_ON(con->v2.in_kvecs[0].iov_len != rem_len); in decrypt_control_remainder()
1076 WARN_ON(con->v2.in_kvecs[1].iov_len != pt_len); in decrypt_control_remainder()
1079 sg_set_buf(&sgs[0], con->v2.in_kvecs[0].iov_base, rem_len); in decrypt_control_remainder()
1080 sg_set_buf(&sgs[1], con->v2.in_buf, pt_len); in decrypt_control_remainder()
1090 struct ceph_msg_data_cursor *cursor = &con->v2.in_cursor; in process_v2_sparse_read()
1105 struct page *spage = con->v2.in_enc_pages[idx]; in process_v2_sparse_read()
1137 ret = sg_alloc_table_from_pages(&enc_sgt, con->v2.in_enc_pages, in decrypt_tail()
1138 con->v2.in_enc_page_cnt, 0, tail_len, in decrypt_tail()
1145 pages = con->v2.in_enc_pages; in decrypt_tail()
1148 ret = setup_message_sgs(&sgt, con->in_msg, FRONT_PAD(con->v2.in_buf), in decrypt_tail()
1149 MIDDLE_PAD(con->v2.in_buf), DATA_PAD(con->v2.in_buf), in decrypt_tail()
1150 con->v2.in_buf, pages, dpos, true); in decrypt_tail()
1155 con->in_msg, con->v2.in_enc_page_cnt, sgt.orig_nents); in decrypt_tail()
1161 ret = process_v2_sparse_read(con, con->v2.in_enc_pages, dpos); in decrypt_tail()
1166 WARN_ON(!con->v2.in_enc_page_cnt); in decrypt_tail()
1167 ceph_release_page_vector(con->v2.in_enc_pages, in decrypt_tail()
1168 con->v2.in_enc_page_cnt); in decrypt_tail()
1169 con->v2.in_enc_pages = NULL; in decrypt_tail()
1170 con->v2.in_enc_page_cnt = 0; in decrypt_tail()
1465 ret = hmac_sha256(con, con->v2.in_sign_kvecs, con->v2.in_sign_kvec_cnt, in prepare_auth_signature()
1482 WARN_ON(con->v2.server_cookie); in prepare_client_ident()
1483 WARN_ON(con->v2.connect_seq); in prepare_client_ident()
1484 WARN_ON(con->v2.peer_global_seq); in prepare_client_ident()
1486 if (!con->v2.client_cookie) { in prepare_client_ident()
1488 get_random_bytes(&con->v2.client_cookie, in prepare_client_ident()
1489 sizeof(con->v2.client_cookie)); in prepare_client_ident()
1490 } while (!con->v2.client_cookie); in prepare_client_ident()
1492 con->v2.client_cookie); in prepare_client_ident()
1495 con->v2.client_cookie); in prepare_client_ident()
1501 global_id, con->v2.global_seq, client->supported_features, in prepare_client_ident()
1502 client->required_features, con->v2.client_cookie); in prepare_client_ident()
1516 ceph_encode_64(&p, con->v2.global_seq); in prepare_client_ident()
1520 ceph_encode_64(&p, con->v2.client_cookie); in prepare_client_ident()
1532 WARN_ON(!con->v2.client_cookie); in prepare_session_reconnect()
1533 WARN_ON(!con->v2.server_cookie); in prepare_session_reconnect()
1534 WARN_ON(!con->v2.connect_seq); in prepare_session_reconnect()
1535 WARN_ON(!con->v2.peer_global_seq); in prepare_session_reconnect()
1539 con->v2.client_cookie, con->v2.server_cookie, con->v2.global_seq, in prepare_session_reconnect()
1540 con->v2.connect_seq, con->in_seq); in prepare_session_reconnect()
1551 ceph_encode_64(&p, con->v2.client_cookie); in prepare_session_reconnect()
1552 ceph_encode_64(&p, con->v2.server_cookie); in prepare_session_reconnect()
1553 ceph_encode_64(&p, con->v2.global_seq); in prepare_session_reconnect()
1554 ceph_encode_64(&p, con->v2.connect_seq); in prepare_session_reconnect()
1563 struct ceph_timespec *ts = CTRL_BODY(con->v2.out_buf); in prepare_keepalive2()
1573 return prepare_control(con, FRAME_TAG_KEEPALIVE2, con->v2.out_buf, in prepare_keepalive2()
1585 p = CTRL_BODY(con->v2.out_buf); in prepare_ack()
1589 return prepare_control(con, FRAME_TAG_ACK, con->v2.out_buf, 8); in prepare_ack()
1595 con->out_msg, aborted, con->v2.out_epil.front_crc, in prepare_epilogue_plain()
1596 con->v2.out_epil.middle_crc, con->v2.out_epil.data_crc); in prepare_epilogue_plain()
1599 add_out_kvec(con, &con->v2.out_epil, CEPH_EPILOGUE_PLAIN_LEN); in prepare_epilogue_plain()
1610 prepare_head_plain(con, con->v2.out_buf, in prepare_message_plain()
1619 con->v2.out_state = OUT_S_FINISH_MESSAGE; in prepare_message_plain()
1623 con->v2.out_epil.front_crc = -1; in prepare_message_plain()
1624 con->v2.out_epil.middle_crc = -1; in prepare_message_plain()
1625 con->v2.out_state = OUT_S_QUEUE_DATA; in prepare_message_plain()
1630 con->v2.out_epil.front_crc = crc32c(-1, msg->front.iov_base, in prepare_message_plain()
1635 con->v2.out_epil.front_crc = -1; in prepare_message_plain()
1639 con->v2.out_epil.middle_crc = in prepare_message_plain()
1643 con->v2.out_epil.middle_crc = data_len(msg) ? -1 : 0; in prepare_message_plain()
1647 con->v2.out_state = OUT_S_QUEUE_DATA; in prepare_message_plain()
1649 con->v2.out_epil.data_crc = 0; in prepare_message_plain()
1651 con->v2.out_state = OUT_S_FINISH_MESSAGE; in prepare_message_plain()
1672 ret = prepare_head_secure_small(con, con->v2.out_buf, in prepare_message_secure()
1683 con->v2.out_state = OUT_S_FINISH_MESSAGE; in prepare_message_secure()
1689 &con->v2.out_epil, NULL, 0, false); in prepare_message_secure()
1700 WARN_ON(con->v2.out_enc_pages || con->v2.out_enc_page_cnt); in prepare_message_secure()
1701 con->v2.out_enc_pages = enc_pages; in prepare_message_secure()
1702 con->v2.out_enc_page_cnt = enc_page_cnt; in prepare_message_secure()
1703 con->v2.out_enc_resid = tail_len; in prepare_message_secure()
1704 con->v2.out_enc_i = 0; in prepare_message_secure()
1718 con->v2.out_state = OUT_S_QUEUE_ENC_PAGE; in prepare_message_secure()
1748 encode_preamble(&desc, con->v2.out_buf); in prepare_message()
1749 fill_header2(CTRL_BODY(con->v2.out_buf), &con->out_msg->hdr, in prepare_message()
1798 add_in_kvec(con, con->v2.in_buf, in prepare_read_preamble()
1801 con->v2.in_state = IN_S_HANDLE_PREAMBLE; in prepare_read_preamble()
1806 int ctrl_len = con->v2.in_desc.fd_lens[0]; in prepare_read_control()
1819 memcpy(buf, con->v2.in_buf, CEPH_PREAMBLE_LEN); in prepare_read_control()
1832 add_in_kvec(con, CTRL_BODY(con->v2.in_buf), ctrl_len); in prepare_read_control()
1834 add_in_kvec(con, con->v2.in_buf, CEPH_CRC_LEN); in prepare_read_control()
1836 con->v2.in_state = IN_S_HANDLE_CONTROL; in prepare_read_control()
1842 int ctrl_len = con->v2.in_desc.fd_lens[0]; in prepare_read_control_remainder()
1850 memcpy(buf, CTRL_BODY(con->v2.in_buf), CEPH_PREAMBLE_INLINE_LEN); in prepare_read_control_remainder()
1854 add_in_kvec(con, con->v2.in_buf, in prepare_read_control_remainder()
1856 con->v2.in_state = IN_S_HANDLE_CONTROL_REMAINDER; in prepare_read_control_remainder()
1865 ceph_msg_data_cursor_init(&con->v2.in_cursor, con->in_msg, in prepare_read_data()
1868 get_bvec_at(&con->v2.in_cursor, &bv); in prepare_read_data()
1882 con->v2.in_state = IN_S_PREPARE_READ_DATA_CONT; in prepare_read_data()
1893 con->v2.in_bvec.bv_len); in prepare_read_data_cont()
1895 get_bvec_at(&con->v2.in_cursor, &bv); in prepare_read_data_cont()
1898 con->v2.in_bvec.bv_len); in prepare_read_data_cont()
1901 con->v2.in_bvec.bv_page, in prepare_read_data_cont()
1902 con->v2.in_bvec.bv_offset, in prepare_read_data_cont()
1903 con->v2.in_bvec.bv_len); in prepare_read_data_cont()
1906 ceph_msg_data_advance(&con->v2.in_cursor, con->v2.in_bvec.bv_len); in prepare_read_data_cont()
1907 if (con->v2.in_cursor.total_resid) { in prepare_read_data_cont()
1908 get_bvec_at(&con->v2.in_cursor, &bv); in prepare_read_data_cont()
1914 WARN_ON(con->v2.in_state != IN_S_PREPARE_READ_DATA_CONT); in prepare_read_data_cont()
1922 add_in_kvec(con, con->v2.in_buf, CEPH_EPILOGUE_PLAIN_LEN); in prepare_read_data_cont()
1923 con->v2.in_state = IN_S_HANDLE_EPILOGUE; in prepare_read_data_cont()
1931 struct ceph_msg_data_cursor *cursor = &con->v2.in_cursor; in prepare_sparse_read_cont()
1933 WARN_ON(con->v2.in_state != IN_S_PREPARE_SPARSE_DATA_CONT); in prepare_sparse_read_cont()
1935 if (iov_iter_is_bvec(&con->v2.in_iter)) { in prepare_sparse_read_cont()
1939 con->v2.in_bvec.bv_len); in prepare_sparse_read_cont()
1943 con->v2.in_bvec.bv_len); in prepare_sparse_read_cont()
1946 con->v2.in_bvec.bv_page, in prepare_sparse_read_cont()
1947 con->v2.in_bvec.bv_offset, in prepare_sparse_read_cont()
1948 con->v2.in_bvec.bv_len); in prepare_sparse_read_cont()
1951 ceph_msg_data_advance(cursor, con->v2.in_bvec.bv_len); in prepare_sparse_read_cont()
1952 cursor->sr_resid -= con->v2.in_bvec.bv_len; in prepare_sparse_read_cont()
1954 con->v2.in_bvec.bv_len, cursor->sr_resid); in prepare_sparse_read_cont()
1965 con->v2.data_len_remain -= bv.bv_len; in prepare_sparse_read_cont()
1968 } else if (iov_iter_is_kvec(&con->v2.in_iter)) { in prepare_sparse_read_cont()
1970 if (con->v2.in_kvec_cnt) { in prepare_sparse_read_cont()
1971 WARN_ON_ONCE(con->v2.in_kvec_cnt > 1); in prepare_sparse_read_cont()
1973 con->v2.in_kvecs[0].iov_base, in prepare_sparse_read_cont()
1974 con->v2.in_kvecs[0].iov_len); in prepare_sparse_read_cont()
1987 add_in_kvec(con, con->v2.in_buf, CEPH_EPILOGUE_PLAIN_LEN); in prepare_sparse_read_cont()
1988 con->v2.in_state = IN_S_HANDLE_EPILOGUE; in prepare_sparse_read_cont()
1996 con->v2.data_len_remain -= ret; in prepare_sparse_read_cont()
2021 con->v2.data_len_remain -= ret; in prepare_sparse_read_cont()
2037 ceph_msg_data_cursor_init(&con->v2.in_cursor, msg, in prepare_sparse_read_data()
2041 con->v2.in_state = IN_S_PREPARE_SPARSE_DATA_CONT; in prepare_sparse_read_data()
2042 con->v2.data_len_remain = data_len(msg); in prepare_sparse_read_data()
2067 con->v2.in_state = IN_S_PREPARE_SPARSE_DATA; in prepare_read_tail_plain()
2069 con->v2.in_state = IN_S_PREPARE_READ_DATA; in prepare_read_tail_plain()
2071 add_in_kvec(con, con->v2.in_buf, CEPH_EPILOGUE_PLAIN_LEN); in prepare_read_tail_plain()
2072 con->v2.in_state = IN_S_HANDLE_EPILOGUE; in prepare_read_tail_plain()
2081 dout("%s con %p i %d resid %d\n", __func__, con, con->v2.in_enc_i, in prepare_read_enc_page()
2082 con->v2.in_enc_resid); in prepare_read_enc_page()
2083 WARN_ON(!con->v2.in_enc_resid); in prepare_read_enc_page()
2085 bvec_set_page(&bv, con->v2.in_enc_pages[con->v2.in_enc_i], in prepare_read_enc_page()
2086 min(con->v2.in_enc_resid, (int)PAGE_SIZE), 0); in prepare_read_enc_page()
2089 con->v2.in_enc_i++; in prepare_read_enc_page()
2090 con->v2.in_enc_resid -= bv.bv_len; in prepare_read_enc_page()
2092 if (con->v2.in_enc_resid) { in prepare_read_enc_page()
2093 con->v2.in_state = IN_S_PREPARE_READ_ENC_PAGE; in prepare_read_enc_page()
2101 WARN_ON(con->v2.in_enc_i != con->v2.in_enc_page_cnt); in prepare_read_enc_page()
2102 con->v2.in_state = IN_S_HANDLE_EPILOGUE; in prepare_read_enc_page()
2119 WARN_ON(con->v2.in_enc_pages || con->v2.in_enc_page_cnt); in prepare_read_tail_secure()
2120 con->v2.in_enc_pages = enc_pages; in prepare_read_tail_secure()
2121 con->v2.in_enc_page_cnt = enc_page_cnt; in prepare_read_tail_secure()
2122 con->v2.in_enc_resid = tail_len; in prepare_read_tail_secure()
2123 con->v2.in_enc_i = 0; in prepare_read_tail_secure()
2137 struct ceph_frame_desc *desc = &con->v2.in_desc; in prepare_skip_message()
2149 con->v2.in_state = IN_S_FINISH_SKIP; in prepare_skip_message()
2158 WARN_ON(con->v2.in_kvecs[0].iov_len != CEPH_BANNER_V2_PREFIX_LEN); in process_banner_prefix()
2160 p = con->v2.in_kvecs[0].iov_base; in process_banner_prefix()
2178 void *end = con->v2.in_kvecs[0].iov_base + con->v2.in_kvecs[0].iov_len; in process_banner_payload()
2185 p = con->v2.in_kvecs[0].iov_base; in process_banner_payload()
2404 ceph_decode_32_safe(&p, end, con->v2.con_mode, bad); in process_auth_done()
2408 __func__, con, global_id, con->v2.con_mode, payload_len); in process_auth_done()
2463 ret = hmac_sha256(con, con->v2.out_sign_kvecs, in process_auth_signature()
2464 con->v2.out_sign_kvec_cnt, hmac); in process_auth_signature()
2477 if (!con->v2.server_cookie) { in process_auth_signature()
2560 con->v2.peer_global_seq = global_seq; in process_server_ident()
2563 con->v2.server_cookie = cookie; in process_server_ident()
2567 WARN_ON(con->v2.server_cookie); in process_server_ident()
2569 WARN_ON(!con->v2.server_cookie); in process_server_ident()
2578 con->v2.out_state = OUT_S_GET_NEXT; in process_server_ident()
2629 con->v2.out_state = OUT_S_GET_NEXT; in process_session_reconnect_ok()
2651 WARN_ON(connect_seq <= con->v2.connect_seq); in process_session_retry()
2652 con->v2.connect_seq = connect_seq + 1; in process_session_retry()
2684 WARN_ON(global_seq <= con->v2.global_seq); in process_session_retry_global()
2685 con->v2.global_seq = ceph_get_global_seq(con->msgr, global_seq); in process_session_retry_global()
2794 int tag = con->v2.in_desc.fd_tag; in process_control()
2862 struct ceph_frame_desc *desc = &con->v2.in_desc; in process_message_header()
2921 void *end = p + con->v2.in_desc.fd_lens[0]; in __handle_control()
2925 if (con->v2.in_desc.fd_tag != FRAME_TAG_MESSAGE) in __handle_control()
2961 struct ceph_frame_desc *desc = &con->v2.in_desc; in handle_preamble()
2973 ret = decode_preamble(con->v2.in_buf, desc); in handle_preamble()
2992 return __handle_control(con, CTRL_BODY(con->v2.in_buf)); in handle_preamble()
2997 int ctrl_len = con->v2.in_desc.fd_lens[0]; in handle_control()
3014 memcpy(buf, con->v2.in_kvecs[0].iov_base, ctrl_len); in handle_control()
3018 return __handle_control(con, con->v2.in_kvecs[0].iov_base); in handle_control()
3034 return __handle_control(con, con->v2.in_kvecs[0].iov_base - in handle_control_remainder()
3052 ret = decode_epilogue(con->v2.in_buf, NULL, NULL, NULL); in handle_epilogue()
3058 ret = decode_epilogue(con->v2.in_buf, &front_crc, in handle_epilogue()
3081 gcm_inc_nonce(&con->v2.in_gcm_nonce); in finish_skip()
3091 con->v2.in_state); in populate_in_iter()
3092 WARN_ON(iov_iter_count(&con->v2.in_iter)); in populate_in_iter()
3101 switch (con->v2.in_state) { in populate_in_iter()
3136 WARN(1, "bad in_state %d", con->v2.in_state); in populate_in_iter()
3148 if (WARN_ON(!iov_iter_count(&con->v2.in_iter))) in populate_in_iter()
3151 iov_iter_count(&con->v2.in_iter)); in populate_in_iter()
3160 iov_iter_count(&con->v2.in_iter)); in ceph_con_v2_try_read()
3170 if (WARN_ON(!iov_iter_count(&con->v2.in_iter))) in ceph_con_v2_try_read()
3191 con->v2.out_epil.data_crc = -1; in queue_data()
3192 ceph_msg_data_cursor_init(&con->v2.out_cursor, con->out_msg, in queue_data()
3195 get_bvec_at(&con->v2.out_cursor, &bv); in queue_data()
3197 con->v2.out_state = OUT_S_QUEUE_DATA_CONT; in queue_data()
3204 con->v2.out_epil.data_crc = ceph_crc32c_page( in queue_data_cont()
3205 con->v2.out_epil.data_crc, con->v2.out_bvec.bv_page, in queue_data_cont()
3206 con->v2.out_bvec.bv_offset, con->v2.out_bvec.bv_len); in queue_data_cont()
3208 ceph_msg_data_advance(&con->v2.out_cursor, con->v2.out_bvec.bv_len); in queue_data_cont()
3209 if (con->v2.out_cursor.total_resid) { in queue_data_cont()
3210 get_bvec_at(&con->v2.out_cursor, &bv); in queue_data_cont()
3212 WARN_ON(con->v2.out_state != OUT_S_QUEUE_DATA_CONT); in queue_data_cont()
3222 con->v2.out_state = OUT_S_FINISH_MESSAGE; in queue_data_cont()
3229 dout("%s con %p i %d resid %d\n", __func__, con, con->v2.out_enc_i, in queue_enc_page()
3230 con->v2.out_enc_resid); in queue_enc_page()
3231 WARN_ON(!con->v2.out_enc_resid); in queue_enc_page()
3233 bvec_set_page(&bv, con->v2.out_enc_pages[con->v2.out_enc_i], in queue_enc_page()
3234 min(con->v2.out_enc_resid, (int)PAGE_SIZE), 0); in queue_enc_page()
3237 con->v2.out_enc_i++; in queue_enc_page()
3238 con->v2.out_enc_resid -= bv.bv_len; in queue_enc_page()
3240 if (con->v2.out_enc_resid) { in queue_enc_page()
3241 WARN_ON(con->v2.out_state != OUT_S_QUEUE_ENC_PAGE); in queue_enc_page()
3249 WARN_ON(con->v2.out_enc_i != con->v2.out_enc_page_cnt); in queue_enc_page()
3250 con->v2.out_state = OUT_S_FINISH_MESSAGE; in queue_enc_page()
3255 dout("%s con %p out_zero %d\n", __func__, con, con->v2.out_zero); in queue_zeros()
3257 if (con->v2.out_zero) { in queue_zeros()
3259 con->v2.out_zero -= con->v2.out_bvec.bv_len; in queue_zeros()
3260 con->v2.out_state = OUT_S_QUEUE_ZEROS; in queue_zeros()
3271 con->v2.out_state = OUT_S_FINISH_MESSAGE; in queue_zeros()
3279 if (con->v2.out_enc_pages) { in finish_message()
3280 WARN_ON(!con->v2.out_enc_page_cnt); in finish_message()
3281 ceph_release_page_vector(con->v2.out_enc_pages, in finish_message()
3282 con->v2.out_enc_page_cnt); in finish_message()
3283 con->v2.out_enc_pages = NULL; in finish_message()
3284 con->v2.out_enc_page_cnt = 0; in finish_message()
3292 con->v2.out_state = OUT_S_GET_NEXT; in finish_message()
3300 con->v2.out_state); in populate_out_iter()
3301 WARN_ON(iov_iter_count(&con->v2.out_iter)); in populate_out_iter()
3309 switch (con->v2.out_state) { in populate_out_iter()
3331 WARN(1, "bad out_state %d", con->v2.out_state); in populate_out_iter()
3335 WARN_ON(con->v2.out_state != OUT_S_GET_NEXT); in populate_out_iter()
3360 if (WARN_ON(!iov_iter_count(&con->v2.out_iter))) in populate_out_iter()
3363 iov_iter_count(&con->v2.out_iter)); in populate_out_iter()
3367 WARN_ON(iov_iter_count(&con->v2.out_iter)); in populate_out_iter()
3378 iov_iter_count(&con->v2.out_iter)); in ceph_con_v2_try_write()
3389 con->v2.global_seq = ceph_get_global_seq(con->msgr, 0); in ceph_con_v2_try_write()
3390 if (con->v2.server_cookie) in ceph_con_v2_try_write()
3391 con->v2.connect_seq++; in ceph_con_v2_try_write()
3416 if (!iov_iter_count(&con->v2.out_iter)) { in ceph_con_v2_try_write()
3465 con->v2.out_epil.front_crc = in prepare_zero_front()
3467 con->v2.out_epil.front_crc = in prepare_zero_front()
3468 crc32c_zeros(con->v2.out_epil.front_crc, resid); in prepare_zero_front()
3470 con->v2.out_epil.front_crc = crc32c_zeros(-1, resid); in prepare_zero_front()
3473 con->v2.out_iter.count -= resid; in prepare_zero_front()
3486 con->v2.out_epil.middle_crc = in prepare_zero_middle()
3488 con->v2.out_epil.middle_crc = in prepare_zero_middle()
3489 crc32c_zeros(con->v2.out_epil.middle_crc, resid); in prepare_zero_middle()
3491 con->v2.out_epil.middle_crc = crc32c_zeros(-1, resid); in prepare_zero_middle()
3494 con->v2.out_iter.count -= resid; in prepare_zero_middle()
3501 con->v2.out_epil.data_crc = crc32c_zeros(-1, data_len(con->out_msg)); in prepare_zero_data()
3511 WARN_ON(!iov_iter_is_kvec(&con->v2.out_iter)); in revoke_at_queue_data()
3512 resid = iov_iter_count(&con->v2.out_iter); in revoke_at_queue_data()
3524 WARN_ON(iov_iter_count(&con->v2.out_iter) != resid); in revoke_at_queue_data()
3525 con->v2.out_state = OUT_S_QUEUE_ZEROS; in revoke_at_queue_data()
3553 WARN_ON(!iov_iter_is_bvec(&con->v2.out_iter)); in revoke_at_queue_data_cont()
3554 resid = iov_iter_count(&con->v2.out_iter); in revoke_at_queue_data_cont()
3555 WARN_ON(!resid || resid > con->v2.out_bvec.bv_len); in revoke_at_queue_data_cont()
3556 sent = con->v2.out_bvec.bv_len - resid; in revoke_at_queue_data_cont()
3560 con->v2.out_epil.data_crc = ceph_crc32c_page( in revoke_at_queue_data_cont()
3561 con->v2.out_epil.data_crc, con->v2.out_bvec.bv_page, in revoke_at_queue_data_cont()
3562 con->v2.out_bvec.bv_offset, sent); in revoke_at_queue_data_cont()
3563 ceph_msg_data_advance(&con->v2.out_cursor, sent); in revoke_at_queue_data_cont()
3565 WARN_ON(resid > con->v2.out_cursor.total_resid); in revoke_at_queue_data_cont()
3566 con->v2.out_epil.data_crc = crc32c_zeros(con->v2.out_epil.data_crc, in revoke_at_queue_data_cont()
3567 con->v2.out_cursor.total_resid); in revoke_at_queue_data_cont()
3569 con->v2.out_iter.count -= resid; in revoke_at_queue_data_cont()
3570 out_zero_add(con, con->v2.out_cursor.total_resid); in revoke_at_queue_data_cont()
3579 WARN_ON(!iov_iter_is_kvec(&con->v2.out_iter)); in revoke_at_finish_message()
3580 resid = iov_iter_count(&con->v2.out_iter); in revoke_at_finish_message()
3600 con->v2.out_iter.count -= CEPH_EPILOGUE_PLAIN_LEN; in revoke_at_finish_message()
3601 WARN_ON(iov_iter_count(&con->v2.out_iter) != resid); in revoke_at_finish_message()
3602 con->v2.out_state = OUT_S_QUEUE_ZEROS; in revoke_at_finish_message()
3613 con->v2.out_iter.count -= CEPH_EPILOGUE_PLAIN_LEN; in revoke_at_finish_message()
3623 con->v2.out_iter.count -= CEPH_EPILOGUE_PLAIN_LEN; in revoke_at_finish_message()
3634 WARN_ON(con->v2.out_zero); in ceph_con_v2_revoke()
3637 WARN_ON(con->v2.out_state != OUT_S_QUEUE_ENC_PAGE && in ceph_con_v2_revoke()
3638 con->v2.out_state != OUT_S_FINISH_MESSAGE); in ceph_con_v2_revoke()
3643 switch (con->v2.out_state) { in ceph_con_v2_revoke()
3654 WARN(1, "bad out_state %d", con->v2.out_state); in ceph_con_v2_revoke()
3666 WARN_ON(!iov_iter_is_kvec(&con->v2.in_iter)); in revoke_at_prepare_read_data()
3667 resid = iov_iter_count(&con->v2.in_iter); in revoke_at_prepare_read_data()
3673 con->v2.in_iter.count -= resid; in revoke_at_prepare_read_data()
3675 con->v2.in_state = IN_S_FINISH_SKIP; in revoke_at_prepare_read_data()
3685 WARN_ON(!iov_iter_is_bvec(&con->v2.in_iter)); in revoke_at_prepare_read_data_cont()
3686 resid = iov_iter_count(&con->v2.in_iter); in revoke_at_prepare_read_data_cont()
3687 WARN_ON(!resid || resid > con->v2.in_bvec.bv_len); in revoke_at_prepare_read_data_cont()
3688 recved = con->v2.in_bvec.bv_len - resid; in revoke_at_prepare_read_data_cont()
3692 ceph_msg_data_advance(&con->v2.in_cursor, recved); in revoke_at_prepare_read_data_cont()
3693 WARN_ON(resid > con->v2.in_cursor.total_resid); in revoke_at_prepare_read_data_cont()
3697 con->v2.in_cursor.total_resid, remaining); in revoke_at_prepare_read_data_cont()
3698 con->v2.in_iter.count -= resid; in revoke_at_prepare_read_data_cont()
3699 set_in_skip(con, con->v2.in_cursor.total_resid + remaining); in revoke_at_prepare_read_data_cont()
3700 con->v2.in_state = IN_S_FINISH_SKIP; in revoke_at_prepare_read_data_cont()
3708 WARN_ON(!iov_iter_is_bvec(&con->v2.in_iter)); in revoke_at_prepare_read_enc_page()
3709 resid = iov_iter_count(&con->v2.in_iter); in revoke_at_prepare_read_enc_page()
3710 WARN_ON(!resid || resid > con->v2.in_bvec.bv_len); in revoke_at_prepare_read_enc_page()
3713 con->v2.in_enc_resid); in revoke_at_prepare_read_enc_page()
3714 con->v2.in_iter.count -= resid; in revoke_at_prepare_read_enc_page()
3715 set_in_skip(con, resid + con->v2.in_enc_resid); in revoke_at_prepare_read_enc_page()
3716 con->v2.in_state = IN_S_FINISH_SKIP; in revoke_at_prepare_read_enc_page()
3726 WARN_ON(!iov_iter_is_bvec(&con->v2.in_iter)); in revoke_at_prepare_sparse_data()
3727 resid = iov_iter_count(&con->v2.in_iter); in revoke_at_prepare_sparse_data()
3730 remaining = CEPH_EPILOGUE_PLAIN_LEN + con->v2.data_len_remain; in revoke_at_prepare_sparse_data()
3731 con->v2.in_iter.count -= resid; in revoke_at_prepare_sparse_data()
3733 con->v2.in_state = IN_S_FINISH_SKIP; in revoke_at_prepare_sparse_data()
3740 resid = iov_iter_count(&con->v2.in_iter); in revoke_at_handle_epilogue()
3744 con->v2.in_iter.count -= resid; in revoke_at_handle_epilogue()
3746 con->v2.in_state = IN_S_FINISH_SKIP; in revoke_at_handle_epilogue()
3751 switch (con->v2.in_state) { in ceph_con_v2_revoke_incoming()
3769 WARN(1, "bad in_state %d", con->v2.in_state); in ceph_con_v2_revoke_incoming()
3776 return con->v2.peer_global_seq; in ceph_con_v2_opened()
3781 con->v2.client_cookie = 0; in ceph_con_v2_reset_session()
3782 con->v2.server_cookie = 0; in ceph_con_v2_reset_session()
3783 con->v2.global_seq = 0; in ceph_con_v2_reset_session()
3784 con->v2.connect_seq = 0; in ceph_con_v2_reset_session()
3785 con->v2.peer_global_seq = 0; in ceph_con_v2_reset_session()
3790 iov_iter_truncate(&con->v2.in_iter, 0); in ceph_con_v2_reset_protocol()
3791 iov_iter_truncate(&con->v2.out_iter, 0); in ceph_con_v2_reset_protocol()
3792 con->v2.out_zero = 0; in ceph_con_v2_reset_protocol()
3798 if (con->v2.in_enc_pages) { in ceph_con_v2_reset_protocol()
3799 WARN_ON(!con->v2.in_enc_page_cnt); in ceph_con_v2_reset_protocol()
3800 ceph_release_page_vector(con->v2.in_enc_pages, in ceph_con_v2_reset_protocol()
3801 con->v2.in_enc_page_cnt); in ceph_con_v2_reset_protocol()
3802 con->v2.in_enc_pages = NULL; in ceph_con_v2_reset_protocol()
3803 con->v2.in_enc_page_cnt = 0; in ceph_con_v2_reset_protocol()
3805 if (con->v2.out_enc_pages) { in ceph_con_v2_reset_protocol()
3806 WARN_ON(!con->v2.out_enc_page_cnt); in ceph_con_v2_reset_protocol()
3807 ceph_release_page_vector(con->v2.out_enc_pages, in ceph_con_v2_reset_protocol()
3808 con->v2.out_enc_page_cnt); in ceph_con_v2_reset_protocol()
3809 con->v2.out_enc_pages = NULL; in ceph_con_v2_reset_protocol()
3810 con->v2.out_enc_page_cnt = 0; in ceph_con_v2_reset_protocol()
3813 con->v2.con_mode = CEPH_CON_MODE_UNKNOWN; in ceph_con_v2_reset_protocol()
3814 memzero_explicit(&con->v2.in_gcm_nonce, CEPH_GCM_IV_LEN); in ceph_con_v2_reset_protocol()
3815 memzero_explicit(&con->v2.out_gcm_nonce, CEPH_GCM_IV_LEN); in ceph_con_v2_reset_protocol()
3817 if (con->v2.hmac_tfm) { in ceph_con_v2_reset_protocol()
3818 crypto_free_shash(con->v2.hmac_tfm); in ceph_con_v2_reset_protocol()
3819 con->v2.hmac_tfm = NULL; in ceph_con_v2_reset_protocol()
3821 if (con->v2.gcm_req) { in ceph_con_v2_reset_protocol()
3822 aead_request_free(con->v2.gcm_req); in ceph_con_v2_reset_protocol()
3823 con->v2.gcm_req = NULL; in ceph_con_v2_reset_protocol()
3825 if (con->v2.gcm_tfm) { in ceph_con_v2_reset_protocol()
3826 crypto_free_aead(con->v2.gcm_tfm); in ceph_con_v2_reset_protocol()
3827 con->v2.gcm_tfm = NULL; in ceph_con_v2_reset_protocol()