1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00
samba-mirror/ctdb/protocol
Zhu Shangzhong 539b5ff32b ctdb: Initialize addr struct to zero before reparsing as IPV4
Failed to kill the tcp connection that using IPv4-mapped IPv6 address
(e.g. ctdb_killtcp eth0 ::ffff:192.168.200.44:2049
::ffff:192.168.200.45:863).

When the ctdb_killtcp is used to kill the tcp connection, the IPs and
ports in the connection will be parsed to conn.client and conn.server
(call stack: main->ctdb_sock_addr_from_string->ip_from_string). In
the ip_from_string, as we are using IPv4-mapped IPv6 addresses, the
ipv6_from_string will be used to parse ip to addr.ip6 first. The next
step the ipv4_from_string will be used to reparse ip to addr.ip.

As a result, the data that dump from conn.server is "2 0 8 1 192 168
200 44 0 0 0 0 0 0 0 0 0 0 255 255 192 168 200 44 0 0 0 0", the data
from conn.client is "2 0 3 95 192 168 200 45 0 0 0 0 0 0 0 0 0 0 255 255
192 168 200 45 0 0 0 0". The connection will be add to conn_list by
ctdb_connection_list_add. Then the reset_connections_send uses conn_list
as parameter to start to reset connections in the conn_list.

In the reset_connections_send, the database "connections" will be
created. The connections from conn_list will be written to the
database(call db_hash_add), and use the data that dump from conn_client
and conn_server as key.

In the reset_connections_capture_tcp_handler, the
ctdb_sys_read_tcp_packet will receive data on the raw socket. And
extract the IPs and ports from the tcp packet. when extracting IP and
port, the tcp4_extract OR tcp6_extract will be used. Then we got the
new conn.client and conn.server. the data that dump from the
conn.server is "2 0 8 1 192 168 200 44 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0", the data from conn.client is "2 0 3 95 192 168 200 45 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0". Finally, we use the data as key to check
if this connection is one being reset(call db_hash_delete). The
db_hash_delete will return ENOENT. Because the two key that being used
by db_hash_delete and db_hash_add are different.

So, the TCP RST will be NOT sent for the connection forever. We should
initialize addr struct to zero before reparsing as IPV4 in the
ip_from_string.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13839

Signed-off-by: Zhu Shangzhong <zhu.shangzhong@zte.com.cn>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@samba.org>
2019-03-15 05:17:13 +00:00
..
protocol_api.h ctdb-protocol: Drop marshalling code for RECEIVE_RECORDS control 2018-10-08 02:46:21 +02:00
protocol_basic.c ctdb-protocol: Separate protocol-basic subsystem 2018-07-05 06:52:42 +02:00
protocol_basic.h ctdb-protocol: Separate protocol-basic subsystem 2018-07-05 06:52:42 +02:00
protocol_call.c ctdb-protocol: Fix marshalling for ctdb_reply_dmaster 2017-08-30 14:59:25 +02:00
protocol_client.c ctdb-protocol: Drop marshalling code for RECEIVE_RECORDS control 2018-10-08 02:46:21 +02:00
protocol_control.c ctdb-protocol: Drop marshalling code for RECEIVE_RECORDS control 2018-10-08 02:46:21 +02:00
protocol_debug.c ctdb-server: Rename CTDB_BROADCAST_VNNMAP -> CTDB_BROADCAST_ACTIVE 2018-07-02 08:51:22 +02:00
protocol_header.c ctdb-protocol: Fix marshalling for ctdb_req_header 2017-08-30 14:59:25 +02:00
protocol_keepalive.c ctdb-protocol: Add marshalling for ctdb_req_keepalive 2017-08-30 14:59:26 +02:00
protocol_message.c ctdb-protocol: Fix marshalling for ctdb_req_message_data 2017-08-30 14:59:26 +02:00
protocol_packet.c ctdb-protocol: Check arguments in ctdb_allocate_pkt 2016-05-03 04:43:20 +02:00
protocol_private.h ctdb-protocol: Separate protocol-basic subsystem 2018-07-05 06:52:42 +02:00
protocol_sock.c ctdb-protocol: Add a generic packet header 2017-09-01 08:52:07 +02:00
protocol_tunnel.c ctdb-protocol: Add protocol marshalling for CTDB_REQ_TUNNEL 2017-10-10 11:45:19 +02:00
protocol_types.c ctdb-protocol: Add req_tunnel counts to ctdb statistics 2017-10-10 11:45:19 +02:00
protocol_util.c ctdb: Initialize addr struct to zero before reparsing as IPV4 2019-03-15 05:17:13 +00:00
protocol_util.h ctdb-common: Add fd argument to ctdb_connection_list_read() 2018-07-28 03:50:11 +02:00
protocol.h ctdb-protocol: Mark RECEIVE_RECORDS control obsolete 2018-10-08 02:46:21 +02:00