Format router modules

Formatted router modules with Astyle.
This commit is contained in:
Markus Mäkelä
2017-01-17 13:48:47 +02:00
parent 735674bb1b
commit a48be9badf
26 changed files with 2181 additions and 2009 deletions

View File

@ -129,85 +129,85 @@ const char* binlog_event_name(int type)
{
switch (type)
{
case START_EVENT_V3:
return "START_EVENT_V3";
case QUERY_EVENT:
return "QUERY_EVENT";
case STOP_EVENT:
return "STOP_EVENT";
case ROTATE_EVENT:
return "ROTATE_EVENT";
case INTVAR_EVENT:
return "INTVAR_EVENT";
case LOAD_EVENT:
return "LOAD_EVENT";
case SLAVE_EVENT:
return "SLAVE_EVENT";
case CREATE_FILE_EVENT:
return "CREATE_FILE_EVENT";
case APPEND_BLOCK_EVENT:
return "APPEND_BLOCK_EVENT";
case EXEC_LOAD_EVENT:
return "EXEC_LOAD_EVENT";
case DELETE_FILE_EVENT:
return "DELETE_FILE_EVENT";
case NEW_LOAD_EVENT:
return "NEW_LOAD_EVENT";
case RAND_EVENT:
return "RAND_EVENT";
case USER_VAR_EVENT:
return "USER_VAR_EVENT";
case FORMAT_DESCRIPTION_EVENT:
return "FORMAT_DESCRIPTION_EVENT";
case XID_EVENT:
return "XID_EVENT";
case BEGIN_LOAD_QUERY_EVENT:
return "BEGIN_LOAD_QUERY_EVENT";
case EXECUTE_LOAD_QUERY_EVENT:
return "EXECUTE_LOAD_QUERY_EVENT";
case TABLE_MAP_EVENT:
return "TABLE_MAP_EVENT";
case WRITE_ROWS_EVENTv0:
return "WRITE_ROWS_EVENTv0";
case UPDATE_ROWS_EVENTv0:
return "UPDATE_ROWS_EVENTv0";
case DELETE_ROWS_EVENTv0:
return "DELETE_ROWS_EVENTv0";
case WRITE_ROWS_EVENTv1:
return "WRITE_ROWS_EVENTv1";
case UPDATE_ROWS_EVENTv1:
return "UPDATE_ROWS_EVENTv1";
case DELETE_ROWS_EVENTv1:
return "DELETE_ROWS_EVENTv1";
case INCIDENT_EVENT:
return "INCIDENT_EVENT";
case HEARTBEAT_EVENT:
return "HEARTBEAT_EVENT";
case IGNORABLE_EVENT:
return "IGNORABLE_EVENT";
case ROWS_QUERY_EVENT:
return "ROWS_QUERY_EVENT";
case WRITE_ROWS_EVENTv2:
return "WRITE_ROWS_EVENTv2";
case UPDATE_ROWS_EVENTv2:
return "UPDATE_ROWS_EVENTv2";
case DELETE_ROWS_EVENTv2:
return "DELETE_ROWS_EVENTv2";
case GTID_EVENT:
return "GTID_EVENT";
case ANONYMOUS_GTID_EVENT:
return "ANONYMOUS_GTID_EVENT";
case PREVIOUS_GTIDS_EVENT:
return "PREVIOUS_GTIDS_EVENT";
case MARIADB_ANNOTATE_ROWS_EVENT:
return "MARIADB_ANNOTATE_ROWS_EVENT";
case MARIADB10_BINLOG_CHECKPOINT_EVENT:
return "MARIADB10_BINLOG_CHECKPOINT_EVENT";
case MARIADB10_GTID_EVENT:
return "MARIADB10_GTID_EVENT";
case MARIADB10_GTID_GTID_LIST_EVENT:
return "MARIADB10_GTID_GTID_LIST_EVENT";
default:
return "UNKNOWN_EVENT";
case START_EVENT_V3:
return "START_EVENT_V3";
case QUERY_EVENT:
return "QUERY_EVENT";
case STOP_EVENT:
return "STOP_EVENT";
case ROTATE_EVENT:
return "ROTATE_EVENT";
case INTVAR_EVENT:
return "INTVAR_EVENT";
case LOAD_EVENT:
return "LOAD_EVENT";
case SLAVE_EVENT:
return "SLAVE_EVENT";
case CREATE_FILE_EVENT:
return "CREATE_FILE_EVENT";
case APPEND_BLOCK_EVENT:
return "APPEND_BLOCK_EVENT";
case EXEC_LOAD_EVENT:
return "EXEC_LOAD_EVENT";
case DELETE_FILE_EVENT:
return "DELETE_FILE_EVENT";
case NEW_LOAD_EVENT:
return "NEW_LOAD_EVENT";
case RAND_EVENT:
return "RAND_EVENT";
case USER_VAR_EVENT:
return "USER_VAR_EVENT";
case FORMAT_DESCRIPTION_EVENT:
return "FORMAT_DESCRIPTION_EVENT";
case XID_EVENT:
return "XID_EVENT";
case BEGIN_LOAD_QUERY_EVENT:
return "BEGIN_LOAD_QUERY_EVENT";
case EXECUTE_LOAD_QUERY_EVENT:
return "EXECUTE_LOAD_QUERY_EVENT";
case TABLE_MAP_EVENT:
return "TABLE_MAP_EVENT";
case WRITE_ROWS_EVENTv0:
return "WRITE_ROWS_EVENTv0";
case UPDATE_ROWS_EVENTv0:
return "UPDATE_ROWS_EVENTv0";
case DELETE_ROWS_EVENTv0:
return "DELETE_ROWS_EVENTv0";
case WRITE_ROWS_EVENTv1:
return "WRITE_ROWS_EVENTv1";
case UPDATE_ROWS_EVENTv1:
return "UPDATE_ROWS_EVENTv1";
case DELETE_ROWS_EVENTv1:
return "DELETE_ROWS_EVENTv1";
case INCIDENT_EVENT:
return "INCIDENT_EVENT";
case HEARTBEAT_EVENT:
return "HEARTBEAT_EVENT";
case IGNORABLE_EVENT:
return "IGNORABLE_EVENT";
case ROWS_QUERY_EVENT:
return "ROWS_QUERY_EVENT";
case WRITE_ROWS_EVENTv2:
return "WRITE_ROWS_EVENTv2";
case UPDATE_ROWS_EVENTv2:
return "UPDATE_ROWS_EVENTv2";
case DELETE_ROWS_EVENTv2:
return "DELETE_ROWS_EVENTv2";
case GTID_EVENT:
return "GTID_EVENT";
case ANONYMOUS_GTID_EVENT:
return "ANONYMOUS_GTID_EVENT";
case PREVIOUS_GTIDS_EVENT:
return "PREVIOUS_GTIDS_EVENT";
case MARIADB_ANNOTATE_ROWS_EVENT:
return "MARIADB_ANNOTATE_ROWS_EVENT";
case MARIADB10_BINLOG_CHECKPOINT_EVENT:
return "MARIADB10_BINLOG_CHECKPOINT_EVENT";
case MARIADB10_GTID_EVENT:
return "MARIADB10_GTID_EVENT";
case MARIADB10_GTID_GTID_LIST_EVENT:
return "MARIADB10_GTID_GTID_LIST_EVENT";
default:
return "UNKNOWN_EVENT";
}
}

