# WL#12720 Add support for network namespaces on setting up listening sockets # Network namespaces is a feature of Linux. # So, ignore this test on any platform except Linux. --source include/linux.inc # This test relies on the fact that environment was configured # to support the network namespace. Namely, the network namespace named 'red' # must be set up on every linux host involved into pushbuild infrastructure. # The network interface in the namespace 'red' must be assigned IP address 10.0.2.1 # and routing between the IP address 10.0.2.1 from the network namespace 'red' # and IP addresses from the root (default) network namespace must be configured. # Until it be done on every linux host inside pushbuild infrastructure this # test must be disabled. --source ../include/have_network_namespaces.inc --let $restart_parameters = restart: --skip-name-resolve --bind-address=127.0.0.1,10.0.2.1/red --source include/restart_mysqld.inc CREATE USER root@127.0.0.1; CREATE USER root@10.0.2.1; CREATE USER root@10.0.1.1; --let $MYSQL_PORT= `SELECT @@port` --echo # Check that client can establish connection to the address 127.0.0.1 from the default network namespace --exec $EXE_MYSQL --no-defaults -u root --port $MYSQL_PORT --host 127.0.0.1 -e "SELECT USER()" --echo # Check that client can establish connection to the address 10.0.2.1 from the network namespace 'red' --exec $EXE_MYSQL --no-defaults -u root --port $MYSQL_PORT --host 10.0.2.1 --network-namespace=red -e "SELECT USER()" --echo # Check that client can't establish connection to the address 10.0.2.1 from a non-existing network namespace 'green' --error 1 --exec $EXE_MYSQL --no-defaults -u root --port $MYSQL_PORT --host 10.0.2.1 --network-namespace=green -e "SELECT USER()" 2>&1 --echo # Simulate case where the mysql client doesn't have the cap_sys_admin_capability --copy_file $EXE_MYSQL $MYSQLTEST_VARDIR/tmp/mysql --error 1 --exec $MYSQLTEST_VARDIR/tmp/mysql --no-defaults -u root --port $MYSQL_PORT --host 10.0.2.1 --network-namespace=red -e "SELECT USER()" 2>&1 --remove_file $MYSQLTEST_VARDIR/tmp/mysql --echo # Check that connections to the host from clients outside the network namespace error out since --echo # they are visible only through the gateway through which the network namespace connects to the --echo # outer root network namespace. --error 1 --exec $EXE_MYSQL --no-defaults -u root --port $MYSQL_PORT --host 10.0.2.1 -e "SELECT USER()" --let $restart_parameters=restart: --skip-name-resolve --bind-address=127.0.0.1,10.0.2.1/red,10.0.1.1/blue --source include/restart_mysqld.inc --echo # Check that client can establish connection to the address 10.0.2.1 from the network namespace 'red' --exec $EXE_MYSQL --no-defaults -u root --port $MYSQL_PORT --host 10.0.2.1 --network-namespace=red -e "SELECT USER()" --echo # Check that client can establish connection to the address 10.0.1.1 from the network namespace 'blue' --exec $EXE_MYSQL --no-defaults -u root --port $MYSQL_PORT --host 10.0.1.1 --network-namespace=blue -e "SELECT USER()" --exec # Use network namespaces with admin port # Calculate value for admin port --let $PORT_OFFSET = 1 --expr $ADMIN_PORT = $MASTER_MYPORT + $PORT_OFFSET --let $restart_parameters=restart: --skip-name-resolve --bind-address=127.0.0.1 --admin-address=10.0.2.1/red --admin-port=$ADMIN_PORT --replace_result $ADMIN_PORT ADMIN_PORT --source include/restart_mysqld.inc GRANT SERVICE_CONNECTION_ADMIN ON *.* TO root@10.0.2.1; --exec $EXE_MYSQL --no-defaults -u root --host 10.0.2.1 --port $ADMIN_PORT --network-namespace=red -e "SELECT USER()" # Restart with a dedicated listener thread for admin connections --let $restart_parameters=restart: --skip-name-resolve --bind-address=127.0.0.1 --admin-address=10.0.2.1/red --admin-port=$ADMIN_PORT --create-admin-listener-thread=true --replace_result $ADMIN_PORT ADMIN_PORT --source include/restart_mysqld.inc --exec $EXE_MYSQL --no-defaults -u root --host 10.0.2.1 --port $ADMIN_PORT --network-namespace=red -e "SELECT USER()" REVOKE SERVICE_CONNECTION_ADMIN ON *.* FROM root@10.0.2.1; --let $restart_parameters=restart: --source include/restart_mysqld.inc --connection default DROP USER root@127.0.0.1; DROP USER root@10.0.2.1; DROP USER root@10.0.1.1;