Skip to content

Commit

Permalink
WL#11652 Support multiple addresses for the --bind-address command op…
Browse files Browse the repository at this point in the history
…tion

This worklog adds support for binding a server to several IP addresses.
To specify several addresses for listening incoming connection requests,
the command line option --bind-address was extended to support comma
separated list of IP addresses to bind. For every specified IP address
a separate TCP socket is created and added to a list of sockets for
listening incoming TCP connections.
  • Loading branch information
Dmitry Shulga committed Jun 21, 2018
1 parent 9318d51 commit b72b101
Show file tree
Hide file tree
Showing 9 changed files with 435 additions and 33 deletions.
79 changes: 79 additions & 0 deletions mysql-test/r/multiaddress_bind.result
@@ -0,0 +1,79 @@
#
# WL#11652 -- Support multiple addresses for the --bind-address command option
#
#
# Server is started with --bind-address=127.0.0.1,::1
# Check that server accepts incoming connection both
# on the address 127.0.0.1 and on the address ::1
#
# Connecting to a server via 127.0.0.1
# Connecting to a server via ::1
SELECT @@global.bind_address;
@@global.bind_address
127.0.0.1,::1
# Stop DB server which was created by MTR default
#
# Starting mysqld in the regular mode...
#
# restart: --bind-address=127.0.0.1
SELECT @@global.bind_address;
@@global.bind_address
127.0.0.1
# Stop DB server which was created by MTR default
#
# Starting mysqld in the regular mode...
#
# restart: --bind-address=*
SELECT @@global.bind_address;
@@global.bind_address
*
# Stop DB server which was created by MTR default
#
# Starting mysqld in the regular mode...
#
# restart: --bind-address=::
SELECT @@global.bind_address;
@@global.bind_address
::
# Stop DB server which was created by MTR default
# Check seperators not being ','.
# Check that specially treated value :: is not allowed as part of
# multi-value option bind-address.
Pattern "Invalid value for command line option bind-addresses:" found
# Check that specially treated value * is not allowed as part of
# multi-value option bind-address.
Pattern "Invalid value for command line option bind-addresses:" found
# Check that server catches a parsing error during processing of
# multi-value option bind-address.
# Two adjacent commas in a value of the option --bind-address is treated
# as an error.
Pattern "Invalid value for command line option bind-addresses:" found
# Check that a server catches a parsing error during processing of
# multi-value option bind-address.
# Comma in the end of a value of the option --bind-address is treated
# as an error.
Pattern "Invalid value for command line option bind-addresses:" found
# Check that a server catches a parsing error during processing of
# multi-value option bind-address.
# Comma in the begining of a value of the option --bind-address
# is treated as an error.
Pattern "Invalid value for command line option bind-addresses:" found
# Check that a server catches a parsing error during processing of
# multi-value option bind-address.
# empty value of the option --bind-address
# is treated as an error.
Pattern "Invalid value for command line option bind-addresses:" found
# Check that a server catches a parsing error during processing of
# multi-value option bind-address.
# Check that specially treated ipv4 address 0.0.0.0 is not allowed
# as part of multi-value option bind-address.
Pattern "Invalid value for command line option bind-addresses:" found
# Check that a server catches a parsing error during processing of
# multi-value option bind-address.
# empty value of the option --bind-address
# is treated as an error.
Pattern "Invalid value for command line option bind-addresses:" found
#
# Starting mysqld in the regular mode...
#
# restart
14 changes: 14 additions & 0 deletions mysql-test/r/multiaddress_bind_not_win.result
@@ -0,0 +1,14 @@
#
# WL#11652 -- Support multiple addresses for the --bind-address command option
#
# Stop DB server which was created by MTR default
# Check that not existing IP address as a value of
# the option --bind-address is treated as an error.
Pattern "Bind on TCP/IP port: Can't assign requested address" found
# Check that not existing IP address as one of a value of
# the option --bind-address is treated as an error.
Pattern "Bind on TCP/IP port: Can't assign requested address" found
#
# Starting mysqld in the regular mode...
#
# restart
2 changes: 2 additions & 0 deletions mysql-test/t/multiaddress_bind-master.opt
@@ -0,0 +1,2 @@
--bind-address=127.0.0.1,::1

182 changes: 182 additions & 0 deletions mysql-test/t/multiaddress_bind.test
@@ -0,0 +1,182 @@
--echo #
--echo # WL#11652 -- Support multiple addresses for the --bind-address command option
--echo #

--source include/check_ipv6.inc

--let $MYSQLD_LOG= $MYSQL_TMP_DIR/server.log
--let $MYSQLD_DATADIR= `SELECT @@datadir`

