Code review update
Code review update
This commit is contained in:
@ -601,7 +601,14 @@ typedef struct binlog_encryption_ctx
|
|||||||
* BLRM_FDE_EVENT_TYPES_OFFSET is the offset in FDE event content that points to
|
* BLRM_FDE_EVENT_TYPES_OFFSET is the offset in FDE event content that points to
|
||||||
* the number of events the master server supports.
|
* the number of events the master server supports.
|
||||||
*/
|
*/
|
||||||
#define BLRM_FDE_EVENT_TYPES_OFFSET (2 + 50 + 4 + 1)
|
#define BLR_FDE_EVENT_BINLOG_VERSION 2
|
||||||
|
#define BLR_FDE_EVENT_SERVER_VERSION 50
|
||||||
|
#define BLR_FDE_EVENT_BINLOG_TIME 4
|
||||||
|
#define BLR_FDE_EVENT_BINLOG_EVENT_HDR_LEN 1
|
||||||
|
#define BLRM_FDE_EVENT_TYPES_OFFSET (BLR_FDE_EVENT_BINLOG_VERSION + \
|
||||||
|
BLR_FDE_EVENT_SERVER_VERSION + \
|
||||||
|
BLR_FDE_EVENT_BINLOG_TIME + \
|
||||||
|
BLR_FDE_EVENT_BINLOG_EVENT_HDR_LEN)
|
||||||
#define BLRM_CRYPTO_SCHEME_LENGTH 1
|
#define BLRM_CRYPTO_SCHEME_LENGTH 1
|
||||||
#define BLRM_KEY_VERSION_LENGTH 4
|
#define BLRM_KEY_VERSION_LENGTH 4
|
||||||
#define BLRM_IV_LENGTH AES_BLOCK_SIZE
|
#define BLRM_IV_LENGTH AES_BLOCK_SIZE
|
||||||
|
|||||||
@ -2328,16 +2328,7 @@ blr_slave_catchup(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, bool large)
|
|||||||
int events_before = slave->stats.n_events;
|
int events_before = slave->stats.n_events;
|
||||||
|
|
||||||
/* Set file encryption context from slave pointer */
|
/* Set file encryption context from slave pointer */
|
||||||
spinlock_acquire(&slave->catch_lock);
|
|
||||||
if (slave->encryption_ctx)
|
|
||||||
{
|
|
||||||
file->encryption_ctx = slave->encryption_ctx;
|
file->encryption_ctx = slave->encryption_ctx;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
file->encryption_ctx = NULL;
|
|
||||||
}
|
|
||||||
spinlock_release(&slave->catch_lock);
|
|
||||||
|
|
||||||
while (burst-- && burst_size > 0 &&
|
while (burst-- && burst_size > 0 &&
|
||||||
(record = blr_read_binlog(router, file, slave->binlog_pos, &hdr, read_errmsg)) != NULL)
|
(record = blr_read_binlog(router, file, slave->binlog_pos, &hdr, read_errmsg)) != NULL)
|
||||||
@ -5716,7 +5707,6 @@ bool blr_notify_waiting_slave(ROUTER_SLAVE *slave)
|
|||||||
static int
|
static int
|
||||||
blr_slave_read_ste(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, uint32_t fde_end_pos)
|
blr_slave_read_ste(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, uint32_t fde_end_pos)
|
||||||
{
|
{
|
||||||
BLFILE *file;
|
|
||||||
REP_HEADER hdr;
|
REP_HEADER hdr;
|
||||||
GWBUF *record, *head;
|
GWBUF *record, *head;
|
||||||
uint8_t *ptr;
|
uint8_t *ptr;
|
||||||
@ -5727,6 +5717,7 @@ blr_slave_read_ste(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, uint32_t fde_en
|
|||||||
|
|
||||||
memset(&hdr, 0, BINLOG_EVENT_HDR_LEN);
|
memset(&hdr, 0, BINLOG_EVENT_HDR_LEN);
|
||||||
|
|
||||||
|
BLFILE *file;
|
||||||
if ((file = blr_open_binlog(router, slave->binlogfile)) == NULL)
|
if ((file = blr_open_binlog(router, slave->binlogfile)) == NULL)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
@ -5754,10 +5745,16 @@ blr_slave_read_ste(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, uint32_t fde_en
|
|||||||
{
|
{
|
||||||
uint8_t *record_ptr = GWBUF_DATA(record);
|
uint8_t *record_ptr = GWBUF_DATA(record);
|
||||||
SLAVE_ENCRYPTION_CTX *new_encryption_ctx = MXS_CALLOC(1, sizeof(SLAVE_ENCRYPTION_CTX));
|
SLAVE_ENCRYPTION_CTX *new_encryption_ctx = MXS_CALLOC(1, sizeof(SLAVE_ENCRYPTION_CTX));
|
||||||
|
|
||||||
|
if (!new_encryption_ctx)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
record_ptr += BINLOG_EVENT_HDR_LEN;
|
record_ptr += BINLOG_EVENT_HDR_LEN;
|
||||||
new_encryption_ctx->binlog_crypto_scheme = record_ptr[0]; // 1 Byte
|
new_encryption_ctx->binlog_crypto_scheme = record_ptr[0]; // 1 Byte
|
||||||
memcpy(&new_encryption_ctx->binlog_key_version, record_ptr + 1, BLRM_KEY_VERSION_LENGTH);
|
memcpy(&new_encryption_ctx->binlog_key_version, record_ptr + 1, BLRM_KEY_VERSION_LENGTH);
|
||||||
memcpy(new_encryption_ctx->nonce, record_ptr + 1 + BLRM_KEY_VERSION_LENGTH, BLRM_NONCE_LENGTH);
|
memcpy(new_encryption_ctx->nonce, record_ptr + 1 + BLRM_KEY_VERSION_LENGTH, BLRM_NONCE_LENGTH);
|
||||||
|
|
||||||
/* Set the pos of first encrypted event */
|
/* Set the pos of first encrypted event */
|
||||||
new_encryption_ctx->first_enc_event_pos = fde_end_pos + hdr.event_size;
|
new_encryption_ctx->first_enc_event_pos = fde_end_pos + hdr.event_size;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user