From: Marc Alff Date: January 10 2012 9:36am Subject: bzr push into mysql-trunk-wl5259 branch (marc.alff:3341 to 3342) List-Archive: http://lists.mysql.com/commits/142355 Message-Id: <201201100936.q0A9aM6T032464@acsmt356.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3342 Marc Alff 2012-01-10 Testing, in progress added: mysql-test/suite/perfschema/r/hostcache_ipv4_addrinfo_again_allow.result mysql-test/suite/perfschema/r/hostcache_ipv4_addrinfo_again_deny.result mysql-test/suite/perfschema/r/hostcache_ipv4_addrinfo_bad_deny.result mysql-test/suite/perfschema/r/hostcache_ipv4_addrinfo_good_allow.result mysql-test/suite/perfschema/r/hostcache_ipv4_addrinfo_good_deny.result mysql-test/suite/perfschema/r/hostcache_ipv4_addrinfo_noname_allow.result mysql-test/suite/perfschema/r/hostcache_ipv4_addrinfo_noname_deny.result mysql-test/suite/perfschema/r/hostcache_ipv4_format.result mysql-test/suite/perfschema/r/hostcache_ipv4_nameinfo_again_allow.result mysql-test/suite/perfschema/r/hostcache_ipv4_nameinfo_again_deny.result mysql-test/suite/perfschema/r/hostcache_ipv4_nameinfo_noname_allow.result mysql-test/suite/perfschema/r/hostcache_ipv4_nameinfo_noname_deny.result mysql-test/suite/perfschema/r/hostcache_peer_addr.result mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_again_allow.test mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_again_deny.test mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_bad_deny.test mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_good_allow.test mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_good_deny.test mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_noname_allow.test mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_noname_deny.test mysql-test/suite/perfschema/t/hostcache_ipv4_format.test mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_again_allow.test mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_again_deny.test mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_noname_allow.test mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_noname_deny.test mysql-test/suite/perfschema/t/hostcache_peer_addr.test modified: sql/hostname.cc sql/hostname.h storage/perfschema/table_host_cache.cc 3341 Marc Alff 2012-01-09 [merge] Merge mysql-trunk --> mysql-trunk-wl5259 modified: mysql-test/r/myisampack.result mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test mysql-test/suite/engines/funcs/r/tc_rename_error.result mysql-test/suite/perfschema/r/misc.result mysql-test/suite/perfschema/t/misc.test mysql-test/t/myisampack.test sql/sql_db.cc storage/perfschema/pfs.cc === added file 'mysql-test/suite/perfschema/r/hostcache_ipv4_addrinfo_again_allow.result' --- a/mysql-test/suite/perfschema/r/hostcache_ipv4_addrinfo_again_allow.result 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/perfschema/r/hostcache_ipv4_addrinfo_again_allow.result 2012-01-10 09:35:16 +0000 @@ -0,0 +1,32 @@ +call mtr.add_suppression("192.0.2.4"); +flush status; +flush hosts; +select @@global.debug; +@@global.debug + +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +grant select on test.* to 'root'@'santa.claus.ipv4.example.com'; +select "Con1 is alive"; +Con1 is alive +Con1 is alive +select current_user(); +current_user() +root@localhost +set global debug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_error_again"; +ERROR HY000: Can't get hostname for your address +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select * from performance_schema.host_cache; +IP HOST SUM_BLOCKING_ERRORS COUNT_NAMEINFO_ERRORS COUNT_FORMAT_ERRORS COUNT_ADDRINFO_ERRORS COUNT_FCRDNS_ERRORS COUNT_HOST_ACL_ERRORS COUNT_USER_ACL_ERRORS +ERROR HY000: Can't get hostname for your address +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select * from performance_schema.host_cache; +IP HOST SUM_BLOCKING_ERRORS COUNT_NAMEINFO_ERRORS COUNT_FORMAT_ERRORS COUNT_ADDRINFO_ERRORS COUNT_FCRDNS_ERRORS COUNT_HOST_ACL_ERRORS COUNT_USER_ACL_ERRORS +revoke select on test.* from 'root'@'santa.claus.ipv4.example.com'; +drop user 'root'@'santa.claus.ipv4.example.com'; +set global debug= default; === added file 'mysql-test/suite/perfschema/r/hostcache_ipv4_addrinfo_again_deny.result' --- a/mysql-test/suite/perfschema/r/hostcache_ipv4_addrinfo_again_deny.result 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/perfschema/r/hostcache_ipv4_addrinfo_again_deny.result 2012-01-10 09:35:16 +0000 @@ -0,0 +1,29 @@ +call mtr.add_suppression("192.0.2.4"); +flush status; +flush hosts; +select @@global.debug; +@@global.debug + +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select "Con1 is alive"; +Con1 is alive +Con1 is alive +select current_user(); +current_user() +root@localhost +set global debug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_error_again"; +ERROR HY000: Can't get hostname for your address +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select * from performance_schema.host_cache; +IP HOST SUM_BLOCKING_ERRORS COUNT_NAMEINFO_ERRORS COUNT_FORMAT_ERRORS COUNT_ADDRINFO_ERRORS COUNT_FCRDNS_ERRORS COUNT_HOST_ACL_ERRORS COUNT_USER_ACL_ERRORS +ERROR HY000: Can't get hostname for your address +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select * from performance_schema.host_cache; +IP HOST SUM_BLOCKING_ERRORS COUNT_NAMEINFO_ERRORS COUNT_FORMAT_ERRORS COUNT_ADDRINFO_ERRORS COUNT_FCRDNS_ERRORS COUNT_HOST_ACL_ERRORS COUNT_USER_ACL_ERRORS +set global debug= default; === added file 'mysql-test/suite/perfschema/r/hostcache_ipv4_addrinfo_bad_deny.result' --- a/mysql-test/suite/perfschema/r/hostcache_ipv4_addrinfo_bad_deny.result 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/perfschema/r/hostcache_ipv4_addrinfo_bad_deny.result 2012-01-10 09:35:16 +0000 @@ -0,0 +1,31 @@ +call mtr.add_suppression("192.0.2.4"); +flush status; +flush hosts; +select @@global.debug; +@@global.debug + +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select "Con1 is alive"; +Con1 is alive +Con1 is alive +select current_user(); +current_user() +root@localhost +set global debug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_fake_bad_ipv4"; +ERROR HY000: Host '192.0.2.4' is not allowed to connect to this MySQL server +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select * from performance_schema.host_cache; +IP HOST SUM_BLOCKING_ERRORS COUNT_NAMEINFO_ERRORS COUNT_FORMAT_ERRORS COUNT_ADDRINFO_ERRORS COUNT_FCRDNS_ERRORS COUNT_HOST_ACL_ERRORS COUNT_USER_ACL_ERRORS +192.0.2.4 NULL 0 0 0 0 1 12 12 +ERROR HY000: Host '192.0.2.4' is not allowed to connect to this MySQL server +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select * from performance_schema.host_cache; +IP HOST SUM_BLOCKING_ERRORS COUNT_NAMEINFO_ERRORS COUNT_FORMAT_ERRORS COUNT_ADDRINFO_ERRORS COUNT_FCRDNS_ERRORS COUNT_HOST_ACL_ERRORS COUNT_USER_ACL_ERRORS +192.0.2.4 NULL 0 0 0 0 1 12 12 +set global debug= default; === added file 'mysql-test/suite/perfschema/r/hostcache_ipv4_addrinfo_good_allow.result' --- a/mysql-test/suite/perfschema/r/hostcache_ipv4_addrinfo_good_allow.result 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/perfschema/r/hostcache_ipv4_addrinfo_good_allow.result 2012-01-10 09:35:16 +0000 @@ -0,0 +1,44 @@ +call mtr.add_suppression("192.0.2.4"); +flush status; +flush hosts; +select @@global.debug; +@@global.debug + +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +grant select on test.* to 'root'@'santa.claus.ipv4.example.com'; +select "Con1 is alive"; +Con1 is alive +Con1 is alive +select current_user(); +current_user() +root@localhost +set global debug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_fake_good_ipv4"; +select "Con2 is alive"; +Con2 is alive +Con2 is alive +select current_user(); +current_user() +root@stripped +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select * from performance_schema.host_cache; +IP HOST SUM_BLOCKING_ERRORS COUNT_NAMEINFO_ERRORS COUNT_FORMAT_ERRORS COUNT_ADDRINFO_ERRORS COUNT_FCRDNS_ERRORS COUNT_HOST_ACL_ERRORS COUNT_USER_ACL_ERRORS +192.0.2.4 santa.claus.ipv4.example.com 0 0 0 0 0 12 12 +select "Con3 is alive"; +Con3 is alive +Con3 is alive +select current_user(); +current_user() +root@stripped +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select * from performance_schema.host_cache; +IP HOST SUM_BLOCKING_ERRORS COUNT_NAMEINFO_ERRORS COUNT_FORMAT_ERRORS COUNT_ADDRINFO_ERRORS COUNT_FCRDNS_ERRORS COUNT_HOST_ACL_ERRORS COUNT_USER_ACL_ERRORS +192.0.2.4 santa.claus.ipv4.example.com 0 0 0 0 0 12 12 +revoke select on test.* from 'root'@'santa.claus.ipv4.example.com'; +drop user 'root'@'santa.claus.ipv4.example.com'; +set global debug= default; === added file 'mysql-test/suite/perfschema/r/hostcache_ipv4_addrinfo_good_deny.result' --- a/mysql-test/suite/perfschema/r/hostcache_ipv4_addrinfo_good_deny.result 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/perfschema/r/hostcache_ipv4_addrinfo_good_deny.result 2012-01-10 09:35:16 +0000 @@ -0,0 +1,31 @@ +call mtr.add_suppression("192.0.2.4"); +flush status; +flush hosts; +select @@global.debug; +@@global.debug + +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select "Con1 is alive"; +Con1 is alive +Con1 is alive +select current_user(); +current_user() +root@localhost +set global debug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_fake_good_ipv4"; +ERROR HY000: Host 'santa.claus.ipv4.example.com' is not allowed to connect to this MySQL server +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select * from performance_schema.host_cache; +IP HOST SUM_BLOCKING_ERRORS COUNT_NAMEINFO_ERRORS COUNT_FORMAT_ERRORS COUNT_ADDRINFO_ERRORS COUNT_FCRDNS_ERRORS COUNT_HOST_ACL_ERRORS COUNT_USER_ACL_ERRORS +192.0.2.4 santa.claus.ipv4.example.com 0 0 0 0 0 12 12 +ERROR HY000: Host 'santa.claus.ipv4.example.com' is not allowed to connect to this MySQL server +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select * from performance_schema.host_cache; +IP HOST SUM_BLOCKING_ERRORS COUNT_NAMEINFO_ERRORS COUNT_FORMAT_ERRORS COUNT_ADDRINFO_ERRORS COUNT_FCRDNS_ERRORS COUNT_HOST_ACL_ERRORS COUNT_USER_ACL_ERRORS +192.0.2.4 santa.claus.ipv4.example.com 0 0 0 0 0 12 12 +set global debug= default; === added file 'mysql-test/suite/perfschema/r/hostcache_ipv4_addrinfo_noname_allow.result' --- a/mysql-test/suite/perfschema/r/hostcache_ipv4_addrinfo_noname_allow.result 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/perfschema/r/hostcache_ipv4_addrinfo_noname_allow.result 2012-01-10 09:35:16 +0000 @@ -0,0 +1,47 @@ +call mtr.add_suppression("192.0.2.4"); +flush status; +flush hosts; +select @@global.debug; +@@global.debug + +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +grant select on test.* to 'root'@'santa.claus.ipv4.example.com'; +grant select on test.* to 'root'@'192.0.2.4'; +select "Con1 is alive"; +Con1 is alive +Con1 is alive +select current_user(); +current_user() +root@localhost +set global debug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_error_noname"; +select "Con2 is alive"; +Con2 is alive +Con2 is alive +select current_user(); +current_user() +root@stripped +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select * from performance_schema.host_cache; +IP HOST SUM_BLOCKING_ERRORS COUNT_NAMEINFO_ERRORS COUNT_FORMAT_ERRORS COUNT_ADDRINFO_ERRORS COUNT_FCRDNS_ERRORS COUNT_HOST_ACL_ERRORS COUNT_USER_ACL_ERRORS +192.0.2.4 NULL 0 0 0 1 0 12 12 +select "Con3 is alive"; +Con3 is alive +Con3 is alive +select current_user(); +current_user() +root@stripped +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select * from performance_schema.host_cache; +IP HOST SUM_BLOCKING_ERRORS COUNT_NAMEINFO_ERRORS COUNT_FORMAT_ERRORS COUNT_ADDRINFO_ERRORS COUNT_FCRDNS_ERRORS COUNT_HOST_ACL_ERRORS COUNT_USER_ACL_ERRORS +192.0.2.4 NULL 0 0 0 1 0 12 12 +revoke select on test.* from 'root'@'santa.claus.ipv4.example.com'; +revoke select on test.* from 'root'@'192.0.2.4'; +drop user 'root'@'santa.claus.ipv4.example.com'; +drop user 'root'@'192.0.2.4'; +set global debug= default; === added file 'mysql-test/suite/perfschema/r/hostcache_ipv4_addrinfo_noname_deny.result' --- a/mysql-test/suite/perfschema/r/hostcache_ipv4_addrinfo_noname_deny.result 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/perfschema/r/hostcache_ipv4_addrinfo_noname_deny.result 2012-01-10 09:35:16 +0000 @@ -0,0 +1,31 @@ +call mtr.add_suppression("192.0.2.4"); +flush status; +flush hosts; +select @@global.debug; +@@global.debug + +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select "Con1 is alive"; +Con1 is alive +Con1 is alive +select current_user(); +current_user() +root@localhost +set global debug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_error_noname"; +ERROR HY000: Host '192.0.2.4' is not allowed to connect to this MySQL server +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select * from performance_schema.host_cache; +IP HOST SUM_BLOCKING_ERRORS COUNT_NAMEINFO_ERRORS COUNT_FORMAT_ERRORS COUNT_ADDRINFO_ERRORS COUNT_FCRDNS_ERRORS COUNT_HOST_ACL_ERRORS COUNT_USER_ACL_ERRORS +192.0.2.4 NULL 0 0 0 1 0 12 12 +ERROR HY000: Host '192.0.2.4' is not allowed to connect to this MySQL server +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select * from performance_schema.host_cache; +IP HOST SUM_BLOCKING_ERRORS COUNT_NAMEINFO_ERRORS COUNT_FORMAT_ERRORS COUNT_ADDRINFO_ERRORS COUNT_FCRDNS_ERRORS COUNT_HOST_ACL_ERRORS COUNT_USER_ACL_ERRORS +192.0.2.4 NULL 0 0 0 1 0 12 12 +set global debug= default; === added file 'mysql-test/suite/perfschema/r/hostcache_ipv4_format.result' --- a/mysql-test/suite/perfschema/r/hostcache_ipv4_format.result 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/perfschema/r/hostcache_ipv4_format.result 2012-01-10 09:35:16 +0000 @@ -0,0 +1,31 @@ +call mtr.add_suppression("192.0.2.4"); +flush status; +flush hosts; +select @@global.debug; +@@global.debug + +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select "Con1 is alive"; +Con1 is alive +Con1 is alive +select current_user(); +current_user() +root@localhost +set global debug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_format_ipv4"; +ERROR HY000: Host '192.0.2.4' is not allowed to connect to this MySQL server +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select * from performance_schema.host_cache; +IP HOST SUM_BLOCKING_ERRORS COUNT_NAMEINFO_ERRORS COUNT_FORMAT_ERRORS COUNT_ADDRINFO_ERRORS COUNT_FCRDNS_ERRORS COUNT_HOST_ACL_ERRORS COUNT_USER_ACL_ERRORS +192.0.2.4 NULL 0 0 1 0 0 12 12 +ERROR HY000: Host '192.0.2.4' is not allowed to connect to this MySQL server +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select * from performance_schema.host_cache; +IP HOST SUM_BLOCKING_ERRORS COUNT_NAMEINFO_ERRORS COUNT_FORMAT_ERRORS COUNT_ADDRINFO_ERRORS COUNT_FCRDNS_ERRORS COUNT_HOST_ACL_ERRORS COUNT_USER_ACL_ERRORS +192.0.2.4 NULL 0 0 1 0 0 12 12 +set global debug= default; === added file 'mysql-test/suite/perfschema/r/hostcache_ipv4_nameinfo_again_allow.result' --- a/mysql-test/suite/perfschema/r/hostcache_ipv4_nameinfo_again_allow.result 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/perfschema/r/hostcache_ipv4_nameinfo_again_allow.result 2012-01-10 09:35:16 +0000 @@ -0,0 +1,42 @@ +call mtr.add_suppression("192.0.2.4"); +flush status; +flush hosts; +select @@global.debug; +@@global.debug + +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +grant select on test.* to 'root'@'192.0.2.4'; +select "Con1 is alive"; +Con1 is alive +Con1 is alive +select current_user(); +current_user() +root@localhost +set global debug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_error_again"; +select "Con2 is alive"; +Con2 is alive +Con2 is alive +select current_user(); +current_user() +root@stripped +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select * from performance_schema.host_cache; +IP HOST SUM_BLOCKING_ERRORS COUNT_NAMEINFO_ERRORS COUNT_FORMAT_ERRORS COUNT_ADDRINFO_ERRORS COUNT_FCRDNS_ERRORS COUNT_HOST_ACL_ERRORS COUNT_USER_ACL_ERRORS +select "Con3 is alive"; +Con3 is alive +Con3 is alive +select current_user(); +current_user() +root@stripped +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select * from performance_schema.host_cache; +IP HOST SUM_BLOCKING_ERRORS COUNT_NAMEINFO_ERRORS COUNT_FORMAT_ERRORS COUNT_ADDRINFO_ERRORS COUNT_FCRDNS_ERRORS COUNT_HOST_ACL_ERRORS COUNT_USER_ACL_ERRORS +revoke select on test.* from 'root'@'192.0.2.4'; +drop user 'root'@'192.0.2.4'; +set global debug= default; === added file 'mysql-test/suite/perfschema/r/hostcache_ipv4_nameinfo_again_deny.result' --- a/mysql-test/suite/perfschema/r/hostcache_ipv4_nameinfo_again_deny.result 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/perfschema/r/hostcache_ipv4_nameinfo_again_deny.result 2012-01-10 09:35:16 +0000 @@ -0,0 +1,44 @@ +call mtr.add_suppression("192.0.2.4"); +flush status; +flush hosts; +select @@global.debug; +@@global.debug + +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select "Con1 is alive"; +Con1 is alive +Con1 is alive +select current_user(); +current_user() +root@localhost +set global debug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_error_again"; +ERROR HY000: Host '192.0.2.4' is not allowed to connect to this MySQL server +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select * from performance_schema.host_cache; +IP HOST SUM_BLOCKING_ERRORS COUNT_NAMEINFO_ERRORS COUNT_FORMAT_ERRORS COUNT_ADDRINFO_ERRORS COUNT_FCRDNS_ERRORS COUNT_HOST_ACL_ERRORS COUNT_USER_ACL_ERRORS +ERROR HY000: Host '192.0.2.4' is not allowed to connect to this MySQL server +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select * from performance_schema.host_cache; +IP HOST SUM_BLOCKING_ERRORS COUNT_NAMEINFO_ERRORS COUNT_FORMAT_ERRORS COUNT_ADDRINFO_ERRORS COUNT_FCRDNS_ERRORS COUNT_HOST_ACL_ERRORS COUNT_USER_ACL_ERRORS +set global debug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_fake_good_ipv4"; +ERROR HY000: Host 'santa.claus.ipv4.example.com' is not allowed to connect to this MySQL server +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select * from performance_schema.host_cache; +IP HOST SUM_BLOCKING_ERRORS COUNT_NAMEINFO_ERRORS COUNT_FORMAT_ERRORS COUNT_ADDRINFO_ERRORS COUNT_FCRDNS_ERRORS COUNT_HOST_ACL_ERRORS COUNT_USER_ACL_ERRORS +192.0.2.4 santa.claus.ipv4.example.com 0 0 0 0 0 12 12 +ERROR HY000: Host 'santa.claus.ipv4.example.com' is not allowed to connect to this MySQL server +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select * from performance_schema.host_cache; +IP HOST SUM_BLOCKING_ERRORS COUNT_NAMEINFO_ERRORS COUNT_FORMAT_ERRORS COUNT_ADDRINFO_ERRORS COUNT_FCRDNS_ERRORS COUNT_HOST_ACL_ERRORS COUNT_USER_ACL_ERRORS +192.0.2.4 santa.claus.ipv4.example.com 0 0 0 0 0 12 12 +set global debug= default; === added file 'mysql-test/suite/perfschema/r/hostcache_ipv4_nameinfo_noname_allow.result' --- a/mysql-test/suite/perfschema/r/hostcache_ipv4_nameinfo_noname_allow.result 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/perfschema/r/hostcache_ipv4_nameinfo_noname_allow.result 2012-01-10 09:35:16 +0000 @@ -0,0 +1,44 @@ +call mtr.add_suppression("192.0.2.4"); +flush status; +flush hosts; +select @@global.debug; +@@global.debug + +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +grant select on test.* to 'root'@'192.0.2.4'; +select "Con1 is alive"; +Con1 is alive +Con1 is alive +select current_user(); +current_user() +root@localhost +set global debug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_error_noname"; +select "Con2 is alive"; +Con2 is alive +Con2 is alive +select current_user(); +current_user() +root@stripped +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select * from performance_schema.host_cache; +IP HOST SUM_BLOCKING_ERRORS COUNT_NAMEINFO_ERRORS COUNT_FORMAT_ERRORS COUNT_ADDRINFO_ERRORS COUNT_FCRDNS_ERRORS COUNT_HOST_ACL_ERRORS COUNT_USER_ACL_ERRORS +192.0.2.4 NULL 0 0 0 0 0 12 12 +select "Con3 is alive"; +Con3 is alive +Con3 is alive +select current_user(); +current_user() +root@stripped +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select * from performance_schema.host_cache; +IP HOST SUM_BLOCKING_ERRORS COUNT_NAMEINFO_ERRORS COUNT_FORMAT_ERRORS COUNT_ADDRINFO_ERRORS COUNT_FCRDNS_ERRORS COUNT_HOST_ACL_ERRORS COUNT_USER_ACL_ERRORS +192.0.2.4 NULL 0 0 0 0 0 12 12 +revoke select on test.* from 'root'@'192.0.2.4'; +drop user 'root'@'192.0.2.4'; +set global debug= default; === added file 'mysql-test/suite/perfschema/r/hostcache_ipv4_nameinfo_noname_deny.result' --- a/mysql-test/suite/perfschema/r/hostcache_ipv4_nameinfo_noname_deny.result 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/perfschema/r/hostcache_ipv4_nameinfo_noname_deny.result 2012-01-10 09:35:16 +0000 @@ -0,0 +1,31 @@ +call mtr.add_suppression("192.0.2.4"); +flush status; +flush hosts; +select @@global.debug; +@@global.debug + +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select "Con1 is alive"; +Con1 is alive +Con1 is alive +select current_user(); +current_user() +root@localhost +set global debug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_error_noname"; +ERROR HY000: Host '192.0.2.4' is not allowed to connect to this MySQL server +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select * from performance_schema.host_cache; +IP HOST SUM_BLOCKING_ERRORS COUNT_NAMEINFO_ERRORS COUNT_FORMAT_ERRORS COUNT_ADDRINFO_ERRORS COUNT_FCRDNS_ERRORS COUNT_HOST_ACL_ERRORS COUNT_USER_ACL_ERRORS +192.0.2.4 NULL 0 0 0 0 0 12 12 +ERROR HY000: Host '192.0.2.4' is not allowed to connect to this MySQL server +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select * from performance_schema.host_cache; +IP HOST SUM_BLOCKING_ERRORS COUNT_NAMEINFO_ERRORS COUNT_FORMAT_ERRORS COUNT_ADDRINFO_ERRORS COUNT_FCRDNS_ERRORS COUNT_HOST_ACL_ERRORS COUNT_USER_ACL_ERRORS +192.0.2.4 NULL 0 0 0 0 0 12 12 +set global debug= default; === added file 'mysql-test/suite/perfschema/r/hostcache_peer_addr.result' --- a/mysql-test/suite/perfschema/r/hostcache_peer_addr.result 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/perfschema/r/hostcache_peer_addr.result 2012-01-10 09:35:16 +0000 @@ -0,0 +1,28 @@ +flush status; +flush hosts; +select @@global.debug; +@@global.debug + +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 +select "Con1 is alive"; +Con1 is alive +Con1 is alive +select current_user(); +current_user() +root@localhost +set global debug= "+d,vio_peer_addr_error"; +ERROR HY000: Can't get hostname for your address +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 1 +ERROR HY000: Can't get hostname for your address +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 2 +set global debug= default; +flush status; +show global status like "%peer%"; +Variable_name Value +Peer_address_errors 0 === added file 'mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_again_allow.test' --- a/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_again_allow.test 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_again_allow.test 2012-01-10 09:35:16 +0000 @@ -0,0 +1,58 @@ + +# +# Tests for the performance_schema host_cache. +# +# Test scenario: +# - a client connects on a TCP/IPv4 socket +# - the client IPv4 can be obtained +# - the client hostname can be obtained +# - IP for that hostname can not be obtained +# - there are no grants for the client IP +# Test results: +# - connection is refused +# - peer_addr_error is unchanged +# - the host_cache records the failing IP and hostname +# + +# [Warning] IP address '192.0.2.4' could not be resolved: +# no reverse address mapping. +call mtr.add_suppression("192.0.2.4"); + +flush status; +flush hosts; +select @@global.debug; +show global status like "%peer%"; + +grant select on test.* to 'root'@'santa.claus.ipv4.example.com'; + +connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,); +select "Con1 is alive"; +select current_user(); +disconnect con1; + +--connection default +set global debug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_error_again"; + +--disable_query_log +--error ER_BAD_HOST_ERROR +connect (con2,"127.0.0.1",root,,test,$MASTER_MYPORT,); +--enable_query_log + +--connection default +show global status like "%peer%"; +select * from performance_schema.host_cache; + +--disable_query_log +--error ER_BAD_HOST_ERROR +connect (con3,"127.0.0.1",root,,test,$MASTER_MYPORT,); +--enable_query_log + +--connection default +show global status like "%peer%"; +select * from performance_schema.host_cache; + +revoke select on test.* from 'root'@'santa.claus.ipv4.example.com'; +drop user 'root'@'santa.claus.ipv4.example.com'; + +set global debug= default; + === added file 'mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_again_deny.test' --- a/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_again_deny.test 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_again_deny.test 2012-01-10 09:35:16 +0000 @@ -0,0 +1,53 @@ + +# +# Tests for the performance_schema host_cache. +# +# Test scenario: +# - a client connects on a TCP/IPv4 socket +# - the client IPv4 can be obtained +# - the client hostname can be obtained +# - IP for that hostname can not be obtained +# - there are no grants for the client IP +# Test results: +# - connection is refused +# - peer_addr_error is unchanged +# - the host_cache records the failing IP and hostname +# + +# [Warning] IP address '192.0.2.4' could not be resolved: +# no reverse address mapping. +call mtr.add_suppression("192.0.2.4"); + +flush status; +flush hosts; +select @@global.debug; +show global status like "%peer%"; + +connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,); +select "Con1 is alive"; +select current_user(); +disconnect con1; + +--connection default +set global debug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_error_again"; + +--disable_query_log +--error ER_BAD_HOST_ERROR +connect (con2,"127.0.0.1",root,,test,$MASTER_MYPORT,); +--enable_query_log + +--connection default +show global status like "%peer%"; +select * from performance_schema.host_cache; + +--disable_query_log +--error ER_BAD_HOST_ERROR +connect (con3,"127.0.0.1",root,,test,$MASTER_MYPORT,); +--enable_query_log + +--connection default +show global status like "%peer%"; +select * from performance_schema.host_cache; + +set global debug= default; + === added file 'mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_bad_deny.test' --- a/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_bad_deny.test 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_bad_deny.test 2012-01-10 09:35:16 +0000 @@ -0,0 +1,53 @@ + +# +# Tests for the performance_schema host_cache. +# +# Test scenario: +# - a client connects on a TCP/IPv4 socket +# - the client IPv4 can be obtained +# - the client hostname can be obtained +# - IP for that hostname can not be obtained +# - there are no grants for the client IP +# Test results: +# - connection is refused +# - peer_addr_error is unchanged +# - the host_cache records the failing IP and hostname +# + +# [Warning] IP address '192.0.2.4' could not be resolved: +# no reverse address mapping. +call mtr.add_suppression("192.0.2.4"); + +flush status; +flush hosts; +select @@global.debug; +show global status like "%peer%"; + +connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,); +select "Con1 is alive"; +select current_user(); +disconnect con1; + +--connection default +set global debug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_fake_bad_ipv4"; + +--disable_query_log +--error ER_HOST_NOT_PRIVILEGED +connect (con2,"127.0.0.1",root,,test,$MASTER_MYPORT,); +--enable_query_log + +--connection default +show global status like "%peer%"; +select * from performance_schema.host_cache; + +--disable_query_log +--error ER_HOST_NOT_PRIVILEGED +connect (con3,"127.0.0.1",root,,test,$MASTER_MYPORT,); +--enable_query_log + +--connection default +show global status like "%peer%"; +select * from performance_schema.host_cache; + +set global debug= default; + === added file 'mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_good_allow.test' --- a/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_good_allow.test 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_good_allow.test 2012-01-10 09:35:16 +0000 @@ -0,0 +1,58 @@ + +# +# Tests for the performance_schema host_cache. +# +# Test scenario: +# - a client connects on a TCP/IPv4 socket +# - the client IPv4 can be obtained +# - the client hostname can be obtained +# - IP for that hostname can not be obtained +# - there are no grants for the client IP +# Test results: +# - connection is refused +# - peer_addr_error is unchanged +# - the host_cache records the failing IP and hostname +# + +# [Warning] IP address '192.0.2.4' could not be resolved: +# no reverse address mapping. +call mtr.add_suppression("192.0.2.4"); + +flush status; +flush hosts; +select @@global.debug; +show global status like "%peer%"; + +grant select on test.* to 'root'@'santa.claus.ipv4.example.com'; + +connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,); +select "Con1 is alive"; +select current_user(); +disconnect con1; + +--connection default +set global debug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_fake_good_ipv4"; + +connect (con2,"127.0.0.1",root,,test,$MASTER_MYPORT,); +select "Con2 is alive"; +select current_user(); +disconnect con2; + +--connection default +show global status like "%peer%"; +select * from performance_schema.host_cache; + +connect (con3,"127.0.0.1",root,,test,$MASTER_MYPORT,); +select "Con3 is alive"; +select current_user(); +disconnect con3; + +--connection default +show global status like "%peer%"; +select * from performance_schema.host_cache; + +revoke select on test.* from 'root'@'santa.claus.ipv4.example.com'; +drop user 'root'@'santa.claus.ipv4.example.com'; + +set global debug= default; + === added file 'mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_good_deny.test' --- a/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_good_deny.test 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_good_deny.test 2012-01-10 09:35:16 +0000 @@ -0,0 +1,53 @@ + +# +# Tests for the performance_schema host_cache. +# +# Test scenario: +# - a client connects on a TCP/IPv4 socket +# - the client IPv4 can be obtained +# - the client hostname can be obtained +# - IP for that hostname can not be obtained +# - there are no grants for the client IP +# Test results: +# - connection is refused +# - peer_addr_error is unchanged +# - the host_cache records the failing IP and hostname +# + +# [Warning] IP address '192.0.2.4' could not be resolved: +# no reverse address mapping. +call mtr.add_suppression("192.0.2.4"); + +flush status; +flush hosts; +select @@global.debug; +show global status like "%peer%"; + +connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,); +select "Con1 is alive"; +select current_user(); +disconnect con1; + +--connection default +set global debug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_fake_good_ipv4"; + +--disable_query_log +--error ER_HOST_NOT_PRIVILEGED +connect (con2,"127.0.0.1",root,,test,$MASTER_MYPORT,); +--enable_query_log + +--connection default +show global status like "%peer%"; +select * from performance_schema.host_cache; + +--disable_query_log +--error ER_HOST_NOT_PRIVILEGED +connect (con3,"127.0.0.1",root,,test,$MASTER_MYPORT,); +--enable_query_log + +--connection default +show global status like "%peer%"; +select * from performance_schema.host_cache; + +set global debug= default; + === added file 'mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_noname_allow.test' --- a/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_noname_allow.test 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_noname_allow.test 2012-01-10 09:35:16 +0000 @@ -0,0 +1,61 @@ + +# +# Tests for the performance_schema host_cache. +# +# Test scenario: +# - a client connects on a TCP/IPv4 socket +# - the client IPv4 can be obtained +# - the client hostname can be obtained +# - IP for that hostname can not be obtained +# - there are no grants for the client IP +# Test results: +# - connection is refused +# - peer_addr_error is unchanged +# - the host_cache records the failing IP and hostname +# + +# [Warning] IP address '192.0.2.4' could not be resolved: +# no reverse address mapping. +call mtr.add_suppression("192.0.2.4"); + +flush status; +flush hosts; +select @@global.debug; +show global status like "%peer%"; + +grant select on test.* to 'root'@'santa.claus.ipv4.example.com'; +grant select on test.* to 'root'@'192.0.2.4'; + +connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,); +select "Con1 is alive"; +select current_user(); +disconnect con1; + +--connection default +set global debug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_error_noname"; + +connect (con2,"127.0.0.1",root,,test,$MASTER_MYPORT,); +select "Con2 is alive"; +select current_user(); +disconnect con2; + +--connection default +show global status like "%peer%"; +select * from performance_schema.host_cache; + +connect (con3,"127.0.0.1",root,,test,$MASTER_MYPORT,); +select "Con3 is alive"; +select current_user(); +disconnect con3; + +--connection default +show global status like "%peer%"; +select * from performance_schema.host_cache; + +revoke select on test.* from 'root'@'santa.claus.ipv4.example.com'; +revoke select on test.* from 'root'@'192.0.2.4'; +drop user 'root'@'santa.claus.ipv4.example.com'; +drop user 'root'@'192.0.2.4'; + +set global debug= default; + === added file 'mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_noname_deny.test' --- a/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_noname_deny.test 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_noname_deny.test 2012-01-10 09:35:16 +0000 @@ -0,0 +1,53 @@ + +# +# Tests for the performance_schema host_cache. +# +# Test scenario: +# - a client connects on a TCP/IPv4 socket +# - the client IPv4 can be obtained +# - the client hostname can be obtained +# - IP for that hostname can not be obtained +# - there are no grants for the client IP +# Test results: +# - connection is refused +# - peer_addr_error is unchanged +# - the host_cache records the failing IP and hostname +# + +# [Warning] IP address '192.0.2.4' could not be resolved: +# no reverse address mapping. +call mtr.add_suppression("192.0.2.4"); + +flush status; +flush hosts; +select @@global.debug; +show global status like "%peer%"; + +connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,); +select "Con1 is alive"; +select current_user(); +disconnect con1; + +--connection default +set global debug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_error_noname"; + +--disable_query_log +--error ER_HOST_NOT_PRIVILEGED +connect (con2,"127.0.0.1",root,,test,$MASTER_MYPORT,); +--enable_query_log + +--connection default +show global status like "%peer%"; +select * from performance_schema.host_cache; + +--disable_query_log +--error ER_HOST_NOT_PRIVILEGED +connect (con3,"127.0.0.1",root,,test,$MASTER_MYPORT,); +--enable_query_log + +--connection default +show global status like "%peer%"; +select * from performance_schema.host_cache; + +set global debug= default; + === added file 'mysql-test/suite/perfschema/t/hostcache_ipv4_format.test' --- a/mysql-test/suite/perfschema/t/hostcache_ipv4_format.test 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_format.test 2012-01-10 09:35:16 +0000 @@ -0,0 +1,53 @@ + +# +# Tests for the performance_schema host_cache. +# +# Test scenario: +# - a client connects on a TCP/IPv4 socket +# - the client IPv4 can be obtained +# - the client hostname can be obtained +# - the client hostname looks like an IPv4 address +# - there are grants for the client IP +# Test results: +# - connection is refused +# - peer_addr_error is unchanged +# - the host_cache records the failing IP with hostname +# + +# [Warning] IP address '192.0.2.4' could not be resolved: +# Name or service not known +call mtr.add_suppression("192.0.2.4"); + +flush status; +flush hosts; +select @@global.debug; +show global status like "%peer%"; + +connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,); +select "Con1 is alive"; +select current_user(); +disconnect con1; + +--connection default +set global debug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_format_ipv4"; + +--disable_query_log +--error ER_HOST_NOT_PRIVILEGED +connect (con2,"127.0.0.1",root,,test,$MASTER_MYPORT,); +--enable_query_log + +--connection default +show global status like "%peer%"; +select * from performance_schema.host_cache; + +--disable_query_log +--error ER_HOST_NOT_PRIVILEGED +connect (con3,"127.0.0.1",root,,test,$MASTER_MYPORT,); +--enable_query_log + +--connection default +show global status like "%peer%"; +select * from performance_schema.host_cache; + +set global debug= default; + === added file 'mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_again_allow.test' --- a/mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_again_allow.test 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_again_allow.test 2012-01-10 09:35:16 +0000 @@ -0,0 +1,57 @@ + +# +# Tests for the performance_schema host_cache. +# +# Test scenario: +# - a client connects on a TCP/IPv4 socket +# - the client IPv4 can be obtained (temp failure) +# - the client hostname can not be obtained +# - there are grants for the client IP +# Test results: +# - connection is accepted +# - peer_addr_error is unchanged +# - the host_cache records the failing IP with no hostname +# + +# [Warning] IP address '192.0.2.4' could not be resolved: +# Temporary failure in name resolution +call mtr.add_suppression("192.0.2.4"); + +flush status; +flush hosts; +select @@global.debug; +show global status like "%peer%"; + +grant select on test.* to 'root'@'192.0.2.4'; + +connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,); +select "Con1 is alive"; +select current_user(); +disconnect con1; + +--connection default +set global debug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_error_again"; + +connect (con2,"127.0.0.1",root,,test,$MASTER_MYPORT,); +select "Con2 is alive"; +select current_user(); +disconnect con2; + +--connection default +show global status like "%peer%"; +select * from performance_schema.host_cache; + +connect (con3,"127.0.0.1",root,,test,$MASTER_MYPORT,); +select "Con3 is alive"; +select current_user(); +disconnect con3; + +--connection default +show global status like "%peer%"; +select * from performance_schema.host_cache; + +revoke select on test.* from 'root'@'192.0.2.4'; +drop user 'root'@'192.0.2.4'; + +set global debug= default; + === added file 'mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_again_deny.test' --- a/mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_again_deny.test 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_again_deny.test 2012-01-10 09:35:16 +0000 @@ -0,0 +1,106 @@ + +# +# Tests for the performance_schema host_cache. +# +# Test scenario: (con2) +# - a client connects on a TCP/IPv4 socket +# - the client IPv4 can be obtained +# - the client IPv4 is not in the cache +# - the client hostname can not be obtained (temp failure) +# - there are no grants for the client IP +# Test results: +# - connection is refused +# - peer_addr_errors is unchanged +# - the host_cache records the failing IP with no hostname +# +# Test scenario: (con3) +# - a client connects on a TCP/IPv4 socket +# - the client IPv4 can be obtained +# - the client IPv4 is in the cache with no hostname +# - the client hostname can not be obtained (temp failure) +# - there are no grants for the client IP +# Test results: +# - connection is refused +# - peer_addr_errors is unchanged +# - the host_cache records the failing IP with no hostname +# +# Test scenario: (con4) +# - a client connects on a TCP/IPv4 socket +# - the client IPv4 can be obtained +# - the client IPv4 is in the cache with no hostname +# - the client hostname can be obtained, finally +# - there are no grants for the client host +# Test results: +# - connection is refused +# - peer_addr_errors is unchanged +# - the host_cache is updated with the resolved hostname +# +# Test scenario: (con5) +# - a client connects on a TCP/IPv4 socket +# - the client IPv4 can be obtained +# - the client IPv4 is in the cache with resolved hostname +# - there are no grants for the client host +# Test results: +# - connection is refused +# - peer_addr_errors is unchanged +# - the host_cache is unchanged +# + +# [Warning] IP address '192.0.2.4' could not be resolved: +# Temporary failure in name resolution +call mtr.add_suppression("192.0.2.4"); + +flush status; +flush hosts; +select @@global.debug; +show global status like "%peer%"; + +connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,); +select "Con1 is alive"; +select current_user(); +disconnect con1; + +--connection default +set global debug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_error_again"; + +--disable_query_log +--error ER_HOST_NOT_PRIVILEGED +connect (con2,"127.0.0.1",root,,test,$MASTER_MYPORT,); +--enable_query_log + +--connection default +show global status like "%peer%"; +select * from performance_schema.host_cache; + +--disable_query_log +--error ER_HOST_NOT_PRIVILEGED +connect (con3,"127.0.0.1",root,,test,$MASTER_MYPORT,); +--enable_query_log + +--connection default +show global status like "%peer%"; +select * from performance_schema.host_cache; + +set global debug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_fake_good_ipv4"; + +--disable_query_log +--error ER_HOST_NOT_PRIVILEGED +connect (con4,"127.0.0.1",root,,test,$MASTER_MYPORT,); +--enable_query_log + +--connection default +show global status like "%peer%"; +select * from performance_schema.host_cache; + +--disable_query_log +--error ER_HOST_NOT_PRIVILEGED +connect (con5,"127.0.0.1",root,,test,$MASTER_MYPORT,); +--enable_query_log + +--connection default +show global status like "%peer%"; +select * from performance_schema.host_cache; + + +set global debug= default; + === added file 'mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_noname_allow.test' --- a/mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_noname_allow.test 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_noname_allow.test 2012-01-10 09:35:16 +0000 @@ -0,0 +1,58 @@ + +# +# Tests for the performance_schema host_cache. +# +# Test scenario: +# - a client connects on a TCP/IPv4 socket +# - the client IPv4 can be obtained +# - the client hostname can not be obtained (NONAME) +# - there are grants for the client IP +# Test results: +# - connection is accepted +# - the user is authorized by IP +# - peer_addr_errors is unchanged +# - the host_cache records the failing IP with no hostname +# + +# [Warning] IP address '192.0.2.4' could not be resolved: +# no reverse address mapping. +call mtr.add_suppression("192.0.2.4"); + +flush status; +flush hosts; +select @@global.debug; +show global status like "%peer%"; + +grant select on test.* to 'root'@'192.0.2.4'; + +connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,); +select "Con1 is alive"; +select current_user(); +disconnect con1; + +--connection default +set global debug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_error_noname"; + +connect (con2,"127.0.0.1",root,,test,$MASTER_MYPORT,); +select "Con2 is alive"; +select current_user(); +disconnect con2; + +--connection default +show global status like "%peer%"; +select * from performance_schema.host_cache; + +connect (con3,"127.0.0.1",root,,test,$MASTER_MYPORT,); +select "Con3 is alive"; +select current_user(); +disconnect con3; + +--connection default +show global status like "%peer%"; +select * from performance_schema.host_cache; + +revoke select on test.* from 'root'@'192.0.2.4'; +drop user 'root'@'192.0.2.4'; + +set global debug= default; + === added file 'mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_noname_deny.test' --- a/mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_noname_deny.test 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_noname_deny.test 2012-01-10 09:35:16 +0000 @@ -0,0 +1,52 @@ + +# +# Tests for the performance_schema host_cache. +# +# Test scenario: +# - a client connects on a TCP/IPv4 socket +# - the client IPv4 can be obtained +# - the client hostname can not be obtained (NONAME) +# - there are no grants for the client IP +# Test results: +# - connection is refused +# - peer_addr_errors is unchanged +# - the host_cache records the failing IP with no hostname +# + +# [Warning] IP address '192.0.2.4' could not be resolved: +# no reverse address mapping. +call mtr.add_suppression("192.0.2.4"); + +flush status; +flush hosts; +select @@global.debug; +show global status like "%peer%"; + +connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,); +select "Con1 is alive"; +select current_user(); +disconnect con1; + +--connection default +set global debug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_error_noname"; + +--disable_query_log +--error ER_HOST_NOT_PRIVILEGED +connect (con2,"127.0.0.1",root,,test,$MASTER_MYPORT,); +--enable_query_log + +--connection default +show global status like "%peer%"; +select * from performance_schema.host_cache; + +--disable_query_log +--error ER_HOST_NOT_PRIVILEGED +connect (con3,"127.0.0.1",root,,test,$MASTER_MYPORT,); +--enable_query_log + +--connection default +show global status like "%peer%"; +select * from performance_schema.host_cache; + +set global debug= default; + === added file 'mysql-test/suite/perfschema/t/hostcache_peer_addr.test' --- a/mysql-test/suite/perfschema/t/hostcache_peer_addr.test 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/perfschema/t/hostcache_peer_addr.test 2012-01-10 09:35:16 +0000 @@ -0,0 +1,47 @@ + +# +# Tests for the performance_schema host_cache. +# +# Test scenario: +# - a client connects on a TCP socket +# - the client IP can not be obtained +# Test results: +# - connection is refused +# - peer_addr_errors is incremented +# - the host_cache is unchanged +# + +flush status; +flush hosts; +select @@global.debug; +show global status like "%peer%"; + +connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,); +select "Con1 is alive"; +select current_user(); +disconnect con1; + +--connection default +set global debug= "+d,vio_peer_addr_error"; + +--disable_query_log +--error ER_BAD_HOST_ERROR +connect (con2,"127.0.0.1",root,,test,$MASTER_MYPORT,); +--enable_query_log + +--connection default +show global status like "%peer%"; + +--disable_query_log +--error ER_BAD_HOST_ERROR +connect (con3,"127.0.0.1",root,,test,$MASTER_MYPORT,); +--enable_query_log + +--connection default +show global status like "%peer%"; + +set global debug= default; + +flush status; +show global status like "%peer%"; + === modified file 'sql/hostname.cc' --- a/sql/hostname.cc 2012-01-09 09:07:34 +0000 +++ b/sql/hostname.cc 2012-01-10 09:35:16 +0000 @@ -148,7 +148,7 @@ static bool add_hostname_impl(const char bool validated, Host_errors *errors) { Host_entry *entry; - bool duplicate; + bool need_add= false; entry= hostname_cache_search(ip_key); @@ -156,45 +156,44 @@ static bool add_hostname_impl(const char { entry= (Host_entry *) malloc(sizeof (Host_entry)); if (entry == NULL) - return TRUE; + return true; - duplicate= false; + need_add= true; memcpy(&entry->ip_key, ip_key, HOST_ENTRY_KEY_SIZE); entry->m_errors.reset(); - } - else - { - duplicate= true; + entry->m_hostname_length= 0; } - if (hostname != NULL) - { - uint len= strlen(hostname); - if (len > sizeof(entry->m_hostname) - 1) - len= sizeof(entry->m_hostname) - 1; - memcpy(entry->m_hostname, hostname, len); - entry->m_hostname[len]= '\0'; - entry->m_hostname_length= len; - - DBUG_PRINT("info", ("Adding/Updating '%s' -> '%s' to the hostname cache...'", - (const char *) ip_key, - (const char *) entry->m_hostname)); - } - else + if (validated) { - entry->m_hostname_length= 0; + if (hostname != NULL) + { + uint len= strlen(hostname); + if (len > sizeof(entry->m_hostname) - 1) + len= sizeof(entry->m_hostname) - 1; + memcpy(entry->m_hostname, hostname, len); + entry->m_hostname[len]= '\0'; + entry->m_hostname_length= len; + + DBUG_PRINT("info", ("Adding/Updating '%s' -> '%s' to the hostname cache...'", + (const char *) ip_key, + (const char *) entry->m_hostname)); + } + else + { + entry->m_hostname_length= 0; - DBUG_PRINT("info", ("Adding '%s' -> empty to the hostname cache...'", - (const char *) ip_key)); + DBUG_PRINT("info", ("Adding/Updating '%s' -> empty to the hostname cache...'", + (const char *) ip_key)); + } } - entry->m_host_validated= validated; entry->m_errors.aggregate(errors); - if (! duplicate) + if (need_add) hostname_cache->add(entry); - return FALSE; + return false; } static bool add_hostname(const char *ip_key, const char *hostname, @@ -363,21 +362,18 @@ bool ip_to_hostname(struct sockaddr_stor *connect_errors= entry->m_errors.get_blocking_errors(); *hostname= NULL; - if (entry->m_host_validated) - { - if (entry->m_hostname_length) - *hostname= my_strdup(entry->m_hostname, MYF(0)); + if (entry->m_hostname_length) + *hostname= my_strdup(entry->m_hostname, MYF(0)); - DBUG_PRINT("info",("IP (%s) has been found in the cache. " - "Hostname: '%s'; connect_errors: %d", - (const char *) ip_key, - (const char *) (*hostname? *hostname : "null"), - (int) *connect_errors)); + DBUG_PRINT("info",("IP (%s) has been found in the cache. " + "Hostname: '%s'; connect_errors: %d", + (const char *) ip_key, + (const char *) (*hostname? *hostname : "null"), + (int) *connect_errors)); - mysql_mutex_unlock(&hostname_cache->lock); + mysql_mutex_unlock(&hostname_cache->lock); - DBUG_RETURN(FALSE); - } + DBUG_RETURN(FALSE); } mysql_mutex_unlock(&hostname_cache->lock); @@ -416,6 +412,13 @@ bool ip_to_hostname(struct sockaddr_stor } ); + DBUG_EXECUTE_IF("getnameinfo_format_ipv4", + { + strcpy(hostname_buffer, "12.12.12.12"); + err_code= 0; + } + ); + if (err_code) { // NOTE: gai_strerror() returns a string ending by a dot. @@ -481,7 +484,7 @@ bool ip_to_hostname(struct sockaddr_stor (const char *) hostname_buffer); errors.m_format_errors= 1; - err_status= add_hostname(ip_key, NULL, false, &errors); + err_status= add_hostname(ip_key, hostname_buffer, false, &errors); *hostname= NULL; *connect_errors= 0; /* New IP added to the cache. */ @@ -504,6 +507,95 @@ bool ip_to_hostname(struct sockaddr_stor err_code= getaddrinfo(hostname_buffer, NULL, &hints, &addr_info_list); + /* + =========================================================================== + + =========================================================================== + */ + DBUG_EXECUTE_IF("getaddrinfo_error_noname", + { + if (err_code == 0) + freeaddrinfo(addr_info_list); + + addr_info_list= NULL; + err_code= EAI_NONAME; + } + ); + + DBUG_EXECUTE_IF("getaddrinfo_error_again", + { + if (err_code == 0) + freeaddrinfo(addr_info_list); + + addr_info_list= NULL; + err_code= EAI_AGAIN; + } + ); + + DBUG_EXECUTE_IF("getaddrinfo_fake_bad_ipv4", + { + if (err_code == 0) + freeaddrinfo(addr_info_list); + + struct sockaddr_in *debug_addr; + struct in_addr *debug_ipv4; + static struct sockaddr_storage debug_sock_addr[2]; + static struct addrinfo debug_addr_info[2]; + debug_addr= (struct sockaddr_in*) & debug_sock_addr[0]; + debug_addr->sin_family= AF_INET; + debug_ipv4= & debug_addr->sin_addr; + debug_ipv4->s_addr= htonl(0xC0000305); /* ipv4 192.0.3.5 */ + + debug_addr= (struct sockaddr_in*) & debug_sock_addr[1]; + debug_addr->sin_family= AF_INET; + debug_ipv4= & debug_addr->sin_addr; + debug_ipv4->s_addr= htonl(0xC0000304); /* ipv4 192.0.3.4 */ + + debug_addr_info[0].ai_addr= (struct sockaddr*) & debug_sock_addr[0]; + debug_addr_info[0].ai_addrlen= sizeof (struct sockaddr_in); + debug_addr_info[0].ai_next= & debug_addr_info[1]; + + debug_addr_info[1].ai_addr= (struct sockaddr*) & debug_sock_addr[1]; + debug_addr_info[1].ai_addrlen= sizeof (struct sockaddr_in); + debug_addr_info[1].ai_next= NULL; + + addr_info_list= & debug_addr_info[0]; + err_code= 0; + } + ); + + DBUG_EXECUTE_IF("getaddrinfo_fake_good_ipv4", + { + if (err_code == 0) + freeaddrinfo(addr_info_list); + + struct sockaddr_in *debug_addr; + struct in_addr *debug_ipv4; + static struct sockaddr_storage debug_sock_addr[2]; + static struct addrinfo debug_addr_info[2]; + debug_addr= (struct sockaddr_in*) & debug_sock_addr[0]; + debug_addr->sin_family= AF_INET; + debug_ipv4= & debug_addr->sin_addr; + debug_ipv4->s_addr= htonl(0xC0000205); /* ipv4 192.0.2.5 */ + + debug_addr= (struct sockaddr_in*) & debug_sock_addr[1]; + debug_addr->sin_family= AF_INET; + debug_ipv4= & debug_addr->sin_addr; + debug_ipv4->s_addr= htonl(0xC0000204); /* ipv4 192.0.2.4 */ + + debug_addr_info[0].ai_addr= (struct sockaddr*) & debug_sock_addr[0]; + debug_addr_info[0].ai_addrlen= sizeof (struct sockaddr_in); + debug_addr_info[0].ai_next= & debug_addr_info[1]; + + debug_addr_info[1].ai_addr= (struct sockaddr*) & debug_sock_addr[1]; + debug_addr_info[1].ai_addrlen= sizeof (struct sockaddr_in); + debug_addr_info[1].ai_next= NULL; + + addr_info_list= & debug_addr_info[0]; + err_code= 0; + } + ); + if (err_code == EAI_NONAME) { /* @@ -556,6 +648,18 @@ bool ip_to_hostname(struct sockaddr_stor { DBUG_PRINT("error", ("Out of memory.")); + DBUG_EXECUTE_IF("getaddrinfo_fake_bad_ipv4", + { + addr_info_list= NULL; + } + ); + + DBUG_EXECUTE_IF("getaddrinfo_fake_good_ipv4", + { + addr_info_list= NULL; + } + ); + freeaddrinfo(addr_info_list); DBUG_RETURN(TRUE); } @@ -590,6 +694,18 @@ bool ip_to_hostname(struct sockaddr_stor /* Free the result of getaddrinfo(). */ + DBUG_EXECUTE_IF("getaddrinfo_fake_bad_ipv4", + { + addr_info_list= NULL; + } + ); + + DBUG_EXECUTE_IF("getaddrinfo_fake_good_ipv4", + { + addr_info_list= NULL; + } + ); + freeaddrinfo(addr_info_list); /* Add an entry for the IP to the cache. */ === modified file 'sql/hostname.h' --- a/sql/hostname.h 2011-08-11 11:25:37 +0000 +++ b/sql/hostname.h 2012-01-10 09:35:16 +0000 @@ -84,8 +84,6 @@ public: char m_hostname[HOSTNAME_LENGTH + 1]; /** Length in bytes of @c m_hostname. */ uint m_hostname_length; - /* Flag that indicate if the hostname was validated. */ - bool m_host_validated; /** Error statistics. */ Host_errors m_errors; }; === modified file 'storage/perfschema/table_host_cache.cc' --- a/storage/perfschema/table_host_cache.cc 2012-01-06 09:52:43 +0000 +++ b/storage/perfschema/table_host_cache.cc 2012-01-10 09:35:16 +0000 @@ -232,7 +232,10 @@ int table_host_cache::read_row_values(TA set_field_varchar_utf8(f, m_row->m_ip, m_row->m_ip_length); break; case 1: /* HOST */ - set_field_varchar_utf8(f, m_row->m_hostname, m_row->m_hostname_length); + if (m_row->m_hostname_length > 0) + set_field_varchar_utf8(f, m_row->m_hostname, m_row->m_hostname_length); + else + f->set_null(); break; case 2: /* SUM_BLOCKING_ERRORS */ set_field_ulonglong(f, m_row->m_sum_blocking_errors); No bundle (reason: useless for push emails).