Merge branch '2.1' into develop
This commit is contained in:
@ -8,6 +8,3 @@ add_subdirectory(maxscaled)
|
||||
add_subdirectory(MySQL)
|
||||
add_subdirectory(telnetd)
|
||||
|
||||
if(BUILD_TESTS)
|
||||
add_subdirectory(testprotocol)
|
||||
endif()
|
||||
|
||||
@ -189,12 +189,10 @@ static int gw_create_backend_connection(DCB *backend_dcb,
|
||||
/** Copy client flags to backend protocol */
|
||||
if (backend_dcb->session->client_dcb->protocol)
|
||||
{
|
||||
/** Copy client flags to backend protocol */
|
||||
protocol->client_capabilities =
|
||||
((MySQLProtocol *)(backend_dcb->session->client_dcb->protocol))->client_capabilities;
|
||||
/** Copy client charset to backend protocol */
|
||||
protocol->charset =
|
||||
((MySQLProtocol *)(backend_dcb->session->client_dcb->protocol))->charset;
|
||||
MySQLProtocol *client = (MySQLProtocol*)backend_dcb->session->client_dcb->protocol;
|
||||
protocol->client_capabilities = client->client_capabilities;
|
||||
protocol->charset = client->charset;
|
||||
protocol->extra_capabilities = client->extra_capabilities;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -224,16 +224,25 @@ int MySQLSendHandshake(DCB* dcb)
|
||||
uint8_t mysql_server_language = 8;
|
||||
uint8_t mysql_server_status[2];
|
||||
uint8_t mysql_scramble_len = 21;
|
||||
uint8_t mysql_filler_ten[10];
|
||||
uint8_t mysql_filler_ten[10] = {};
|
||||
/* uint8_t mysql_last_byte = 0x00; not needed */
|
||||
char server_scramble[GW_MYSQL_SCRAMBLE_SIZE + 1] = "";
|
||||
char *version_string;
|
||||
int len_version_string = 0;
|
||||
int id_num;
|
||||
|
||||
bool is_maria = false;
|
||||
|
||||
if (dcb->service->dbref)
|
||||
{
|
||||
mysql_server_language = dcb->service->dbref->server->charset;
|
||||
|
||||
if (dcb->service->dbref->server->server_string &&
|
||||
strstr(dcb->service->dbref->server->server_string, "10.2."))
|
||||
{
|
||||
/** The backend servers support the extended capabilities */
|
||||
is_maria = true;
|
||||
}
|
||||
}
|
||||
|
||||
MySQLProtocol *protocol = DCB_PROTOCOL(dcb, MySQLProtocol);
|
||||
@ -256,9 +265,15 @@ int MySQLSendHandshake(DCB* dcb)
|
||||
// copy back to the caller
|
||||
memcpy(protocol->scramble, server_scramble, GW_MYSQL_SCRAMBLE_SIZE);
|
||||
|
||||
// fill the handshake packet
|
||||
|
||||
memset(mysql_filler_ten, 0x00, sizeof(mysql_filler_ten));
|
||||
if (is_maria)
|
||||
{
|
||||
/**
|
||||
* The new 10.2 capability flags are stored in the last 4 bytes of the
|
||||
* 10 byte filler block.
|
||||
*/
|
||||
uint32_t new_flags = MXS_MARIA_CAP_STMT_BULK_OPERATIONS;
|
||||
memcpy(mysql_filler_ten + 6, &new_flags, sizeof(new_flags));
|
||||
}
|
||||
|
||||
// thread id, now put thePID
|
||||
id_num = getpid() + dcb->fd;
|
||||
@ -324,11 +339,19 @@ int MySQLSendHandshake(DCB* dcb)
|
||||
mysql_handshake_payload++;
|
||||
|
||||
// write server capabilities part one
|
||||
mysql_server_capabilities_one[0] = GW_MYSQL_SERVER_CAPABILITIES_BYTE1;
|
||||
mysql_server_capabilities_one[1] = GW_MYSQL_SERVER_CAPABILITIES_BYTE2;
|
||||
mysql_server_capabilities_one[0] = (uint8_t)GW_MYSQL_CAPABILITIES_SERVER;
|
||||
mysql_server_capabilities_one[1] = (uint8_t)(GW_MYSQL_CAPABILITIES_SERVER >> 8);
|
||||
|
||||
// Check that we match the old values
|
||||
ss_dassert(mysql_server_capabilities_one[0] = 0xff);
|
||||
ss_dassert(mysql_server_capabilities_one[1] = 0xf7);
|
||||
|
||||
mysql_server_capabilities_one[0] &= ~(int)GW_MYSQL_CAPABILITIES_COMPRESS;
|
||||
if (is_maria)
|
||||
{
|
||||
/** A MariaDB 10.2 server doesn't send the CLIENT_MYSQL capability
|
||||
* to signal that it supports extended capabilities */
|
||||
mysql_server_capabilities_one[0] &= ~(uint8_t)GW_MYSQL_CAPABILITIES_CLIENT_MYSQL;
|
||||
}
|
||||
|
||||
if (ssl_required_by_dcb(dcb))
|
||||
{
|
||||
@ -349,8 +372,13 @@ int MySQLSendHandshake(DCB* dcb)
|
||||
mysql_handshake_payload = mysql_handshake_payload + sizeof(mysql_server_status);
|
||||
|
||||
//write server capabilities part two
|
||||
mysql_server_capabilities_two[0] = 15;
|
||||
mysql_server_capabilities_two[1] = 128;
|
||||
mysql_server_capabilities_two[0] = (uint8_t)(GW_MYSQL_CAPABILITIES_SERVER >> 16);
|
||||
mysql_server_capabilities_two[1] = (uint8_t)(GW_MYSQL_CAPABILITIES_SERVER >> 24);
|
||||
|
||||
// Check that we match the old values
|
||||
ss_dassert(mysql_server_capabilities_two[0] == 15);
|
||||
/** NOTE: pre-2.1 versions sent the fourth byte of the capabilities as
|
||||
the value 128 even though there's no such capability. */
|
||||
|
||||
memcpy(mysql_handshake_payload, mysql_server_capabilities_two, sizeof(mysql_server_capabilities_two));
|
||||
mysql_handshake_payload = mysql_handshake_payload + sizeof(mysql_server_capabilities_two);
|
||||
@ -531,6 +559,13 @@ static void store_client_information(DCB *dcb, GWBUF *buffer)
|
||||
proto->client_capabilities = gw_mysql_get_byte4(data + MYSQL_CLIENT_CAP_OFFSET);
|
||||
proto->charset = data[MYSQL_CHARSET_OFFSET];
|
||||
|
||||
/** MariaDB 10.2 compatible clients don't set the first bit to signal that
|
||||
* there are extra capabilities stored in the last 4 bytes of the 23 byte filler. */
|
||||
if ((proto->client_capabilities & GW_MYSQL_CAPABILITIES_CLIENT_MYSQL) == 0)
|
||||
{
|
||||
proto->extra_capabilities = gw_mysql_get_byte4(data + MARIADB_CAP_OFFSET);
|
||||
}
|
||||
|
||||
if (len > MYSQL_AUTH_PACKET_BASE_SIZE)
|
||||
{
|
||||
strcpy(ses->user, (char*)data + MYSQL_AUTH_PACKET_BASE_SIZE);
|
||||
@ -825,7 +860,12 @@ static bool process_client_commands(DCB* dcb, int bytes_available, GWBUF** buffe
|
||||
}
|
||||
|
||||
MySQLProtocol *proto = (MySQLProtocol*)dcb->protocol;
|
||||
proto->current_command = cmd;
|
||||
if (dcb->protocol_packet_length - MYSQL_HEADER_LEN != GW_MYSQL_MAX_PACKET_LEN)
|
||||
{
|
||||
/** We're processing the first packet of a command */
|
||||
proto->current_command = cmd;
|
||||
}
|
||||
|
||||
dcb->protocol_packet_length = pktlen + MYSQL_HEADER_LEN;
|
||||
dcb->protocol_bytes_processed = 0;
|
||||
}
|
||||
|
||||
@ -103,6 +103,7 @@ MySQLProtocol* mysql_protocol_init(DCB* dcb, int fd)
|
||||
p->protocol_command.scom_nresponse_packets = 0;
|
||||
p->protocol_command.scom_nbytes_to_read = 0;
|
||||
p->stored_query = NULL;
|
||||
p->extra_capabilities = 0;
|
||||
#if defined(SS_DEBUG)
|
||||
p->protocol_chk_top = CHK_NUM_PROTOCOL;
|
||||
p->protocol_chk_tail = CHK_NUM_PROTOCOL;
|
||||
@ -1364,8 +1365,12 @@ mxs_auth_state_t gw_send_backend_auth(DCB *dcb)
|
||||
|
||||
payload++;
|
||||
|
||||
// 23 bytes of 0
|
||||
payload += 23;
|
||||
// 19 filler bytes of 0
|
||||
payload += 19;
|
||||
|
||||
// Either MariaDB 10.2 extra capabilities or 4 bytes filler
|
||||
memcpy(payload, &conn->extra_capabilities, sizeof(conn->extra_capabilities));
|
||||
payload += 4;
|
||||
|
||||
if (dcb->server->server_ssl && dcb->ssl_state != SSL_ESTABLISHED)
|
||||
{
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
add_library(testprotocol SHARED testprotocol.c)
|
||||
set_target_properties(testprotocol PROPERTIES VERSION "1.0.0")
|
||||
install_module(testprotocol core)
|
||||
@ -1,131 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 MariaDB Corporation Ab
|
||||
*
|
||||
* Use of this software is governed by the Business Source License included
|
||||
* in the LICENSE.TXT file and at www.mariadb.com/bsl11.
|
||||
*
|
||||
* Change Date: 2019-07-01
|
||||
*
|
||||
* On the date above, in accordance with the Business Source License, use
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file testprotocol.c - Testing protocol module
|
||||
*
|
||||
* Not intended for actual use. This protocol module does nothing useful and
|
||||
* is only meant to test that the module loading works.
|
||||
*
|
||||
* @verbatim
|
||||
* Revision History
|
||||
* Date Who Description
|
||||
* 20/02/2015 Markus Mäkelä Initial implementation
|
||||
*
|
||||
* @endverbatim
|
||||
*/
|
||||
|
||||
#include <maxscale/modinfo.h>
|
||||
#include <maxscale/dcb.h>
|
||||
#include <maxscale/buffer.h>
|
||||
#include <maxscale/protocol.h>
|
||||
|
||||
static int test_read(DCB* dcb)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
static int test_write(DCB *dcb, GWBUF* buf)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
static int test_write_ready(DCB *dcb)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
static int test_error(DCB *dcb)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
static int test_hangup(DCB *dcb)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
static int test_accept(DCB *dcb)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
static int test_connect(struct dcb *dcb, struct server *srv, struct session *ses)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
static int test_close(DCB *dcb)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
static int test_listen(DCB *dcb, char *config)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
static int test_auth(DCB* dcb, struct server *srv, struct session *ses, GWBUF *buf)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
static int test_session(DCB *dcb, void* data)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
static char *test_default_auth()
|
||||
{
|
||||
return "NullAuthAllow";
|
||||
}
|
||||
static int test_connection_limit(DCB *dcb, int limit)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The module entry point routine. It is this routine that
|
||||
* must populate the structure that is referred to as the
|
||||
* "module object", this is a structure with the set of
|
||||
* external entry points for this module.
|
||||
*
|
||||
* @return The module object
|
||||
*/
|
||||
MXS_MODULE* MXS_CREATE_MODULE()
|
||||
{
|
||||
static MXS_PROTOCOL MyObject =
|
||||
{
|
||||
test_read, /**< Read - EPOLLIN handler */
|
||||
test_write, /**< Write - data from gateway */
|
||||
test_write_ready, /**< WriteReady - EPOLLOUT handler */
|
||||
test_error, /**< Error - EPOLLERR handler */
|
||||
test_hangup, /**< HangUp - EPOLLHUP handler */
|
||||
test_accept, /**< Accept */
|
||||
test_connect, /**< Connect */
|
||||
test_close, /**< Close */
|
||||
test_listen, /**< Create a listener */
|
||||
test_auth, /**< Authentication */
|
||||
test_session, /**< Session */
|
||||
test_default_auth, /**< Default authenticator */
|
||||
test_connection_limit /**< Connection limit */
|
||||
};
|
||||
|
||||
static MXS_MODULE info =
|
||||
{
|
||||
MXS_MODULE_API_PROTOCOL,
|
||||
MXS_MODULE_IN_DEVELOPMENT,
|
||||
MXS_PROTOCOL_VERSION,
|
||||
"Test protocol",
|
||||
"V1.1.0",
|
||||
&MyObject,
|
||||
NULL, /* Process init. */
|
||||
NULL, /* Process finish. */
|
||||
NULL, /* Thread init. */
|
||||
NULL, /* Thread finish. */
|
||||
{
|
||||
{MXS_END_MODULE_PARAMS}
|
||||
}
|
||||
};
|
||||
|
||||
return &info;
|
||||
}
|
||||
Reference in New Issue
Block a user