--echo #
--echo # Server is started with --bind-address=127.0.0.1,::1
--echo # Check that server accepts incoming connection both
--echo # on the address 127.0.0.1 and on the address ::1
--echo #
--echo # Connecting to a server via 127.0.0.1
--connect(con1,127.0.0.1,root,,,,,TCP)

--echo # Connecting to a server via ::1
--connect(con2,::1,root,,,,,TCP)

--connection con1
--disconnect con1

--connection con2
--disconnect con2

--connection default
SELECT @@global.bind_address;

--echo # Stop DB server which was created by MTR default
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--source include/shutdown_mysqld.inc

--echo #
--echo # Starting mysqld in the regular mode...
--echo #
--let $restart_parameters =restart: --bind-address=127.0.0.1
--source include/start_mysqld.inc
SELECT @@global.bind_address;

--echo # Stop DB server which was created by MTR default
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--source include/shutdown_mysqld.inc

--echo #
--echo # Starting mysqld in the regular mode...
--echo #
--let $restart_parameters =restart: --bind-address=*
--source include/start_mysqld.inc
SELECT @@global.bind_address;

--echo # Stop DB server which was created by MTR default
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--source include/shutdown_mysqld.inc

--echo #
--echo # Starting mysqld in the regular mode...
--echo #
--let $restart_parameters =restart: --bind-address=::
--source include/start_mysqld.inc
SELECT @@global.bind_address;

--echo # Stop DB server which was created by MTR default
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--source include/shutdown_mysqld.inc

--echo # Check seperators not being ','.
--error 1
--exec $MYSQLD --log-error=$MYSQLD_LOG --datadir=$MYSQLD_DATADIR --no-defaults --secure-file-priv="" --bind-address=127.0.0.1 ::1

--let SEARCH_FILE=$MYSQLD_LOG
--let SEARCH_PATTERN= Invalid value for command line option bind-addresses:

--remove_file $MYSQLD_LOG

--echo # Check that specially treated value :: is not allowed as part of
--echo # multi-value option bind-address.
--error 1
--exec $MYSQLD --log-error=$MYSQLD_LOG --datadir=$MYSQLD_DATADIR --no-defaults --secure-file-priv="" --bind-address=127.0.0.1,::1,::

--let SEARCH_FILE=$MYSQLD_LOG
--let SEARCH_PATTERN= Invalid value for command line option bind-addresses:
--source include/search_pattern.inc

--remove_file $MYSQLD_LOG

--echo # Check that specially treated value * is not allowed as part of
--echo # multi-value option bind-address.
--error 1
--exec $MYSQLD --log-error=$MYSQLD_LOG --datadir=$MYSQLD_DATADIR --no-defaults --secure-file-priv="" --bind-address=127.0.0.1,::1,*

--let SEARCH_FILE=$MYSQLD_LOG
--let SEARCH_PATTERN= Invalid value for command line option bind-addresses:
--source include/search_pattern.inc

--remove_file $MYSQLD_LOG

--echo # Check that server catches a parsing error during processing of
--echo # multi-value option bind-address.
--echo # Two adjacent commas in a value of the option --bind-address is treated
--echo # as an error.
--error 1
--exec $MYSQLD --log-error=$MYSQLD_LOG --datadir=$MYSQLD_DATADIR --no-defaults --secure-file-priv="" --bind-address=127.0.0.1,,::1

--let SEARCH_FILE=$MYSQLD_LOG
--let SEARCH_PATTERN= Invalid value for command line option bind-addresses:
--source include/search_pattern.inc

--remove_file $MYSQLD_LOG

--echo # Check that a server catches a parsing error during processing of
--echo # multi-value option bind-address.
--echo # Comma in the end of a value of the option --bind-address is treated
--echo # as an error.
--error 1
--exec $MYSQLD --log-error=$MYSQLD_LOG --datadir=$MYSQLD_DATADIR --no-defaults --secure-file-priv="" --bind-address=127.0.0.1,::1,

--let SEARCH_FILE=$MYSQLD_LOG
--let SEARCH_PATTERN= Invalid value for command line option bind-addresses:
--source include/search_pattern.inc

--remove_file $MYSQLD_LOG

--echo # Check that a server catches a parsing error during processing of
--echo # multi-value option bind-address.
--echo # Comma in the begining of a value of the option --bind-address
--echo # is treated as an error.
--error 1
--exec $MYSQLD --log-error=$MYSQLD_LOG --datadir=$MYSQLD_DATADIR --no-defaults --secure-file-priv="" --bind-address=,127.0.0.1,::1

