Skip to content

Commit 8ee5668

Browse files
author
Nirbhay Choubey
committed
Changes in wsrep_guess_ip()
* Changed loopback detection to be done via ifa->ifa_flags * Removed unused function wsrep_guess_address()
1 parent af651c8 commit 8ee5668

File tree

4 files changed

+13
-21
lines changed

4 files changed

+13
-21
lines changed

mysql-test/suite/galera/suite.pm

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ return "No my_print_defaults" unless $epath;
2424

2525
push @::global_suppressions,
2626
(
27-
qr(WSREP: Failed to guess base node address),
28-
qr(WSREP: Guessing address for incoming client connections failed),
2927
qr(WSREP: wsrep_sst_receive_address is set to '127.0.0.1),
3028
qr(WSREP: Could not open saved state file for reading: ),
3129
qr(WSREP: Gap in state sequence. Need state transfer.),

mysql-test/suite/wsrep/suite.pm

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ return "No my_print_defaults" unless $epath;
2424

2525
push @::global_suppressions,
2626
(
27-
qr(WSREP: Failed to guess base node address),
28-
qr(WSREP: Guessing address for incoming client connections failed),
2927
qr(WSREP: Could not open saved state file for reading: ),
3028
qr(WSREP: option --wsrep-casual-reads is deprecated),
3129
qr(WSREP: --wsrep-casual-reads=ON takes precedence over --wsrep-sync-wait=0),

sql/wsrep_utils.cc

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@
3535
#include <netdb.h> // getaddrinfo()
3636

3737
#ifdef HAVE_GETIFADDRS
38+
#include <net/if.h>
3839
#include <ifaddrs.h>
39-
#endif
40+
#endif /* HAVE_GETIFADDRS */
4041

4142
extern char** environ; // environment variables
4243

@@ -406,6 +407,13 @@ size_t wsrep_guess_ip (char* buf, size_t buf_len)
406407
return ip_len;
407408
}
408409

410+
/*
411+
getifaddrs() is avaiable at least on Linux since glib 2.3, FreeBSD,
412+
MAC OSX, OpenSolaris, Solaris.
413+
414+
On platforms which do not support getifaddrs() this function returns
415+
a failure and user is prompted to do manual configuration.
416+
*/
409417
#if HAVE_GETIFADDRS
410418
struct ifaddrs *ifaddr, *ifa;
411419
if (getifaddrs(&ifaddr) == 0)
@@ -415,34 +423,23 @@ size_t wsrep_guess_ip (char* buf, size_t buf_len)
415423
if (!ifa->ifa_addr || ifa->ifa_addr->sa_family != AF_INET) // TODO AF_INET6
416424
continue;
417425

418-
if (vio_getnameinfo(ifa->ifa_addr, buf, buf_len, NULL, 0, NI_NUMERICHOST))
426+
// Skip loopback interfaces (like lo:127.0.0.1)
427+
if (ifa->ifa_flags & IFF_LOOPBACK)
419428
continue;
420429

421-
if (strcmp(buf, "127.0.0.1") == 0) // lame
430+
if (vio_getnameinfo(ifa->ifa_addr, buf, buf_len, NULL, 0, NI_NUMERICHOST))
422431
continue;
423432

424433
freeifaddrs(ifaddr);
425434
return strlen(buf);
426435
}
427436
freeifaddrs(ifaddr);
428437
}
429-
#endif
438+
#endif /* HAVE_GETIFADDRS */
430439

431440
return 0;
432441
}
433442

434-
size_t wsrep_guess_address(char* buf, size_t buf_len)
435-
{
436-
size_t addr_len = wsrep_guess_ip (buf, buf_len);
437-
438-
if (addr_len && addr_len < buf_len) {
439-
addr_len += snprintf (buf + addr_len, buf_len - addr_len,
440-
":%u", mysqld_port);
441-
}
442-
443-
return addr_len;
444-
}
445-
446443
/*
447444
* WSREPXid
448445
*/

sql/wsrep_utils.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
unsigned int wsrep_check_ip (const char* addr);
2222
size_t wsrep_guess_ip (char* buf, size_t buf_len);
23-
size_t wsrep_guess_address(char* buf, size_t buf_len);
2423

2524
namespace wsp {
2625
class node_status

0 commit comments

Comments
 (0)