View File

@ -132,7 +132,7 @@ static const MXS_ENUM_VALUE enc_algo_values[] =
{
{"aes_cbc", BLR_AES_CBC},
#if OPENSSL_VERSION_NUMBER > 0x10000000L
{"aes_ctr",BLR_AES_CTR},
{"aes_ctr", BLR_AES_CTR},
#endif
{NULL}
};
@ -864,7 +864,7 @@ createInstance(SERVICE *service, char **options)
if (inst->trx_safe)
{
MXS_NOTICE("%s: Service has transaction safety option set to ON",
service->name);
service->name);
}
/* Log whether the binlog encryption option value is on */
@ -1652,9 +1652,9 @@ diagnostics(ROUTER *router, DCB *dcb)
{
dcb_printf(dcb, "\t\tSlave_mode: catchup. %s%s\n",
((session->cstate & CS_EXPECTCB) == 0 ? "" :
"Waiting for DCB queue to drain."),
"Waiting for DCB queue to drain."),
((session->cstate & CS_BUSY) == 0 ? "" :
" Busy in slave catchup."));
" Busy in slave catchup."));
}
}
#if SPINLOCK_PROFILE
@ -2469,11 +2469,11 @@ destroyInstance(ROUTER *instance)
}
MXS_INFO("%s is being stopped by MaxScale shudown. Disconnecting from master %s:%d, "
"read up to log %s, pos %lu, transaction safe pos %lu",
inst->service->name,
inst->service->dbref->server->name,
inst->service->dbref->server->port,
inst->binlog_name, inst->current_pos, inst->binlog_position);
"read up to log %s, pos %lu, transaction safe pos %lu",
inst->service->name,
inst->service->dbref->server->name,
inst->service->dbref->server->port,
inst->binlog_name, inst->current_pos, inst->binlog_position);
if (inst->trx_safe && inst->pending_transaction)
{
@ -2509,71 +2509,71 @@ unsigned int from_hex(char c)
*/
bool blr_extract_key(const char *buffer, int nline, ROUTER_INSTANCE *router)
{
char *p = (char *)buffer;
int length = 0;
uint8_t *key = (uint8_t *)router->encryption.key_value;
char *p = (char *)buffer;
int length = 0;
uint8_t *key = (uint8_t *)router->encryption.key_value;
while (isspace(*p) && *p != '\n')
{
p++;
}
while (isspace(*p) && *p != '\n')
{
p++;
}
/* Skip comments */
if (*p == '#')
{
return false;
}
/* Skip comments */
if (*p == '#')
{
return false;
}
unsigned int id = strtoll(p, &p, 10);
unsigned int id = strtoll(p, &p, 10);
/* key range is 1 .. 255 */
if (id < 1 || id > 255)
{
MXS_WARNING("Invalid Key Id (values 1..255) found in file %s. Line %d, index 0.",
router->encryption.key_management_filename,
nline);
return false;
}
/* key range is 1 .. 255 */
if (id < 1 || id > 255)
{
MXS_WARNING("Invalid Key Id (values 1..255) found in file %s. Line %d, index 0.",
router->encryption.key_management_filename,
nline);
return false;
}
/* Continue only if read id is BINLOG_SYSTEM_DATA_CRYPTO_SCHEME (value is 1) */
if (id != BINLOG_SYSTEM_DATA_CRYPTO_SCHEME)
{
return false;
}
/* Continue only if read id is BINLOG_SYSTEM_DATA_CRYPTO_SCHEME (value is 1) */
if (id != BINLOG_SYSTEM_DATA_CRYPTO_SCHEME)
{
return false;
}
/* Look for ';' separator */
if (*p != ';')
{
MXS_ERROR("Syntax error in Encryption Key file at line %d, index %lu. File %s",
nline,
p - buffer,
router->encryption.key_management_filename);
return false;
}
/* Look for ';' separator */
if (*p != ';')
{
MXS_ERROR("Syntax error in Encryption Key file at line %d, index %lu. File %s",
nline,
p - buffer,
router->encryption.key_management_filename);
return false;
}
p++;
p++;
/* Now read the hex data */
/* Now read the hex data */
while (isxdigit(p[0]) && isxdigit(p[1]) && length <= BINLOG_AES_MAX_KEY_LEN)
{
key[length++] = from_hex(p[0]) * 16 + from_hex(p[1]);
p += 2;
}
while (isxdigit(p[0]) && isxdigit(p[1]) && length <= BINLOG_AES_MAX_KEY_LEN)
{
key[length++] = from_hex(p[0]) * 16 + from_hex(p[1]);
p += 2;
}
if (isxdigit(*p) ||
(length != 16 && length != 24 && length != 32))
{
MXS_ERROR("Found invalid Encryption Key at line %d, index %lu. File %s",
nline,
p - buffer,
router->encryption.key_management_filename);
return false;
}
if (isxdigit(*p) ||
(length != 16 && length != 24 && length != 32))
{
MXS_ERROR("Found invalid Encryption Key at line %d, index %lu. File %s",
nline,
p - buffer,
router->encryption.key_management_filename);
return false;
}
router->encryption.key_len = length;
router->encryption.key_len = length;
return true;
return true;
}
/**
@ -2589,8 +2589,8 @@ bool blr_get_encryption_key(ROUTER_INSTANCE *router)
if (router->encryption.key_management_filename == NULL)
{
MXS_ERROR("Service %s, encryption key is not set. "
"Please specify key filename with 'encryption_key_file'",
router->service->name);
"Please specify key filename with 'encryption_key_file'",
router->service->name);
return false;
}
else
@ -2668,8 +2668,8 @@ int blr_parse_key_file(ROUTER_INSTANCE *router)
if (!found_keyid)
{
MXS_ERROR("No Key with Id = 1 has been found in file %s. Read %d lines.",
router->encryption.key_management_filename,
n_lines);
router->encryption.key_management_filename,
n_lines);
return n_lines;
}
else

View File

@ -501,12 +501,12 @@ typedef struct
*/
typedef struct binlog_encryption_setup
{
bool enabled;
int encryption_algorithm;
char *key_management_filename;
uint8_t key_value[BINLOG_AES_MAX_KEY_LEN];
unsigned long key_len;
uint8_t key_id;
bool enabled;
int encryption_algorithm;
char *key_management_filename;
uint8_t key_value[BINLOG_AES_MAX_KEY_LEN];
unsigned long key_len;
uint8_t key_id;
} BINLOG_ENCRYPTION_SETUP;
/**
@ -756,7 +756,8 @@ extern int blr_write_binlog_record(ROUTER_INSTANCE *, REP_HEADER *, uint32_t po
extern int blr_file_rotate(ROUTER_INSTANCE *, char *, uint64_t);
extern void blr_file_flush(ROUTER_INSTANCE *);
extern BLFILE *blr_open_binlog(ROUTER_INSTANCE *, char *);
extern GWBUF *blr_read_binlog(ROUTER_INSTANCE *, BLFILE *, unsigned long, REP_HEADER *, char *, const SLAVE_ENCRYPTION_CTX *);
extern GWBUF *blr_read_binlog(ROUTER_INSTANCE *, BLFILE *, unsigned long, REP_HEADER *, char *,
const SLAVE_ENCRYPTION_CTX *);
extern void blr_close_binlog(ROUTER_INSTANCE *, BLFILE *);
extern unsigned long blr_file_size(BLFILE *);
extern int blr_statistics(ROUTER_INSTANCE *, ROUTER_SLAVE *, GWBUF *);

View File

@ -85,10 +85,14 @@ static inline const EVP_CIPHER *aes_ctr(unsigned int klen)
{
switch (klen)
{
case 16: return EVP_aes_128_ctr();
case 24: return EVP_aes_192_ctr();
case 32: return EVP_aes_256_ctr();
default: return 0;
case 16:
return EVP_aes_128_ctr();
case 24:
return EVP_aes_192_ctr();
case 32:
return EVP_aes_256_ctr();
default:
return 0;
}
}
#endif
@ -103,10 +107,14 @@ static inline const EVP_CIPHER *aes_cbc(uint klen)
{
switch (klen)
{
case 16: return EVP_aes_128_cbc();
case 24: return EVP_aes_192_cbc();
case 32: return EVP_aes_256_cbc();
default: return 0;
case 16:
return EVP_aes_128_cbc();
case 24:
return EVP_aes_192_cbc();
case 32:
return EVP_aes_256_cbc();
default:
return 0;
}
}
@ -120,10 +128,14 @@ static inline const EVP_CIPHER *aes_ecb(uint klen)
{
switch (klen)
{
case 16: return EVP_aes_128_ecb();
case 24: return EVP_aes_192_ecb();
case 32: return EVP_aes_256_ecb();
default: return 0;
case 16:
return EVP_aes_128_ecb();
case 24:
return EVP_aes_192_ecb();
case 32:
return EVP_aes_256_ecb();
default:
return 0;
}
}
@ -184,11 +196,11 @@ static uint8_t *blr_create_start_encryption_event(ROUTER_INSTANCE *router,
uint32_t event_pos,
bool do_checksum);
static GWBUF *blr_prepare_encrypted_event(ROUTER_INSTANCE *router,
uint8_t *event,
uint32_t event_size,
uint32_t pos,
const uint8_t *nonce,
int action);
uint8_t *event,
uint32_t event_size,
uint32_t pos,
const uint8_t *nonce,
int action);
static GWBUF *blr_aes_crypt(ROUTER_INSTANCE *router,
uint8_t *event,
uint32_t event_size,
@ -555,7 +567,9 @@ blr_write_binlog_record(ROUTER_INSTANCE *router, REP_HEADER *hdr, uint32_t size,
gwbuf_free(encrypted);
encrypted = NULL;
} else {
}
else
{
/* Write current received event form master */
n = pwrite(router->binlog_fd, buf, size, router->last_written);
}
@ -814,7 +828,7 @@ blr_read_binlog(ROUTER_INSTANCE *router,
{
case 0:
MXS_INFO("Reached end of binlog file '%s' at %lu.",
file->binlogname, pos);
file->binlogname, pos);
/* set ok indicator */
hdr->ok = SLAVE_POS_READ_OK;
@ -878,7 +892,7 @@ blr_read_binlog(ROUTER_INSTANCE *router,
{
case 0:
MXS_INFO("Reached end of binlog file at %lu.",
pos);
pos);
/* set ok indicator */
hdr->ok = SLAVE_POS_READ_OK;
@ -959,7 +973,7 @@ blr_read_binlog(ROUTER_INSTANCE *router,
if (n == 0)
{
MXS_INFO("Reached end of binlog file at %lu while reading remaining bytes.",
pos);
pos);
/* set ok indicator */
hdr->ok = SLAVE_POS_READ_OK;
@ -1484,37 +1498,37 @@ blr_read_events_all_events(ROUTER_INSTANCE *router, int fix, int debug)
if (start_encryption_seen)
{
uint8_t iv[AES_BLOCK_SIZE + 1] = "";
char iv_hex[AES_BLOCK_SIZE * 2 + 1] = "";
/* The event size, 4 bytes, is written in clear: use it */
uint32_t event_size = EXTRACT32(hdbuf + BINLOG_EVENT_LEN_OFFSET);
uint8_t iv[AES_BLOCK_SIZE + 1] = "";
char iv_hex[AES_BLOCK_SIZE * 2 + 1] = "";
/* The event size, 4 bytes, is written in clear: use it */
uint32_t event_size = EXTRACT32(hdbuf + BINLOG_EVENT_LEN_OFFSET);
/**
* Events are encrypted.
*
* Print the IV for the current encrypted event.
*/
/**
* Events are encrypted.
*
* Print the IV for the current encrypted event.
*/
if (debug & BLR_REPORT_REP_HEADER)
{
/* Get binlog file "nonce" and other data from router encryption_ctx */
BINLOG_ENCRYPTION_CTX *enc_ctx = router->encryption_ctx;
if (debug & BLR_REPORT_REP_HEADER)
{
/* Get binlog file "nonce" and other data from router encryption_ctx */
BINLOG_ENCRYPTION_CTX *enc_ctx = router->encryption_ctx;
/* Encryption IV is 12 bytes nonce + 4 bytes event position */
memcpy(iv, enc_ctx->nonce, BLRM_NONCE_LENGTH);
gw_mysql_set_byte4(iv + BLRM_NONCE_LENGTH, (unsigned long)pos);
/* Encryption IV is 12 bytes nonce + 4 bytes event position */
memcpy(iv, enc_ctx->nonce, BLRM_NONCE_LENGTH);
gw_mysql_set_byte4(iv + BLRM_NONCE_LENGTH, (unsigned long)pos);
/* Human readable version */
gw_bin2hex(iv_hex, iv, BLRM_IV_LENGTH);
/* Human readable version */
gw_bin2hex(iv_hex, iv, BLRM_IV_LENGTH);
MXS_DEBUG("** Encrypted Event @ %lu: the IV is %s, size is %lu, next pos is %lu\n",
(unsigned long)pos,
iv_hex, (unsigned long)event_size,
(unsigned long)(pos + event_size));
}
MXS_DEBUG("** Encrypted Event @ %lu: the IV is %s, size is %lu, next pos is %lu\n",
(unsigned long)pos,
iv_hex, (unsigned long)event_size,
(unsigned long)(pos + event_size));
}
/* Set event size only in hdr struct, before decryption */
hdr.event_size = event_size;
/* Set event size only in hdr struct, before decryption */
hdr.event_size = event_size;
}
else
@ -1690,16 +1704,16 @@ blr_read_events_all_events(ROUTER_INSTANCE *router, int fix, int debug)
/* decrypt events */
if (start_encryption_seen)
{
uint8_t iv[AES_BLOCK_SIZE + 1] = "";
char iv_hex[AES_BLOCK_SIZE * 2 + 1] = "";
uint32_t event_size = EXTRACT32(hdbuf + BINLOG_EVENT_LEN_OFFSET);
uint8_t *decrypt_ptr;
unsigned long next_pos;
char errmsg[BLRM_STRERROR_R_MSG_SIZE + 1] = "";
uint8_t iv[AES_BLOCK_SIZE + 1] = "";
char iv_hex[AES_BLOCK_SIZE * 2 + 1] = "";
uint32_t event_size = EXTRACT32(hdbuf + BINLOG_EVENT_LEN_OFFSET);
uint8_t *decrypt_ptr;
unsigned long next_pos;
char errmsg[BLRM_STRERROR_R_MSG_SIZE + 1] = "";
/**
* Events are encrypted.
*/
/**
* Events are encrypted.
*/
if ((decrypted_event = blr_prepare_encrypted_event(router,
data,
@ -2403,11 +2417,13 @@ blr_file_write_master_config(ROUTER_INSTANCE *router, char *error)
{
fprintf(config_file, "master_ssl=%d\n", router->ssl_enabled);
fprintf(config_file, "master_ssl_key=%s\n", ssl_key);
fprintf(config_file, "master_ssl_cert=%s\n",ssl_cert);
fprintf(config_file, "master_ssl_cert=%s\n", ssl_cert);
fprintf(config_file, "master_ssl_ca=%s\n", ssl_ca);
}
if (ssl_version && strlen(ssl_version))
{
fprintf(config_file, "master_tls_version=%s\n", ssl_version);
}
fclose(config_file);
@ -2525,12 +2541,12 @@ blr_create_ignorable_event(uint32_t event_size,
* The algorithm is first to compute the checksum of an empty buffer
* and then the checksum of the real event: 4 byte less than event_size
*/
uint32_t chksum;
chksum = crc32(0L, NULL, 0);
chksum = crc32(chksum, new_event, event_size - BINLOG_EVENT_CRC_SIZE);
uint32_t chksum;
chksum = crc32(0L, NULL, 0);
chksum = crc32(chksum, new_event, event_size - BINLOG_EVENT_CRC_SIZE);
// checksum is stored after current event data using 4 bytes
encode_value(new_event + event_size - BINLOG_EVENT_CRC_SIZE, chksum, 32);
// checksum is stored after current event data using 4 bytes
encode_value(new_event + event_size - BINLOG_EVENT_CRC_SIZE, chksum, 32);
}
return new_event;
}
@ -2546,7 +2562,8 @@ blr_create_ignorable_event(uint32_t event_size,
* @return 1 on success, 0 on error
*/
static int
blr_write_special_event(ROUTER_INSTANCE *router, uint32_t file_offset, uint32_t event_size, REP_HEADER *hdr, int type)
blr_write_special_event(ROUTER_INSTANCE *router, uint32_t file_offset, uint32_t event_size, REP_HEADER *hdr,
int type)
{
int n;
uint8_t *new_event;
@ -2554,92 +2571,92 @@ blr_write_special_event(ROUTER_INSTANCE *router, uint32_t file_offset, uint32_t
switch (type)
{
case BLRM_IGNORABLE:
new_event_desc = "IGNORABLE";
MXS_INFO("Hole detected while writing in binlog '%s' @ %lu: an %s event "
"of %lu bytes will be written at pos %lu",
router->binlog_name,
router->current_pos,
new_event_desc,
(unsigned long)event_size,
(unsigned long)file_offset);
case BLRM_IGNORABLE:
new_event_desc = "IGNORABLE";
MXS_INFO("Hole detected while writing in binlog '%s' @ %lu: an %s event "
"of %lu bytes will be written at pos %lu",
router->binlog_name,
router->current_pos,
new_event_desc,
(unsigned long)event_size,
(unsigned long)file_offset);
/* Create the Ignorable event */
if ((new_event = blr_create_ignorable_event(event_size,
hdr,
file_offset,
router->master_chksum)) == NULL)
{
return 0;
}
if (router->encryption.enabled && router->encryption_ctx != NULL)
{
GWBUF *encrypted;
uint8_t *encr_ptr;
if ((encrypted = blr_prepare_encrypted_event(router,
new_event,
event_size,
router->current_pos,
NULL,
BINLOG_FLAG_ENCRYPT)) == NULL)
{
return 0;
}
memcpy(new_event, GWBUF_DATA(encrypted), event_size);
gwbuf_free(encrypted);
}
break;
case BLRM_START_ENCRYPTION:
new_event_desc = "MARIADB10_START_ENCRYPTION";
MXS_INFO("New event %s is being added in binlog '%s' @ %lu: "
"%lu bytes will be written at pos %lu",
new_event_desc,
router->binlog_name,
router->current_pos,
(unsigned long)event_size,
(unsigned long)file_offset);
/* Create the MARIADB10_START_ENCRYPTION event */
if ((new_event = blr_create_start_encryption_event(router,
file_offset,
router->master_chksum)) == NULL)
{
return 0;
}
break;
default:
new_event_desc = "UNKNOWN";
MXS_ERROR("Cannot create special binlog event of %s type and size %lu "
"in binlog file '%s' @ %lu",
new_event_desc,
(unsigned long)event_size,
router->binlog_name,
router->current_pos);
/* Create the Ignorable event */
if ((new_event = blr_create_ignorable_event(event_size,
hdr,
file_offset,
router->master_chksum)) == NULL)
{
return 0;
break;
}
if (router->encryption.enabled && router->encryption_ctx != NULL)
{
GWBUF *encrypted;
uint8_t *encr_ptr;
if ((encrypted = blr_prepare_encrypted_event(router,
new_event,
event_size,
router->current_pos,
NULL,
BINLOG_FLAG_ENCRYPT)) == NULL)
{
return 0;
}
memcpy(new_event, GWBUF_DATA(encrypted), event_size);
gwbuf_free(encrypted);
}
break;
case BLRM_START_ENCRYPTION:
new_event_desc = "MARIADB10_START_ENCRYPTION";
MXS_INFO("New event %s is being added in binlog '%s' @ %lu: "
"%lu bytes will be written at pos %lu",
new_event_desc,
router->binlog_name,
router->current_pos,
(unsigned long)event_size,
(unsigned long)file_offset);
/* Create the MARIADB10_START_ENCRYPTION event */
if ((new_event = blr_create_start_encryption_event(router,
file_offset,
router->master_chksum)) == NULL)
{
return 0;
}
break;
default:
new_event_desc = "UNKNOWN";
MXS_ERROR("Cannot create special binlog event of %s type and size %lu "
"in binlog file '%s' @ %lu",
new_event_desc,
(unsigned long)event_size,
router->binlog_name,
router->current_pos);
return 0;
break;
}
/* Write the event */
if ((n = pwrite(router->binlog_fd, new_event, event_size, router->last_written)) != event_size)
{
char err_msg[MXS_STRERROR_BUFLEN];
MXS_ERROR("%s: Failed to write %s special binlog record at %lu of %s, %s. "
"Truncating to previous record.",
router->service->name, new_event_desc, (unsigned long)file_offset,
router->binlog_name,
strerror_r(errno, err_msg, sizeof(err_msg)));
char err_msg[MXS_STRERROR_BUFLEN];
MXS_ERROR("%s: Failed to write %s special binlog record at %lu of %s, %s. "
"Truncating to previous record.",
router->service->name, new_event_desc, (unsigned long)file_offset,
router->binlog_name,
strerror_r(errno, err_msg, sizeof(err_msg)));
/* Remove any partial event that was written */
if (ftruncate(router->binlog_fd, router->binlog_position))
{
MXS_ERROR("%s: Failed to truncate %s special binlog record at %lu of %s, %s. ",
router->service->name, new_event_desc, (unsigned long)file_offset,
router->binlog_name,
strerror_r(errno, err_msg, sizeof(err_msg)));
}
MXS_FREE(new_event);
return 0;
/* Remove any partial event that was written */
if (ftruncate(router->binlog_fd, router->binlog_position))
{
MXS_ERROR("%s: Failed to truncate %s special binlog record at %lu of %s, %s. ",
router->service->name, new_event_desc, (unsigned long)file_offset,
router->binlog_name,
strerror_r(errno, err_msg, sizeof(err_msg)));
}
MXS_FREE(new_event);
return 0;
}
MXS_FREE(new_event);
@ -2688,7 +2705,7 @@ blr_create_start_encryption_event(ROUTER_INSTANCE *router, uint32_t event_pos, b
event_size += BINLOG_EVENT_CRC_SIZE;
}
new_event= MXS_CALLOC(1, event_size);
new_event = MXS_CALLOC(1, event_size);
if (new_event == NULL)
{
return NULL;
@ -2813,11 +2830,11 @@ static GWBUF *blr_aes_crypt(ROUTER_INSTANCE *router,
EVP_CIPHER_CTX_set_padding(&ctx, 0);
/* Encryt/Decrypt the input data */
if(!EVP_CipherUpdate(&ctx,
out_ptr + 4,
&outlen,
buffer,
size))
if (!EVP_CipherUpdate(&ctx,
out_ptr + 4,
&outlen,
buffer,
size))
{
MXS_ERROR("Error in EVP_CipherUpdate");
EVP_CIPHER_CTX_cleanup(&ctx);
@ -2835,8 +2852,8 @@ static GWBUF *blr_aes_crypt(ROUTER_INSTANCE *router,
(out_ptr + 4 + outlen),
(int*)&flen))
{
MXS_ERROR("Error in EVP_CipherFinal_ex");
finale_ret = 0;
MXS_ERROR("Error in EVP_CipherFinal_ex");
finale_ret = 0;
}
}
else
@ -2854,16 +2871,16 @@ static GWBUF *blr_aes_crypt(ROUTER_INSTANCE *router,
router->encryption.key_value,
router->encryption.key_len))
{
MXS_ERROR("Error in blr_aes_create_tail_for_cbc");
finale_ret = 0;
MXS_ERROR("Error in blr_aes_create_tail_for_cbc");
finale_ret = 0;
}
}
}
if (!finale_ret)
{
MXS_FREE(outbuf);
outbuf = NULL;
MXS_FREE(outbuf);
outbuf = NULL;
}
EVP_CIPHER_CTX_cleanup(&ctx);
@ -2919,10 +2936,10 @@ static GWBUF *blr_prepare_encrypted_event(ROUTER_INSTANCE *router,
* 5: Copy saved_event_size 4 bytes into encrypted_data + 9
*/
/* (1): Save event size (buf + 9, 4 bytes) */
memcpy(&event_size, buf + BINLOG_EVENT_LEN_OFFSET, 4);
/* (2): move first 4 bytes of buf to buf + 9 */
memmove(buf + BINLOG_EVENT_LEN_OFFSET, buf, 4);
/* (1): Save event size (buf + 9, 4 bytes) */
memcpy(&event_size, buf + BINLOG_EVENT_LEN_OFFSET, 4);
/* (2): move first 4 bytes of buf to buf + 9 */
memmove(buf + BINLOG_EVENT_LEN_OFFSET, buf, 4);
#ifdef SS_DEBUG
char iv_hex[AES_BLOCK_SIZE * 2 + 1] = "";
@ -2938,30 +2955,30 @@ static GWBUF *blr_prepare_encrypted_event(ROUTER_INSTANCE *router,
(unsigned long)(pos + size));
#endif
/**
* (3): encrypt the event stored in buf starting from (buf + 4):
* with len (event_size - 4)
*
* NOTE: the encrypted_data buffer returned by blr_aes_encrypt() contains:
* (size - 4) encrypted bytes + (4) bytes event size in clear
*
* The encrypted buffer has same size of the original event (size variable)
*/
/**
* (3): encrypt the event stored in buf starting from (buf + 4):
* with len (event_size - 4)
*
* NOTE: the encrypted_data buffer returned by blr_aes_encrypt() contains:
* (size - 4) encrypted bytes + (4) bytes event size in clear
*
* The encrypted buffer has same size of the original event (size variable)
*/
if ((encrypted = blr_aes_crypt(router, buf + 4, size - 4, iv, action)) == NULL)
{
return NULL;
}
if ((encrypted = blr_aes_crypt(router, buf + 4, size - 4, iv, action)) == NULL)
{
return NULL;
}
enc_ptr = GWBUF_DATA(encrypted);
enc_ptr = GWBUF_DATA(encrypted);
/* (4): move encrypted_data + 9 (4 bytes) to encrypted_data[0] */
memmove(enc_ptr, enc_ptr + BINLOG_EVENT_LEN_OFFSET, 4);
/* (4): move encrypted_data + 9 (4 bytes) to encrypted_data[0] */
memmove(enc_ptr, enc_ptr + BINLOG_EVENT_LEN_OFFSET, 4);
/* (5): Copy saved_event_size 4 bytes into encrypted_data + 9 */
memcpy(enc_ptr + BINLOG_EVENT_LEN_OFFSET, &event_size, 4);
/* (5): Copy saved_event_size 4 bytes into encrypted_data + 9 */
memcpy(enc_ptr + BINLOG_EVENT_LEN_OFFSET, &event_size, 4);
return encrypted;
return encrypted;
}
/**
@ -3052,11 +3069,11 @@ static int blr_aes_create_tail_for_cbc(uint8_t *output,
/* Initialise with AES_ECB and NULL iv */
if (!EVP_CipherInit_ex(&t_ctx,
ciphers[BLR_AES_ECB](key_len),
NULL,
key,
NULL, /* NULL iv */
BINLOG_FLAG_ENCRYPT))
ciphers[BLR_AES_ECB](key_len),
NULL,
key,
NULL, /* NULL iv */
BINLOG_FLAG_ENCRYPT))
{
MXS_ERROR("Error in EVP_CipherInit_ex CBC for last block (ECB)");
EVP_CIPHER_CTX_cleanup(&t_ctx);
@ -3113,13 +3130,13 @@ static int blr_binlog_event_check(ROUTER_INSTANCE *router,
{
/* event pos & size checks */
if (hdr->event_size == 0 || ((hdr->next_pos != (pos + hdr->event_size)) &&
(hdr->event_type != ROTATE_EVENT)))
(hdr->event_type != ROTATE_EVENT)))
{
snprintf(errmsg, BINLOG_ERROR_MSG_LEN,
"Client requested master to start replication from invalid "
"position %lu in binlog file '%s'", pos,
binlogname);
return 0;
"Client requested master to start replication from invalid "
"position %lu in binlog file '%s'", pos,
binlogname);
return 0;
}
/* event type checks */
@ -3132,9 +3149,9 @@ static int blr_binlog_event_check(ROUTER_INSTANCE *router,
hdr->event_type, pos, binlogname);
return 0;
}
}
else
{
}
else
{
if (hdr->event_type > MAX_EVENT_TYPE)
{
snprintf(errmsg, BINLOG_ERROR_MSG_LEN,

View File

@ -724,72 +724,72 @@ blr_master_response(ROUTER_INSTANCE *router, GWBUF *buf)
router->master_state = BLRM_REQUEST_BINLOGDUMP;
}
case BLRM_CHECK_SEMISYNC:
{
/**
* This branch could be reached as fallthrough from BLRM_REGISTER
* if request_semi_sync option is false
*/
if (router->master_state == BLRM_CHECK_SEMISYNC)
{
/* Get master semi-sync installed, enabled, disabled */
router->master_semi_sync = blr_get_master_semisync(buf);
{
/**
* This branch could be reached as fallthrough from BLRM_REGISTER
* if request_semi_sync option is false
*/
if (router->master_state == BLRM_CHECK_SEMISYNC)
{
/* Get master semi-sync installed, enabled, disabled */
router->master_semi_sync = blr_get_master_semisync(buf);
/* Discard buffer */
gwbuf_free(buf);
/* Discard buffer */
gwbuf_free(buf);
if (router->master_semi_sync == MASTER_SEMISYNC_NOT_AVAILABLE)
{
/* not installed */
MXS_NOTICE("%s: master server %s:%d doesn't have semi_sync capability",
router->service->name,
router->service->dbref->server->name,
router->service->dbref->server->port);
if (router->master_semi_sync == MASTER_SEMISYNC_NOT_AVAILABLE)
{
/* not installed */
MXS_NOTICE("%s: master server %s:%d doesn't have semi_sync capability",
router->service->name,
router->service->dbref->server->name,
router->service->dbref->server->port);
/* Continue */
router->master_state = BLRM_REQUEST_BINLOGDUMP;
/* Continue */
router->master_state = BLRM_REQUEST_BINLOGDUMP;
}
else
{
if (router->master_semi_sync == MASTER_SEMISYNC_DISABLED)
{
/* Installed but not enabled, right now */
MXS_NOTICE("%s: master server %s:%d doesn't have semi_sync enabled right now, "
"Requesting Semi-Sync Replication",
router->service->name,
router->service->dbref->server->name,
router->service->dbref->server->port);
}
else
{
/* Installed and enabled */
MXS_NOTICE("%s: master server %s:%d has semi_sync enabled, Requesting Semi-Sync Replication",
router->service->name,
router->service->dbref->server->name,
router->service->dbref->server->port);
}
}
else
{
if (router->master_semi_sync == MASTER_SEMISYNC_DISABLED)
{
/* Installed but not enabled, right now */
MXS_NOTICE("%s: master server %s:%d doesn't have semi_sync enabled right now, "
"Requesting Semi-Sync Replication",
router->service->name,
router->service->dbref->server->name,
router->service->dbref->server->port);
}
else
{
/* Installed and enabled */
MXS_NOTICE("%s: master server %s:%d has semi_sync enabled, Requesting Semi-Sync Replication",
router->service->name,
router->service->dbref->server->name,
router->service->dbref->server->port);
}
buf = blr_make_query(router->master, "SET @rpl_semi_sync_slave = 1");
router->master_state = BLRM_REQUEST_SEMISYNC;
router->master->func.write(router->master, buf);
buf = blr_make_query(router->master, "SET @rpl_semi_sync_slave = 1");
router->master_state = BLRM_REQUEST_SEMISYNC;
router->master->func.write(router->master, buf);
break;
break;
}
}
}
}
case BLRM_REQUEST_SEMISYNC:
/**
* This branch could be reached as fallthrough from BLRM_REGISTER or BLRM_CHECK_SEMISYNC
* if request_semi_sync option is false or master doesn't support semisync or it's not enabled
*/
if (router->master_state == BLRM_REQUEST_SEMISYNC)
{
/* discard master reply */
gwbuf_free(buf);
if (router->master_state == BLRM_REQUEST_SEMISYNC)
{
/* discard master reply */
gwbuf_free(buf);
/* Continue */
router->master_state = BLRM_REQUEST_BINLOGDUMP;
}
/* Continue */
router->master_state = BLRM_REQUEST_BINLOGDUMP;
}
case BLRM_REQUEST_BINLOGDUMP:
/**
@ -1361,7 +1361,7 @@ blr_handle_binlog_record(ROUTER_INSTANCE *router, GWBUF *pkt)
var_block_len = ptr[MYSQL_HEADER_LEN + 1 + BINLOG_EVENT_HDR_LEN + 4 + 4 + 1 + 2];
statement_len = len - (MYSQL_HEADER_LEN + 1 + BINLOG_EVENT_HDR_LEN + 4 + 4 + 1 + 2 + 2 \
+ var_block_len + 1 + db_name_len);
+ var_block_len + 1 + db_name_len);
statement_sql = MXS_CALLOC(1, statement_len + 1);
MXS_ABORT_IF_NULL(statement_sql);
memcpy(statement_sql,
@ -2540,11 +2540,16 @@ blr_get_master_semisync(GWBUF *buf)
}
free(key);
if (val) {
if (val)
{
if (strncasecmp(val, "ON", 4) == 0)
{
master_semisync = MASTER_SEMISYNC_ENABLED;
}
else
{
master_semisync = MASTER_SEMISYNC_DISABLED;
}
}
free(val);

View File

@ -203,7 +203,7 @@ blr_slave_request(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue)
slave->stats.n_queries++;
return blr_slave_query(router, slave, queue);
case COM_REGISTER_SLAVE:
case COM_REGISTER_SLAVE:
if (router->master_state == BLRM_UNCONFIGURED)
{
slave->state = BLRS_ERRORED;
@ -242,7 +242,7 @@ blr_slave_request(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue)
return blr_slave_register(router, slave, queue);
}
case COM_BINLOG_DUMP:
case COM_BINLOG_DUMP:
{
char task_name[BLRM_TASK_NAME_LEN + 1] = "";
int rc = 0;
@ -826,8 +826,8 @@ blr_slave_query(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue)
}
else
{
MXS_FREE(query_text);
return blr_slave_send_ok(router, slave);
MXS_FREE(query_text);
return blr_slave_send_ok(router, slave);
}
}
} /* RESET current configured master */
@ -1092,8 +1092,8 @@ blr_slave_query(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue)
MXS_INFO("%s: created new binlog file '%s' by 'CHANGE MASTER TO' command",
router->service->name, router->binlog_name);
}
}
return blr_slave_send_ok(router, slave);
}
return blr_slave_send_ok(router, slave);
}
}
}
@ -1506,7 +1506,8 @@ blr_slave_send_slave_status(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave)
memcpy((char *)ptr, column, col_len); // Result string
ptr += col_len;
snprintf(column, max_column_size, "%s", router->service->dbref->server->name ? router->service->dbref->server->name : "");
snprintf(column, max_column_size, "%s",
router->service->dbref->server->name ? router->service->dbref->server->name : "");
col_len = strlen(column);
*ptr++ = col_len; // Length of result string
memcpy((char *)ptr, column, col_len); // Result string
@ -2384,48 +2385,48 @@ blr_slave_catchup(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, bool large)
*
* Read it if slave->encryption_ctx is NULL and set the slave->encryption_ctx accordingly
*/
spinlock_acquire(&slave->catch_lock);
spinlock_acquire(&slave->catch_lock);
if (hdr.event_type == MARIADB10_START_ENCRYPTION_EVENT && !slave->encryption_ctx)
{
/* read it, set slave & file context */
uint8_t *record_ptr = GWBUF_DATA(record);
SLAVE_ENCRYPTION_CTX *encryption_ctx = MXS_CALLOC(1, sizeof(SLAVE_ENCRYPTION_CTX));
if (hdr.event_type == MARIADB10_START_ENCRYPTION_EVENT && !slave->encryption_ctx)
{
/* read it, set slave & file context */
uint8_t *record_ptr = GWBUF_DATA(record);
SLAVE_ENCRYPTION_CTX *encryption_ctx = MXS_CALLOC(1, sizeof(SLAVE_ENCRYPTION_CTX));
MXS_ABORT_IF_NULL(encryption_ctx);
record_ptr += BINLOG_EVENT_HDR_LEN;
encryption_ctx->binlog_crypto_scheme = record_ptr[0];
memcpy(&encryption_ctx->binlog_key_version, record_ptr + 1, BLRM_KEY_VERSION_LENGTH);
memcpy(encryption_ctx->nonce, record_ptr + 1 + BLRM_KEY_VERSION_LENGTH, BLRM_NONCE_LENGTH);
MXS_ABORT_IF_NULL(encryption_ctx);
record_ptr += BINLOG_EVENT_HDR_LEN;
encryption_ctx->binlog_crypto_scheme = record_ptr[0];
memcpy(&encryption_ctx->binlog_key_version, record_ptr + 1, BLRM_KEY_VERSION_LENGTH);
memcpy(encryption_ctx->nonce, record_ptr + 1 + BLRM_KEY_VERSION_LENGTH, BLRM_NONCE_LENGTH);
/* Save current first_enc_event_pos */
encryption_ctx->first_enc_event_pos = hdr.next_pos;
/* Save current first_enc_event_pos */
encryption_ctx->first_enc_event_pos = hdr.next_pos;
/* set the encryption ctx into slave */
slave->encryption_ctx = encryption_ctx;
/* set the encryption ctx into slave */
slave->encryption_ctx = encryption_ctx;
MXS_INFO("Start Encryption event found while reading. Binlog %s is encrypted. First event at %lu",
slave->binlogfile,
(unsigned long) hdr.next_pos);
}
else
{
MXS_INFO("Found ignorable event [%s] of size %lu while reading binlog %s at %lu",
blr_get_event_description(router, hdr.event_type),
(unsigned long)hdr.event_size,
slave->binlogfile,
(unsigned long) slave->binlog_pos);
}
MXS_INFO("Start Encryption event found while reading. Binlog %s is encrypted. First event at %lu",
slave->binlogfile,
(unsigned long) hdr.next_pos);
}
else
{
MXS_INFO("Found ignorable event [%s] of size %lu while reading binlog %s at %lu",
blr_get_event_description(router, hdr.event_type),
(unsigned long)hdr.event_size,
slave->binlogfile,
(unsigned long) slave->binlog_pos);
}
/* set next pos */
slave->binlog_pos = hdr.next_pos;
/* set next pos */
slave->binlog_pos = hdr.next_pos;
spinlock_release(&slave->catch_lock);
spinlock_release(&slave->catch_lock);
gwbuf_free(record);
record = NULL;
gwbuf_free(record);
record = NULL;
break;
break;
}
if (hdr.event_type == ROTATE_EVENT)
@ -2527,7 +2528,7 @@ blr_slave_catchup(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, bool large)
/**
* End of while reading
* Checking last buffer first
*/
*/
if (record == NULL)
{
slave->stats.n_failed_read++;
@ -3333,7 +3334,8 @@ static int
blr_slave_send_ok(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave)
{
GWBUF *pkt;
uint8_t ok_packet[] = {
uint8_t ok_packet[] =
{
7, 0, 0, // Payload length
1, // Seqno,
0, // OK,
@ -3616,7 +3618,7 @@ blr_start_slave(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave)
}
}
/** Start replication from master */
/** Start replication from master */
blr_start_master(router);
MXS_NOTICE("%s: START SLAVE executed by %s@%s. Trying connection to master %s:%d, "
@ -3726,7 +3728,7 @@ int blr_handle_change_master(ROUTER_INSTANCE* router, char *command, char *error
if ((cmd_string = MXS_STRDUP(cmd_ptr + 2)) == NULL)
{
static const char MESSAGE[] ="error allocating memory for statement parsing";
static const char MESSAGE[] = "error allocating memory for statement parsing";
ss_dassert(sizeof(MESSAGE) <= BINLOG_ERROR_MSG_LEN);
strcpy(error, MESSAGE);
@ -3807,23 +3809,24 @@ int blr_handle_change_master(ROUTER_INSTANCE* router, char *command, char *error
{
if (change_master.ssl_enabled && atoi(change_master.ssl_enabled))
{
snprintf(error, BINLOG_ERROR_MSG_LEN, "MASTER_SSL=1 but some required options are missing: check MASTER_SSL_CERT, MASTER_SSL_KEY, MASTER_SSL_CA");
snprintf(error, BINLOG_ERROR_MSG_LEN,
"MASTER_SSL=1 but some required options are missing: check MASTER_SSL_CERT, MASTER_SSL_KEY, MASTER_SSL_CA");
ssl_error = -1;
}
}
if (ssl_error == -1)
{
MXS_ERROR("%s: %s", router->service->name, error);
MXS_ERROR("%s: %s", router->service->name, error);
/* restore previous master_host and master_port */
blr_master_restore_config(router, current_master);
/* restore previous master_host and master_port */
blr_master_restore_config(router, current_master);
blr_master_free_parsed_options(&change_master);
blr_master_free_parsed_options(&change_master);
spinlock_release(&router->lock);
spinlock_release(&router->lock);
return -1;
return -1;
}
/**
@ -5680,7 +5683,7 @@ blr_escape_config_string(char *input)
}
else
{
if (ptr+1)
if (ptr + 1)
{
ptr++;
}
@ -5814,16 +5817,20 @@ blr_set_master_ssl(ROUTER_INSTANCE *router, CHANGE_MASTER_OPTIONS config, char *
}
if (updated)
{
return 1;
}
else
{
return 0;
}
}
/**
* Notify a waiting slave that new events are stored in binlog file
*
* @param slave Current connected slave
* @return true if slave has been notified
* @return true if slave has been notified
*
*/
bool blr_notify_waiting_slave(ROUTER_SLAVE *slave)

View File

@ -252,7 +252,7 @@ printUsage(const char *progname)
*
* @param inst The current binlog instance
* @param key_file The AES Key filename
* @param aes_algo The AES algorithm
* @param aes_algo The AES algorithm
* @return 1 on failure, 0 on success
*/
static int set_encryption_options(ROUTER_INSTANCE *inst, char *key_file, char *aes_algo)
@ -273,34 +273,34 @@ static int set_encryption_options(ROUTER_INSTANCE *inst, char *key_file, char *a
}
else
{
/* Check aes algorithm */
if (aes_algo)
{
int ret = blr_check_encryption_algorithm(aes_algo);
if (ret > -1)
{
inst->encryption.encryption_algorithm = ret;
}
else
{
MXS_ERROR("Invalid encryption_algorithm '%s'. "
"Supported algorithms: %s",
aes_algo,
blr_encryption_algorithm_list());
return 1;
}
}
else
{
inst->encryption.encryption_algorithm = BINLOG_DEFAULT_ENC_ALGO;
}
/* Check aes algorithm */
if (aes_algo)
{
int ret = blr_check_encryption_algorithm(aes_algo);
if (ret > -1)
{
inst->encryption.encryption_algorithm = ret;
}
else
{
MXS_ERROR("Invalid encryption_algorithm '%s'. "
"Supported algorithms: %s",
aes_algo,
blr_encryption_algorithm_list());
return 1;
}
}
else
{
inst->encryption.encryption_algorithm = BINLOG_DEFAULT_ENC_ALGO;
}
MXS_NOTICE("Decrypting binlog file with algorithm: %s,"
" KEY len %lu bits",
blr_get_encryption_algorithm(inst->encryption.encryption_algorithm),
8 * inst->encryption.key_len);
MXS_NOTICE("Decrypting binlog file with algorithm: %s,"
" KEY len %lu bits",
blr_get_encryption_algorithm(inst->encryption.encryption_algorithm),
8 * inst->encryption.key_len);
return 0;
return 0;
}
}
else

File diff suppressed because it is too large Load Diff