--let SEARCH_FILE=$MYSQLD_LOG
--let SEARCH_PATTERN= Invalid value for command line option bind-addresses:
--source include/search_pattern.inc

--remove_file $MYSQLD_LOG

--echo # Check that a server catches a parsing error during processing of
--echo # multi-value option bind-address.
--echo # empty value of the option --bind-address
--echo # is treated as an error.
--error 1
--exec $MYSQLD --log-error=$MYSQLD_LOG --datadir=$MYSQLD_DATADIR --no-defaults --secure-file-priv="" --bind-address=

--let SEARCH_FILE=$MYSQLD_LOG
--let SEARCH_PATTERN= Invalid value for command line option bind-addresses:
--source include/search_pattern.inc

--remove_file $MYSQLD_LOG

--echo # Check that a server catches a parsing error during processing of
--echo # multi-value option bind-address.

--echo # Check that specially treated ipv4 address 0.0.0.0 is not allowed
--echo # as part of multi-value option bind-address.
--error 1
--exec $MYSQLD --log-error=$MYSQLD_LOG --datadir=$MYSQLD_DATADIR --no-defaults --secure-file-priv="" --bind-address=0.0.0.0,::1

--let SEARCH_FILE=$MYSQLD_LOG
--let SEARCH_PATTERN= Invalid value for command line option bind-addresses:
--source include/search_pattern.inc

--remove_file $MYSQLD_LOG

--echo # Check that a server catches a parsing error during processing of
--echo # multi-value option bind-address.
--echo # empty value of the option --bind-address
--echo # is treated as an error.
--error 1
--exec $MYSQLD --log-error=$MYSQLD_LOG --datadir=$MYSQLD_DATADIR --no-defaults --secure-file-priv="" --bind-address=

--let SEARCH_FILE=$MYSQLD_LOG
--let SEARCH_PATTERN= Invalid value for command line option bind-addresses:
--source include/search_pattern.inc

--remove_file $MYSQLD_LOG

--echo #
--echo # Starting mysqld in the regular mode...
--echo #
--let $restart_parameters =

--source include/start_mysqld.inc
42 changes: 42 additions & 0 deletions mysql-test/t/multiaddress_bind_not_win.test
@@ -0,0 +1,42 @@
--echo #
--echo # WL#11652 -- Support multiple addresses for the --bind-address command option
--echo #

--source include/check_ipv6.inc
--source include/not_windows.inc

--let $MYSQLD_LOG= $MYSQL_TMP_DIR/server.log
--let $MYSQLD_DATADIR= `SELECT @@datadir`

--echo # Stop DB server which was created by MTR default
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--source include/shutdown_mysqld.inc

--echo # Check that not existing IP address as a value of
--echo # the option --bind-address is treated as an error.
--error 1
--exec $MYSQLD --log-error=$MYSQLD_LOG --datadir=$MYSQLD_DATADIR --no-defaults --secure-file-priv="" --bind-address=128.0.0.1

--let SEARCH_FILE=$MYSQLD_LOG
--let SEARCH_PATTERN= Bind on TCP/IP port: Can't assign requested address
--source include/search_pattern.inc

--remove_file $MYSQLD_LOG

--echo # Check that not existing IP address as one of a value of
--echo # the option --bind-address is treated as an error.
--error 1
--exec $MYSQLD --log-error=$MYSQLD_LOG --datadir=$MYSQLD_DATADIR --no-defaults --secure-file-priv="" --bind-address=128.0.0.1,::1

--let SEARCH_FILE=$MYSQLD_LOG
--let SEARCH_PATTERN= Bind on TCP/IP port: Can't assign requested address
--source include/search_pattern.inc

--remove_file $MYSQLD_LOG

--echo #
--echo # Starting mysqld in the regular mode...
--echo #
--let $restart_parameters =

--source include/start_mysqld.inc
3 changes: 3 additions & 0 deletions share/errmsg-utf8.txt
Expand Up @@ -18179,6 +18179,9 @@ ER_IB_MSG_1284
ER_CANT_SET_ERROR_SUPPRESSION_LIST_FROM_COMMAND_LINE
eng "%s: Could not add suppression rule for code \"%s\". Rule-set may be full, or code may not correspond to an error-log message."

ER_INVALID_VALUE_OF_BIND_ADDRESSES
eng "Invalid value for command line option bind-addresses: '%s'"

#
# End of 8.0 Server error messages.
# (Please read comments from the header of this section before adding error
Expand Down

0 comments on commit b72b101

Please sign in to comment.