From 37dd561470777cd5105799f4354a50076e298e85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Mon, 6 Mar 2017 10:20:45 +0200 Subject: [PATCH] Add support for IPv6 Both the listeners and servers now support IPv6 addresses. The namedserverfilter does not yet use the new structures and needs to be fixed in a following commit. --- include/maxscale/dcb.h | 12 +- include/maxscale/utils.h | 24 +++- server/core/config.c | 1 - server/core/dcb.c | 65 +++++++--- server/core/service.c | 4 +- server/core/utils.c | 114 ++++++------------ .../authenticator/MySQLAuth/mysql_auth.c | 10 +- .../namedserverfilter/namedserverfilter.c | 11 +- .../MySQL/MySQLBackend/mysql_backend.c | 62 +++++----- server/modules/routing/avrorouter/avro.c | 2 +- server/modules/routing/binlogrouter/blr.c | 4 +- .../modules/routing/binlogrouter/blr_master.c | 4 +- .../modules/routing/binlogrouter/blr_slave.c | 24 ++-- 13 files changed, 167 insertions(+), 170 deletions(-) diff --git a/include/maxscale/dcb.h b/include/maxscale/dcb.h index 994508011..a65cf3840 100644 --- a/include/maxscale/dcb.h +++ b/include/maxscale/dcb.h @@ -197,7 +197,7 @@ typedef struct dcb int flags; /**< DCB flags */ char *remote; /**< Address of remote end */ char *user; /**< User name for connection */ - struct sockaddr_in ipv4; /**< remote end IPv4 address */ + struct sockaddr_storage ip; /**< remote IPv4/IPv6 address */ char *protoname; /**< Name of the protocol */ void *protocol; /**< The protocol specific state */ size_t protocol_packet_length; /**< How long the protocol specific packet is */ @@ -240,7 +240,7 @@ typedef struct dcb } DCB; #define DCB_INIT {.dcb_chk_top = CHK_NUM_DCB, \ - .evq = DCBEVENTQ_INIT, .ipv4 = {0}, .func = {0}, .authfunc = {0}, \ + .evq = DCBEVENTQ_INIT, .ip = {0}, .func = {0}, .authfunc = {0}, \ .stats = {0}, .memdata = DCBMM_INIT, \ .fd = DCBFD_CLOSED, .stats = DCBSTATS_INIT, .ssl_state = SSL_HANDSHAKE_UNKNOWN, \ .state = DCB_STATE_ALLOC, .dcb_chk_tail = CHK_NUM_DCB, \ @@ -343,6 +343,14 @@ void dcb_process_idle_sessions(int thr); */ bool dcb_foreach(bool (*func)(DCB *, void *), void *data); +/** + * @brief Return the port number this DCB is connected to + * + * @param dcb DCB to inspect + * @return Port number the DCB is connected to or -1 if information is not available + */ +int dcb_get_port(const DCB *dcb); + /** * DCB flags values */ diff --git a/include/maxscale/utils.h b/include/maxscale/utils.h index 9b9d65070..ca32996ec 100644 --- a/include/maxscale/utils.h +++ b/include/maxscale/utils.h @@ -38,10 +38,28 @@ MXS_BEGIN_DECLS bool utils_init(); /*< Call this first before using any other function */ void utils_end(); -int setnonblocking(int fd); -int parse_bindconfig(const char *, struct sockaddr_in *); -int setipaddress(struct in_addr *, char *); +/** + * Parse the bind configuration data. + * + * The configuration is passed as string in the `address|port` format. + * + * @param config The bind address and port separated by a '|' + * @param addr The sockaddr_in6 in which the data is written + * @return 1 on success, 0 on failure + */ +int parse_bindconfig(const char *, struct sockaddr_in6 *, int *); + +/** + * @brief Create a network socket and a socket configuration + * + * @param dest Pointer to a struct sockaddr_storage where the configuration is stored + * @param host The target host for which the socket is created + * + * @return The opened socket or -1 on failure + */int create_network_socket(struct sockaddr_storage *, char *); + +int setnonblocking(int fd); char *gw_strend(register const char *s); static char gw_randomchar(); int gw_generate_random_str(char *output, int len); diff --git a/server/core/config.c b/server/core/config.c index 433a4734c..932ef3bd2 100644 --- a/server/core/config.c +++ b/server/core/config.c @@ -83,7 +83,6 @@ typedef struct duplicate_context static bool duplicate_context_init(DUPLICATE_CONTEXT* context); static void duplicate_context_finish(DUPLICATE_CONTEXT* context); -extern int setipaddress(struct in_addr *, char *); static bool process_config_context(CONFIG_CONTEXT *); static bool process_config_update(CONFIG_CONTEXT *); static char *config_get_value(MXS_CONFIG_PARAMETER *, const char *); diff --git a/server/core/dcb.c b/server/core/dcb.c index 5c40e8f9d..dd4d20e9f 100644 --- a/server/core/dcb.c +++ b/server/core/dcb.c @@ -2865,25 +2865,30 @@ dcb_accept(DCB *listener) if (client_conn.ss_family == AF_UNIX) { // client address + // Should this be `localhost` like it is in the MariaDB server? client_dcb->remote = MXS_STRDUP_A("localhost_from_socket"); - // set localhost IP for user authentication - (client_dcb->ipv4).sin_addr.s_addr = 0x0100007F; } else { - /* client IPv4 in raw data*/ - memcpy(&client_dcb->ipv4, - (struct sockaddr_in *)&client_conn, - sizeof(struct sockaddr_in)); - /* client IPv4 in string representation */ - client_dcb->remote = (char *)MXS_CALLOC(INET_ADDRSTRLEN + 1, sizeof(char)); + /* client IP in raw data*/ + memcpy(&client_dcb->ip, &client_conn, sizeof(client_conn)); + /* client IP in string representation */ + client_dcb->remote = (char *)MXS_CALLOC(INET6_ADDRSTRLEN + 1, sizeof(char)); - if (client_dcb->remote != NULL) + if (client_dcb->remote) { - inet_ntop(AF_INET, - &(client_dcb->ipv4).sin_addr, - client_dcb->remote, - INET_ADDRSTRLEN); + void *ptr; + if (client_dcb->ip.ss_family == AF_INET) + { + ptr = &((struct sockaddr_in*)&client_dcb->ip)->sin_addr; + } + else + { + ptr = &((struct sockaddr_in6*)&client_dcb->ip)->sin6_addr; + } + + inet_ntop(client_dcb->ip.ss_family, ptr, + client_dcb->remote, INET6_ADDRSTRLEN); } } memcpy(&client_dcb->func, protocol_funcs, sizeof(MXS_PROTOCOL)); @@ -3077,7 +3082,7 @@ dcb_listen(DCB *listener, const char *config, const char *protocol_name) return -1; } - MXS_NOTICE("Listening connections at %s with protocol %s", config, protocol_name); + MXS_NOTICE("Listening for connections at %s with protocol %s", config, protocol_name); // assign listener_socket to dcb listener->fd = listener_socket; @@ -3105,18 +3110,18 @@ static int dcb_listen_create_socket_inet(const char *config_bind) { int listener_socket; - struct sockaddr_in server_address; + struct sockaddr_in6 server_address = {}; int one = 1; + int sock_type = 0; - memset(&server_address, 0, sizeof(server_address)); - if (!parse_bindconfig(config_bind, &server_address)) + if (!parse_bindconfig(config_bind, &server_address, &sock_type)) { MXS_ERROR("Error in parse_bindconfig for [%s]", config_bind); return -1; } /** Create the TCP socket */ - if ((listener_socket = socket(AF_INET, SOCK_STREAM, 0)) < 0) + if ((listener_socket = socket(sock_type, SOCK_STREAM, 0)) < 0) { char errbuf[MXS_STRERROR_BUFLEN]; MXS_ERROR("Can't create socket: %i, %s", @@ -3140,7 +3145,7 @@ dcb_listen_create_socket_inet(const char *config_bind) return -1; } - if (bind(listener_socket, (struct sockaddr *) &server_address, sizeof(server_address)) < 0) + if (bind(listener_socket, (struct sockaddr*)&server_address, sizeof(server_address)) < 0) { char errbuf[MXS_STRERROR_BUFLEN]; MXS_ERROR("Failed to bind on '%s': %i, %s", @@ -3460,3 +3465,25 @@ bool dcb_foreach(bool(*func)(DCB *, void *), void *data) return more; } + +int dcb_get_port(const DCB *dcb) +{ + int rval = -1; + + if (dcb->ip.ss_family == AF_INET) + { + struct sockaddr_in* ip = (struct sockaddr_in*)&dcb->ip; + rval = ntohs(ip->sin_port); + } + else if (dcb->ip.ss_family == AF_INET6) + { + struct sockaddr_in6* ip = (struct sockaddr_in6*)&dcb->ip; + rval = ntohs(ip->sin6_port); + } + else + { + ss_dassert(dcb->ip.ss_family == AF_UNIX); + } + + return rval; +} diff --git a/server/core/service.c b/server/core/service.c index 26e1e71a4..6d3b7a7bf 100644 --- a/server/core/service.c +++ b/server/core/service.c @@ -307,11 +307,11 @@ serviceStartPort(SERVICE *service, SERV_LISTENER *port) if (port->address) { - sprintf(config_bind, "%s:%d", port->address, port->port); + sprintf(config_bind, "%s|%d", port->address, port->port); } else { - sprintf(config_bind, "0.0.0.0:%d", port->port); + sprintf(config_bind, "0.0.0.0|%d", port->port); } /** Load the authentication users before before starting the listener */ diff --git a/server/core/utils.c b/server/core/utils.c index 1c60ca56c..fa3f73ba6 100644 --- a/server/core/utils.c +++ b/server/core/utils.c @@ -895,113 +895,70 @@ void utils_end() SPINLOCK tmplock = SPINLOCK_INIT; -/* - * Set IP address in socket structure in_addr - * - * @param a Pointer to a struct in_addr into which the address is written - * @param p The hostname to lookup - * @return 1 on success, 0 on failure - */ -int -setipaddress(struct in_addr *a, char *p) +int create_network_socket(struct sockaddr_storage *dest, char *host) { #ifdef __USE_POSIX - struct addrinfo *ai = NULL, hint; - int rc; - struct sockaddr_in *res_addr; - memset(&hint, 0, sizeof (hint)); - + struct addrinfo *ai = NULL, hint = {}; + int so, rc; hint.ai_socktype = SOCK_STREAM; + hint.ai_family = AF_UNSPEC; - /* - * This is for the listening socket, matching INADDR_ANY only for now. - * For future specific addresses bind, a dedicated routine woulbd be better - */ - - if (strcmp(p, "0.0.0.0") == 0) + if (strcmp(host, "0.0.0.0") == 0 || strcmp(host, "::") == 0) { + /** All interfaces */ hint.ai_flags = AI_PASSIVE; - hint.ai_family = AF_UNSPEC; - if ((rc = getaddrinfo(p, NULL, &hint, &ai)) != 0) + if ((rc = getaddrinfo(host, NULL, &hint, &ai)) != 0) { MXS_ERROR("Failed to obtain address for host %s, %s", - p, + host, gai_strerror(rc)); - return 0; + return -1; } } else { - hint.ai_flags = AI_CANONNAME; - hint.ai_family = AF_INET; - - if ((rc = getaddrinfo(p, NULL, &hint, &ai)) != 0) + hint.ai_flags = AI_ALL; + if ((rc = getaddrinfo(host, NULL, &hint, &ai)) != 0) { MXS_ERROR("Failed to obtain address for host %s, %s", - p, + host, gai_strerror(rc)); - return 0; + return -1; } } /* take the first one */ if (ai != NULL) { - res_addr = (struct sockaddr_in *)(ai->ai_addr); - memcpy(a, &res_addr->sin_addr, sizeof(struct in_addr)); + so = socket(ai->ai_family, SOCK_STREAM, 0); - freeaddrinfo(ai); - - return 1; - } -#else - struct hostent *h; - - spinlock_acquire(&tmplock); - h = gethostbyname(p); - spinlock_release(&tmplock); - - if (h == NULL) - { - if ((a->s_addr = inet_addr(p)) == -1) + if (so < 0) { - MXS_ERROR("gethostbyname failed for [%s]", p); - - return 0; + char errbuf[MXS_STRERROR_BUFLEN]; + MXS_ERROR("Socket creation failed: %d, %s.", + errno, strerror_r(errno, errbuf, sizeof(errbuf))); + } + else + { + memcpy(dest, ai->ai_addr, ai->ai_addrlen); + freeaddrinfo(ai); } } - else - { - /* take the first one */ - memcpy(a, h->h_addr, h->h_length); - - return 1; - } +#else +#error Only the POSIX networking interface is supported #endif - return 0; + return so; } - -/** - * Parse the bind config data. This is passed in a string as address:port. - * - * The address may be either a . separated IP address or a hostname to - * lookup. The address 0.0.0.0 is the wildcard address for SOCKADR_ANY. - * The ':' and port are required. - * - * @param config The bind address and port separated by a ':' - * @param addr The sockaddr_in in which the data is written - * @return 0 on failure - */ -int -parse_bindconfig(const char *config, struct sockaddr_in *addr) +int parse_bindconfig(const char *config, struct sockaddr_in6 *addr, int *sock_type) { char buf[strlen(config) + 1]; strcpy(buf, config); + *sock_type = strchr(buf, '.') ? AF_INET : AF_INET6; - char *port = strrchr(buf, ':'); + char *port = strrchr(buf, '|'); short pnum; if (port) { @@ -1014,19 +971,20 @@ parse_bindconfig(const char *config, struct sockaddr_in *addr) return 0; } - if (!strcmp(buf, "0.0.0.0")) + if (!strcmp(buf, "0.0.0.0") || !strcmp(buf, "::")) { - addr->sin_addr.s_addr = htonl(INADDR_ANY); + *sock_type = AF_INET6; + addr->sin6_addr = in6addr_any; } else { - if (!inet_aton(buf, &addr->sin_addr)) + if (inet_pton(*sock_type, buf, &addr->sin6_addr) < 1) { struct hostent *hp = gethostbyname(buf); if (hp) { - bcopy(hp->h_addr, &(addr->sin_addr.s_addr), hp->h_length); + inet_pton(*sock_type, hp->h_addr_list[0], &addr->sin6_addr); } else { @@ -1036,8 +994,8 @@ parse_bindconfig(const char *config, struct sockaddr_in *addr) } } - addr->sin_family = AF_INET; - addr->sin_port = htons(pnum); + addr->sin6_family = *sock_type; + addr->sin6_port = htons(pnum); return 1; } diff --git a/server/modules/authenticator/MySQLAuth/mysql_auth.c b/server/modules/authenticator/MySQLAuth/mysql_auth.c index a29487419..41953c377 100644 --- a/server/modules/authenticator/MySQLAuth/mysql_auth.c +++ b/server/modules/authenticator/MySQLAuth/mysql_auth.c @@ -325,15 +325,7 @@ mysql_auth_authenticate(DCB *dcb) else if (dcb->service->log_auth_warnings) { MXS_WARNING("%s: login attempt for user '%s'@%s:%d, authentication failed.", - dcb->service->name, client_data->user, dcb->remote, ntohs(dcb->ipv4.sin_port)); - if (dcb->ipv4.sin_addr.s_addr == 0x0100007F && - !dcb->service->localhost_match_wildcard_host) - { - MXS_NOTICE("If you have a wildcard grant that covers" - " this address, try adding " - "'localhost_match_wildcard_host=true' for " - "service '%s'. ", dcb->service->name); - } + dcb->service->name, client_data->user, dcb->remote, dcb_get_port(dcb)); } /* let's free the auth_token now */ diff --git a/server/modules/filter/namedserverfilter/namedserverfilter.c b/server/modules/filter/namedserverfilter/namedserverfilter.c index 6d2f6e864..46be8e27f 100644 --- a/server/modules/filter/namedserverfilter/namedserverfilter.c +++ b/server/modules/filter/namedserverfilter/namedserverfilter.c @@ -74,7 +74,7 @@ typedef struct static bool validate_ip_address(const char *); static int check_source_host(REGEXHINT_INSTANCE *, const char *, - const struct sockaddr_in *); + const struct sockaddr_storage *); static REGEXHINT_SOURCE_HOST *set_source_address(const char *); static void free_instance(REGEXHINT_INSTANCE *); @@ -237,7 +237,7 @@ newSession(MXS_FILTER *instance, MXS_SESSION *session) { my_session->active = check_source_host(my_instance, remote, - &session->client_dcb->ipv4); + &session->client_dcb->ip); } /* Check client user against 'user' option */ @@ -446,12 +446,12 @@ static bool validate_ip_address(const char *host) */ static int check_source_host(REGEXHINT_INSTANCE *instance, const char *remote, - const struct sockaddr_in *ipv4) + const struct sockaddr_storage *ip) { int ret = 0; struct sockaddr_in check_ipv4; - memcpy(&check_ipv4, ipv4, sizeof(check_ipv4)); + memcpy(&check_ipv4, ip, sizeof(check_ipv4)); switch (instance->source->netmask) { @@ -562,7 +562,8 @@ static REGEXHINT_SOURCE_HOST *set_source_address(const char *input_host) source_host->netmask = netmask; /* fill IPv4 data struct */ - if (setipaddress(&source_host->ipv4.sin_addr, format_host) && strlen(format_host)) + //TODO: Fix this + if (false /* setipaddress(&source_host->ipv4.sin_addr, format_host) && strlen(format_host)*/) { /* if netmask < 32 there are % wildcards */ diff --git a/server/modules/protocol/MySQL/MySQLBackend/mysql_backend.c b/server/modules/protocol/MySQL/MySQLBackend/mysql_backend.c index bedd8eb0e..907156ec9 100644 --- a/server/modules/protocol/MySQL/MySQLBackend/mysql_backend.c +++ b/server/modules/protocol/MySQL/MySQLBackend/mysql_backend.c @@ -271,34 +271,35 @@ return_fd: * backend server. In failure, fd == -1 and socket is closed. * */ -static int -gw_do_connect_to_backend(char *host, int port, int *fd) +static int gw_do_connect_to_backend(char *host, int port, int *fd) { - struct sockaddr_in serv_addr; - int rv; - int so = 0; + struct sockaddr_storage serv_addr = {}; + int rv = -1; int bufsize; - memset(&serv_addr, 0, sizeof serv_addr); - serv_addr.sin_family = (int)AF_INET; - so = socket((int)AF_INET, (int)SOCK_STREAM, 0); + /* prepare for connect */ + int so = create_network_socket(&serv_addr, host); if (so < 0) { char errbuf[MXS_STRERROR_BUFLEN]; - MXS_ERROR("Establishing connection to backend server " - "%s:%d failed.\n\t\t Socket creation failed " - "due %d, %s.", - host, - port, - errno, - strerror_r(errno, errbuf, sizeof(errbuf))); - rv = -1; - goto return_rv; + MXS_ERROR("Establishing connection to backend server %s:%d failed.", host, port); + return rv; } - /* prepare for connect */ - setipaddress(&serv_addr.sin_addr, host); - serv_addr.sin_port = htons(port); + + /** Configure the destination port */ + if (serv_addr.ss_family == AF_INET) + { + struct sockaddr_in *ip = (struct sockaddr_in*)&serv_addr; + ip->sin_port = htons(port); + } + else + { + ss_dassert(serv_addr.ss_family == AF_INET6); + struct sockaddr_in6 *ip = (struct sockaddr_in6*)&serv_addr; + ip->sin6_port = htons(port); + } + bufsize = MXS_BACKEND_SO_SNDBUF; if (setsockopt(so, SOL_SOCKET, SO_SNDBUF, &bufsize, sizeof(bufsize)) != 0) @@ -311,10 +312,9 @@ gw_do_connect_to_backend(char *host, int port, int *fd) port, errno, strerror_r(errno, errbuf, sizeof(errbuf))); - rv = -1; /** Close socket */ close_socket(so); - goto return_rv; + return rv; } bufsize = MXS_BACKEND_SO_RCVBUF; @@ -328,10 +328,9 @@ gw_do_connect_to_backend(char *host, int port, int *fd) port, errno, strerror_r(errno, errbuf, sizeof(errbuf))); - rv = -1; /** Close socket */ close_socket(so); - goto return_rv; + return rv; } int one = 1; @@ -345,10 +344,9 @@ gw_do_connect_to_backend(char *host, int port, int *fd) port, errno, strerror_r(errno, errbuf, sizeof(errbuf))); - rv = -1; /** Close socket */ close_socket(so); - goto return_rv; + return rv; } /* set socket to as non-blocking here */ @@ -364,23 +362,19 @@ gw_do_connect_to_backend(char *host, int port, int *fd) else { char errbuf[MXS_STRERROR_BUFLEN]; - MXS_ERROR("Failed to connect backend server %s:%d, " - "due %d, %s.", - host, - port, - errno, - strerror_r(errno, errbuf, sizeof(errbuf))); + MXS_ERROR("Failed to connect backend server %s:%d due to: %d, %s.", + host, port, errno, strerror_r(errno, errbuf, sizeof(errbuf))); /** Close socket */ close_socket(so); - goto return_rv; + return rv; } } + *fd = so; MXS_DEBUG("%lu [gw_do_connect_to_backend] Connected to backend server " "%s:%d, fd %d.", pthread_self(), host, port, so); -return_rv: return rv; } diff --git a/server/modules/routing/avrorouter/avro.c b/server/modules/routing/avrorouter/avro.c index f9ca49f74..20cc5a9b1 100644 --- a/server/modules/routing/avrorouter/avro.c +++ b/server/modules/routing/avrorouter/avro.c @@ -893,7 +893,7 @@ diagnostics(MXS_ROUTER *router, DCB *dcb) dcb_printf(dcb, "\t\tClient UUID: %s\n", session->uuid); dcb_printf(dcb, "\t\tClient_host_port: %s:%d\n", - session->dcb->remote, ntohs((session->dcb->ipv4).sin_port)); + session->dcb->remote, dcb_get_port(session->dcb)); dcb_printf(dcb, "\t\tUsername: %s\n", session->dcb->user); dcb_printf(dcb, "\t\tClient DCB: %p\n", session->dcb); dcb_printf(dcb, "\t\tClient protocol: %s\n", diff --git a/server/modules/routing/binlogrouter/blr.c b/server/modules/routing/binlogrouter/blr.c index 67d3ef9bb..ab6ea16b0 100644 --- a/server/modules/routing/binlogrouter/blr.c +++ b/server/modules/routing/binlogrouter/blr.c @@ -1132,7 +1132,7 @@ closeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session) MXS_NOTICE("%s: Slave %s:%d, server id %d, disconnected after %ld seconds. " "%d SQL commands, %d events sent (%lu bytes), binlog '%s', " "last position %lu", - router->service->name, slave->dcb->remote, ntohs((slave->dcb->ipv4).sin_port), + router->service->name, slave->dcb->remote, dcb_get_port(slave->dcb), slave->serverid, time(0) - slave->connect_time, slave->stats.n_queries, @@ -1533,7 +1533,7 @@ diagnostics(MXS_ROUTER *router, DCB *dcb) } dcb_printf(dcb, "\t\tSlave_host_port: %s:%d\n", - session->dcb->remote, ntohs((session->dcb->ipv4).sin_port)); + session->dcb->remote, dcb_get_port(session->dcb)); dcb_printf(dcb, "\t\tUsername: %s\n", session->dcb->user); diff --git a/server/modules/routing/binlogrouter/blr_master.c b/server/modules/routing/binlogrouter/blr_master.c index 7febbfd24..65aa0e5cb 100644 --- a/server/modules/routing/binlogrouter/blr_master.c +++ b/server/modules/routing/binlogrouter/blr_master.c @@ -2347,7 +2347,7 @@ bool blr_send_event(blr_thread_role_t role, "the event has already been sent by thread %lu in the role of %s. " "%u bytes buffered for writing in DCB %p. %lu events received from master.", slave->dcb->remote, - ntohs((slave->dcb->ipv4).sin_port), + dcb_get_port(slave->dcb), slave->serverid, binlog_name, binlog_pos, @@ -2410,7 +2410,7 @@ bool blr_send_event(blr_thread_role_t role, { MXS_ERROR("Failed to send an event of %u bytes to slave at %s:%d.", hdr->event_size, slave->dcb->remote, - ntohs(slave->dcb->ipv4.sin_port)); + dcb_get_port(slave->dcb)); } return rval; } diff --git a/server/modules/routing/binlogrouter/blr_slave.c b/server/modules/routing/binlogrouter/blr_slave.c index 24a210cb5..696cf557c 100644 --- a/server/modules/routing/binlogrouter/blr_slave.c +++ b/server/modules/routing/binlogrouter/blr_slave.c @@ -2055,7 +2055,7 @@ blr_slave_binlog_dump(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue "Latest safe position %lu, end of binlog file %lu", router->service->name, slave->dcb->remote, - ntohs((slave->dcb->ipv4).sin_port), + dcb_get_port(slave->dcb), slave->serverid, slave->binlogfile, (unsigned long)slave->binlog_pos, @@ -2176,7 +2176,7 @@ blr_slave_binlog_dump(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue MXS_NOTICE("%s: Slave %s:%d, server id %d requested binlog file %s from position %lu", router->service->name, slave->dcb->remote, - ntohs((slave->dcb->ipv4).sin_port), + dcb_get_port(slave->dcb), slave->serverid, slave->binlogfile, (unsigned long)slave->binlog_pos); @@ -2340,7 +2340,7 @@ blr_slave_catchup(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, bool large) } MXS_ERROR("Slave %s:%i, server-id %d, binlog '%s': blr_slave_catchup " "failed to open binlog file", - slave->dcb->remote, ntohs((slave->dcb->ipv4).sin_port), slave->serverid, + slave->dcb->remote, dcb_get_port(slave->dcb), slave->serverid, slave->binlogfile); slave->cstate &= ~CS_BUSY; @@ -2464,7 +2464,7 @@ blr_slave_catchup(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, bool large) MXS_ERROR("Slave %s:%i, server-id %d, binlog '%s': blr_slave_catchup " "failed to open binlog file in rotate event", slave->dcb->remote, - ntohs((slave->dcb->ipv4).sin_port), + dcb_get_port(slave->dcb), slave->serverid, slave->binlogfile); @@ -2503,7 +2503,7 @@ blr_slave_catchup(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, bool large) MXS_WARNING("Slave %s:%i, server-id %d, binlog '%s, position %u: " "Slave-thread could not send event to slave, closing connection.", slave->dcb->remote, - ntohs((slave->dcb->ipv4).sin_port), + dcb_get_port(slave->dcb), slave->serverid, binlog_name, binlog_pos); @@ -2538,7 +2538,7 @@ blr_slave_catchup(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, bool large) MXS_ERROR("%s Slave %s:%i, server-id %d, binlog '%s', %s", router->service->name, slave->dcb->remote, - ntohs((slave->dcb->ipv4).sin_port), + dcb_get_port(slave->dcb), slave->serverid, slave->binlogfile, read_errmsg); @@ -2549,7 +2549,7 @@ blr_slave_catchup(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, bool large) MXS_ERROR("%s Slave %s:%i, server-id %d, binlog '%s', %s", router->service->name, slave->dcb->remote, - ntohs((slave->dcb->ipv4).sin_port), + dcb_get_port(slave->dcb), slave->serverid, slave->binlogfile, read_errmsg); @@ -2571,7 +2571,7 @@ blr_slave_catchup(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, bool large) MXS_ERROR("%s Slave %s:%i, server-id %d, binlog '%s', %s", router->service->name, slave->dcb->remote, - ntohs((slave->dcb->ipv4).sin_port), + dcb_get_port(slave->dcb), slave->serverid, slave->binlogfile, read_errmsg); @@ -2601,7 +2601,7 @@ blr_slave_catchup(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, bool large) "current committed transaction event being sent: %lu, %s", router->service->name, slave->dcb->remote, - ntohs((slave->dcb->ipv4).sin_port), + dcb_get_port(slave->dcb), slave->serverid, slave->binlogfile, slave->stats.n_events - events_before, @@ -2676,7 +2676,7 @@ blr_slave_catchup(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, bool large) "previous failure of the master.", router->service->name, slave->dcb->remote, - ntohs((slave->dcb->ipv4).sin_port), + dcb_get_port(slave->dcb), slave->serverid, slave->binlogfile, (unsigned long)slave->binlog_pos, router->binlog_name, router->binlog_position); @@ -2921,7 +2921,7 @@ blr_slave_read_fde(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave) { MXS_ERROR("Slave %s:%i, server-id %d, binlog '%s', blr_read_binlog failure: %s", slave->dcb->remote, - ntohs((slave->dcb->ipv4).sin_port), + dcb_get_port(slave->dcb), slave->serverid, slave->binlogfile, err_msg); @@ -5882,7 +5882,7 @@ blr_slave_read_ste(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, uint32_t fde_en { MXS_ERROR("Slave %s:%i, server-id %d, binlog '%s', blr_read_binlog failure: %s", slave->dcb->remote, - ntohs((slave->dcb->ipv4).sin_port), + dcb_get_port(slave->dcb), slave->serverid, slave->binlogfile, err_msg);