Get service capabilities from a better source

The DCB pointer in the MySQLProtocol struct doesn't appear to be updated
in all cases which causes it to be an unreliable source. As the session
itself is always available and it always has the service pointer properly
set, it should be used instead.

Also removed the dead protocol compression code and replaced the
parameters with the service capability bits.
This commit is contained in:
Markus Mäkelä 2018-03-15 23:02:49 +02:00
parent 20c5ca1619
commit 10a9d70851
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
3 changed files with 13 additions and 19 deletions

View File

@ -510,15 +510,16 @@ int gw_decode_mysql_server_handshake(MySQLProtocol *conn, uint8_t *payload);
/**
* Create a response to the server handshake
*
* @param client Shared session data
* @param conn MySQL Protocol object for this connection
* @param with_ssl Whether to create an SSL response or a normal response packet
* @param ssl_established Set to true if the SSL response has been sent
* @param client Shared session data
* @param conn MySQL Protocol object for this connection
* @param with_ssl Whether to create an SSL response or a normal response packet
* @param ssl_established Set to true if the SSL response has been sent
* @param service_capabilities Capabilities of the connecting service
*
* @return Generated response packet
*/
GWBUF* gw_generate_auth_response(MYSQL_session* client, MySQLProtocol *conn,
bool with_ssl, bool ssl_established);
bool with_ssl, bool ssl_established, uint64_t service_capabilities);
/** Read the backend server's handshake */
bool gw_read_backend_handshake(DCB *dcb, GWBUF *buffer);

View File

@ -104,7 +104,7 @@ void LocalClient::process(uint32_t events)
{
if (gw_decode_mysql_server_handshake(&m_protocol, GWBUF_DATA(buf) + MYSQL_HEADER_LEN) == 0)
{
GWBUF* response = gw_generate_auth_response(&m_client, &m_protocol, false, false);
GWBUF* response = gw_generate_auth_response(&m_client, &m_protocol, false, false, 0);
m_queue.push_front(response);
m_state = VC_RESPONSE_SENT;
}

View File

@ -1215,7 +1215,7 @@ load_hashed_password(uint8_t *scramble, uint8_t *payload, uint8_t *passwd)
* @note Capability bits are defined in maxscale/protocol/mysql.h
*/
static uint32_t
create_capabilities(MySQLProtocol *conn, bool with_ssl, bool db_specified, bool compress)
create_capabilities(MySQLProtocol *conn, bool with_ssl, bool db_specified, uint64_t capabilities)
{
uint32_t final_capabilities;
@ -1230,8 +1230,6 @@ create_capabilities(MySQLProtocol *conn, bool with_ssl, bool db_specified, bool
/* final_capabilities |= (uint32_t)GW_MYSQL_CAPABILITIES_SSL_VERIFY_SERVER_CERT; */
}
uint64_t capabilities = service_get_capabilities(conn->owner_dcb->session->service);
if (rcap_type_required(capabilities, RCAP_TYPE_SESSION_STATE_TRACKING))
{
/** add session track */
@ -1241,13 +1239,6 @@ create_capabilities(MySQLProtocol *conn, bool with_ssl, bool db_specified, bool
/** support multi statments */
final_capabilities |= (uint32_t)GW_MYSQL_CAPABILITIES_MULTI_STATEMENTS;
/* Compression is not currently supported */
ss_dassert(!compress);
if (compress)
{
final_capabilities |= (uint32_t)GW_MYSQL_CAPABILITIES_COMPRESS;
}
if (db_specified)
{
/* With database specified */
@ -1265,7 +1256,8 @@ create_capabilities(MySQLProtocol *conn, bool with_ssl, bool db_specified, bool
}
GWBUF* gw_generate_auth_response(MYSQL_session* client, MySQLProtocol *conn,
bool with_ssl, bool ssl_established)
bool with_ssl, bool ssl_established,
uint64_t service_capabilities)
{
uint8_t client_capabilities[4] = {0, 0, 0, 0};
uint8_t *curr_passwd = NULL;
@ -1275,7 +1267,7 @@ GWBUF* gw_generate_auth_response(MYSQL_session* client, MySQLProtocol *conn,
curr_passwd = client->client_sha1;
}
uint32_t capabilities = create_capabilities(conn, with_ssl, client->db[0], false);
uint32_t capabilities = create_capabilities(conn, with_ssl, client->db[0], service_capabilities);
gw_mysql_set_byte4(client_capabilities, capabilities);
/**
@ -1379,7 +1371,8 @@ mxs_auth_state_t gw_send_backend_auth(DCB *dcb)
gw_get_shared_session_auth_info(dcb->session->client_dcb, &client);
GWBUF* buffer = gw_generate_auth_response(&client, (MySQLProtocol*)dcb->protocol,
with_ssl, ssl_established);
with_ssl, ssl_established,
dcb->service->capabilities);
ss_dassert(buffer);
if (with_ssl && !ssl_established)