diff --git a/src/core/tsi/alts/handshaker/alts_handshaker_client.cc b/src/core/tsi/alts/handshaker/alts_handshaker_client.cc index 5c5a407f54f..61927276195 100644 --- a/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +++ b/src/core/tsi/alts/handshaker/alts_handshaker_client.cc @@ -508,8 +508,8 @@ static grpc_byte_buffer* get_serialized_start_client( upb_strview_makez(ptr->data)); ptr = ptr->next; } - grpc_gcp_StartClientHandshakeReq_set_max_frame_size(start_client, - client->max_frame_size); + grpc_gcp_StartClientHandshakeReq_set_max_frame_size( + start_client, static_cast(client->max_frame_size)); return get_serialized_handshaker_req(req, arena.ptr()); } @@ -569,8 +569,8 @@ static grpc_byte_buffer* get_serialized_start_server( arena.ptr()); grpc_gcp_RpcProtocolVersions_assign_from_struct( server_version, arena.ptr(), &client->options->rpc_versions); - grpc_gcp_StartServerHandshakeReq_set_max_frame_size(start_server, - client->max_frame_size); + grpc_gcp_StartServerHandshakeReq_set_max_frame_size( + start_server, static_cast(client->max_frame_size)); return get_serialized_handshaker_req(req, arena.ptr()); } diff --git a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc index b2687825d17..2a925182d3f 100644 --- a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +++ b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc @@ -41,9 +41,6 @@ #include "src/core/tsi/alts/handshaker/alts_tsi_utils.h" #include "src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h" -const size_t kMinFrameSize = 16 * 1024; -const size_t kMaxFrameSize = 128 * 1024; - /* Main struct for ALTS TSI handshaker. */ struct alts_tsi_handshaker { tsi_handshaker base; @@ -166,17 +163,17 @@ static tsi_result handshaker_result_create_zero_copy_grpc_protector( // In case the peer does not send max frame size (e.g. peer is gRPC Go or // peer uses an old binary), the negotiated frame size is set to - // kMinFrameSize (ignoring max_output_protected_frame_size value if + // kTsiAltsMinFrameSize (ignoring max_output_protected_frame_size value if // present). Otherwise, it is based on peer and user specified max frame // size (if present). - size_t max_frame_size = kMinFrameSize; + size_t max_frame_size = kTsiAltsMinFrameSize; if (result->max_frame_size) { size_t peer_max_frame_size = result->max_frame_size; max_frame_size = std::min(peer_max_frame_size, max_output_protected_frame_size == nullptr - ? kMaxFrameSize + ? kTsiAltsMaxFrameSize : *max_output_protected_frame_size); - max_frame_size = std::max(max_frame_size, kMinFrameSize); + max_frame_size = std::max(max_frame_size, kTsiAltsMinFrameSize); } max_output_protected_frame_size = &max_frame_size; gpr_log(GPR_DEBUG, @@ -622,7 +619,7 @@ tsi_result alts_tsi_handshaker_create( handshaker->options = grpc_alts_credentials_options_copy(options); handshaker->max_frame_size = user_specified_max_frame_size != 0 ? user_specified_max_frame_size - : kMaxFrameSize; + : kTsiAltsMaxFrameSize; handshaker->base.vtable = handshaker->use_dedicated_cq ? &handshaker_vtable_dedicated : &handshaker_vtable; diff --git a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h index 6959c563a5e..e1ae985a84d 100644 --- a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +++ b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h @@ -39,9 +39,9 @@ const size_t kTsiAltsNumOfPeerProperties = 5; // Frame size negotiation extends send frame size range to -// [kMinFrameSize, kMaxFrameSize] -ABSL_CONST_INIT extern const size_t kMinFrameSize; -ABSL_CONST_INIT extern const size_t kMaxFrameSize; +// [kTsiAltsMinFrameSize, kTsiAltsMaxFrameSize]. +const size_t kTsiAltsMinFrameSize = 16 * 1024; +const size_t kTsiAltsMaxFrameSize = 128 * 1024; typedef struct alts_tsi_handshaker alts_tsi_handshaker; diff --git a/test/core/tsi/alts/handshaker/alts_tsi_handshaker_test.cc b/test/core/tsi/alts/handshaker/alts_tsi_handshaker_test.cc index 8f38640ef67..2127e980488 100644 --- a/test/core/tsi/alts/handshaker/alts_tsi_handshaker_test.cc +++ b/test/core/tsi/alts/handshaker/alts_tsi_handshaker_test.cc @@ -296,7 +296,7 @@ static void on_client_next_success_cb(tsi_result status, void* user_data, size_t actual_max_frame_size; tsi_zero_copy_grpc_protector_max_frame_size(zero_copy_protector, &actual_max_frame_size); - GPR_ASSERT(actual_max_frame_size == kMaxFrameSize); + GPR_ASSERT(actual_max_frame_size == kTsiAltsMaxFrameSize); tsi_zero_copy_grpc_protector_destroy(zero_copy_protector); /* Validate peer identity. */ tsi_peer peer; @@ -370,7 +370,7 @@ static void on_server_next_success_cb(tsi_result status, void* user_data, size_t actual_max_frame_size; tsi_zero_copy_grpc_protector_max_frame_size(zero_copy_protector, &actual_max_frame_size); - GPR_ASSERT(actual_max_frame_size == kMinFrameSize); + GPR_ASSERT(actual_max_frame_size == kTsiAltsMinFrameSize); tsi_zero_copy_grpc_protector_destroy(zero_copy_protector); /* Validate peer identity. */ tsi_peer peer;